- fixed: The TouchedActors array in the Dehacked parser was not freed after parsing was done.

- Initialize the alt HUD explicitly in D_DoomMain.
- don't let S_UnloadReverbDef leave a broken list of sound environments behind.
- Added more code to explicitly delete data before initializing it.

SVN r3039 (trunk)
This commit is contained in:
Christoph Oelckers 2010-12-15 00:09:31 +00:00
parent 22372fff25
commit 770a879f6a
25 changed files with 156 additions and 38 deletions

View File

@ -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);

View File

@ -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<FString> &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] = {

View File

@ -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__ */

View File

@ -423,6 +423,8 @@ static void FreeSBarInfoScript()
void SBarInfo::Load()
{
FreeSBarInfoScript();
MugShotStates.Clear();
if(gameinfo.statusbar.IsNotEmpty())
{
int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true);

View File

@ -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)
{

View File

@ -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

View File

@ -44,6 +44,7 @@
#include "w_wad.h"
TArray<FKeySection> KeySections;
extern TArray<FString> 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)
{

View File

@ -53,9 +53,10 @@
class DLoadSaveMenu : public DListMenu
{
DECLARE_CLASS(DLoadSaveMenu, DListMenu)
friend void ClearSaveGames();
protected:
static TDeletingArray<FSaveGameNode*> SaveGames;
static TArray<FSaveGameNode*> SaveGames;
static int LastSaved;
static int LastAccessed;
@ -114,7 +115,7 @@ public:
IMPLEMENT_CLASS(DLoadSaveMenu)
TDeletingArray<FSaveGameNode*> DLoadSaveMenu::SaveGames;
TArray<FSaveGameNode*> DLoadSaveMenu::SaveGames;
int DLoadSaveMenu::LastSaved = -1;
int DLoadSaveMenu::LastAccessed = -1;
@ -126,6 +127,21 @@ FSaveGameNode *quickSaveSlot;
//
//=============================================================================
void ClearSaveGames()
{
for(unsigned i=0;i<DLoadSaveMenu::SaveGames.Size(); i++)
{
delete DLoadSaveMenu::SaveGames[i];
}
DLoadSaveMenu::SaveGames.Clear();
}
//=============================================================================
//
// Save data maintenance (stored statically)
//
//=============================================================================
int DLoadSaveMenu::RemoveSaveSlot (int index)
{
FSaveGameNode *file = SaveGames[index];
@ -194,6 +210,8 @@ void DLoadSaveMenu::ReadSaveStrings ()
findstate_t c_file;
FString filter;
LastSaved = LastAccessed = -1;
quickSaveSlot = NULL;
filter = G_BuildSaveName ("*.zds", -1);
filefirst = I_FindFirst (filter.GetChars(), &c_file);
if (filefirst != ((void *)(-1)))

View File

@ -111,6 +111,22 @@ struct FListMenuDescriptor : public FMenuDescriptor
const PClass *mClass;
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
bool mCenter;
void Reset()
{
// Reset the default settings (ignore all other values in the struct)
mSelectOfsX = 0;
mSelectOfsY = 0;
mSelector.SetInvalid();
mDisplayTop = 0;
mXpos = 0;
mYpos = 0;
mLinespacing = 0;
mNetgameMessage = "";
mFont = NULL;
mFontColor = CR_UNTRANSLATED;
mFontColor2 = CR_UNTRANSLATED;
}
};
struct FOptionMenuSettings
@ -141,6 +157,14 @@ struct FOptionMenuDescriptor : public FMenuDescriptor
void CalcIndent();
FOptionMenuItem *GetItem(FName name);
void Reset()
{
// Reset the default settings (ignore all other values in the struct)
mPosition = 0;
mScrollTop = 0;
mIndent = 0;
mDontDim = 0;
}
};

View File

@ -52,6 +52,8 @@
#include "optionmenuitems.h"
void ClearSaveGames();
MenuDescriptorList MenuDescriptors;
static FListMenuDescriptor DefaultListMenuSettings; // contains common settings for all list menus
static FOptionMenuDescriptor DefaultOptionMenuSettings; // contains common settings for all Option menus
@ -84,6 +86,8 @@ static void DeinitMenus()
}
}
DMenu::CurrentMenu = NULL;
DefaultListMenuSettings.mItems.Clear();
ClearSaveGames();
}
//=============================================================================
@ -825,8 +829,11 @@ void M_ParseMenuDefs()
OptionSettings.mFontColorHeader = V_FindFontColor(gameinfo.mFontColorHeader);
OptionSettings.mFontColorHighlight = V_FindFontColor(gameinfo.mFontColorHighlight);
OptionSettings.mFontColorSelection = V_FindFontColor(gameinfo.mFontColorSelection);
DefaultListMenuSettings.Reset();
DefaultOptionMenuSettings.Reset();
atterm( DeinitMenus);
DeinitMenus();
while ((lump = Wads.FindLump ("MENUDEF", &lastlump)) != -1)
{
FScanner sc(lump);
@ -841,6 +848,10 @@ void M_ParseMenuDefs()
else if (sc.Compare("DEFAULTLISTMENU"))
{
ParseListMenuBody(sc, &DefaultListMenuSettings);
if (DefaultListMenuSettings.mItems.Size() > 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
{

View File

@ -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

View File

@ -133,6 +133,7 @@ void SetupPlayerClasses ()
{
FPlayerClass newclass;
PlayerClasses.Clear();
for (unsigned i=0; i<gameinfo.PlayerClasses.Size(); i++)
{
newclass.Flags = 0;

View File

@ -127,6 +127,22 @@ void R_SetDefaultColormap (const char *name)
}
}
//==========================================================================
//
// R_DeinitColormaps
//
//==========================================================================
void R_DeinitColormaps ()
{
fakecmaps.Clear();
if (realcolormaps != NULL)
{
delete[] realcolormaps;
realcolormaps = NULL;
}
}
//==========================================================================
//
// R_InitColormaps
@ -141,6 +157,8 @@ void R_InitColormaps ()
FakeCmap cm;
R_DeinitColormaps();
cm.name[0] = 0;
cm.blend = 0;
fakecmaps.Push(cm);
@ -215,21 +233,6 @@ void R_InitColormaps ()
numfakecmaps = fakecmaps.Size();
}
//==========================================================================
//
// R_DeinitColormaps
//
//==========================================================================
void R_DeinitColormaps ()
{
if (realcolormaps != NULL)
{
delete[] realcolormaps;
realcolormaps = NULL;
}
}
//==========================================================================
//
// [RH] Returns an index into realcolormaps. Multiply it by

View File

@ -866,7 +866,10 @@ void R_InitSprites ()
numskins++;
}
SpriteFrames.Clear();
// [RH] Do some preliminary setup
if (skins != NULL) delete [] skins;
skins = new FPlayerSkin[numskins];
memset (skins, 0, sizeof(*skins) * numskins);
for (i = 0; i < numskins; i++)

View File

@ -869,7 +869,9 @@ void R_DeinitTranslationTables()
translationtables[i][j] = NULL;
}
}
translationtables[i].Clear();
}
BloodTranslationColors.Clear();
}
//----------------------------------------------------------------------------

View File

@ -587,6 +587,7 @@ void S_ParseReverbDef ()
int lump, lastlump = 0;
atterm (S_UnloadReverbDef);
S_UnloadReverbDef ();
while ((lump = Wads.FindLump ("REVERBS", &lastlump)) != -1)
{
@ -597,15 +598,21 @@ void S_ParseReverbDef ()
void S_UnloadReverbDef ()
{
ReverbContainer *probe = Environments;
ReverbContainer **pNext = NULL;
while (probe != NULL)
{
ReverbContainer *next = probe->Next;
if (!probe->Builtin)
{
if (pNext != NULL) *pNext = probe->Next;
delete[] const_cast<char *>(probe->Name);
delete probe;
}
else
{
pNext = &probe->Next;
}
probe = next;
}
Environments = &Off;

View File

@ -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.

View File

@ -130,11 +130,11 @@ extern TArray<level_info_t> wadlevelinfos;
static void ParseStatistics(const char *fn, TArray<FStatistics> &statlist)
{
statlist.Clear();
try
{
FScanner sc;
sc.OpenFile(fn);
statlist.Clear();
while (sc.GetString())
{

View File

@ -337,6 +337,8 @@ void LoadActors ()
{
int lastlump, lump;
StateParams.Clear();
GlobalSymbols.ReleaseSymbols();
DropItemList.Clear();
FScriptPosition::ResetErrorCounter();
InitThingdef();

View File

@ -123,7 +123,8 @@ class FStateExpressions
TArray<FStateExpression> 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);

View File

@ -2765,7 +2765,7 @@ FStateExpressions StateParams;
//
//==========================================================================
FStateExpressions::~FStateExpressions()
void FStateExpressions::Clear()
{
for(unsigned i=0; i<Size(); i++)
{
@ -2774,6 +2774,7 @@ FStateExpressions::~FStateExpressions()
delete expressions[i].expr;
}
}
expressions.Clear();
}
//==========================================================================

View File

@ -2050,6 +2050,11 @@ void V_InitFontColors ()
info.Index = -1;
TranslationParms[0].Clear();
TranslationParms[1].Clear();
TranslationLookup.Clear();
TranslationColors.Clear();
while ((lump = Wads.FindLump ("TEXTCOLO", &lastlump)) != -1)
{
if (gameinfo.flags & GI_NOTEXTCOLOR)
@ -2435,3 +2440,13 @@ void V_InitFonts()
}
}
}
void V_ClearFonts()
{
while (FFont::FirstFont != NULL)
{
delete FFont::FirstFont;
}
FFont::FirstFont = NULL;
SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = NULL;
}

View File

@ -128,7 +128,7 @@ protected:
static FFont *FirstFont;
friend struct FontsDeleter;
friend void V_Shutdown();
friend void V_ClearFonts();
friend FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font);
};
@ -137,6 +137,7 @@ protected:
extern FFont *SmallFont, *SmallFont2, *BigFont, *ConFont, *IntermissionFont;
void V_InitFonts();
void V_ClearFonts();
EColorRange V_FindFontColor (FName name);
PalEntry V_LogColorFromColorRange (EColorRange range);
EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int boldcolor);

View File

@ -1692,10 +1692,7 @@ void V_Shutdown()
s->ObjectFlags |= OF_YesReallyDelete;
delete s;
}
while (FFont::FirstFont != NULL)
{
delete FFont::FirstFont;
}
V_ClearFonts();
}
EXTERN_CVAR (Bool, vid_tft)

View File

@ -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;
}
}