mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- copied the restart cleanup code into its own function
This commit is contained in:
parent
282047e67c
commit
42a54ef545
1 changed files with 73 additions and 61 deletions
134
src/d_main.cpp
134
src/d_main.cpp
|
@ -134,6 +134,7 @@ void D_AddWildFile (TArray<FString> &wadfiles, const char *pattern);
|
||||||
void D_LoadWadSettings ();
|
void D_LoadWadSettings ();
|
||||||
void ParseGLDefs();
|
void ParseGLDefs();
|
||||||
void DrawFullscreenSubtitle(const char *text);
|
void DrawFullscreenSubtitle(const char *text);
|
||||||
|
void D_Cleanup();
|
||||||
|
|
||||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||||
|
|
||||||
|
@ -2745,73 +2746,84 @@ void D_DoomMain (void)
|
||||||
// Clean up after a restart
|
// Clean up after a restart
|
||||||
//
|
//
|
||||||
|
|
||||||
// Music and sound should be stopped first
|
D_Cleanup();
|
||||||
S_StopMusic(true);
|
|
||||||
S_StopAllChannels ();
|
|
||||||
|
|
||||||
M_ClearMenus(); // close menu if open
|
|
||||||
F_EndFinale(); // If an intermission is active, end it now
|
|
||||||
AM_ClearColorsets();
|
|
||||||
|
|
||||||
// clean up game state
|
|
||||||
ST_Clear();
|
|
||||||
D_ErrorCleanup ();
|
|
||||||
for (auto Level : AllLevels())
|
|
||||||
{
|
|
||||||
Level->Thinkers.DestroyThinkersInList(STAT_STATIC);
|
|
||||||
}
|
|
||||||
staticEventManager.Shutdown();
|
|
||||||
P_FreeLevelData();
|
|
||||||
|
|
||||||
M_SaveDefaults(NULL); // save config before the restart
|
|
||||||
|
|
||||||
// delete all data that cannot be left until reinitialization
|
|
||||||
screen->CleanForRestart();
|
|
||||||
V_ClearFonts(); // must clear global font pointers
|
|
||||||
ColorSets.Clear();
|
|
||||||
PainFlashes.Clear();
|
|
||||||
R_DeinitTranslationTables(); // some tables are initialized from outside the translation code.
|
|
||||||
gameinfo.~gameinfo_t();
|
|
||||||
new (&gameinfo) gameinfo_t; // Reset gameinfo
|
|
||||||
S_ShutdownMusic();
|
|
||||||
S_Shutdown(); // free all channels and delete playlist
|
|
||||||
C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here
|
|
||||||
DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods
|
|
||||||
DeinitMenus();
|
|
||||||
LightDefaults.DeleteAndClear(); // this can leak heap memory if it isn't cleared.
|
|
||||||
|
|
||||||
// delete DoomStartupInfo data
|
|
||||||
DoomStartupInfo.Name = "";
|
|
||||||
DoomStartupInfo.BkColor = DoomStartupInfo.FgColor = DoomStartupInfo.Type = 0;
|
|
||||||
DoomStartupInfo.LoadLights = DoomStartupInfo.LoadBrightmaps = -1;
|
|
||||||
|
|
||||||
GC::FullGC(); // clean up before taking down the object list.
|
|
||||||
|
|
||||||
// Delete the reference to the VM functions here which were deleted and will be recreated after the restart.
|
|
||||||
FAutoSegIterator probe(ARegHead, ARegTail);
|
|
||||||
while (*++probe != NULL)
|
|
||||||
{
|
|
||||||
AFuncDesc *afunc = (AFuncDesc *)*probe;
|
|
||||||
*(afunc->VMPointer) = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GC::DelSoftRootHead();
|
|
||||||
|
|
||||||
PClass::StaticShutdown();
|
|
||||||
|
|
||||||
GC::FullGC(); // perform one final garbage collection after shutdown
|
|
||||||
|
|
||||||
assert(GC::Root == nullptr);
|
|
||||||
|
|
||||||
restart++;
|
|
||||||
PClass::bShutdown = false;
|
|
||||||
PClass::bVMOperational = false;
|
|
||||||
|
|
||||||
gamestate = GS_STARTUP;
|
gamestate = GS_STARTUP;
|
||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// clean up the resources
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void D_Cleanup()
|
||||||
|
{
|
||||||
|
// Music and sound should be stopped first
|
||||||
|
S_StopMusic(true);
|
||||||
|
S_StopAllChannels ();
|
||||||
|
|
||||||
|
M_ClearMenus(); // close menu if open
|
||||||
|
F_EndFinale(); // If an intermission is active, end it now
|
||||||
|
AM_ClearColorsets();
|
||||||
|
|
||||||
|
// clean up game state
|
||||||
|
ST_Clear();
|
||||||
|
D_ErrorCleanup ();
|
||||||
|
for (auto Level : AllLevels())
|
||||||
|
{
|
||||||
|
Level->Thinkers.DestroyThinkersInList(STAT_STATIC);
|
||||||
|
}
|
||||||
|
staticEventManager.Shutdown();
|
||||||
|
P_FreeLevelData();
|
||||||
|
|
||||||
|
M_SaveDefaults(NULL); // save config before the restart
|
||||||
|
|
||||||
|
// delete all data that cannot be left until reinitialization
|
||||||
|
screen->CleanForRestart();
|
||||||
|
V_ClearFonts(); // must clear global font pointers
|
||||||
|
ColorSets.Clear();
|
||||||
|
PainFlashes.Clear();
|
||||||
|
R_DeinitTranslationTables(); // some tables are initialized from outside the translation code.
|
||||||
|
gameinfo.~gameinfo_t();
|
||||||
|
new (&gameinfo) gameinfo_t; // Reset gameinfo
|
||||||
|
S_ShutdownMusic();
|
||||||
|
S_Shutdown(); // free all channels and delete playlist
|
||||||
|
C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here
|
||||||
|
DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods
|
||||||
|
DeinitMenus();
|
||||||
|
LightDefaults.DeleteAndClear(); // this can leak heap memory if it isn't cleared.
|
||||||
|
|
||||||
|
// delete DoomStartupInfo data
|
||||||
|
DoomStartupInfo.Name = "";
|
||||||
|
DoomStartupInfo.BkColor = DoomStartupInfo.FgColor = DoomStartupInfo.Type = 0;
|
||||||
|
DoomStartupInfo.LoadLights = DoomStartupInfo.LoadBrightmaps = -1;
|
||||||
|
|
||||||
|
GC::FullGC(); // clean up before taking down the object list.
|
||||||
|
|
||||||
|
// Delete the reference to the VM functions here which were deleted and will be recreated after the restart.
|
||||||
|
FAutoSegIterator probe(ARegHead, ARegTail);
|
||||||
|
while (*++probe != NULL)
|
||||||
|
{
|
||||||
|
AFuncDesc *afunc = (AFuncDesc *)*probe;
|
||||||
|
*(afunc->VMPointer) = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GC::DelSoftRootHead();
|
||||||
|
|
||||||
|
PClass::StaticShutdown();
|
||||||
|
|
||||||
|
GC::FullGC(); // perform one final garbage collection after shutdown
|
||||||
|
|
||||||
|
assert(GC::Root == nullptr);
|
||||||
|
|
||||||
|
restart++;
|
||||||
|
PClass::bShutdown = false;
|
||||||
|
PClass::bVMOperational = false;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// restart the game
|
// restart the game
|
||||||
|
|
Loading…
Reference in a new issue