/* ============== SV_Load_f ============== */ void SV_Load_f( void ) { if( Cmd_Argc() != 2 ) { Msg( "Usage: load <savename>\n" ); return; } if( host_xashds_hacks->value ) { Cbuf_InsertText(va("rcon load %s\n",Cmd_Argv( 1 ))); Cbuf_AddText("connect 127.0.0.1\n"); return; } if( host.type == HOST_DEDICATED ) { SV_InactivateClients (); SV_DeactivateServer (); } SV_LoadGame( Cmd_Argv( 1 )); if( host.type == HOST_DEDICATED ) SV_ActivateServer(); }
qboolean SV_NewGame( const char *mapName, qboolean loadGame ) { if( !loadGame ) { if( !SV_MapIsValid( mapName, GI->sp_entity, NULL )) { return false; } SV_ClearSaveDir (); SV_Shutdown( true ); } else { S_StopAllSounds (); SV_DeactivateServer (); } sv.loadgame = loadGame; sv.background = false; sv.changelevel = false; if( !SV_SpawnServer( mapName, NULL )) return false; SV_LevelInit( mapName, NULL, NULL, loadGame ); sv.loadgame = loadGame; SV_ActivateServer(); if( sv.state != ss_active ) return false; return true; }
/* ================== SV_Map_f Goes directly to a given map without any savegame archiving. For development work ================== */ void SV_Map_f( void ) { char *spawn_entity; string mapname; int flags; if( Cmd_Argc() != 2 ) { Msg( "Usage: map <mapname>\n" ); return; } // hold mapname to other place Q_strncpy( mapname, Cmd_Argv( 1 ), sizeof( mapname )); // determine spawn entity classname if( sv_maxclients->integer == 1 ) spawn_entity = GI->sp_entity; else spawn_entity = GI->mp_entity; flags = SV_MapIsValid( mapname, spawn_entity, NULL ); if( flags & MAP_INVALID_VERSION ) { Msg( "SV_NewMap: map %s is invalid or not supported\n", mapname ); return; } if(!( flags & MAP_IS_EXIST )) { Msg( "SV_NewMap: map %s doesn't exist\n", mapname ); return; } if(!( flags & MAP_HAS_SPAWNPOINT )) { Msg( "SV_NewMap: map %s doesn't have a valid spawnpoint\n", mapname ); return; } // init network stuff NET_Config(( sv_maxclients->integer > 1 )); // changing singleplayer to multiplayer or back. refresh the player count if(( sv_maxclients->modified ) || ( deathmatch->modified ) || ( coop->modified ) || ( teamplay->modified )) Host_ShutdownServer(); SCR_BeginLoadingPlaque( false ); sv.changelevel = false; sv.background = false; sv.loadgame = false; // set right state SV_ClearSaveDir (); // delete all temporary *.hl files SV_DeactivateServer(); SV_SpawnServer( mapname, NULL ); SV_LevelInit( mapname, NULL, NULL, false ); SV_ActivateServer (); }
/* ================== SV_Map_f Goes directly to a given map without any savegame archiving. For development work ================== */ void SV_Map_f( void ) { char *spawn_entity; string mapname; int flags; if( Cmd_Argc() != 2 ) { Msg( "Usage: map <mapname>\n" ); return; } // hold mapname to other place Q_strncpy( mapname, Cmd_Argv( 1 ), sizeof( mapname )); // determine spawn entity classname if( sv_maxclients->integer == 1 ) spawn_entity = GI->sp_entity; else spawn_entity = GI->mp_entity; flags = SV_MapIsValid( mapname, spawn_entity, NULL ); if( flags & MAP_INVALID_VERSION ) { Msg( "SV_NewMap: map %s is invalid or not supported\n", mapname ); return; } if(!( flags & MAP_IS_EXIST )) { Msg( "SV_NewMap: map %s doesn't exist\n", mapname ); return; } if(!( flags & MAP_HAS_SPAWNPOINT )) { Msg( "SV_NewMap: map %s doesn't have a valid spawnpoint\n", mapname ); return; } #ifndef _DEDICATED SCR_BeginLoadingPlaque( false ); #endif sv.background = false; sv.loadgame = false; // set right state SV_ClearSaveDir (); // delete all temporary *.hl files SV_DeactivateServer(); SV_SpawnServer( mapname, NULL ); SV_LevelInit( mapname, NULL, NULL, false ); SV_ActivateServer (); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( qboolean reconnect ) { // already freed if( !SV_Active( )) return; if( host.type == HOST_DEDICATED ) MsgDev( D_INFO, "SV_Shutdown: %s\n", host.finalmsg ); if( svs.clients ) SV_FinalMessage( host.finalmsg, reconnect ); Master_Shutdown(); if( !reconnect ) SV_UnloadProgs (); else SV_DeactivateServer (); // free current level Q_memset( &sv, 0, sizeof( sv )); Host_SetServerState( sv.state ); // free server static data if( svs.clients ) { Z_Free( svs.clients ); svs.clients = NULL; } if( svs.baselines ) { Z_Free( svs.baselines ); svs.baselines = NULL; } if( svs.packet_entities ) { Z_Free( svs.packet_entities ); svs.packet_entities = NULL; svs.num_client_entities = 0; svs.next_client_entities = 0; } svs.initialized = false; }