diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 225f24cab9..e5fd308b5d 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2880,6 +2880,8 @@ void FinishDehPatch () // Now that all Dehacked patches have been processed, it's okay to free StateMap. StateMap.Clear(); StateMap.ShrinkToFit(); + TouchedActors.Clear(); + TouchedActors.ShrinkToFit(); } void ModifyDropAmount(AInventory *inv, int dropamount); diff --git a/src/d_main.cpp b/src/d_main.cpp index 2eaabf76d2..2b3e273a9a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -122,6 +122,7 @@ extern void M_SetDefaultMode (); extern void R_ExecuteSetViewSize (); extern void G_NewInit (); extern void SetupPlayerClasses (); +extern void HUD_InitHud(); const FIWADInfo *D_FindIWAD(TArray &wadfiles, const char *iwad, const char *basewad); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -2134,7 +2135,6 @@ void D_DoomMain (void) R_Init (); Printf ("DecalLibrary: Load decals.\n"); - DecalLibrary.Clear (); DecalLibrary.ReadAllDecals (); // [RH] Add any .deh and .bex files on the command line. @@ -2187,6 +2187,7 @@ void D_DoomMain (void) //SBarInfo support. SBarInfo::Load(); + HUD_InitHud(); // [RH] User-configurable startup strings. Because BOOM does. static const char *startupString[5] = { diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index b2f6173bf2..71dc66672b 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -383,6 +383,7 @@ DBaseStatusBar *CreateCustomStatusBar(int script=0); void ST_FormatMapName(FString &mapname, const char *mapnamecolor = ""); void ST_LoadCrosshair(bool alwaysload=false); +void ST_Clear(); extern FTexture *CrosshairImage; #endif /* __SBAR_H__ */ diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index ee29a3b5d2..a552a3ad1d 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -423,6 +423,8 @@ static void FreeSBarInfoScript() void SBarInfo::Load() { + FreeSBarInfoScript(); + MugShotStates.Clear(); if(gameinfo.statusbar.IsNotEmpty()) { int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true); diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index d766d89024..9901c79409 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -769,14 +769,11 @@ static void DrawCoordinates(player_t * CPlayer) // draw the overlay // //--------------------------------------------------------------------------- -void HUD_InitHud(); void DrawHUD() { player_t * CPlayer = StatusBar->CPlayer; - if (HudFont==NULL) HUD_InitHud(); - players[consoleplayer].inventorytics = 0; if (hud_althudscale && SCREENWIDTH>640) { diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 75084ae38e..09fb9417b8 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -197,6 +197,23 @@ void ST_LoadCrosshair(bool alwaysload) CrosshairImage = TexMan[TexMan.CheckForTexture(name, FTexture::TEX_MiscPatch)]; } +//--------------------------------------------------------------------------- +// +// ST_Clear +// +//--------------------------------------------------------------------------- + +void ST_Clear() +{ + if (StatusBar != NULL) + { + StatusBar->Destroy(); + StatusBar = NULL; + } + CrosshairImage = NULL; + CrosshairNum = 0; +} + //--------------------------------------------------------------------------- // // Constructor diff --git a/src/keysections.cpp b/src/keysections.cpp index bfec4060e3..8d23c95820 100644 --- a/src/keysections.cpp +++ b/src/keysections.cpp @@ -44,6 +44,7 @@ #include "w_wad.h" TArray KeySections; +extern TArray KeyConfWeapons; static void LoadKeys (const char *modname, bool dbl) { @@ -159,6 +160,7 @@ void D_LoadWadSettings () ParsingKeyConf = true; KeySections.Clear(); + KeyConfWeapons.Clear(); while ((lump = Wads.FindLump ("KEYCONF", &lastlump)) != -1) { diff --git a/src/menu/loadsavemenu.cpp b/src/menu/loadsavemenu.cpp index 97bda8494e..bdc5c3c307 100644 --- a/src/menu/loadsavemenu.cpp +++ b/src/menu/loadsavemenu.cpp @@ -53,9 +53,10 @@ class DLoadSaveMenu : public DListMenu { DECLARE_CLASS(DLoadSaveMenu, DListMenu) + friend void ClearSaveGames(); protected: - static TDeletingArray SaveGames; + static TArray SaveGames; static int LastSaved; static int LastAccessed; @@ -114,7 +115,7 @@ public: IMPLEMENT_CLASS(DLoadSaveMenu) -TDeletingArray DLoadSaveMenu::SaveGames; +TArray DLoadSaveMenu::SaveGames; int DLoadSaveMenu::LastSaved = -1; int DLoadSaveMenu::LastAccessed = -1; @@ -126,6 +127,21 @@ FSaveGameNode *quickSaveSlot; // //============================================================================= +void ClearSaveGames() +{ + for(unsigned i=0;i 0) + { + I_FatalError("You cannot add menu items to the menu default settings."); + } } else if (sc.Compare("OPTIONVALUE")) { @@ -861,6 +872,10 @@ void M_ParseMenuDefs() else if (sc.Compare("DEFAULTOPTIONMENU")) { ParseOptionMenuBody(sc, &DefaultOptionMenuSettings); + if (DefaultOptionMenuSettings.mItems.Size() > 0) + { + I_FatalError("You cannot add menu items to the menu default settings."); + } } else { diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b2e3852862..fa30df88fc 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -4074,11 +4074,7 @@ static void P_Shutdown () P_DeinitKeyMessages (); P_FreeLevelData (); P_FreeExtraLevelData (); - if (StatusBar != NULL) - { - StatusBar->Destroy(); - StatusBar = NULL; - } + ST_Clear(); } #if 0 diff --git a/src/p_user.cpp b/src/p_user.cpp index a9c04ad499..831d65dd5c 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -133,6 +133,7 @@ void SetupPlayerClasses () { FPlayerClass newclass; + PlayerClasses.Clear(); for (unsigned i=0; iNext; if (!probe->Builtin) { + if (pNext != NULL) *pNext = probe->Next; delete[] const_cast(probe->Name); delete probe; } + else + { + pNext = &probe->Next; + } probe = next; } Environments = &Off; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index c09e913be8..4c4053899b 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -292,6 +292,7 @@ void S_Init () if (S_SoundCurve != NULL) { delete[] S_SoundCurve; + S_SoundCurve = NULL; } // Heretic and Hexen have sound curve lookup tables. Doom does not. diff --git a/src/statistics.cpp b/src/statistics.cpp index 9c07ac6da1..fe72f76670 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -130,11 +130,11 @@ extern TArray wadlevelinfos; static void ParseStatistics(const char *fn, TArray &statlist) { + statlist.Clear(); try { FScanner sc; sc.OpenFile(fn); - statlist.Clear(); while (sc.GetString()) { diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 1b2f844bd9..0d9dfad30c 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -337,6 +337,8 @@ void LoadActors () { int lastlump, lump; + StateParams.Clear(); + GlobalSymbols.ReleaseSymbols(); DropItemList.Clear(); FScriptPosition::ResetErrorCounter(); InitThingdef(); diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 6b2124149d..41925b7120 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -123,7 +123,8 @@ class FStateExpressions TArray expressions; public: - ~FStateExpressions(); + ~FStateExpressions() { Clear(); } + void Clear(); int Add(FxExpression *x, const PClass *o, bool c); int Reserve(int num, const PClass *cls); void Set(int num, FxExpression *x, bool cloned = false); diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 1315d70ee6..5f7238e296 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -2765,7 +2765,7 @@ FStateExpressions StateParams; // //========================================================================== -FStateExpressions::~FStateExpressions() +void FStateExpressions::Clear() { for(unsigned i=0; iObjectFlags |= OF_YesReallyDelete; delete s; } - while (FFont::FirstFont != NULL) - { - delete FFont::FirstFont; - } + V_ClearFonts(); } EXTERN_CVAR (Bool, vid_tft) diff --git a/src/xlat/parse_xlat.cpp b/src/xlat/parse_xlat.cpp index 6221c54975..5edcde581c 100644 --- a/src/xlat/parse_xlat.cpp +++ b/src/xlat/parse_xlat.cpp @@ -156,16 +156,23 @@ struct XlatParseContext : public FParseContext // //========================================================================== +void P_ClearTranslator() +{ + SimpleLineTranslations.Clear(); + NumBoomish = 0; + SectorTranslations.Clear(); + SectorMasks.Clear(); + memset(LineFlagTranslations, 0, sizeof(LineFlagTranslations)); + LastTranslator = ""; +} + void P_LoadTranslator(const char *lumpname) { // Only read the lump if it differs from the previous one. if (LastTranslator.CompareNoCase(lumpname)) { // Clear the old data before parsing the lump. - SimpleLineTranslations.Clear(); - NumBoomish = 0; - SectorTranslations.Clear(); - SectorMasks.Clear(); + P_ClearTranslator(); void *pParser = XlatParseAlloc(malloc); @@ -179,3 +186,5 @@ void P_LoadTranslator(const char *lumpname) LastTranslator = lumpname; } } + +