================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */
| 449 | ================ |
| 450 | */ |
| 451 | void SV_Shutdown( const char *finalmsg ) { |
| 452 | int i; |
| 453 | |
| 454 | if ( !com_sv_running || !com_sv_running->integer ) { |
| 455 | return; |
| 456 | } |
| 457 | |
| 458 | //Com_Printf( "----- Server Shutdown -----\n" ); |
| 459 | |
| 460 | if ( svs.clients && !com_errorEntered ) { |
| 461 | SV_FinalMessage( finalmsg ); |
| 462 | } |
| 463 | |
| 464 | SV_RemoveOperatorCommands(); |
| 465 | SV_ShutdownGameProgs(qfalse); |
| 466 | |
| 467 | if (svs.snapshotEntities) |
| 468 | { |
| 469 | Z_Free(svs.snapshotEntities); |
| 470 | svs.snapshotEntities = NULL; |
| 471 | } |
| 472 | |
| 473 | for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { |
| 474 | if ( sv.configstrings[i] ) { |
| 475 | Z_Free( sv.configstrings[i] ); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // free current level |
| 480 | memset( &sv, 0, sizeof( sv ) ); |
| 481 | |
| 482 | // free server static data |
| 483 | if ( svs.clients ) { |
| 484 | SV_FreeClient(svs.clients); |
| 485 | Z_Free( svs.clients ); |
| 486 | } |
| 487 | memset( &svs, 0, sizeof( svs ) ); |
| 488 | |
| 489 | // Ensure we free any memory used by the leaf cache. |
| 490 | CM_CleanLeafCache(); |
| 491 | |
| 492 | Cvar_Set( "sv_running", "0" ); |
| 493 | |
| 494 | //Com_Printf( "---------------------------\n" ); |
| 495 | } |
| 496 |
no test coverage detected