summaryrefslogtreecommitdiff
path: root/source/sv_init.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-09-07 16:46:20 +0000
committerAndrey Nazarov <skuller@skuller.net>2010-09-07 16:46:20 +0000
commit8f76ac32949a283e000b27f6acd4359aa5de1806 (patch)
tree39c2088e732aed475e54680eec3ad13733994c26 /source/sv_init.c
parent9622b711c2b8e4641a778e144cf20ebfc87b12de (diff)
Re-resolve master servers after one day.
Don't spam server console with ping acks from masters. Added ‘listmasters’ command for checking IPs and ack times. Send the first heartbeat soon after server initialization.
Diffstat (limited to 'source/sv_init.c')
-rw-r--r--source/sv_init.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/source/sv_init.c b/source/sv_init.c
index 9c19b01..3f11d6a 100644
--- a/source/sv_init.c
+++ b/source/sv_init.c
@@ -38,7 +38,7 @@ void SV_ClientReset( client_t *client ) {
}
#if USE_FPS
-static void SV_SetFrameTime( void ) {
+static void set_frame_time( void ) {
int i = sv_fps->integer / 10;
clamp( i, 1, 6 );
@@ -50,6 +50,34 @@ static void SV_SetFrameTime( void ) {
}
#endif
+#if !USE_CLIENT
+static void resolve_masters( void ) {
+ master_t *m;
+ time_t now, delta;
+
+ now = time( NULL );
+ FOR_EACH_MASTER( m ) {
+ // re-resolve valid address after one day,
+ // resolve invalid address after three hours
+ delta = m->adr.port ? 24*60*60 : 3*60*60;
+ if( now < m->last_resolved ) {
+ m->last_resolved = now;
+ continue;
+ }
+ if( now - m->last_resolved < delta ) {
+ continue;
+ }
+ if( NET_StringToAdr( m->name, &m->adr, PORT_MASTER ) ) {
+ Com_DPrintf( "Master server at %s.\n", NET_AdrToString( &m->adr ) );
+ } else {
+ Com_WPrintf( "Couldn't resolve master: %s\n", m->name );
+ m->adr.port = 0;
+ }
+ m->last_resolved = now = time( NULL );
+ }
+}
+#endif
+
/*
================
SV_SpawnServer
@@ -93,6 +121,10 @@ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint
client->spawncount = sv.spawncount;
}
+#if !USE_CLIENT
+ resolve_masters();
+#endif
+
Q_concat( string, sizeof( string ), "maps/", server, ".bsp", NULL );
sv.cm = *cm;
strcpy( sv.configstrings[CS_MODELS + 1], string );
@@ -112,7 +144,7 @@ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint
// spawn the rest of the entities on the map
//
#if USE_FPS
- SV_SetFrameTime();
+ set_frame_time();
#endif
// precache and static commands can be issued during
@@ -267,6 +299,9 @@ void SV_InitGame( qboolean ismvd ) {
SV_RateInit( &svs.ratelimit_badpass, 1, sv_badauth_time->value * 1000 );
SV_RateInit( &svs.ratelimit_badrcon, 1, sv_badauth_time->value * 1000 );
+ // send heartbeat very soon
+ svs.last_heartbeat = -(HEARTBEAT_SECONDS-5)*1000;
+
List_Init( &svs.udp_client_list );
for( i = 0; i < sv_maxclients->integer; i++ ) {