- 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
parent 01441cd4f0
commit 8fcf93d65a
68 changed files with 870 additions and 489 deletions

View file

@ -1,3 +1,23 @@
May 11, 2006
- 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.
May 11, 2006 (Changes by Graf Zahl)
- Converted the stealth monsters to DECORATE.
- Added string replacement option to obituary strings.

View file

@ -93,6 +93,11 @@ void G_DoReborn (int playernum, bool freshbot);
DCajunMaster::~DCajunMaster()
{
ForgetBots();
if (getspawned != NULL)
{
delete getspawned;
getspawned = NULL;
}
}
//This function is called every tick (from g_game.c),

View file

@ -87,6 +87,9 @@ extern int gametic;
extern bool automapactive; // in AM_map.c
extern BOOL advancedemo;
extern FBaseCVar *CVars;
extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE];
int ConCols, PhysRows;
BOOL vidactive = false, gotconback = false;
BOOL cursoron = false;
@ -103,6 +106,13 @@ static char *BufferRover = ConsoleBuffer;
static void ClearConsole ();
struct GameAtExit
{
GameAtExit *Next;
char Command[1];
};
static GameAtExit *ExitCmdList;
#define SCROLLUP 1
#define SCROLLDN 2
@ -116,6 +126,11 @@ static const char *TickerLabel;
static bool TickerVisible;
static bool ConsoleDrawing;
// Buffer for AddToConsole()
static char *work = NULL;
static int worklen = 0;
struct History
{
struct History *Older;
@ -133,22 +148,6 @@ static byte CmdLine[260];
static struct History *HistHead = NULL, *HistTail = NULL, *HistPos = NULL;
static int HistSize;
static struct HistoryFree
{
~HistoryFree()
{
History *hist = HistTail;
while (hist != NULL)
{
History *next = hist->Newer;
free (hist);
hist = next;
}
}
} HistoryFree_er;
CVAR (Float, con_notifytime, 3.f, CVAR_ARCHIVE)
CVAR (Bool, con_centernotify, false, CVAR_ARCHIVE)
CUSTOM_CVAR (Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high resolutions?
@ -421,6 +420,113 @@ void C_InitConsole (int width, int height, BOOL ingame)
}
}
//==========================================================================
//
// CCMD atexit
//
//==========================================================================
CCMD (atexit)
{
if (argv.argc() == 1)
{
Printf ("Registered atexit commands:\n");
GameAtExit *record = ExitCmdList;
while (record != NULL)
{
Printf ("%s\n", record->Command);
record = record->Next;
}
return;
}
for (int i = 1; i < argv.argc(); ++i)
{
GameAtExit *record = (GameAtExit *)M_Malloc (
sizeof(GameAtExit)+strlen(argv[i]));
strcpy (record->Command, argv[i]);
record->Next = ExitCmdList;
ExitCmdList = record;
}
}
//==========================================================================
//
// C_DeinitConsole
//
// Executes the contents of the atexit cvar, if any, at quit time.
// Then releases all of the console's memory.
//
//==========================================================================
void C_DeinitConsole ()
{
GameAtExit *cmd = ExitCmdList;
while (cmd != NULL)
{
GameAtExit *next = cmd->Next;
AddCommandString (cmd->Command);
free (cmd);
cmd = next;
}
// Free command history
History *hist = HistTail;
while (hist != NULL)
{
History *next = hist->Newer;
free (hist);
hist = next;
}
HistTail = HistHead = HistPos = NULL;
// Free cvars allocated at runtime
FBaseCVar *var, *next, **nextp;
for (var = CVars, nextp = &CVars; var != NULL; var = next)
{
next = var->m_Next;
if (var->GetFlags() & CVAR_UNSETTABLE)
{
delete var;
*nextp = next;
}
else
{
nextp = &var->m_Next;
}
}
// Free alias commands. (i.e. The "commands" that can be allocated
// at runtime.)
for (size_t i = 0; i < countof(Commands); ++i)
{
FConsoleCommand *cmd = Commands[i];
while (cmd != NULL)
{
FConsoleCommand *next = cmd->m_Next;
if (cmd->IsAlias())
{
delete cmd;
}
cmd = next;
}
}
// Make sure all tab commands are cleared before the memory for
// their names is deallocated.
C_ClearTabCommands ();
// Free AddToConsole()'s work buffer
if (work != NULL)
{
free (work);
work = NULL;
worklen = 0;
}
}
static void ClearConsole ()
{
RowAdjust = 0;
@ -544,21 +650,6 @@ static void AddLine (const char *text, bool more, int len)
}
}
static char *work = NULL;
static int worklen = 0;
static struct FreeWork
{
~FreeWork()
{
if (work != NULL)
{
free (work);
work = NULL;
}
}
} FreeTheWork;
void AddToConsole (int printlevel, const char *text)
{
static enum
@ -1814,6 +1905,11 @@ void C_RemoveTabCommand (const char *name)
}
}
void C_ClearTabCommands ()
{
TabCommands.Clear();
}
static int FindDiffPoint (FName name1, const char *str2)
{
const char *str1 = name1.GetChars();

View file

@ -51,6 +51,7 @@ extern constate_e ConsoleState;
// Initialize the console
void C_InitConsole (int width, int height, BOOL ingame);
void C_DeinitConsole ();
// Adjust the console for a new screen mode
void C_NewModeAdjust (void);
@ -78,5 +79,6 @@ BOOL C_Responder (event_t *ev);
void C_AddTabCommand (const char *name);
void C_RemoveTabCommand (const char *name);
void C_ClearTabCommands(); // Removes all tab commands
#endif

View file

@ -68,22 +68,6 @@ FBaseCVar *CVars = NULL;
int cvar_defflags;
static struct RuntimeCVarDestroyer
{
~RuntimeCVarDestroyer()
{
FBaseCVar *var, *next;
for (var = CVars; var != NULL; var = next)
{
next = var->m_Next;
if (var->GetFlags() & CVAR_UNSETTABLE)
{
delete var;
}
}
}
} DestroyTheRuntimeCVars;
FBaseCVar::FBaseCVar (const FBaseCVar &var)
{
I_FatalError ("Use of cvar copy constructor");

View file

@ -175,7 +175,7 @@ private:
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, DWORD filter);
friend struct RuntimeCVarDestroyer;
friend void C_DeinitConsole();
};
class FBoolCVar : public FBaseCVar

View file

@ -149,29 +149,6 @@ FActionMap ActionMaps[] =
#define NUM_ACTIONS countof(ActionMaps)
static struct AliasKiller
{
~AliasKiller()
{
// Scan the hash table for all aliases and delete them.
// Regular commands will be destroyed automatically.
for (size_t i = 0; i < countof(Commands); ++i)
{
FConsoleCommand *cmd = Commands[i];
while (cmd != NULL)
{
FConsoleCommand *next = cmd->m_Next;
if (cmd->IsAlias())
{
delete cmd;
}
cmd = next;
}
}
}
} KillTheAliases;
IMPLEMENT_CLASS (DWaitingCommand)

View file

@ -91,12 +91,6 @@
// TYPES -------------------------------------------------------------------
struct GameAtExit
{
GameAtExit *Next;
char Command[1];
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
extern void M_RestoreMode ();
@ -117,7 +111,6 @@ void D_AddWildFile (const char *pattern);
void D_DoomLoop ();
static const char *BaseFileSearch (const char *file, const char *ext, bool lookfirstinprogdir=false);
static void STACK_ARGS DoConsoleAtExit ();
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
@ -221,7 +214,6 @@ static const char *IWADNames[] =
"strife0.wad",
NULL
};
static GameAtExit *ExitCmdList;
// CODE --------------------------------------------------------------------
@ -620,56 +612,6 @@ void D_Display (bool screenshot)
FrameCycles = cycles;
}
//==========================================================================
//
// DoConsoleAtExit
//
// Executes the contents of the atexit cvar, if any, at quit time.
//
//==========================================================================
static void STACK_ARGS DoConsoleAtExit ()
{
GameAtExit *cmd = ExitCmdList;
while (cmd != NULL)
{
GameAtExit *next = cmd->Next;
AddCommandString (cmd->Command);
free (cmd);
cmd = next;
}
}
//==========================================================================
//
// CCMD atexit
//
//==========================================================================
CCMD (atexit)
{
if (argv.argc() == 1)
{
Printf ("Registered atexit commands:\n");
GameAtExit *record = ExitCmdList;
while (record != NULL)
{
Printf ("%s\n", record->Command);
record = record->Next;
}
return;
}
for (int i = 1; i < argv.argc(); ++i)
{
GameAtExit *record = (GameAtExit *)M_Malloc (
sizeof(GameAtExit)+strlen(argv[i]));
strcpy (record->Command, argv[i]);
record->Next = ExitCmdList;
ExitCmdList = record;
}
}
//==========================================================================
//
// D_ErrorCleanup ()
@ -1905,12 +1847,9 @@ void D_DoomMain (void)
file[PATH_MAX-1] = 0;
#if defined(_MSC_VER) || defined(__GNUC__)
PClass::StaticInit ();
#endif
atterm (DObject::StaticShutdown);
atterm (DoConsoleAtExit);
PClass::StaticInit ();
atterm (C_DeinitConsole);
gamestate = GS_STARTUP;

View file

@ -1629,7 +1629,7 @@ void D_CheckNetGame (void)
// Called before quitting to leave a net game
// without hanging the other players
//
void STACK_ARGS D_QuitNetGame (void)
void D_QuitNetGame (void)
{
int i, j, k;
@ -2184,7 +2184,9 @@ void Net_DoCommand (int type, byte **stream, int player)
case DEM_SAVEGAME:
if (gamestate == GS_LEVEL)
{
savegamefile = ReadString (stream);
s = ReadString (stream);
savegamefile = s;
delete[] s;
s = ReadString (stream);
memset (savedescription, 0, sizeof(savedescription));
strncpy (savedescription, s, sizeof(savedescription));

View file

@ -108,7 +108,7 @@ void NetUpdate (void);
// Broadcasts special packets to other players
// to notify of game exit
void STACK_ARGS D_QuitNetGame (void);
void D_QuitNetGame (void);
//? how many ticks to run?
void TryRunTics (void);

View file

@ -595,7 +595,7 @@ void DObject::DestroyScan ()
}
}
void STACK_ARGS DObject::StaticShutdown ()
void DObject::StaticShutdown ()
{
Inactive = true;
}

View file

@ -254,7 +254,7 @@ public:
// use this method.
static void PointerSubstitution (DObject *old, DObject *notOld);
static void STACK_ARGS StaticShutdown ();
static void StaticShutdown ();
PClass *GetClass() const
{

View file

@ -10,42 +10,51 @@ PClass *PClass::TypeHash[PClass::HASH_SIZE];
// A harmless non_NULL FlatPointer for classes without pointers.
static const size_t TheEnd = ~0;
static struct TypeInfoDataFreeer
void PClass::StaticInit ()
{
~TypeInfoDataFreeer()
{
TArray<size_t *> uniqueFPs(64);
unsigned int i, j;
atterm (StaticShutdown);
for (i = 0; i < PClass::m_Types.Size(); ++i)
TAutoSegIterator<ClassReg *, &CRegHead, &CRegTail> probe;
while (++probe != NULL)
{
probe->RegisterClass ();
}
}
void PClass::StaticShutdown ()
{
TArray<size_t *> uniqueFPs(64);
unsigned int i, j;
for (i = 0; i < PClass::m_Types.Size(); ++i)
{
PClass *type = PClass::m_Types[i];
PClass::m_Types[i] = NULL;
if (type->FlatPointers != &TheEnd && type->FlatPointers != type->Pointers)
{
PClass *type = PClass::m_Types[i];
PClass::m_Types[i] = NULL;
if (type->FlatPointers != &TheEnd && type->FlatPointers != type->Pointers)
// FlatPointers are shared by many classes, so we must check for
// duplicates and only delete those that are unique.
for (j = 0; j < uniqueFPs.Size(); ++j)
{
// FlatPointers are shared by many classes, so we must check for
// duplicates and only delete those that are unique.
for (j = 0; j < uniqueFPs.Size(); ++j)
if (type->FlatPointers == uniqueFPs[j])
{
if (type->FlatPointers == uniqueFPs[j])
{
break;
}
}
if (j == uniqueFPs.Size())
{
uniqueFPs.Push(const_cast<size_t *>(type->FlatPointers));
break;
}
}
// For runtime classes, this call will also delete the PClass.
PClass::StaticFreeData (type);
}
for (i = 0; i < uniqueFPs.Size(); ++i)
{
delete[] uniqueFPs[i];
if (j == uniqueFPs.Size())
{
uniqueFPs.Push(const_cast<size_t *>(type->FlatPointers));
}
}
// For runtime classes, this call will also delete the PClass.
PClass::StaticFreeData (type);
}
} FreeTypeInfoData;
for (i = 0; i < uniqueFPs.Size(); ++i)
{
delete[] uniqueFPs[i];
}
}
void PClass::StaticFreeData (PClass *type)
{
@ -70,17 +79,6 @@ void PClass::StaticFreeData (PClass *type)
}
}
void PClass::StaticInit ()
{
TAutoSegIterator<ClassReg *, &CRegHead, &CRegTail> probe;
while (++probe != NULL)
{
probe->RegisterClass ();
}
}
void ClassReg::RegisterClass ()
{
assert (MyClass != NULL);

View file

@ -8,6 +8,7 @@
struct PClass
{
static void StaticInit ();
static void StaticShutdown ();
static void StaticFreeData (PClass *type);
// Per-class information -------------------------------------

View file

@ -135,6 +135,7 @@ void FCompressedFile::BeEmpty ()
m_Buffer = NULL;
m_File = NULL;
m_NoCompress = false;
m_Mode = ENotOpen;
}
static const char LZOSig[4] = { 'F', 'L', 'Z', 'O' };
@ -425,6 +426,14 @@ FCompressedMemFile::FCompressedMemFile (const char *name, EOpenMode mode)
}
*/
FCompressedMemFile::~FCompressedMemFile ()
{
if (m_ImplodedBuffer != NULL)
{
free (m_ImplodedBuffer);
}
}
bool FCompressedMemFile::Open (const char *name, EOpenMode mode)
{
if (mode == EWriting)

View file

@ -46,7 +46,8 @@ public:
enum EOpenMode
{
EReading,
EWriting
EWriting,
ENotOpen
};
enum ESeekPos
@ -117,6 +118,7 @@ class FCompressedMemFile : public FCompressedFile
public:
FCompressedMemFile ();
FCompressedMemFile (FILE *file); // Create for reading
~FCompressedMemFile ();
bool Open (const char *name, EOpenMode mode); // Works for reading only
bool Open (void *memblock); // Open for reading only

View file

@ -1623,7 +1623,7 @@ void G_DoLoadGame ()
// Check whether this savegame actually has been created by a compatible engine.
// Since there are ZDoom derivates using the exact same savegame format but
// with mutual incompatibilities this check simplifies things significantly.
char * engine = M_GetPNGText (png, "Engine");
char *engine = M_GetPNGText (png, "Engine");
if (engine == NULL || 0 != strcmp (engine, GAMESIG))
{
// Make a special case for the message printed for old savegames that don't
@ -1634,12 +1634,17 @@ void G_DoLoadGame ()
}
else
{
Printf ("Savegame is from another ZDoom-based engine\n");
Printf ("Savegame is from another ZDoom-based engine: %s\n", engine);
delete[] engine;
}
delete png;
fclose (stdfile);
return;
}
if (engine != NULL)
{
delete[] engine;
}
if (!M_GetPNGText (png, "ZDoom Save Version", sigcheck, 16) ||
0 != strncmp (sigcheck, SAVESIG, 9) || // ZDOOMSAVE is the first 9 chars

View file

@ -211,6 +211,7 @@ public:
oldlife = -1;
oldkeys = -1;
oldhealth = -1;
ArtiRefresh = 0;
}
DrawMainBar ();
}
@ -408,10 +409,10 @@ private:
// Ammo
GetCurrentAmmo (ammo1, ammo2, ammocount1, ammocount2);
if (ammo1==ammo2)
if (ammo1 == ammo2)
{
// Don't show the same ammo twice.
ammo2=NULL;
ammo2 = NULL;
}
if (oldammo1 != ammo1 || oldammo2 != ammo2 ||
oldammocount1 != ammocount1 || oldammocount2 != ammocount2)

View file

@ -278,6 +278,7 @@ public:
oldfrags = -9999; //can't use -1, 'cuz of negative frags
oldlife = -1;
oldkeys[0] = oldkeys[1] = oldkeys[2] = oldkeys[3] = oldkeys[4] = NULL;
ArtiRefresh = 0;
//oldhealth = -1;
}
if (!automapactive)

View file

@ -99,14 +99,6 @@ static void ClearEpisodes ();
static void ClearLevelInfoStrings (level_info_t *linfo);
static void ClearClusterInfoStrings (cluster_info_t *cinfo);
static struct EpisodeKiller
{
~EpisodeKiller()
{
ClearEpisodes();
}
} KillTheEpisodes;
static FRandom pr_classchoice ("RandomPlayerClassChoice");
TArray<EndSequence> EndSequences;
@ -141,23 +133,6 @@ level_locals_t level; // info about current level
static TArray<cluster_info_t> wadclusterinfos;
TArray<level_info_t> wadlevelinfos;
static struct LevelClusterInfoKiller
{
~LevelClusterInfoKiller()
{
unsigned int i;
for (i = 0; i < wadlevelinfos.Size(); ++i)
{
ClearLevelInfoStrings (&wadlevelinfos[i]);
}
for (i = 0; i < wadclusterinfos.Size(); ++i)
{
ClearClusterInfoStrings (&wadclusterinfos[i]);
}
}
} KillTheLevelAndClusterInfos;
// MAPINFO is parsed slightly differently when the map name is just a number.
static bool HexenHack;
@ -469,6 +444,8 @@ void G_ParseMapInfo ()
{
int lump, lastlump = 0;
atterm (G_UnloadMapInfo);
// Parse the default MAPINFO for the current game.
switch (gameinfo.gametype)
{
@ -1181,6 +1158,27 @@ void G_SetForEndGame (char *nextmap)
}
}
void G_UnloadMapInfo ()
{
unsigned int i;
G_ClearSnapshots ();
for (i = 0; i < wadlevelinfos.Size(); ++i)
{
ClearLevelInfoStrings (&wadlevelinfos[i]);
}
wadlevelinfos.Clear();
for (i = 0; i < wadclusterinfos.Size(); ++i)
{
ClearClusterInfoStrings (&wadclusterinfos[i]);
}
wadclusterinfos.Clear();
ClearEpisodes();
}
level_info_t *FindLevelByWarpTrans (int num)
{
for (unsigned i = wadlevelinfos.Size(); i-- != 0; )

View file

@ -318,6 +318,7 @@ level_info_t *CheckLevelRedirect (level_info_t *info);
char *CalcMapName (int episode, int level);
void G_ParseMapInfo (void);
void G_UnloadMapInfo ();
void G_ClearSnapshots (void);
void G_SnapshotLevel (void);

View file

@ -87,14 +87,6 @@ static bool ignorekey; // set to true when the current lock is not being used
static void ClearLocks();
static struct LockDeleter
{
~LockDeleter()
{
ClearLocks();
}
} DeleteTheLocks;
static const char * keywords_lock[]={
"ANY",
"MESSAGE",
@ -327,6 +319,7 @@ static void ClearLocks()
//===========================================================================
//
// P_InitKeyMessages
//
//===========================================================================
@ -359,6 +352,16 @@ void P_InitKeyMessages()
keysdone=true;
}
//===========================================================================
//
// P_DeinitKeyMessages
//
//===========================================================================
void P_DeinitKeyMessages()
{
ClearLocks();
}
//===========================================================================
//

View file

@ -17,6 +17,7 @@ protected:
bool P_CheckKeys (AActor *owner, int keynum, bool remote);
void P_InitKeyMessages ();
void P_DeinitKeyMessages ();
int P_GetMapColorForLock (int lock);
int P_GetMapColorForKey (AInventory *key);

View file

@ -86,7 +86,14 @@ FArchive &operator<< (FArchive &arc, FState *&state)
}
else
{
I_Error ("Cannot find owner for state %p\n", state);
I_Error ("Cannot find owner for state %p:\n"
"%s %c%c %3d [%p] -> %p", state,
sprites[state->sprite.index].name,
state->GetFrame() + 'A',
state->GetFullbright() ? '*' : ' ',
state->GetTics(),
state->GetAction(),
state->GetNextState());
}
}
else

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;

View file

@ -44,10 +44,11 @@ void M_Ticker (void);
// draws the menus directly into the screen buffer.
void M_Drawer (void);
// Called by D_DoomMain,
// loads the config file.
// Called by D_DoomMain, loads the config file.
void M_Init (void);
void M_Deinit ();
// Called by intro code to force menu up upon a keypress,
// does nothing if menu is already up.
void M_StartControlPanel (bool makeSound);

View file

@ -337,7 +337,7 @@ FString GetUserFile (const char *file, bool nodir)
// M_SaveDefaults
//
void STACK_ARGS M_SaveDefaults ()
void M_SaveDefaults ()
{
GameConfig->ArchiveGlobalData ();
if (GameNames[gameinfo.gametype] != NULL)

View file

@ -40,7 +40,7 @@ void M_ScreenShot (char *filename);
void M_LoadDefaults ();
void STACK_ARGS M_SaveDefaults ();
void M_SaveDefaults ();
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection);
FString GetUserFile (const char *path, bool nodir=false);

View file

@ -812,22 +812,6 @@ EXTERN_CVAR (Bool, fullscreen)
static value_t Depths[22];
static struct DepthNameKiller
{
~DepthNameKiller()
{
for (int i = 0; i < countof(Depths); ++i)
{
if (Depths[i].name != NULL)
{
delete[] Depths[i].name;
Depths[i].name = NULL;
}
}
M_FreeModesList();
}
} KillTheDepthValues;
EXTERN_CVAR (Bool, vid_tft) // Defined below
CUSTOM_CVAR (Int, menu_screenratios, 0, CVAR_ARCHIVE)
{
@ -3055,3 +3039,20 @@ CCMD (addmenukey)
ControlsMenu.items = &CustomControlsItems[0];
ControlsMenu.numitems = (int)CustomControlsItems.Size();
}
void M_Deinit ()
{
// Free bitdepth names for the modes menu.
for (int i = 0; i < countof(Depths); ++i)
{
if (Depths[i].name != NULL)
{
delete[] Depths[i].name;
Depths[i].name = NULL;
}
}
// Free resolutions from the modes menu.
M_FreeModesList();
}

View file

@ -81,7 +81,7 @@ PNGHandle::~PNGHandle ()
{
for (unsigned int i = 0; i < TextChunks.Size(); ++i)
{
delete TextChunks[i];
delete[] TextChunks[i];
}
if (bDeleteFilePtr)
{

View file

@ -74,6 +74,7 @@ CVAR (Bool, genglnodes, false, CVAR_SERVERINFO);
CVAR (Bool, showloadtimes, false, 0);
static void P_InitTagLists ();
static void P_Shutdown ();
//
// MAP related Lookup tables.
@ -2798,6 +2799,8 @@ void P_FreeLevelData ()
level.total_monsters = level.total_items = level.total_secrets =
level.killed_monsters = level.found_items = level.found_secrets =
wminfo.maxfrags = 0;
FBehavior::StaticUnloadModules ();
level.behavior = NULL;
if (vertexes != NULL)
{
delete[] vertexes;
@ -2915,42 +2918,32 @@ void P_FreeLevelData ()
extern msecnode_t *headsecnode;
static struct AutoFreeLevelData
void P_FreeExtraLevelData()
{
~AutoFreeLevelData()
// Free all blocknodes and msecnodes.
// *NEVER* call this function without calling
// P_FreeLevelData() first, or they might not all be freed.
{
P_FreeLevelData();
// Blocknodes and msecnodes should be freed now, when we
// can be sure they are all easily located in their
// free lists.
FBlockNode *node = FBlockNode::FreeBlocks;
while (node != NULL)
{
FBlockNode *node = FBlockNode::FreeBlocks;
while (node != NULL)
{
FBlockNode *next = node->NextBlock;
delete node;
node = next;
}
}
{
msecnode_t *node = headsecnode;
while (node != NULL)
{
msecnode_t *next = node->m_snext;
free (node);
node = next;
}
headsecnode = NULL;
}
if (StatusBar != NULL)
{
delete StatusBar;
StatusBar = NULL;
FBlockNode *next = node->NextBlock;
delete node;
node = next;
}
}
} LevelDataFree_er;
{
msecnode_t *node = headsecnode;
while (node != NULL)
{
msecnode_t *next = node->m_snext;
free (node);
node = next;
}
headsecnode = NULL;
}
}
//
// P_SetupLevel
@ -3349,6 +3342,8 @@ void P_SetupLevel (char *lumpname, int position)
//
void P_Init ()
{
atterm (P_Shutdown);
P_InitEffects (); // [RH]
P_InitPicAnims ();
P_InitSwitchList ();
@ -3357,6 +3352,19 @@ void P_Init ()
R_InitSprites ();
}
static void P_Shutdown ()
{
R_DeinitSprites ();
P_DeinitKeyMessages ();
P_FreeLevelData ();
P_FreeExtraLevelData ();
if (StatusBar != NULL)
{
delete StatusBar;
StatusBar = NULL;
}
}
#if 0
#include "c_dispatch.h"
CCMD (lineloc)

View file

@ -33,6 +33,7 @@
void P_SetupLevel (char *mapname, int position);
void P_FreeLevelData();
void P_FreeExtraLevelData();
// Called by startup code.
void P_Init (void);

View file

@ -83,18 +83,6 @@ drawseg_t *drawsegs;
drawseg_t* firstdrawseg;
drawseg_t* ds_p;
static struct DrawSegFree
{
~DrawSegFree()
{
if (drawsegs != NULL)
{
free (drawsegs);
drawsegs = NULL;
}
}
} FreeDrawSegs;
size_t FirstInterestingDrawseg;
TArray<size_t> InterestingDrawsegs;

View file

@ -1508,7 +1508,11 @@ void FFlatTexture::MakeTexture ()
{
FWadLump lump = Wads.OpenLumpNum (SourceLump);
Pixels = new BYTE[Width*Height];
lump.Read (Pixels, Width*Height);
long numread = lump.Read (Pixels, Width*Height);
if (numread < Width*Height)
{
memset (Pixels + numread, 0xBB, Width*Height - numread);
}
FlipSquareBlockRemap (Pixels, Width, Height, GPalette.Remap);
}
@ -2842,23 +2846,6 @@ int firstfakecmap;
byte *realcolormaps;
int lastusedcolormap;
static struct ColorMapKiller
{
~ColorMapKiller()
{
if (fakecmaps != NULL)
{
delete[] fakecmaps;
fakecmaps = NULL;
}
if (realcolormaps != NULL)
{
delete[] realcolormaps;
realcolormaps = NULL;
}
}
} KillTheColormaps;
void R_SetDefaultColormap (const char *name)
{
if (strnicmp (fakecmaps[0].name, name, 8) != 0)
@ -2983,6 +2970,20 @@ void R_InitColormaps ()
}
}
void R_DeinitColormaps ()
{
if (fakecmaps != NULL)
{
delete[] fakecmaps;
fakecmaps = NULL;
}
if (realcolormaps != NULL)
{
delete[] realcolormaps;
realcolormaps = NULL;
}
}
// [RH] Returns an index into realcolormaps. Multiply it by
// 256*NUMCOLORMAPS to find the start of the colormap to use.
// WATERMAP is an exception and returns a blending value instead.
@ -3026,7 +3027,25 @@ void R_InitData ()
C_InitConsole (SCREENWIDTH, SCREENHEIGHT, true);
}
void R_DeinitData ()
{
R_DeinitColormaps ();
// Free openings
if (openings != NULL)
{
free (openings);
openings = NULL;
}
// Free drawsegs
if (drawsegs != NULL)
{
free (drawsegs);
drawsegs = NULL;
}
}
//
// R_PrecacheLevel
@ -3382,7 +3401,7 @@ static void R_InitPatches ()
}
}
#if 0
#ifdef _DEBUG
// Prints the spans generated for a texture. Only needed for debugging.
CCMD (printspans)
{

View file

@ -289,6 +289,7 @@ private:
// I/O, setting up the stuff.
void R_InitData (void);
void R_DeinitData ();
void R_PrecacheLevel (void);

View file

@ -77,6 +77,8 @@ bool RP_SetupFrame (bool backside);
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void R_Shutdown();
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern bool DrawFSHUD; // [RH] Defined in d_main.cpp
@ -764,8 +766,10 @@ CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
//
//==========================================================================
void R_Init (void)
void R_Init ()
{
atterm (R_Shutdown);
R_InitData ();
R_InitPointToAngle ();
R_InitTables ();
@ -790,6 +794,19 @@ void R_Init (void)
framecount = 0;
}
//==========================================================================
//
// R_Shutdown
//
//==========================================================================
static void R_Shutdown ()
{
R_DeinitParticles();
R_DeinitPlanes();
R_DeinitData();
}
//==========================================================================
//
// R_PointInSubsector

View file

@ -72,20 +72,6 @@ static visplane_t *visplanes[MAXVISPLANES+1]; // killough
static visplane_t *freetail; // killough
static visplane_t **freehead = &freetail; // killough
static struct VisPlaneFree
{
~VisPlaneFree()
{
R_ClearPlanes(false);
for (visplane_t *pl = freetail; pl != NULL; )
{
visplane_t *next = pl->next;
free (pl);
pl = next;
}
}
} VisPlaneFree_er;
visplane_t *floorplane;
visplane_t *ceilingplane;
@ -113,18 +99,6 @@ size_t maxopenings;
short *openings;
ptrdiff_t lastopening;
static struct OpeningsFree
{
~OpeningsFree()
{
if (openings != NULL)
{
free (openings);
openings = NULL;
}
}
} FreeOpenings;
//
// Clip values are the solid pixel bounding the range.
// floorclip starts out SCREENHEIGHT and is just outside the range
@ -181,6 +155,23 @@ void R_InitPlanes ()
{
}
//==========================================================================
//
// R_DeinitPlanes
//
//==========================================================================
void R_DeinitPlanes ()
{
R_ClearPlanes(false);
for (visplane_t *pl = freetail; pl != NULL; )
{
visplane_t *next = pl->next;
free (pl);
pl = next;
}
}
//==========================================================================
//
// R_MapPlane

View file

@ -80,6 +80,7 @@ extern short ceilingclip[MAXWIDTH];
extern fixed_t yslope[MAXHEIGHT];
void R_InitPlanes ();
void R_DeinitPlanes ();
void R_ClearPlanes (bool fullclear);
void R_DrawPlanes ();

View file

@ -678,17 +678,9 @@ vissprite_t **vissprite_p;
vissprite_t **lastvissprite;
int newvissprite;
static struct VisSpriteDeleter
{
~VisSpriteDeleter()
{
for (int i = 0; i < MaxVisSprites; ++i)
{
delete vissprites[i];
}
free (vissprites);
}
} DeleteTheVisSprites;
static vissprite_t **spritesorter;
static int spritesortersize = 0;
static int vsprcount;
static void R_CreateSkinTranslation (const char *palname)
{
@ -797,14 +789,33 @@ void R_InitSprites ()
qsort (&skins[1], numskins-1, sizeof(FPlayerSkin), skinsorter);
}
static struct SkinDeleter
void R_DeinitSprites()
{
~SkinDeleter()
// Free skins
if (skins != NULL)
{
if (skins!=NULL) delete[] skins;
delete[] skins;
skins = NULL;
}
} DeleteTheSkins;
// Free vissprites
for (int i = 0; i < MaxVisSprites; ++i)
{
delete vissprites[i];
}
free (vissprites);
vissprites = NULL;
vissprite_p = lastvissprite = NULL;
MaxVisSprites = 0;
// Free vissprites sorter
if (spritesorter != NULL)
{
delete[] spritesorter;
spritesortersize = 0;
spritesorter = NULL;
}
}
//
// R_ClearSprites
@ -1562,23 +1573,6 @@ void R_DrawPlayerSprites (void)
// more vissprites that need to be sorted, the better the performance
// gain compared to the old function.
//
static vissprite_t **spritesorter;
static int spritesortersize = 0;
static int vsprcount;
static struct SpriteSorterFree
{
~SpriteSorterFree()
{
if (spritesorter != NULL)
{
delete[] spritesorter;
spritesortersize = 0;
spritesorter = NULL;
}
}
} SpriteSorterFree_er;
// Sort vissprites by depth, far to near
static int STACK_ARGS sv_compare (const void *arg1, const void *arg2)
{
@ -2006,14 +2000,6 @@ void R_DrawMasked (void)
// [RH] Particle functions
//
static void STACK_ARGS FreeParticles()
{
if (Particles != NULL)
{
delete[] Particles;
}
}
void R_InitParticles ()
{
char *i;
@ -2027,7 +2013,16 @@ void R_InitParticles ()
Particles = new particle_t[NumParticles];
R_ClearParticles ();
atterm (FreeParticles);
atterm (R_DeinitParticles);
}
void R_DeinitParticles()
{
if (Particles != NULL)
{
delete[] Particles;
Particles = NULL;
}
}
void R_ClearParticles ()

View file

@ -59,6 +59,7 @@ inline particle_t *NewParticle (void)
}
void R_InitParticles ();
void R_DeinitParticles ();
void R_ClearParticles ();
void R_DrawParticle (vissprite_t *);
void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside);
@ -97,6 +98,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside);
void R_AddPSprites ();
void R_DrawSprites ();
void R_InitSprites ();
void R_DeinitSprites ();
void R_ClearSprites ();
void R_DrawMasked ();

View file

@ -49,6 +49,7 @@
#include "r_data.h"
#include "m_random.h"
#include "d_netinf.h"
#include "i_system.h"
// MACROS ------------------------------------------------------------------
@ -210,19 +211,6 @@ static const char *SICommandStrings[] =
static TArray<FRandomSoundList> S_rnd;
static FMusicVolume *MusicVolumes;
static struct MusicVolumeDeleter
{
~MusicVolumeDeleter()
{
while(MusicVolumes!=NULL)
{
FMusicVolume * next = MusicVolumes->Next;
free(MusicVolumes);
MusicVolumes=next;
}
}
} DeleteTheMusicVolumes;
static int NumPlayerReserves;
static bool DoneReserving;
static bool PlayerClassesIsSorted;
@ -568,26 +556,29 @@ static void S_ClearSoundData()
S_sfx.Clear();
for(i=0;i<256;i++)
for(i = 0; i < countof(Ambients); i++)
{
if (Ambients[i]) delete Ambients[i];
Ambients[i]=NULL;
if (Ambients[i] != NULL)
{
delete Ambients[i];
Ambients[i] = NULL;
}
}
while (MusicVolumes != NULL)
{
FMusicVolume * me = MusicVolumes;
FMusicVolume *me = MusicVolumes;
MusicVolumes = me->Next;
delete me;
}
S_rnd.Clear();
DoneReserving=false;
NumPlayerReserves=0;
PlayerClassesIsSorted=false;
DoneReserving = false;
NumPlayerReserves = 0;
PlayerClassesIsSorted = false;
PlayerClasses.Clear();
PlayerSounds.Clear();
DefPlayerClass=0;
*DefPlayerClassName=0;
DefPlayerClass = 0;
*DefPlayerClassName = 0;
}
//==========================================================================
@ -602,6 +593,7 @@ void S_ParseSndInfo ()
{
int lump;
atterm (S_ClearSoundData);
S_ClearSoundData(); // remove old sound data first!
CurrentPitchMask = 0;

View file

@ -6,6 +6,7 @@
#include "cmdlib.h"
#include "templates.h"
#include "w_wad.h"
#include "i_system.h"
struct FEAXField
{
@ -382,25 +383,6 @@ ReverbContainer *DefaultEnvironments[26] =
ReverbContainer *Environments = &Off;
static struct ReverbContainerDeleter
{
~ReverbContainerDeleter()
{
ReverbContainer *probe = Environments;
while (probe != NULL)
{
ReverbContainer *next = probe->Next;
if (!probe->Builtin)
{
delete[] const_cast<char *>(probe->Name);
delete probe;
}
probe = next;
}
}
} DeleteTheReverbContainers;
ReverbContainer *S_FindEnvironment (const char *name)
{
ReverbContainer *probe = Environments;
@ -587,6 +569,8 @@ void S_ParseSndEax ()
{
int lump, lastlump = 0;
atterm (S_UnloadSndEax);
while ((lump = Wads.FindLump ("SNDEAX", &lastlump)) != -1)
{
SC_OpenLumpNum (lump, "SNDEAX");
@ -594,3 +578,20 @@ void S_ParseSndEax ()
SC_Close ();
}
}
void S_UnloadSndEax ()
{
ReverbContainer *probe = Environments;
while (probe != NULL)
{
ReverbContainer *next = probe->Next;
if (!probe->Builtin)
{
delete[] const_cast<char *>(probe->Name);
delete probe;
}
probe = next;
}
Environments = &Off;
}

View file

@ -167,29 +167,6 @@ CVAR (Bool, snd_flipstereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
// CODE --------------------------------------------------------------------
static struct FreeSoundData
{
~FreeSoundData()
{
if (Channel != NULL)
{
delete[] Channel;
Channel = NULL;
numChannels = 0;
}
if (SoundCurve != NULL)
{
delete[] SoundCurve;
SoundCurve = NULL;
}
if (PlayList != NULL)
{
delete PlayList;
PlayList = NULL;
}
}
} SoundDataFree_er;
//==========================================================================
//
// P_AproxDistance2
@ -306,6 +283,7 @@ void S_Init ()
int curvelump;
Printf ("S_Init\n");
atterm (S_Shutdown);
// remove old data (S_Init can be called multiple times!)
LastLocalSndInfo = LastLocalSndSeq = "";
@ -365,6 +343,32 @@ void S_Init ()
// S_sfx[i].usefulness = -1;
}
//==========================================================================
//
// S_Shutdown
//
//==========================================================================
void S_Shutdown ()
{
if (Channel != NULL)
{
delete[] Channel;
Channel = NULL;
numChannels = 0;
}
if (SoundCurve != NULL)
{
delete[] SoundCurve;
SoundCurve = NULL;
}
if (PlayList != NULL)
{
delete PlayList;
PlayList = NULL;
}
}
//==========================================================================
//
// S_Start

View file

@ -76,6 +76,7 @@ extern TArray<sfxinfo_t> S_sfx;
// allocates channel buffer, sets S_sfx lookup.
//
void S_Init ();
void S_Shutdown ();
// Per level startup code.
// Kills playing sounds at start of level and starts new music.
@ -181,6 +182,7 @@ void S_UpdateSounds (void *listener);
// [RH] S_sfx "maintenance" routines
void S_ParseSndInfo ();
void S_ParseSndEax ();
void S_UnloadSndEax ();
void S_HashSounds ();
int S_FindSound (const char *logicalname);

View file

@ -49,7 +49,7 @@ EXTERN_CVAR (Float, vid_winscale)
IVideo *Video;
void STACK_ARGS I_ShutdownHardware ()
void I_ShutdownHardware ()
{
if (screen)
delete screen, screen = NULL;

View file

@ -88,6 +88,6 @@ class IJoystick : public IInputDevice
};
void I_InitHardware ();
void STACK_ARGS I_ShutdownHardware ();
void I_ShutdownHardware ();
#endif // __HARDWARE_H__

View file

@ -39,13 +39,21 @@
DArgs Args;
#define MAX_TERMS 16
void (STACK_ARGS *TermFuncs[MAX_TERMS]) ();
#define MAX_TERMS 32
void (*TermFuncs[MAX_TERMS]) ();
const char *TermNames[MAX_TERMS];
static int NumTerms;
void addterm (void (STACK_ARGS *func) (), const char *name)
void addterm (void (*func) (), const char *name)
{
// Make sure this function wasn't already registered.
for (int i = 0; i < NumTerms; ++i)
{
if (TermFuncs[i] == func)
{
return;
}
}
if (NumTerms == MAX_TERMS)
{
func ();

View file

@ -323,7 +323,7 @@ void BuildAddress (sockaddr_in *address, char *name)
*portpart = ':';
}
void STACK_ARGS CloseNetwork (void)
void CloseNetwork (void)
{
if (mysocket != INVALID_SOCKET)
{
@ -386,7 +386,7 @@ void WaitForPlayers (int i)
doomcom.numplayers = doomcom.numnodes;
}
void STACK_ARGS SendAbort (void)
void SendAbort (void)
{
BYTE dis[2] = { PRE_FAKE, PRE_DISCONNECT };

View file

@ -277,7 +277,7 @@ void CalculateCPUSpeed ()
//
static int has_exited;
void STACK_ARGS I_Quit (void)
void I_Quit (void)
{
has_exited = 1; /* Prevent infinitely recursive exits -- killough */

View file

@ -166,7 +166,7 @@ ticcmd_t *I_BaseTiccmd (void);
// Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb.
void STACK_ARGS I_Quit (void);
void I_Quit (void);
void I_Tactile (int on, int off, int total);
@ -174,7 +174,7 @@ void I_Tactile (int on, int off, int total);
void STACK_ARGS I_Error (const char *error, ...) GCCPRINTF(1,2);
void STACK_ARGS I_FatalError (const char *error, ...) GCCPRINTF(1,2);
void addterm (void (STACK_ARGS *func)(void), const char *name);
void addterm (void (*func)(void), const char *name);
#define atterm(t) addterm (t, #t)
void popterm ();

View file

@ -137,7 +137,7 @@ void I_InitMusic (void)
}
void STACK_ARGS I_ShutdownMusic(void)
void I_ShutdownMusic(void)
{
if (MusicDown)
return;

View file

@ -42,7 +42,7 @@
// MUSIC I/O
//
void I_InitMusic ();
void STACK_ARGS I_ShutdownMusic ();
void I_ShutdownMusic ();
void I_BuildMIDIMenuList (struct value_s **values, float *numValues);
// Volume.

View file

@ -237,7 +237,7 @@ void I_InitSound ()
}
void STACK_ARGS I_ShutdownSound (void)
void I_ShutdownSound (void)
{
if (GSnd != NULL)
{

View file

@ -124,6 +124,6 @@ public:
extern SoundRenderer *GSnd;
void I_InitSound ();
void STACK_ARGS I_ShutdownSound ();
void I_ShutdownSound ();
#endif

View file

@ -110,17 +110,6 @@ static const byte myislower[256] =
FFont *FFont::FirstFont = NULL;
static struct FontsDeleter
{
~FontsDeleter()
{
while (FFont::FirstFont != NULL)
{
delete FFont::FirstFont;
}
}
} DeleteAllTheFonts;
#if defined(_MSC_VER) && _MSC_VER < 1310
template<> FArchive &operator<< (FArchive &arc, FFont* &font)
#else

View file

@ -110,6 +110,8 @@ protected:
static FFont *FirstFont;
friend struct FontsDeleter;
friend void V_Shutdown();
#if defined(_MSC_VER) && _MSC_VER < 1310
template<> friend FArchive &operator<< (FArchive &arc, FFont* &font);
#else

View file

@ -853,6 +853,8 @@ void V_Init (void)
char *i;
int width, height, bits;
atterm (V_Shutdown);
// [RH] Initialize palette management
InitPalette ();
@ -919,8 +921,6 @@ void V_Init (void)
bits = vid_defbits;
}
atterm (FreeCanvasChain);
I_ClosestResolution (&width, &height, bits);
if (!V_SetResolution (width, height, bits))
@ -935,7 +935,16 @@ void V_Init (void)
BuildTransTable (GPalette.BaseColors);
}
void STACK_ARGS FreeCanvasChain ()
void V_Shutdown()
{
FreeCanvasChain();
while (FFont::FirstFont != NULL)
{
delete FFont::FirstFont;
}
}
void FreeCanvasChain ()
{
if (screen != NULL)
{

View file

@ -189,7 +189,7 @@ private:
DCanvas *Next;
static DCanvas *CanvasChain;
friend void STACK_ARGS FreeCanvasChain ();
friend void FreeCanvasChain ();
};
// A canvas in system memory.
@ -286,6 +286,8 @@ extern "C" DWORD *Col2RGB8_LessPrecision[65];
// Allocates buffer screens, call before R_Init.
void V_Init ();
void V_Shutdown ();
void V_MarkRect (int x, int y, int width, int height);
// Returns the closest color to the one desired. String

View file

@ -55,7 +55,7 @@ IVideo *Video;
//static IMouse *Mouse;
//static IJoystick *Joystick;
void STACK_ARGS I_ShutdownHardware ()
void I_ShutdownHardware ()
{
if (screen)
delete screen, screen = NULL;

View file

@ -88,6 +88,6 @@ class IJoystick : public IInputDevice
};
void I_InitHardware ();
void STACK_ARGS I_ShutdownHardware ();
void I_ShutdownHardware ();
#endif // __HARDWARE_H__

View file

@ -434,7 +434,7 @@ DWORD FCDThread::Dispatch (DWORD method, DWORD parm1, DWORD parm2, DWORD parm3)
//
//==========================================================================
static void STACK_ARGS KillThread ()
static void KillThread ()
{
if (CDThread != NULL)
{

View file

@ -1479,7 +1479,7 @@ BOOL I_InitInput (void *hwnd)
// Free all input resources
void STACK_ARGS I_ShutdownInput ()
void I_ShutdownInput ()
{
if (g_pKey)
{

View file

@ -37,7 +37,7 @@
#include "doomtype.h"
BOOL I_InitInput (void *hwnd);
void STACK_ARGS I_ShutdownInput ();
void I_ShutdownInput ();
void I_PutInClipboard (const char *str);
char *I_GetFromClipboard ();

View file

@ -99,14 +99,25 @@ BOOL (*pIsDebuggerPresent)(VOID);
extern UINT TimerPeriod;
extern HCURSOR TheArrowCursor, TheInvisibleCursor;
#define MAX_TERMS 16
void (STACK_ARGS *TermFuncs[MAX_TERMS])(void);
#define MAX_TERMS 32
void (*TermFuncs[MAX_TERMS])(void);
static int NumTerms;
void atterm (void (STACK_ARGS *func)(void))
{
// Make sure this function wasn't already registered.
for (int i = 0; i < NumTerms; ++i)
{
if (TermFuncs[i] == func)
{
return;
}
}
if (NumTerms == MAX_TERMS)
{
func ();
I_FatalError ("Too many exit functions registered.\nIncrease MAX_TERMS in i_main.cpp");
}
TermFuncs[NumTerms++] = func;
}
@ -132,7 +143,7 @@ static int STACK_ARGS NewFailure (size_t size)
}
#endif
static void STACK_ARGS UnCOM (void)
static void UnCOM (void)
{
CoUninitialize ();
}

View file

@ -323,7 +323,7 @@ void BuildAddress (sockaddr_in *address, char *name)
*portpart = ':';
}
void STACK_ARGS CloseNetwork (void)
void CloseNetwork (void)
{
if (mysocket != INVALID_SOCKET)
{
@ -386,7 +386,7 @@ void WaitForPlayers (int i)
doomcom.numplayers = doomcom.numnodes;
}
void STACK_ARGS SendAbort (void)
void SendAbort (void)
{
BYTE dis[2] = { PRE_FAKE, PRE_DISCONNECT };

View file

@ -484,7 +484,7 @@ void CalculateCPUSpeed ()
//
static int has_exited;
void STACK_ARGS I_Quit (void)
void I_Quit (void)
{
has_exited = 1; /* Prevent infinitely recursive exits -- killough */

View file

@ -172,7 +172,7 @@ ticcmd_t *I_BaseTiccmd (void);
// Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb.
void STACK_ARGS I_Quit (void);
void I_Quit (void);
void I_Tactile (int on, int off, int total);
@ -180,7 +180,7 @@ void I_Tactile (int on, int off, int total);
void STACK_ARGS I_Error (const char *error, ...) GCCPRINTF(1,2);
void STACK_ARGS I_FatalError (const char *error, ...) GCCPRINTF(1,2);
void atterm (void (STACK_ARGS *func)(void));
void atterm (void (*func)(void));
void popterm ();
// Repaint the pre-game console

View file

@ -4435,6 +4435,264 @@
</File>
</Filter>
</Filter>
<Filter
Name="SDL Files"
Filter="">
<File
RelativePath=".\src\sdl\crashcatcher.c">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\dikeys.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\hardware.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\hardware.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_cd.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_input.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_input.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_main.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_movie.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_net.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_net.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_system.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_system.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\i_video.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\sdlvideo.cpp">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\sdl\sdlvideo.h">
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>