diff options
author | Tim Angus <tim@ngus.net> | 2009-10-03 15:17:16 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:38 +0000 |
commit | 6d2ffb4c637a49983bc6ce22b68ccec0ed09e0f4 (patch) | |
tree | ff15343e4a2ae5a2512c1c21e05a3821a46f10da /src/server/sv_main.c | |
parent | e9e52d0b7ec9bae071534df7581126d69d3e9bf8 (diff) |
* Merge ioq3-r1637
Diffstat (limited to 'src/server/sv_main.c')
-rw-r--r-- | src/server/sv_main.c | 107 |
1 files changed, 73 insertions, 34 deletions
diff --git a/src/server/sv_main.c b/src/server/sv_main.c index 305cf299..41bfec4a 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -74,7 +74,7 @@ SV_ExpandNewlines Converts newlines to "\n" so a line prints nicer =============== */ -char *SV_ExpandNewlines( char *in ) { +static char *SV_ExpandNewlines( char *in ) { static char string[1024]; int l; @@ -97,10 +97,11 @@ char *SV_ExpandNewlines( char *in ) { ====================== SV_ReplacePendingServerCommands - This is ugly +FIXME: This is ugly ====================== */ -int SV_ReplacePendingServerCommands( client_t *client, const char *cmd ) { +#if 0 // unused +static int SV_ReplacePendingServerCommands( client_t *client, const char *cmd ) { int i, index, csnum1, csnum2; for ( i = client->reliableSent+1; i <= client->reliableSequence; i++ ) { @@ -117,6 +118,7 @@ int SV_ReplacePendingServerCommands( client_t *client, const char *cmd ) { } return qfalse; } +#endif /* ====================== @@ -223,52 +225,89 @@ but not on every player enter or exit. #define HEARTBEAT_MSEC 300*1000 #define HEARTBEAT_GAME "Tremulous" void SV_MasterHeartbeat( void ) { - static netadr_t adr[MAX_MASTER_SERVERS]; + static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string. int i; int res; + int netenabled; + + netenabled = Cvar_VariableIntegerValue("net_enabled"); // "dedicated 1" is for lan play, "dedicated 2" is for inet public play - if ( !com_dedicated || com_dedicated->integer != 2 ) { + if (!com_dedicated || com_dedicated->integer != 2 || !(netenabled & (NET_ENABLEV4 | NET_ENABLEV6))) return; // only dedicated servers send heartbeats - } // if not time yet, don't send anything - if ( svs.time < svs.nextHeartbeatTime ) { + if ( svs.time < svs.nextHeartbeatTime ) return; - } - svs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC; + svs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC; // send to group masters - for ( i = 0 ; i < MAX_MASTER_SERVERS ; i++ ) { - if ( !sv_master[i]->string[0] ) { + for (i = 0; i < MAX_MASTER_SERVERS; i++) + { + if(!sv_master[i]->string[0]) continue; - } // see if we haven't already resolved the name // resolving usually causes hitches on win95, so only // do it when needed - if ( sv_master[i]->modified ) { + if(sv_master[i]->modified || (adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)) + { sv_master[i]->modified = qfalse; - - Com_Printf( "Resolving %s\n", sv_master[i]->string ); - res = NET_StringToAdr( sv_master[i]->string, &adr[i], NA_UNSPEC ); - if ( !res ) { - Com_Printf( "Couldn't resolve address: %s\n", sv_master[i]->string ); - continue; + + if(netenabled & NET_ENABLEV4) + { + Com_Printf("Resolving %s (IPv4)\n", sv_master[i]->string); + res = NET_StringToAdr(sv_master[i]->string, &adr[i][0], NA_IP); + + if(res == 2) + { + // if no port was specified, use the default master port + adr[i][0].port = BigShort(PORT_MASTER); + } + + if(res) + Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i][0])); + else + Com_Printf( "%s has no IPv4 address.\n", sv_master[i]->string); } - if ( res == 2 ) { - // if no port was specified, use the default master port - adr[i].port = BigShort( PORT_MASTER ); + + if(netenabled & NET_ENABLEV6) + { + Com_Printf("Resolving %s (IPv6)\n", sv_master[i]->string); + res = NET_StringToAdr(sv_master[i]->string, &adr[i][1], NA_IP6); + + if(res == 2) + { + // if no port was specified, use the default master port + adr[i][1].port = BigShort(PORT_MASTER); + } + + if(res) + Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i][1])); + else + Com_Printf( "%s has no IPv6 address.\n", sv_master[i]->string); + } + + if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD) + { + Com_Printf("Couldn't resolve address: %s\n", sv_master[i]->string); + Cvar_Set(sv_master[i]->name, ""); + sv_master[i]->modified = qfalse; + continue; } - Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i])); } Com_Printf ("Sending heartbeat to %s\n", sv_master[i]->string ); + // this command should be changed if the server info / status format // ever incompatably changes - NET_OutOfBandPrint( NS_SERVER, adr[i], "heartbeat %s\n", HEARTBEAT_GAME ); + + if(adr[i][0].type != NA_BAD) + NET_OutOfBandPrint( NS_SERVER, adr[i][0], "heartbeat %s\n", HEARTBEAT_GAME ); + if(adr[i][1].type != NA_BAD) + NET_OutOfBandPrint( NS_SERVER, adr[i][1], "heartbeat %s\n", HEARTBEAT_GAME ); } } @@ -342,7 +381,7 @@ and all connected players. Used for getting detailed information after the simple info query. ================ */ -void SVC_Status( netadr_t from ) { +static void SVC_Status( netadr_t from ) { char player[1024]; char status[MAX_MSGLEN]; int i; @@ -449,7 +488,7 @@ SVC_FlushRedirect ================ */ -void SV_FlushRedirect( char *outputbuf ) { +static void SV_FlushRedirect( char *outputbuf ) { NET_OutOfBandPrint( NS_SERVER, svs.redirectAddress, "print\n%s", outputbuf ); } @@ -462,7 +501,7 @@ Shift down the remaining args Redirect all printfs =============== */ -void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { +static void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { qboolean valid; unsigned int time; char remaining[1024]; @@ -483,10 +522,10 @@ void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { if ( !strlen( sv_rconPassword->string ) || strcmp (Cmd_Argv(1), sv_rconPassword->string) ) { valid = qfalse; - Com_Printf ("Bad rcon from %s:\n%s\n", NET_AdrToString (from), Cmd_Argv(2) ); + Com_Printf ("Bad rcon from %s: %s\n", NET_AdrToString (from), Cmd_ArgsFrom(2) ); } else { valid = qtrue; - Com_Printf ("Rcon from %s:\n%s\n", NET_AdrToString (from), Cmd_Argv(2) ); + Com_Printf ("Rcon from %s: %s\n", NET_AdrToString (from), Cmd_ArgsFrom(2) ); } // start redirecting all print outputs to the packet @@ -532,7 +571,7 @@ Clients that are in the game can still send connectionless packets. ================= */ -void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { +static void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { char *s; char *c; @@ -554,7 +593,7 @@ void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { } else if (!Q_stricmp(c, "getinfo")) { SVC_Info( from ); } else if (!Q_stricmp(c, "getchallenge")) { - SV_GetChallenge( from ); + SV_GetChallenge(from); } else if (!Q_stricmp(c, "connect")) { SV_DirectConnect( from ); } else if (!Q_stricmp(c, "rcon")) { @@ -641,7 +680,7 @@ SV_CalcPings Updates the cl->ping variables =================== */ -void SV_CalcPings( void ) { +static void SV_CalcPings( void ) { int i, j; client_t *cl; int total, count; @@ -697,7 +736,7 @@ for a few seconds to make sure any final reliable message gets resent if necessary ================== */ -void SV_CheckTimeouts( void ) { +static void SV_CheckTimeouts( void ) { int i; client_t *cl; int droppoint; @@ -738,7 +777,7 @@ void SV_CheckTimeouts( void ) { SV_CheckPaused ================== */ -qboolean SV_CheckPaused( void ) { +static qboolean SV_CheckPaused( void ) { int count; client_t *cl; int i; |