diff options
author | Andrey Nazarov <skuller@skuller.net> | 2009-05-29 21:32:02 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2009-05-29 21:32:02 +0000 |
commit | 3ef036028a652f979a4197dd4a2ddd779e437597 (patch) | |
tree | 42c11d1e5396509e41d3776b80eaca3660a998db /source/sv_init.c | |
parent | 454fc2e2eb975e359696850f07c071aa0736aac7 (diff) |
Ran all source files through expand(1).
Diffstat (limited to 'source/sv_init.c')
-rw-r--r-- | source/sv_init.c | 312 |
1 files changed, 156 insertions, 156 deletions
diff --git a/source/sv_init.c b/source/sv_init.c index cdeff2f..92cab7a 100644 --- a/source/sv_init.c +++ b/source/sv_init.c @@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sv_local.h" -server_static_t svs; // persistant server info -server_t sv; // local server +server_static_t svs; // persistant server info +server_t sv; // local server void SV_ClientReset( client_t *client ) { if( client->state < cs_connected ) { @@ -59,39 +59,39 @@ clients along with it. ================ */ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint ) { - int i; - char string[MAX_QPATH]; - client_t *client; + int i; + char string[MAX_QPATH]; + client_t *client; - Com_Printf( "------- Server Initialization -------\n" ); - Com_Printf( "SpawnServer: %s\n", server ); + Com_Printf( "------- Server Initialization -------\n" ); + Com_Printf( "SpawnServer: %s\n", server ); - CM_FreeMap( &sv.cm ); - - // wipe the entire per-level structure - memset( &sv, 0, sizeof( sv ) ); - sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds(); - sv.spawncount &= 0x7FFFFFFF; + CM_FreeMap( &sv.cm ); + + // wipe the entire per-level structure + memset( &sv, 0, sizeof( sv ) ); + sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds(); + sv.spawncount &= 0x7FFFFFFF; // reset entity counter - svs.nextEntityStates = 0; - - // save name for levels that don't set message - Q_strlcpy( sv.configstrings[CS_NAME], server, MAX_QPATH ); - Q_strlcpy( sv.name, server, sizeof( sv.name ) ); - - if( Cvar_VariableInteger( "deathmatch" ) ) { - sprintf( sv.configstrings[CS_AIRACCEL], + svs.nextEntityStates = 0; + + // save name for levels that don't set message + Q_strlcpy( sv.configstrings[CS_NAME], server, MAX_QPATH ); + Q_strlcpy( sv.name, server, sizeof( sv.name ) ); + + if( Cvar_VariableInteger( "deathmatch" ) ) { + sprintf( sv.configstrings[CS_AIRACCEL], "%d", sv_airaccelerate->integer ); - } else { - strcpy( sv.configstrings[CS_AIRACCEL], "0" ); - } + } else { + strcpy( sv.configstrings[CS_AIRACCEL], "0" ); + } FOR_EACH_CLIENT( client ) { - // needs to reconnect + // needs to reconnect SV_ClientReset( client ); client->spawncount = sv.spawncount; - } + } Q_concat( string, sizeof( string ), "maps/", server, ".bsp", NULL ); sv.cm = *cm; @@ -103,47 +103,47 @@ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint sprintf( sv.configstrings[ CS_MODELS + 1 + i ], "*%d", i ); } - // - // clear physics interaction links - // - SV_ClearWorld(); + // + // clear physics interaction links + // + SV_ClearWorld(); - // - // spawn the rest of the entities on the map - // + // + // spawn the rest of the entities on the map + // #if USE_FPS SV_SetFrameTime(); #endif - // precache and static commands can be issued during - // map initialization - sv.state = ss_loading; + // precache and static commands can be issued during + // map initialization + sv.state = ss_loading; - // load and spawn all other entities - ge->SpawnEntities ( sv.name, cm->cache->entitystring, spawnpoint ); + // load and spawn all other entities + ge->SpawnEntities ( sv.name, cm->cache->entitystring, spawnpoint ); - // run two frames to allow everything to settle - ge->RunFrame (); - ge->RunFrame (); + // run two frames to allow everything to settle + ge->RunFrame (); + ge->RunFrame (); - // make sure maxclients string is correct + // make sure maxclients string is correct sprintf( sv.configstrings[CS_MAXCLIENTS], "%d", sv_maxclients->integer ); - // all precaches are complete - sv.state = ss_game; + // all precaches are complete + sv.state = ss_game; #if USE_MVD_SERVER // respawn dummy MVD client, set base states, etc - SV_MvdMapChanged(); + SV_MvdMapChanged(); #endif - // set serverinfo variable - SV_InfoSet( "mapname", sv.name ); + // set serverinfo variable + SV_InfoSet( "mapname", sv.name ); SV_InfoSet( "port", net_port->string ); - Cvar_SetInteger( sv_running, ss_game, CVAR_SET_DIRECT ); - Cvar_Set( "sv_paused", "0" ); - Cvar_Set( "timedemo", "0" ); + Cvar_SetInteger( sv_running, ss_game, CVAR_SET_DIRECT ); + Cvar_Set( "sv_paused", "0" ); + Cvar_Set( "timedemo", "0" ); EXEC_TRIGGER( sv_changemapcmd ); @@ -151,7 +151,7 @@ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint SV_SetConsoleTitle(); #endif - Com_Printf ("-------------------------------------\n"); + Com_Printf ("-------------------------------------\n"); } /* @@ -163,72 +163,72 @@ If ismvd is true, load the built-in MVD game module. ============== */ void SV_InitGame( qboolean ismvd ) { - int i, entnum; - edict_t *ent; - client_t *client; - - if( svs.initialized ) { - // cause any connected clients to reconnect - SV_Shutdown( "Server restarted\n", KILL_RESTART ); - } else { + int i, entnum; + edict_t *ent; + client_t *client; + + if( svs.initialized ) { + // cause any connected clients to reconnect + SV_Shutdown( "Server restarted\n", KILL_RESTART ); + } else { #if USE_CLIENT - // make sure the client is down - CL_Disconnect( ERR_SILENT, NULL ); - SCR_BeginLoadingPlaque(); + // make sure the client is down + CL_Disconnect( ERR_SILENT, NULL ); + SCR_BeginLoadingPlaque(); #endif - CM_FreeMap( &sv.cm ); - memset( &sv, 0, sizeof( sv ) ); - } + CM_FreeMap( &sv.cm ); + memset( &sv, 0, sizeof( sv ) ); + } - // get any latched variable changes (maxclients, etc) - Cvar_GetLatchedVars (); + // get any latched variable changes (maxclients, etc) + Cvar_GetLatchedVars (); - CL_LocalConnect(); + CL_LocalConnect(); - if( ismvd ) { - Cvar_Set( "deathmatch", "1" ); - Cvar_Set( "coop", "0" ); - } else { - if( Cvar_VariableInteger( "coop" ) && + if( ismvd ) { + Cvar_Set( "deathmatch", "1" ); + Cvar_Set( "coop", "0" ); + } else { + if( Cvar_VariableInteger( "coop" ) && Cvar_VariableInteger( "deathmatch" ) ) { - Com_Printf( "Deathmatch and Coop both set, disabling Coop\n" ); - Cvar_Set( "coop", "0" ); - } - - // dedicated servers can't be single player and are usually DM - // so unless they explicity set coop, force it to deathmatch - if( Com_IsDedicated() ) { - if( !Cvar_VariableInteger( "coop" ) ) - Cvar_Set( "deathmatch", "1" ); - } - } - - // init clients - if( Cvar_VariableInteger( "deathmatch" ) ) { - if( sv_maxclients->integer <= 1 ) { - Cvar_SetInteger( sv_maxclients, 8, CVAR_SET_DIRECT ); - } else if( sv_maxclients->integer > CLIENTNUM_RESERVED ) { - Cvar_SetInteger( sv_maxclients, CLIENTNUM_RESERVED, CVAR_SET_DIRECT ); - } - } else if( Cvar_VariableInteger( "coop" ) ) { - if( sv_maxclients->integer <= 1 || sv_maxclients->integer > 4 ) - Cvar_Set( "maxclients", "4" ); - } else { // non-deathmatch, non-coop is one player - Cvar_FullSet( "maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH, + Com_Printf( "Deathmatch and Coop both set, disabling Coop\n" ); + Cvar_Set( "coop", "0" ); + } + + // dedicated servers can't be single player and are usually DM + // so unless they explicity set coop, force it to deathmatch + if( Com_IsDedicated() ) { + if( !Cvar_VariableInteger( "coop" ) ) + Cvar_Set( "deathmatch", "1" ); + } + } + + // init clients + if( Cvar_VariableInteger( "deathmatch" ) ) { + if( sv_maxclients->integer <= 1 ) { + Cvar_SetInteger( sv_maxclients, 8, CVAR_SET_DIRECT ); + } else if( sv_maxclients->integer > CLIENTNUM_RESERVED ) { + Cvar_SetInteger( sv_maxclients, CLIENTNUM_RESERVED, CVAR_SET_DIRECT ); + } + } else if( Cvar_VariableInteger( "coop" ) ) { + if( sv_maxclients->integer <= 1 || sv_maxclients->integer > 4 ) + Cvar_Set( "maxclients", "4" ); + } else { // non-deathmatch, non-coop is one player + Cvar_FullSet( "maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH, CVAR_SET_DIRECT ); - } + } // enable networking - if( sv_maxclients->integer > 1 ) { - NET_Config( NET_SERVER ); + if( sv_maxclients->integer > 1 ) { + NET_Config( NET_SERVER ); } - svs.udp_client_pool = SV_Mallocz( sizeof( client_t ) * sv_maxclients->integer ); + svs.udp_client_pool = SV_Mallocz( sizeof( client_t ) * sv_maxclients->integer ); - svs.numEntityStates = sv_maxclients->integer * UPDATE_BACKUP * MAX_PACKET_ENTITIES; - svs.entityStates = SV_Mallocz( sizeof( entity_state_t ) * svs.numEntityStates ); + svs.numEntityStates = sv_maxclients->integer * UPDATE_BACKUP * MAX_PACKET_ENTITIES; + svs.entityStates = SV_Mallocz( sizeof( entity_state_t ) * svs.numEntityStates ); #if USE_MVD_SERVER // initialize MVD server @@ -242,46 +242,46 @@ void SV_InitGame( qboolean ismvd ) { #if USE_ZLIB svs.z.zalloc = SV_Zalloc; svs.z.zfree = SV_Zfree; - if( deflateInit2( &svs.z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, + if( deflateInit2( &svs.z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY ) != Z_OK ) { Com_Error( ERR_FATAL, "%s: deflateInit2() failed", __func__ ); } #endif - // init game + // init game #if USE_MVD_CLIENT - if( ismvd ) { - if( ge ) { - SV_ShutdownGameProgs(); - } - ge = &mvd_ge; - ge->Init(); - } else + if( ismvd ) { + if( ge ) { + SV_ShutdownGameProgs(); + } + ge = &mvd_ge; + ge->Init(); + } else #endif - SV_InitGameProgs(); + SV_InitGameProgs(); - // init rate limits - SV_RateInit( &svs.ratelimit_status, sv_status_limit->integer, 1000 ); - SV_RateInit( &svs.ratelimit_badpass, 1, sv_badauth_time->value * 1000 ); - SV_RateInit( &svs.ratelimit_badrcon, 1, sv_badauth_time->value * 1000 ); + // init rate limits + SV_RateInit( &svs.ratelimit_status, sv_status_limit->integer, 1000 ); + SV_RateInit( &svs.ratelimit_badpass, 1, sv_badauth_time->value * 1000 ); + SV_RateInit( &svs.ratelimit_badrcon, 1, sv_badauth_time->value * 1000 ); List_Init( &svs.udp_client_list ); - for( i = 0; i < sv_maxclients->integer; i++ ) { + for( i = 0; i < sv_maxclients->integer; i++ ) { client = svs.udp_client_pool + i; - entnum = i + 1; - ent = EDICT_NUM( entnum ); - ent->s.number = entnum; - client->edict = ent; + entnum = i + 1; + ent = EDICT_NUM( entnum ); + ent->s.number = entnum; + client->edict = ent; client->number = i; - } + } #if USE_AC_SERVER AC_Connect( ismvd ); #endif - svs.initialized = qtrue; + svs.initialized = qtrue; } @@ -298,40 +298,40 @@ Map can also be a.cin, .pcx, or .dm2 file Nextserver is used to allow a cinematic to play, then proceed to another level: - map tram.cin+jail_e3 + map tram.cin+jail_e3 ====================== */ void SV_Map (const char *levelstring, qboolean restart) { - char level[MAX_QPATH]; - char spawnpoint[MAX_QPATH]; - char expanded[MAX_QPATH]; - char *ch; + char level[MAX_QPATH]; + char spawnpoint[MAX_QPATH]; + char expanded[MAX_QPATH]; + char *ch; cm_t cm; - // skip the end-of-unit flag if necessary - if( *levelstring == '*' ) { - levelstring++; - } - - // save levelstring as it typically points to cmd_argv - Q_strlcpy( level, levelstring, sizeof( level ) ); - - // if there is a + in the map, set nextserver to the remainder - ch = strchr(level, '+'); - if (ch) { - *ch = 0; - Cvar_Set ("nextserver", va("gamemap \"%s\"", ch+1)); - } else { - Cvar_Set ("nextserver", ""); + // skip the end-of-unit flag if necessary + if( *levelstring == '*' ) { + levelstring++; } - // if there is a $, use the remainder as a spawnpoint - ch = strchr( level, '$' ); - if( ch ) { - *ch = 0; - strcpy( spawnpoint, ch + 1 ); - } else { - spawnpoint[0] = 0; + // save levelstring as it typically points to cmd_argv + Q_strlcpy( level, levelstring, sizeof( level ) ); + + // if there is a + in the map, set nextserver to the remainder + ch = strchr(level, '+'); + if (ch) { + *ch = 0; + Cvar_Set ("nextserver", va("gamemap \"%s\"", ch+1)); + } else { + Cvar_Set ("nextserver", ""); + } + + // if there is a $, use the remainder as a spawnpoint + ch = strchr( level, '$' ); + if( ch ) { + *ch = 0; + strcpy( spawnpoint, ch + 1 ); + } else { + spawnpoint[0] = 0; } Q_concat( expanded, sizeof( expanded ), "maps/", level, ".bsp", NULL ); @@ -340,9 +340,9 @@ void SV_Map (const char *levelstring, qboolean restart) { return; } - if( sv.state != ss_game || restart ) { - SV_InitGame( qfalse ); // the game is just starting - } + if( sv.state != ss_game || restart ) { + SV_InitGame( qfalse ); // the game is just starting + } // change state to loading if( sv.state > ss_loading ) { @@ -350,13 +350,13 @@ void SV_Map (const char *levelstring, qboolean restart) { } #if USE_CLIENT - SCR_BeginLoadingPlaque(); // for local system + SCR_BeginLoadingPlaque(); // for local system #endif SV_BroadcastCommand( "changing map=%s\n", level ); SV_SendClientMessages(); SV_SendAsyncPackets(); SV_SpawnServer( &cm, level, spawnpoint ); - SV_BroadcastCommand( "reconnect\n" ); + SV_BroadcastCommand( "reconnect\n" ); } |