/* * SV_Map * command from the console or progs. */ void SV_Map( const char *level, qboolean devmap ) { client_t *cl; int i; if( svs.demo.file ) SV_Demo_Stop_f(); // skip the end-of-unit flag if necessary if( level[0] == '*' ) level++; if( sv.state == ss_dead ) SV_InitGame(); // the game is just starting // remove all bots before changing map for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) { if( cl->state && cl->edict && ( cl->edict->r.svflags & SVF_FAKECLIENT ) ) { SV_DropClient( cl, DROP_TYPE_GENERAL, NULL ); } } // wsw : Medar : this used to be at SV_SpawnServer, but we need to do it before sending changing // so we don't send frames after sending changing command // leave slots at start for clients only for( i = 0; i < sv_maxclients->integer; i++ ) { // needs to reconnect if( svs.clients[i].state > CS_CONNECTING ) { svs.clients[i].state = CS_CONNECTING; } // limit number of connected multiview clients if( svs.clients[i].mv ) { if( sv.num_mv_clients < sv_maxmvclients->integer ) sv.num_mv_clients++; else svs.clients[i].mv = qfalse; } svs.clients[i].lastframe = -1; memset( svs.clients[i].gameCommands, 0, sizeof( svs.clients[i].gameCommands ) ); } SV_MOTD_Update(); SCR_BeginLoadingPlaque(); // for local system SV_BroadcastCommand( "changing\n" ); SV_SendClientMessages(); SV_SpawnServer( level, devmap ); SV_BroadcastCommand( "reconnect\n" ); }
/* * SV_Init * * Only called at plat.exe startup, not for each game */ void SV_Init( void ) { cvar_t *sv_pps; cvar_t *sv_fps; assert( !sv_initialized ); memset( &svc, 0, sizeof( svc ) ); SV_InitOperatorCommands(); sv_mempool = Mem_AllocPool( NULL, "Server" ); Cvar_Get( "sv_cheats", "0", CVAR_SERVERINFO | CVAR_LATCH ); Cvar_Get( "protocol", va( "%i", APP_PROTOCOL_VERSION ), CVAR_SERVERINFO | CVAR_NOSET ); sv_ip = Cvar_Get( "sv_ip", "", CVAR_ARCHIVE | CVAR_LATCH ); sv_port = Cvar_Get( "sv_port", va( "%i", PORT_SERVER ), CVAR_ARCHIVE | CVAR_LATCH ); sv_ip6 = Cvar_Get( "sv_ip6", "::", CVAR_ARCHIVE | CVAR_LATCH ); sv_port6 = Cvar_Get( "sv_port6", va( "%i", PORT_SERVER ), CVAR_ARCHIVE | CVAR_LATCH ); #ifdef TCP_SUPPORT sv_tcp = Cvar_Get( "sv_tcp", "1", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_LATCH ); #endif rcon_password = Cvar_Get( "rcon_password", "", 0 ); sv_hostname = Cvar_Get( "sv_hostname", APPLICATION " server", CVAR_SERVERINFO | CVAR_ARCHIVE ); sv_timeout = Cvar_Get( "sv_timeout", "125", 0 ); sv_zombietime = Cvar_Get( "sv_zombietime", "2", 0 ); sv_enforcetime = Cvar_Get( "sv_enforcetime", "1", 0 ); sv_showclamp = Cvar_Get( "sv_showclamp", "0", 0 ); sv_showRcon = Cvar_Get( "sv_showRcon", "1", 0 ); sv_showChallenge = Cvar_Get( "sv_showChallenge", "0", 0 ); sv_showInfoQueries = Cvar_Get( "sv_showInfoQueries", "0", 0 ); sv_highchars = Cvar_Get( "sv_highchars", "1", 0 ); sv_uploads_baseurl = Cvar_Get( "sv_uploads_baseurl", "", CVAR_ARCHIVE ); sv_uploads_demos_baseurl = Cvar_Get( "sv_uploads_demos_baseurl", "", CVAR_ARCHIVE ); if( dedicated->integer ) { sv_uploads = Cvar_Get( "sv_uploads", "1", CVAR_READONLY ); sv_uploads_from_server = Cvar_Get( "sv_uploads_from_server", "1", CVAR_READONLY ); sv_autoUpdate = Cvar_Get( "sv_autoUpdate", "1", CVAR_ARCHIVE ); sv_pure = Cvar_Get( "sv_pure", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO ); #ifdef PUBLIC_BUILD sv_public = Cvar_Get( "sv_public", "1", CVAR_ARCHIVE | CVAR_LATCH ); #else sv_public = Cvar_Get( "sv_public", "0", CVAR_ARCHIVE | CVAR_LATCH ); #endif } else { sv_uploads = Cvar_Get( "sv_uploads", "1", CVAR_ARCHIVE ); sv_uploads_from_server = Cvar_Get( "sv_uploads_from_server", "1", CVAR_ARCHIVE ); sv_autoUpdate = Cvar_Get( "sv_autoUpdate", "0", CVAR_READONLY ); sv_pure = Cvar_Get( "sv_pure", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO ); sv_public = Cvar_Get( "sv_public", "0", CVAR_ARCHIVE ); } sv_iplimit = Cvar_Get( "sv_iplimit", "3", CVAR_ARCHIVE ); sv_lastAutoUpdate = Cvar_Get( "sv_lastAutoUpdate", "0", CVAR_READONLY|CVAR_ARCHIVE ); sv_pure_forcemodulepk3 = Cvar_Get( "sv_pure_forcemodulepk3", "", CVAR_LATCH ); sv_defaultmap = Cvar_Get( "sv_defaultmap", "wdm1", CVAR_ARCHIVE ); sv_write_defaultmap = Cvar_Get( "sv_write_defaultmap", "0", CVAR_ARCHIVE ); sv_reconnectlimit = Cvar_Get( "sv_reconnectlimit", "3", CVAR_ARCHIVE ); sv_maxclients = Cvar_Get( "sv_maxclients", "8", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH ); sv_maxmvclients = Cvar_Get( "sv_maxmvclients", "4", CVAR_ARCHIVE | CVAR_SERVERINFO ); Cvar_Get( "sv_modmanifest", "", CVAR_READONLY ); Cvar_ForceSet( "sv_modmanifest", "" ); // fix invalid sv_maxclients values if( sv_maxclients->integer < 1 ) Cvar_FullSet( "sv_maxclients", "1", CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, qtrue ); else if( sv_maxclients->integer > MAX_CLIENTS ) Cvar_FullSet( "sv_maxclients", va( "%i", MAX_CLIENTS ), CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, qtrue ); sv_demodir = Cvar_Get( "sv_demodir", "", CVAR_NOSET ); if( sv_demodir->string[0] && Com_GlobMatch( "*[^0-9a-zA-Z_@]*", sv_demodir->string, qfalse ) ) { Com_Printf( "Invalid demo prefix string: %s\n", sv_demodir->string ); Cvar_ForceSet( "sv_demodir", "" ); } // wsw : jal : cap client's exceding server rules sv_maxrate = Cvar_Get( "sv_maxrate", "0", CVAR_DEVELOPER ); sv_compresspackets = Cvar_Get( "sv_compresspackets", "1", CVAR_DEVELOPER ); sv_skilllevel = Cvar_Get( "sv_skilllevel", "1", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH ); if( sv_skilllevel->integer > 2 ) Cvar_ForceSet( "sv_skilllevel", "2" ); if( sv_skilllevel->integer < 0 ) Cvar_ForceSet( "sv_skilllevel", "0" ); sv_masterservers = Cvar_Get( "masterservers", DEFAULT_MASTER_SERVERS_IPS, CVAR_LATCH ); sv_debug_serverCmd = Cvar_Get( "sv_debug_serverCmd", "0", CVAR_ARCHIVE ); sv_MOTD = Cvar_Get( "sv_MOTD", "0", CVAR_ARCHIVE ); sv_MOTDFile = Cvar_Get( "sv_MOTDFile", "", CVAR_ARCHIVE ); sv_MOTDString = Cvar_Get( "sv_MOTDString", "", CVAR_ARCHIVE ); SV_MOTD_Update(); // this is a message holder for shared use MSG_Init( &tmpMessage, tmpMessageData, sizeof( tmpMessageData ) ); // init server updates ratio if( dedicated->integer ) sv_pps = Cvar_Get( "sv_pps", "20", CVAR_SERVERINFO|CVAR_NOSET ); else sv_pps = Cvar_Get( "sv_pps", "20", CVAR_SERVERINFO ); svc.snapFrameTime = (int)( 1000 / sv_pps->value ); if( svc.snapFrameTime > 200 ) { // too slow, also, netcode uses a byte Cvar_ForceSet( "sv_pps", "5" ); svc.snapFrameTime = 200; } else if( svc.snapFrameTime < 10 ) { // abusive Cvar_ForceSet( "sv_pps", "100" ); svc.snapFrameTime = 10; } sv_fps = Cvar_Get( "sv_fps", "62", CVAR_NOSET ); svc.gameFrameTime = (int)( 1000 / sv_fps->value ); if( svc.gameFrameTime > svc.snapFrameTime ) { // gamecode can never be slower than snaps svc.gameFrameTime = svc.snapFrameTime; Cvar_ForceSet( "sv_fps", sv_pps->dvalue ); } Com_Printf( "Game running at %i fps. Server transmit at %i pps\n", sv_fps->integer, sv_pps->integer ); //init the master servers list SV_InitMaster(); SV_MM_Init(); ML_Init(); sv_initialized = qtrue; }