- 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:
parent
01441cd4f0
commit
8fcf93d65a
68 changed files with 866 additions and 485 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue