- Merged a lot of these static destructor-only structs into regular

functions added to the exit chain with atterm so that they can be called
  in a deterministic order and not whatever order the linker decides to put
  them in.
- Fixed: DCajunMaster did not free its getspawned.
- Fixed: P_FreeLevelData() did not free ACS scripts.
- Fixed: Level snapshots were not freed at exit.
- Fixed: The save/load menu list was not freed at exit.
- Fixed: FCompressedMemFile needs a destructor to free the m_ImplodedBuffer.
- Fixed: G_DoLoadGame() did not free the engine string.
- Fixed: M_ReadSaveStrings() did not free the engine string.
- Fixed: Processing DEM_SAVEGAME did not free the pathname string.
- Added a check for truncated flats to FFlatTexture::MakeTexture() because
  Heretic's F_SKY1 is only four bytes long.
- Added a dump of the offending state to the "Cannot find state..." diagnostic.
- Fixed: FCompressedFile did not initialize m_Mode in its default constructor.
- Fixed: Heretic and Hexen status bars did not initialize ArtiRefresh.
- Fixed: PNGHandle destructor should use delete[] to free TextChunks.


SVN r111 (trunk)
This commit is contained in:
Randy Heit 2006-05-12 03:14:40 +00:00
commit 8fcf93d65a
68 changed files with 866 additions and 485 deletions

View file

@ -112,6 +112,8 @@ static void M_QuickLoad ();
static void M_LoadSelect (const FSaveGameNode *file);
static void M_SaveSelect (const FSaveGameNode *file);
static void M_ReadSaveStrings ();
static void M_UnloadSaveStrings ();
static FSaveGameNode *M_RemoveSaveSlot (FSaveGameNode *file);
static void M_ExtractSaveData (const FSaveGameNode *file);
static void M_UnloadSaveData ();
static void M_InsertSaveNode (FSaveGameNode *node);
@ -605,7 +607,7 @@ void M_GameFiles (int choice)
//
// Find savegames and read their titles
//
void M_ReadSaveStrings ()
static void M_ReadSaveStrings ()
{
if (SaveGames.IsEmpty ())
{
@ -613,6 +615,8 @@ void M_ReadSaveStrings ()
findstate_t c_file;
FString filter;
atterm (M_UnloadSaveStrings);
filter = G_BuildSaveName ("*.zds", -1);
filefirst = I_FindFirst (filter.GetChars(), &c_file);
if (filefirst != ((void *)(-1)))
@ -676,6 +680,10 @@ void M_ReadSaveStrings ()
}
delete[] ver;
}
if (engine != NULL)
{
delete[] engine;
}
delete png;
}
else
@ -725,6 +733,36 @@ void M_ReadSaveStrings ()
}
}
static void M_UnloadSaveStrings()
{
M_UnloadSaveData();
while (!SaveGames.IsEmpty())
{
M_RemoveSaveSlot (static_cast<FSaveGameNode *>(SaveGames.Head));
}
}
static FSaveGameNode *M_RemoveSaveSlot (FSaveGameNode *file)
{
FSaveGameNode *next = static_cast<FSaveGameNode *>(file->Succ);
if (file == TopSaveGame)
{
TopSaveGame = next;
}
if (quickSaveSlot == file)
{
quickSaveSlot = NULL;
}
if (lastSaveSlot == file)
{
lastSaveSlot = NULL;
}
file->Remove ();
delete file;
return next;
}
void M_InsertSaveNode (FSaveGameNode *node)
{
FSaveGameNode *probe;
@ -2800,21 +2838,7 @@ static void M_DeleteSaveResponse (int choice)
remove (SelSaveGame->Filename.GetChars());
M_UnloadSaveData ();
if (SelSaveGame == TopSaveGame)
{
TopSaveGame = next;
}
if (quickSaveSlot == SelSaveGame)
{
quickSaveSlot = NULL;
}
if (lastSaveSlot == SelSaveGame)
{
lastSaveSlot = NULL;
}
SelSaveGame->Remove ();
delete SelSaveGame;
SelSaveGame = next;
SelSaveGame = M_RemoveSaveSlot (SelSaveGame);
M_ExtractSaveData (SelSaveGame);
}
}
@ -3107,6 +3131,8 @@ void M_Init (void)
{
int i;
atterm (M_Deinit);
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
{
TopLevelMenu = currentMenu = &MainDef;