/** * @sa CL_Frame */ static void CL_SendCommand (void) { /* get new key events */ IN_SendKeyEvents(); /* process console commands */ Cbuf_Execute(); /* send intentions now */ CL_SendChangedUserinfos(); /* fix any cheating cvars */ Cvar_FixCheatVars(); switch (cls.state) { case ca_disconnected: /* if the local server is running and we aren't connected then connect */ if (Com_ServerState()) { cls.servername[0] = '\0'; cls.serverport[0] = '\0'; CL_SetClientState(ca_connecting); return; } break; case ca_connecting: if (CL_Milliseconds() - cls.connectTime > cl_connecttimeout->integer) { if (GAME_IsMultiplayer()) Com_Error(ERR_DROP, "Server is not reachable"); } break; case ca_connected: if (cls.waitingForStart) { if (CL_Milliseconds() - cls.waitingForStart > cl_connecttimeout->integer) { Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout", cl_connecttimeout->integer / 1000); } else { SCR_DrawLoading(100); } } break; default: break; } }
/* * SV_SpawnServer * Change the server to a new map, taking all connected clients along with it. */ static void SV_SpawnServer( const char *server, qboolean devmap ) { unsigned checksum; int i; if( devmap ) Cvar_ForceSet( "sv_cheats", "1" ); Cvar_FixCheatVars(); Com_Printf( "------- Server Initialization -------\n" ); Com_Printf( "SpawnServer: %s\n", server ); svs.spawncount++; // any partially connected client will be restarted Com_SetServerState( ss_dead ); // wipe the entire per-level structure memset( &sv, 0, sizeof( sv ) ); SV_ResetClientFrameCounters(); svs.realtime = 0; svs.gametime = 0; SV_UpdateActivity(); Q_strncpyz( sv.mapname, server, sizeof( sv.mapname ) ); SV_SetServerConfigStrings(); sv.nextSnapTime = 1000; Q_snprintfz( sv.configstrings[CS_WORLDMODEL], sizeof( sv.configstrings[CS_WORLDMODEL] ), "maps/%s.bsp", server ); CM_LoadMap( svs.cms, sv.configstrings[CS_WORLDMODEL], qfalse, &checksum ); Q_snprintfz( sv.configstrings[CS_MAPCHECKSUM], sizeof( sv.configstrings[CS_MAPCHECKSUM] ), "%i", checksum ); // reserve the first modelIndexes for inline models for( i = 1; i < CM_NumInlineModels( svs.cms ); i++ ) Q_snprintfz( sv.configstrings[CS_MODELS + i], sizeof( sv.configstrings[CS_MODELS + i] ), "*%i", i ); // set serverinfo variable Cvar_FullSet( "mapname", sv.mapname, CVAR_SERVERINFO | CVAR_READONLY, qtrue ); // // spawn the rest of the entities on the map // // precache and static commands can be issued during // map initialization sv.state = ss_loading; Com_SetServerState( sv.state ); // set purelist SV_ReloadPureList(); // load and spawn all other entities ge->InitLevel( sv.mapname, CM_EntityString( svs.cms ), CM_EntityStringLen( svs.cms ), 0, svs.gametime, svs.realtime ); // run two frames to allow everything to settle ge->RunFrame( svc.snapFrameTime, svs.gametime ); ge->RunFrame( svc.snapFrameTime, svs.gametime ); SV_CreateBaseline(); // create a baseline for more efficient communications // all precaches are complete sv.state = ss_game; Com_SetServerState( sv.state ); Com_Printf( "-------------------------------------\n" ); }