static void set_active_state(void) { cls.state = ca_active; cl.serverdelta = Q_align(cl.frame.number, CL_FRAMEDIV); cl.time = cl.servertime = 0; // set time, needed for demos #if USE_FPS cl.keytime = cl.keyservertime = 0; cl.keyframe = cl.frame; // initialize keyframe to make sure it's valid #endif // initialize oldframe so lerping doesn't hurt anything cl.oldframe.valid = false; cl.oldframe.ps = cl.frame.ps; #if USE_FPS cl.oldkeyframe.valid = false; cl.oldkeyframe.ps = cl.keyframe.ps; #endif cl.frameflags = 0; if (cls.netchan) { cl.initialSeq = cls.netchan->outgoing_sequence; } if (cls.demo.playback) { // init some demo things CL_FirstDemoFrame(); } else { // set initial cl.predicted_origin and cl.predicted_angles VectorScale(cl.frame.ps.pmove.origin, 0.125f, cl.predicted_origin); VectorScale(cl.frame.ps.pmove.velocity, 0.125f, cl.predicted_velocity); if (cl.frame.ps.pmove.pm_type < PM_DEAD && cls.serverProtocol > PROTOCOL_VERSION_DEFAULT) { // enhanced servers don't send viewangles CL_PredictAngles(); } else { // just use what server provided VectorCopy(cl.frame.ps.viewangles, cl.predicted_angles); } } SCR_EndLoadingPlaque(); // get rid of loading plaque SCR_LagClear(); Con_Close(false); // get rid of connection screen CL_CheckForPause(); CL_UpdateFrameTimes(); if (!cls.demo.playback) { EXEC_TRIGGER(cl_beginmapcmd); Cmd_ExecTrigger("#cl_enterlevel"); } }
/* ================ SV_SpawnServer Change the server to a new map, taking all connected clients along with it. ================ */ void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint ) { int i; client_t *client; #if USE_CLIENT SCR_BeginLoadingPlaque(); // for local system #endif Com_Printf( "------- Server Initialization -------\n" ); Com_Printf( "SpawnServer: %s\n", server ); // everyone needs to reconnect FOR_EACH_CLIENT( client ) { SV_ClientReset( client ); } SV_BroadcastCommand( "changing map=%s\n", server ); SV_SendClientMessages(); SV_SendAsyncPackets(); // free current level CM_FreeMap( &sv.cm ); SV_FreeFile( sv.entitystring ); // wipe the entire per-level structure memset( &sv, 0, sizeof( sv ) ); sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds(); sv.spawncount &= 0x7FFFFFFF; // set legacy spawncounts FOR_EACH_CLIENT( client ) { client->spawncount = sv.spawncount; } // reset entity counter svs.next_entity = 0; #if USE_FPS // set framerate parameters set_frame_time(); #endif // 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" ); } #if !USE_CLIENT resolve_masters(); #endif override_entity_string( server ); sv.cm = *cm; sprintf( sv.configstrings[CS_MAPCHECKSUM], "%d", ( int )cm->cache->checksum ); // set inline model names Q_concat( sv.configstrings[CS_MODELS + 1], MAX_QPATH, "maps/", server, ".bsp", NULL ); for( i = 1; i < cm->cache->nummodels; i++ ) { sprintf( sv.configstrings[ CS_MODELS + 1 + i ], "*%d", i ); } // // clear physics interaction links // SV_ClearWorld(); // // spawn the rest of the entities on the map // // precache and static commands can be issued during // map initialization sv.state = ss_loading; X86_PUSH_FPCW; X86_SINGLE_FPCW; // load and spawn all other entities ge->SpawnEntities ( sv.name, sv.entitystring ? sv.entitystring : cm->cache->entitystring, spawnpoint ); // run two frames to allow everything to settle ge->RunFrame (); sv.framenum++; ge->RunFrame (); sv.framenum++; X86_POP_FPCW; // make sure maxclients string is correct sprintf( sv.configstrings[CS_MAXCLIENTS], "%d", sv_maxclients->integer ); // all precaches are complete sv.state = ss_game; #if USE_MVD_SERVER // respawn dummy MVD client, set base states, etc SV_MvdMapChanged(); #endif // set serverinfo variable SV_InfoSet( "mapname", sv.name ); SV_InfoSet( "port", net_port->string ); Cvar_SetInteger( sv_running, ss_game, FROM_CODE ); Cvar_Set( "sv_paused", "0" ); Cvar_Set( "timedemo", "0" ); EXEC_TRIGGER( sv_changemapcmd ); #if USE_SYSCON SV_SetConsoleTitle(); #endif SV_BroadcastCommand( "reconnect\n" ); Com_Printf ("-------------------------------------\n"); }