void SV_ClearLastLevel(void) { Menu_Reset(); Z_TagFree(TAG_G_ALLOC); Z_TagFree(TAG_UI_ALLOC); G_FreeRoffs(); R_ModelFree(); Music_Free(); Sys_IORequestQueueClear(); AS_FreePartial(); G_ASPreCacheFree(); Ghoul2InfoArray_Free(); G2_FreeRag(); ClearAllNavStructures(); ClearModelsAlreadyDone(); CL_FreeServerCommands(); CL_FreeReliableCommands(); CM_Free(); ShaderEntryPtrs_Clear(); numVehicles = 0; if (svs.clients) { SV_FreeClient( svs.clients ); } }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown (%s) -----\n", finalmsg ); NET_LeaveMulticast6(); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); #ifdef DEDICATED Com_ShutdownRef(); #endif MSG_ShutdownNetFields(); // free current level SV_ClearServer(); // free server static data if(svs.players) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreePlayer(&svs.players[index]); Z_Free(svs.players); } if(svs.clients) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreeClient(&svs.clients[index]); Z_Free(svs.clients); } Com_Memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Cvar_Set("sv_public", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
/* ===================== SV_DropClient Called when the player is totally leaving the server, either willingly or unwillingly. This is NOT called if the entire server is quiting or crashing -- SV_FinalCommand() will handle that ===================== */ void SV_DropClient( client_t *drop, const char *reason ) { if ( drop->state == clientState_t::CS_ZOMBIE ) { return; // already dropped } Log::Debug( "Going to CS_ZOMBIE for %s", drop->name ); drop->state = clientState_t::CS_ZOMBIE; // become free in a few seconds // call the prog function for removing a client // this will remove the body, among other things gvm.GameClientDisconnect( drop - svs.clients ); if ( SV_IsBot(drop) ) { SV_BotFreeClient( drop - svs.clients ); } else { // tell everyone why they got dropped // Gordon: we want this displayed elsewhere now SV_SendServerCommand( nullptr, "print %s\"^* \"%s\"\n\"", Cmd_QuoteString( drop->name ), Cmd_QuoteString( reason ) ); // add the disconnect command SV_SendServerCommand( drop, "disconnect %s\n", Cmd_QuoteString( reason ) ); } // nuke user info SV_SetUserinfo( drop - svs.clients, "" ); SV_FreeClient( drop ); // if this was the last client on the server, send a heartbeat // to the master so it is known the server is empty // send a heartbeat now so the master will get up to date info // if there is already a slot for this IP address, reuse it int i; for ( i = 0; i < sv_maxclients->integer; i++ ) { if ( svs.clients[ i ].state >= clientState_t::CS_CONNECTED ) { break; } } if ( i == sv_maxclients->integer ) { SV_Heartbeat_f(); } }
/* ===================== SV_DropClient Called when the player is totally leaving the server, either willingly or unwillingly. This is NOT called if the entire server is quiting or crashing -- SV_FinalMessage() will handle that ===================== */ void SV_DropClient( client_t *drop, const char *reason ) { int i; challenge_t *challenge; if ( drop->state == CS_ZOMBIE ) { return; // already dropped } // see if we already have a challenge for this ip challenge = &svs.challenges[0]; for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) { if ( NET_CompareAdr( drop->netchan.remoteAddress, challenge->adr ) ) { Com_Memset(challenge, 0, sizeof(*challenge)); break; } } // Free all allocated data on the client structure SV_FreeClient(drop); // tell everyone why they got dropped SV_SendServerCommand( NULL, "print \"%s" S_COLOR_WHITE " %s\n\"", drop->name, reason ); // call the prog function for removing a client // this will remove the body, among other things VM_Call( gvm, GAME_CLIENT_DISCONNECT, drop - svs.clients ); // add the disconnect command SV_SendServerCommand( drop, "disconnect \"%s\"", reason); // nuke user info SV_SetUserinfo( drop - svs.clients, "" ); Com_DPrintf( "Going to CS_ZOMBIE for %s\n", drop->name ); drop->state = CS_ZOMBIE; // become free in a few seconds // if this was the last client on the server, send a heartbeat // to the master so it is known the server is empty // send a heartbeat now so the master will get up to date info // if there is already a slot for this ip, reuse it for (i=0 ; i < sv_maxclients->integer ; i++ ) { if ( svs.clients[i].state >= CS_CONNECTED ) { break; } } if ( i == sv_maxclients->integer ) { SV_Heartbeat_f(); } }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( const char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } PrintBanner(_( "Server Shutdown" )) NET_LeaveMulticast6(); if ( svs.clients && !com_errorEntered ) { SV_FinalCommand( va( "print %s", Cmd_QuoteString( finalmsg ) ), qtrue ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free server static data if ( svs.clients ) { int index; for ( index = 0; index < sv_maxclients->integer; index++ ) { SV_FreeClient( &svs.clients[ index ] ); } //Z_Free( svs.clients ); free( svs.clients ); // RF, avoid trying to allocate large chunk on a fragmented zone } memset( &svs, 0, sizeof( svs ) ); svs.serverLoad = -1; Cvar_Set( "sv_running", "0" ); #ifndef DEDICATED NET_Config( qtrue ); #endif Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( qfalse ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( const char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } PrintBanner( "Server Shutdown" ) NET_LeaveMulticast6(); if ( svs.clients ) { SV_FinalCommand( va( "print %s", Cmd_QuoteString( finalmsg ) ), true ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free server static data if ( svs.clients ) { int index; for ( index = 0; index < sv_maxclients->integer; index++ ) { SV_FreeClient( &svs.clients[ index ] ); } free( svs.clients ); } memset( &svs, 0, sizeof( svs ) ); svs.serverLoad = -1; Cvar_Set( "sv_running", "0" ); #ifndef BUILD_SERVER NET_Config( true ); #endif Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( false ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown (%s) -----\n", finalmsg ); NET_LeaveMulticast6(); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free siege static data since this is cross level or shutdown, not map restart if(svs.siege) { Z_Free(svs.siege); } // free server static data if(svs.clients) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreeClient(&svs.clients[index]); Z_Free(svs.clients); } Com_Memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { int i; if ( !com_sv_running || !com_sv_running->integer ) { return; } //Com_Printf( "----- Server Shutdown -----\n" ); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_ShutdownGameProgs(qfalse); if (svs.snapshotEntities) { Z_Free(svs.snapshotEntities); svs.snapshotEntities = NULL; } for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { if ( sv.configstrings[i] ) { Z_Free( sv.configstrings[i] ); } } // free current level memset( &sv, 0, sizeof( sv ) ); // free server static data if ( svs.clients ) { SV_FreeClient(svs.clients); Z_Free( svs.clients ); } memset( &svs, 0, sizeof( svs ) ); // Ensure we free any memory used by the leaf cache. CM_CleanLeafCache(); Cvar_Set( "sv_running", "0" ); //Com_Printf( "---------------------------\n" ); }
// Called when each game quits, before Sys_Quit or Sys_Error void SV_Shutdown( const char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown (%s) -----\n", finalmsg ); NET_LeaveMulticast6(); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); svs.gameStarted = qfalse; // free current level SV_ClearServer(); // free server static data if(svs.clients) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreeClient(&svs.clients[index]); Z_Free(svs.clients); } memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse, "Server shutdown" ); }