mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- move static AM color initialization into the AM_StaticInit function.
- move D_LoadWadSettings to keysections.cpp. - made some more data reloadable. - data structures filled by P_SetupLevel should be cleared before loading the level. They can remain non-empty in case of an error. There's probably more to fix here... - fixed: MidiDevices and MusicAliases were not cleared before reloading local SNDINFOs. - fixed signed/unsigned warnings in AddSwitchPair for real (GCC really allows -1u? MSVC prints a warning for that.) SVN r3036 (trunk)
This commit is contained in:
parent
ee20d0ea7a
commit
f0f17e531c
23 changed files with 134 additions and 107 deletions
|
@ -529,7 +529,12 @@ struct FDropItem
|
|||
class FDropItemPtrArray : public TArray<FDropItem *>
|
||||
{
|
||||
public:
|
||||
~FDropItemPtrArray();
|
||||
~FDropItemPtrArray()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
extern FDropItemPtrArray DropItemList;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -131,6 +131,7 @@ void D_ProcessEvents ();
|
|||
void G_BuildTiccmd (ticcmd_t* cmd);
|
||||
void D_DoAdvanceDemo ();
|
||||
void D_AddWildFile (TArray<FString> &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
|
||||
|
|
|
@ -353,6 +353,7 @@ void FDecalLib::ReadAllDecals ()
|
|||
}
|
||||
Animators.Clear();
|
||||
FDecalCombinerAnim::AnimatorList.Clear();
|
||||
DecalTranslations.Clear();
|
||||
|
||||
DecalLibrary.Clear();
|
||||
|
||||
|
|
|
@ -1809,6 +1809,7 @@ static void ClearMapinfo()
|
|||
AllSkills.Clear();
|
||||
DefaultSkill = -1;
|
||||
DeinitIntermissions();
|
||||
level.info = NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "c_bind.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "gameconfigfile.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
TArray<FKeySection> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<FDropItem *>::Clear();
|
||||
}
|
||||
|
||||
int StoreDropItemChain(FDropItem *chain)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -242,6 +242,8 @@ void P_InitTerrainTypes ()
|
|||
int lump;
|
||||
int size;
|
||||
|
||||
Splashes.Clear();
|
||||
Terrains.Clear();
|
||||
size = (TexMan.NumTextures()+1);
|
||||
TerrainTypes.Resize(size);
|
||||
TerrainTypes.Clear();
|
||||
|
|
|
@ -2357,6 +2357,7 @@ void R_InitParticles ()
|
|||
if ( NumParticles < 100 )
|
||||
NumParticles = 100;
|
||||
|
||||
R_DeinitParticles();
|
||||
Particles = new particle_t[NumParticles];
|
||||
R_ClearParticles ();
|
||||
atterm (R_DeinitParticles);
|
||||
|
|
|
@ -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!
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ static void ParseStatistics(const char *fn, TArray<FStatistics> &statlist)
|
|||
{
|
||||
FScanner sc;
|
||||
sc.OpenFile(fn);
|
||||
statlist.Clear();
|
||||
|
||||
while (sc.GetString())
|
||||
{
|
||||
|
|
|
@ -131,6 +131,7 @@ void FTeam::ParseTeamInfo ()
|
|||
{
|
||||
int iLump, iLastLump = 0;
|
||||
|
||||
Teams.Clear();
|
||||
while ((iLump = Wads.FindLump ("TEAMINFO", &iLastLump)) != -1)
|
||||
{
|
||||
FScanner Scan (iLump);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -337,6 +337,7 @@ void LoadActors ()
|
|||
{
|
||||
int lastlump, lump;
|
||||
|
||||
DropItemList.Clear();
|
||||
FScriptPosition::ResetErrorCounter();
|
||||
InitThingdef();
|
||||
lastlump = 0;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue