diff --git a/src/actor.h b/src/actor.h index 79358148fe..13425e48a4 100644 --- a/src/actor.h +++ b/src/actor.h @@ -529,7 +529,12 @@ struct FDropItem class FDropItemPtrArray : public TArray { public: - ~FDropItemPtrArray(); + ~FDropItemPtrArray() + { + Clear(); + } + + void Clear(); }; extern FDropItemPtrArray DropItemList; diff --git a/src/am_map.cpp b/src/am_map.cpp index d3fbc1140b..5eb759ee3f 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -545,6 +545,21 @@ void AM_StaticInit() } markpointnum = 0; mapback.SetInvalid(); + + static DWORD *lastpal = NULL; + //static int lastback = -1; + DWORD *palette; + + palette = (DWORD *)GPalette.BaseColors; + + int i, j; + + for (i = j = 0; i < 11; i++, j += 3) + { + DoomColors[i].FromRGB(DoomPaletteVals[j], DoomPaletteVals[j+1], DoomPaletteVals[j+2]); + StrifeColors[i].FromRGB(StrifePaletteVals[j], StrifePaletteVals[j+1], StrifePaletteVals[j+2]); + RavenColors[i].FromRGB(RavenPaletteVals[j], RavenPaletteVals[j+1], RavenPaletteVals[j+2]); + } } //============================================================================= @@ -878,24 +893,6 @@ void AM_initVariables () static void AM_initColors (bool overlayed) { - static DWORD *lastpal = NULL; - //static int lastback = -1; - DWORD *palette; - - palette = (DWORD *)GPalette.BaseColors; - - if (lastpal != palette) - { - int i, j; - - for (i = j = 0; i < 11; i++, j += 3) - { - DoomColors[i].FromRGB(DoomPaletteVals[j], DoomPaletteVals[j+1], DoomPaletteVals[j+2]); - StrifeColors[i].FromRGB(StrifePaletteVals[j], StrifePaletteVals[j+1], StrifePaletteVals[j+2]); - RavenColors[i].FromRGB(RavenPaletteVals[j], RavenPaletteVals[j+1], RavenPaletteVals[j+2]); - } - } - if (overlayed) { YourColor.FromCVar (am_ovyourcolor); @@ -1020,8 +1017,6 @@ static void AM_initColors (bool overlayed) break; } - - lastpal = palette; } //============================================================================= diff --git a/src/d_main.cpp b/src/d_main.cpp index ffe4afdbd8..2eaabf76d2 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -131,6 +131,7 @@ void D_ProcessEvents (); void G_BuildTiccmd (ticcmd_t* cmd); void D_DoAdvanceDemo (); void D_AddWildFile (TArray &wadfiles, const char *pattern); +void D_LoadWadSettings (); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- @@ -1563,80 +1564,6 @@ bool ConsiderPatches (const char *arg) return argc > 0; } -//========================================================================== -// -// D_LoadWadSettings -// -// Parses any loaded KEYCONF lumps. These are restricted console scripts -// that can only execute the alias, defaultbind, addkeysection, -// addmenukey, weaponsection, and addslotdefault commands. -// -//========================================================================== - -void D_LoadWadSettings () -{ - char cmd[4096]; - int lump, lastlump = 0; - - ParsingKeyConf = true; - - while ((lump = Wads.FindLump ("KEYCONF", &lastlump)) != -1) - { - FMemLump data = Wads.ReadLump (lump); - const char *eof = (char *)data.GetMem() + Wads.LumpLength (lump); - const char *conf = (char *)data.GetMem(); - - while (conf < eof) - { - size_t i; - - // Fetch a line to execute - for (i = 0; conf + i < eof && conf[i] != '\n'; ++i) - { - cmd[i] = conf[i]; - } - cmd[i] = 0; - conf += i; - if (*conf == '\n') - { - conf++; - } - - // Comments begin with // - char *stop = cmd + i - 1; - char *comment = cmd; - int inQuote = 0; - - if (*stop == '\r') - *stop-- = 0; - - while (comment < stop) - { - if (*comment == '\"') - { - inQuote ^= 1; - } - else if (!inQuote && *comment == '/' && *(comment + 1) == '/') - { - break; - } - comment++; - } - if (comment == cmd) - { // Comment at line beginning - continue; - } - else if (comment < stop) - { // Comment in middle of line - *comment = 0; - } - - AddCommandString (cmd); - } - } - ParsingKeyConf = false; -} - //========================================================================== // // D_MultiExec diff --git a/src/decallib.cpp b/src/decallib.cpp index 072262da9c..6bbf0f74da 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -353,6 +353,7 @@ void FDecalLib::ReadAllDecals () } Animators.Clear(); FDecalCombinerAnim::AnimatorList.Clear(); + DecalTranslations.Clear(); DecalLibrary.Clear(); diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index bc1a19d48d..4199305d3f 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1809,6 +1809,7 @@ static void ClearMapinfo() AllSkills.Clear(); DefaultSkill = -1; DeinitIntermissions(); + level.info = NULL; } //========================================================================== diff --git a/src/gi.cpp b/src/gi.cpp index 705f9b8019..0e010724a8 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -77,7 +77,7 @@ static gameborder_t StrifeBorder = // Custom GAMEINFO ------------------------------------------------------------ -const char* GameInfoBoarders[] = +const char* GameInfoBorders[] = { "DoomBorder", "HereticBorder", @@ -219,7 +219,7 @@ void FMapInfoParser::ParseGameInfo() { if(sc.CheckToken(TK_Identifier)) { - switch(sc.MustMatchString(GameInfoBoarders)) + switch(sc.MustMatchString(GameInfoBorders)) { default: gameinfo.border = &DoomBorder; diff --git a/src/info.cpp b/src/info.cpp index f345a6e7f8..32aa92a915 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -53,6 +53,7 @@ extern void LoadActors (); extern void InitBotStuff(); +extern void ClearStrifeTypes(); //========================================================================== @@ -122,6 +123,7 @@ void FActorInfo::StaticInit () } Printf ("LoadActors: Load actor definitions.\n"); + ClearStrifeTypes(); LoadActors (); InitBotStuff(); } diff --git a/src/keysections.cpp b/src/keysections.cpp index 6ef0538f6e..bfec4060e3 100644 --- a/src/keysections.cpp +++ b/src/keysections.cpp @@ -41,6 +41,7 @@ #include "c_bind.h" #include "c_dispatch.h" #include "gameconfigfile.h" +#include "w_wad.h" TArray KeySections; @@ -141,3 +142,78 @@ CCMD (addmenukey) } } +//========================================================================== +// +// D_LoadWadSettings +// +// Parses any loaded KEYCONF lumps. These are restricted console scripts +// that can only execute the alias, defaultbind, addkeysection, +// addmenukey, weaponsection, and addslotdefault commands. +// +//========================================================================== + +void D_LoadWadSettings () +{ + char cmd[4096]; + int lump, lastlump = 0; + + ParsingKeyConf = true; + KeySections.Clear(); + + while ((lump = Wads.FindLump ("KEYCONF", &lastlump)) != -1) + { + FMemLump data = Wads.ReadLump (lump); + const char *eof = (char *)data.GetMem() + Wads.LumpLength (lump); + const char *conf = (char *)data.GetMem(); + + while (conf < eof) + { + size_t i; + + // Fetch a line to execute + for (i = 0; conf + i < eof && conf[i] != '\n'; ++i) + { + cmd[i] = conf[i]; + } + cmd[i] = 0; + conf += i; + if (*conf == '\n') + { + conf++; + } + + // Comments begin with // + char *stop = cmd + i - 1; + char *comment = cmd; + int inQuote = 0; + + if (*stop == '\r') + *stop-- = 0; + + while (comment < stop) + { + if (*comment == '\"') + { + inQuote ^= 1; + } + else if (!inQuote && *comment == '/' && *(comment + 1) == '/') + { + break; + } + comment++; + } + if (comment == cmd) + { // Comment at line beginning + continue; + } + else if (comment < stop) + { // Comment in middle of line + *comment = 0; + } + + AddCommandString (cmd); + } + } + ParsingKeyConf = false; +} + diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 0bdc622fce..c8728515b1 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -70,7 +70,6 @@ CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) DMenu *DMenu::CurrentMenu; int DMenu::MenuTime; -FListMenuDescriptor *MainMenu; FGameStartup GameStartupInfo; EMenuState menuactive; bool M_DemoNoPlay; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 9b1119e0dd..39da6b65a3 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -145,6 +145,11 @@ void SetStrifeType(int convid, const PClass *Class) StrifeTypes[convid] = Class; } +void ClearStrifeTypes() +{ + StrifeTypes.Clear(); +} + void SetConversation(int convid, const PClass *Class, int dlgindex) { if (convid != -1) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bc173b9cb0..0b13c8c759 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5586,12 +5586,13 @@ void FreeDropItemChain(FDropItem *chain) } } -FDropItemPtrArray::~FDropItemPtrArray() +void FDropItemPtrArray::Clear() { for (unsigned int i = 0; i < Size(); ++i) { FreeDropItemChain ((*this)[i]); } + TArray::Clear(); } int StoreDropItemChain(FDropItem *chain) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 7017d5c8b9..4dec4a95c7 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3491,6 +3491,7 @@ void P_FreeExtraLevelData() delete node; node = next; } + FBlockNode::FreeBlocks = NULL; } { msecnode_t *node = headsecnode; @@ -3528,8 +3529,11 @@ void P_SetupLevel (char *lumpname, int position) wminfo.partime = 180; + MapThingsConverted.Clear(); + linemap.Clear(); FCanvasTextureInfo::EmptyList (); R_FreePastViewers (); + P_ClearUDMFKeys(); if (!savegamerestore) { diff --git a/src/p_states.cpp b/src/p_states.cpp index 15ff371174..21dd1537de 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -861,7 +861,6 @@ bool FStateDefinitions::AddStates(FState *state, const char *framechars) int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults) { - static int c=0; int count = StateArray.Size(); if (count > 0) diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index 14d2bb3df0..c3df86b274 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -242,6 +242,8 @@ void P_InitTerrainTypes () int lump; int size; + Splashes.Clear(); + Terrains.Clear(); size = (TexMan.NumTextures()+1); TerrainTypes.Resize(size); TerrainTypes.Clear(); diff --git a/src/r_things.cpp b/src/r_things.cpp index 4d40c04cd6..6fa357434c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2357,6 +2357,7 @@ void R_InitParticles () if ( NumParticles < 100 ) NumParticles = 100; + R_DeinitParticles(); Particles = new particle_t[NumParticles]; R_ClearParticles (); atterm (R_DeinitParticles); diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 32c2f3222f..3245c20fa1 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -857,6 +857,8 @@ static void S_ClearSoundData() PlayerSounds.Clear(); DefPlayerClass = 0; DefPlayerClassName = ""; + MusicAliases.Clear(); + MidiDevices.Clear(); } //========================================================================== @@ -867,10 +869,11 @@ static void S_ClearSoundData() // Also registers Blood SFX files and Strife's voices. //========================================================================== -void S_ParseSndInfo () +void S_ParseSndInfo (bool redefine) { int lump; + if (!redefine) SavedPlayerSounds.Clear(); // clear skin sounds only for initial parsing. atterm (S_ClearSoundData); S_ClearSoundData(); // remove old sound data first! diff --git a/src/s_sound.cpp b/src/s_sound.cpp index bb85541c49..c09e913be8 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -322,7 +322,7 @@ void S_Init () void S_InitData () { LastLocalSndInfo = LastLocalSndSeq = ""; - S_ParseSndInfo (); + S_ParseSndInfo (false); S_ParseSndSeq (-1); S_ParseMusInfo(); } @@ -408,7 +408,7 @@ void S_Start () } // Parse the global SNDINFO - S_ParseSndInfo(); + S_ParseSndInfo(true); if (*LocalSndInfo) { diff --git a/src/s_sound.h b/src/s_sound.h index ee831bddfa..12e7ee3c65 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -331,7 +331,7 @@ void S_UpdateSounds (AActor *listener); void S_RestoreEvictedChannels(); // [RH] S_sfx "maintenance" routines -void S_ParseSndInfo (); +void S_ParseSndInfo (bool redefine); void S_ParseReverbDef (); void S_UnloadReverbDef (); diff --git a/src/statistics.cpp b/src/statistics.cpp index 276090ebd3..9c07ac6da1 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -134,6 +134,7 @@ static void ParseStatistics(const char *fn, TArray &statlist) { FScanner sc; sc.OpenFile(fn); + statlist.Clear(); while (sc.GetString()) { diff --git a/src/teaminfo.cpp b/src/teaminfo.cpp index c54b2f9d6b..f5c3c35e20 100644 --- a/src/teaminfo.cpp +++ b/src/teaminfo.cpp @@ -131,6 +131,7 @@ void FTeam::ParseTeamInfo () { int iLump, iLastLump = 0; + Teams.Clear(); while ((iLump = Wads.FindLump ("TEAMINFO", &iLastLump)) != -1) { FScanner Scan (iLump); diff --git a/src/textures/anim_switches.cpp b/src/textures/anim_switches.cpp index b065f0b96e..014e879f87 100644 --- a/src/textures/anim_switches.cpp +++ b/src/textures/anim_switches.cpp @@ -317,7 +317,7 @@ void FTextureManager::AddSwitchPair (FSwitchDef *def1, FSwitchDef *def2) unsigned int i; FSwitchDef *sw1 = NULL; FSwitchDef *sw2 = NULL; - unsigned int index1 = -1, index2 = -1; + unsigned int index1 = 0xffffffff, index2 = 0xffffffff; for (i = mSwitchDefs.Size (); i-- > 0; ) { @@ -325,13 +325,13 @@ void FTextureManager::AddSwitchPair (FSwitchDef *def1, FSwitchDef *def2) { index1 = i; sw1 = mSwitchDefs[index1]; - if (index2 != -1u) break; + if (index2 != 0xffffffff) break; } if (mSwitchDefs[i]->PreTexture == def2->PreTexture) { index2 = i; sw2 = mSwitchDefs[index2]; - if (index1 != -1u) break; + if (index1 != 0xffffffff) break; } } diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 6362c62fe8..1b2f844bd9 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -337,6 +337,7 @@ void LoadActors () { int lastlump, lump; + DropItemList.Clear(); FScriptPosition::ResetErrorCounter(); InitThingdef(); lastlump = 0; diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 54de97aa86..30c35a0a40 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -584,6 +584,7 @@ void InitThingdef() } // Create a sorted list of properties + if (properties.Size() == 0) { FAutoSegIterator probe(GRegHead, GRegTail); @@ -596,6 +597,7 @@ void InitThingdef() } // Create a sorted list of native action functions + if (AFTable.Size() == 0) { FAutoSegIterator probe(ARegHead, ARegTail); @@ -608,6 +610,7 @@ void InitThingdef() } // Create a sorted list of native variables + if (variables.Size() == 0) { FAutoSegIterator probe(MRegHead, MRegTail);