MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ExecuteMapChange

Method ExecuteMapChange

neo/framework/async/AsyncServer.cpp:243–364  ·  view source on GitHub ↗

================== idAsyncServer::ExecuteMapChange ================== */

Source from the content-addressed store, hash-verified

241==================
242*/
243void idAsyncServer::ExecuteMapChange( void ) {
244 int i;
245 idBitMsg msg;
246 byte msgBuf[MAX_MESSAGE_SIZE];
247 idStr mapName;
248 findFile_t ff;
249 bool addonReload = false;
250 char bestGameType[ MAX_STRING_CHARS ];
251
252 assert( active );
253
254 // reset any pureness
255 fileSystem->ClearPureChecksums();
256
257 // make sure the map/gametype combo is good
258 game->GetBestGameType( cvarSystem->GetCVarString("si_map"), cvarSystem->GetCVarString("si_gametype"), bestGameType );
259 cvarSystem->SetCVarString("si_gametype", bestGameType );
260
261 // initialize map settings
262 cmdSystem->BufferCommandText( CMD_EXEC_NOW, "rescanSI" );
263
264 sprintf( mapName, "maps/%s", sessLocal.mapSpawnData.serverInfo.GetString( "si_map" ) );
265 mapName.SetFileExtension( ".map" );
266 ff = fileSystem->FindFile( mapName, !serverReloadingEngine );
267 switch( ff ) {
268 case FIND_NO:
269 common->Printf( "Can't find map %s\n", mapName.c_str() );
270 cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "disconnect\n" );
271 return;
272 case FIND_ADDON:
273 // NOTE: we have no problem with addon dependencies here because if the map is in
274 // an addon pack that's already on search list, then all it's deps are assumed to be on search as well
275 common->Printf( "map %s is in an addon pak - reloading\n", mapName.c_str() );
276 addonReload = true;
277 break;
278 default:
279 break;
280 }
281
282 // if we are asked to do a full reload, the strategy is completely different
283 if ( !serverReloadingEngine && ( addonReload || idAsyncNetwork::serverReloadEngine.GetInteger() != 0 ) ) {
284 if ( idAsyncNetwork::serverReloadEngine.GetInteger() != 0 ) {
285 common->Printf( "net_serverReloadEngine enabled - doing a full reload\n" );
286 }
287 // tell the clients to reconnect
288 // FIXME: shouldn't they wait for the new pure list, then reload?
289 // in a lot of cases this is going to trigger two reloadEngines for the clients
290 // one to restart, the other one to set paks right ( with addon for instance )
291 // can fix by reconnecting without reloading and waiting for the server to tell..
292 for ( i = 0; i < MAX_ASYNC_CLIENTS; i++ ) {
293 if ( clients[ i ].clientState >= SCS_PUREWAIT && i != localClientNum ) {
294 msg.Init( msgBuf, sizeof( msgBuf ) );
295 msg.WriteByte( SERVER_RELIABLE_MESSAGE_RELOAD );
296 SendReliableMessage( i, msg );
297 clients[ i ].clientState = SCS_ZOMBIE; // so we don't bother sending a disconnect
298 }
299 }
300 cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadEngine" );

Callers 4

NextMap_fMethod · 0.45

Calls 15

sprintfFunction · 0.85
Sys_MillisecondsFunction · 0.85
ClearPureChecksumsMethod · 0.80
GetCVarStringMethod · 0.80
SetCVarStringMethod · 0.80
BufferCommandTextMethod · 0.80
FindFileMethod · 0.80
GetIntegerMethod · 0.80
SetIntegerMethod · 0.80
GetBestGameTypeMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected