- Changed FScanner so that opening a lump gives the complete wad+lump name

rather than a generic one, so identifying errors among files that all have
  the same lump name no longer involves any degree of guesswork in
  determining exactly which file the error occurred in.
- Added a check to S_ParseSndSeq() for SNDSEQ lumps with unterminated final
  sequences.
- Fixed: Parts of s_sndseq.cpp that scan the Sequences array need NULL
  pointer checks, in case an improper sequence was encountered during
  parsing but not early enough to avoid creating a slot for it in the array.


SVN r874 (trunk)
This commit is contained in:
Randy Heit 2008-04-03 03:19:21 +00:00
parent b430977adf
commit d2c275bbb3
24 changed files with 65 additions and 32 deletions

View file

@ -1,4 +1,13 @@
April 2, 2008 April 2, 2008
- Changed FScanner so that opening a lump gives the complete wad+lump name
rather than a generic one, so identifying errors among files that all have
the same lump name no longer involves any degree of guesswork in
determining exactly which file the error occurred in.
- Added a check to S_ParseSndSeq() for SNDSEQ lumps with unterminated final
sequences.
- Fixed: Parts of s_sndseq.cpp that scan the Sequences array need NULL
pointer checks, in case an improper sequence was encountered during
parsing but not early enough to avoid creating a slot for it in the array.
- Added support for dumping from RAW/DRO/IMF files, so now anything that - Added support for dumping from RAW/DRO/IMF files, so now anything that
can be played as OPL can also be dumped. can be played as OPL can also be dumped.
- Removed the opl_enable cvar, since OPL playback is now selectable as just - Removed the opl_enable cvar, since OPL playback is now selectable as just

View file

@ -346,7 +346,7 @@ void FDecalLib::ReadAllDecals ()
while ((lump = Wads.FindLump ("DECALDEF", &lastlump)) != -1) while ((lump = Wads.FindLump ("DECALDEF", &lastlump)) != -1)
{ {
FScanner sc(lump, "DECALDEF"); FScanner sc(lump);
ReadDecals (sc); ReadDecals (sc);
} }
// Supporting code to allow specifying decals directly in the DECORATE lump // Supporting code to allow specifying decals directly in the DECORATE lump

View file

@ -632,7 +632,7 @@ static void G_DoParseMapInfo (int lump)
int clusterindex; int clusterindex;
QWORD levelflags; QWORD levelflags;
FScanner sc(lump, Wads.GetLumpFullName(lump)); FScanner sc(lump);
SetLevelDefaults (&defaultinfo); SetLevelDefaults (&defaultinfo);
HexenHack = false; HexenHack = false;

View file

@ -344,7 +344,7 @@ void P_InitKeyMessages()
ClearLocks(); ClearLocks();
while ((lump = Wads.FindLump ("LOCKDEFS", &lastlump)) != -1) while ((lump = Wads.FindLump ("LOCKDEFS", &lastlump)) != -1)
{ {
FScanner sc(lump, "LOCKDEFS"); FScanner sc(lump);
while (sc.GetString ()) while (sc.GetString ())
{ {
if (sc.Compare("LOCK")) if (sc.Compare("LOCK"))

View file

@ -130,7 +130,7 @@ void SBarInfo::ParseSBarInfo(int lump)
{ {
gameType = gameinfo.gametype; gameType = gameinfo.gametype;
bool baseSet = false; bool baseSet = false;
FScanner sc(lump, Wads.GetLumpFullName(lump)); FScanner sc(lump);
sc.SetCMode(true); sc.SetCMode(true);
while(sc.CheckToken(TK_Identifier) || sc.CheckToken(TK_Include)) while(sc.CheckToken(TK_Identifier) || sc.CheckToken(TK_Include))
{ {

View file

@ -928,7 +928,7 @@ void HUD_InitHud()
while ((lump = Wads.FindLump ("ALTHUDCF", &lastlump)) != -1) while ((lump = Wads.FindLump ("ALTHUDCF", &lastlump)) != -1)
{ {
FScanner sc(lump, "ALTHUDCF"); FScanner sc(lump);
while (sc.GetString()) while (sc.GetString())
{ {
if (sc.Compare("Health")) if (sc.Compare("Health"))

View file

@ -3438,7 +3438,7 @@ void InitCrosshairsList()
while ((lump = Wads.FindLump("XHAIRS", &lastlump)) != -1) while ((lump = Wads.FindLump("XHAIRS", &lastlump)) != -1)
{ {
FScanner sc(lump, "XHAIRS"); FScanner sc(lump);
while (sc.GetNumber()) while (sc.GetNumber())
{ {
value.value = float(sc.Number); value.value = float(sc.Number);

View file

@ -556,7 +556,7 @@ void FBehavior::StaticLoadDefaultModules ()
while ((lump = Wads.FindLump ("LOADACS", &lastlump)) != -1) while ((lump = Wads.FindLump ("LOADACS", &lastlump)) != -1)
{ {
FScanner sc(lump, "LOADACS"); FScanner sc(lump);
while (sc.GetString()) while (sc.GetString())
{ {
int acslump = Wads.CheckNumForName (sc.String, ns_acslibrary); int acslump = Wads.CheckNumForName (sc.String, ns_acslibrary);

View file

@ -267,7 +267,7 @@ void P_InitTerrainTypes ()
lastlump = 0; lastlump = 0;
while (-1 != (lump = Wads.FindLump ("TERRAIN", &lastlump)) ) while (-1 != (lump = Wads.FindLump ("TERRAIN", &lastlump)) )
{ {
FScanner sc(lump, "TERRAIN"); FScanner sc(lump);
ParseOuter (sc); ParseOuter (sc);
} }
Splashes.ShrinkToFit (); Splashes.ShrinkToFit ();

View file

@ -289,7 +289,7 @@ static void R_InitAnimDefs ()
while ((lump = Wads.FindLump ("ANIMDEFS", &lastlump)) != -1) while ((lump = Wads.FindLump ("ANIMDEFS", &lastlump)) != -1)
{ {
FScanner sc(lump, "ANIMDEFS"); FScanner sc(lump);
while (sc.GetString ()) while (sc.GetString ())
{ {

View file

@ -453,7 +453,7 @@ void R_InitSkins (void)
sndlumps[j] = -1; sndlumps[j] = -1;
skins[i].namespc = Wads.GetLumpNamespace (base); skins[i].namespc = Wads.GetLumpNamespace (base);
FScanner sc(base, "S_SKIN"); FScanner sc(base);
intname = 0; intname = 0;
crouchname = 0; crouchname = 0;

View file

@ -895,7 +895,7 @@ static void S_AddSNDINFO (int lump)
bool skipToEndIf; bool skipToEndIf;
TArray<WORD> list; TArray<WORD> list;
FScanner sc(lump, "SNDINFO"); FScanner sc(lump);
skipToEndIf = false; skipToEndIf = false;
while (sc.GetString ()) while (sc.GetString ())

View file

@ -465,7 +465,7 @@ FArchive &operator<< (FArchive &arc, ReverbContainer *&env)
return arc; return arc;
} }
static void ReadEAX (int lump, const char *lumpname) static void ReadEAX (int lump)
{ {
FScanner sc; FScanner sc;
const ReverbContainer *def; const ReverbContainer *def;
@ -476,7 +476,7 @@ static void ReadEAX (int lump, const char *lumpname)
bool inited[NUM_EAX_FIELDS]; bool inited[NUM_EAX_FIELDS];
BYTE bools[32]; BYTE bools[32];
sc.OpenLumpNum(lump, lumpname); sc.OpenLumpNum(lump);
while (sc.GetString ()) while (sc.GetString ())
{ {
name = copystring (sc.String); name = copystring (sc.String);
@ -576,7 +576,7 @@ void S_ParseSndEax ()
while ((lump = Wads.FindLump ("SNDEAX", &lastlump)) != -1) while ((lump = Wads.FindLump ("SNDEAX", &lastlump)) != -1)
{ {
ReadEAX (lump, "SNDEAX"); ReadEAX (lump);
} }
} }

View file

@ -432,7 +432,7 @@ static void AssignHexenTranslations (void)
{ {
for (seq = 0; seq < Sequences.Size(); seq++) for (seq = 0; seq < Sequences.Size(); seq++)
{ {
if (HexenSequences[i].Name == Sequences[seq]->SeqName) if (Sequences[seq] != NULL && HexenSequences[i].Name == Sequences[seq]->SeqName)
break; break;
} }
if (seq == Sequences.Size()) if (seq == Sequences.Size())
@ -499,7 +499,7 @@ void S_ParseSndSeq (int levellump)
lump = levellump; lump = levellump;
levellump = -2; levellump = -2;
} }
FScanner sc(lump, "SNDSEQ"); FScanner sc(lump);
while (sc.GetString ()) while (sc.GetString ())
{ {
bool bDoorSound = false; bool bDoorSound = false;
@ -514,7 +514,7 @@ void S_ParseSndSeq (int levellump)
seqtype = sc.String[0]; seqtype = sc.String[0];
for (curseq = 0; curseq < (int)Sequences.Size(); curseq++) for (curseq = 0; curseq < (int)Sequences.Size(); curseq++)
{ {
if (Sequences[curseq]->SeqName == seqname) if (Sequences[curseq] != NULL && Sequences[curseq]->SeqName == seqname)
{ {
M_Free (Sequences[curseq]); M_Free (Sequences[curseq]);
Sequences[curseq] = NULL; Sequences[curseq] = NULL;
@ -684,6 +684,10 @@ void S_ParseSndSeq (int levellump)
break; break;
} }
} }
if (curseq > 0)
{
sc.ScriptError("End of file encountered before the final sequence ended.");
}
} }
if (gameinfo.gametype == GAME_Hexen) if (gameinfo.gametype == GAME_Hexen)
@ -883,7 +887,7 @@ static int FindSequence (FName seqname)
for (i = Sequences.Size(); i-- > 0; ) for (i = Sequences.Size(); i-- > 0; )
{ {
if (seqname == Sequences[i]->SeqName) if (Sequences[i] != NULL && seqname == Sequences[i]->SeqName)
{ {
return i; return i;
} }

View file

@ -91,10 +91,10 @@ FScanner::FScanner(const FScanner &other)
// //
//========================================================================== //==========================================================================
FScanner::FScanner(int lumpnum, const char *name) FScanner::FScanner(int lumpnum)
{ {
ScriptOpen = false; ScriptOpen = false;
OpenLumpNum(lumpnum, name); OpenLumpNum(lumpnum);
} }
//========================================================================== //==========================================================================
@ -169,7 +169,7 @@ void FScanner::Open (const char *name)
{ {
I_Error("Could not find script lump '%s'\n", name); I_Error("Could not find script lump '%s'\n", name);
} }
OpenLumpNum(lump, name); OpenLumpNum(lump);
} }
//========================================================================== //==========================================================================
@ -219,14 +219,14 @@ void FScanner::OpenMem (const char *name, char *buffer, int size)
// //
//========================================================================== //==========================================================================
void FScanner :: OpenLumpNum (int lump, const char *name) void FScanner :: OpenLumpNum (int lump)
{ {
Close (); Close ();
{ {
FMemLump mem = Wads.ReadLump(lump); FMemLump mem = Wads.ReadLump(lump);
ScriptBuffer = mem.GetString(); ScriptBuffer = mem.GetString();
} }
ScriptName = name; ScriptName = Wads.GetLumpFullPath(lump);
PrepareScript (); PrepareScript ();
} }

View file

@ -13,7 +13,7 @@ public:
// Methods ------------------------------------------------------ // Methods ------------------------------------------------------
FScanner(); FScanner();
FScanner(const FScanner &other); FScanner(const FScanner &other);
FScanner(int lumpnum, const char *name); FScanner(int lumpnum);
~FScanner(); ~FScanner();
FScanner &operator=(const FScanner &other); FScanner &operator=(const FScanner &other);
@ -21,7 +21,7 @@ public:
void Open(const char *lumpname); void Open(const char *lumpname);
void OpenFile(const char *filename); void OpenFile(const char *filename);
void OpenMem(const char *name, char *buffer, int size); void OpenMem(const char *name, char *buffer, int size);
void OpenLumpNum(int lump, const char *name); void OpenLumpNum(int lump);
void Close(); void Close();
void SetCMode(bool cmode); void SetCMode(bool cmode);

View file

@ -149,7 +149,7 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p
code |= orMask; code |= orMask;
FScanner sc(lumpnum, "LANGUAGE"); FScanner sc(lumpnum);
sc.SetCMode (true); sc.SetCMode (true);
while (sc.GetString ()) while (sc.GetString ())
{ {

View file

@ -84,7 +84,7 @@ void TEAMINFO_Init ()
while ((lump = Wads.FindLump ("TEAMINFO", &lastlump)) != -1) while ((lump = Wads.FindLump ("TEAMINFO", &lastlump)) != -1)
{ {
FScanner sc(lump, "TEAMINFO"); FScanner sc(lump);
while (sc.GetString ()) while (sc.GetString ())
{ {
if (sc.Compare("CLEARTEAMS")) if (sc.Compare("CLEARTEAMS"))

View file

@ -508,7 +508,7 @@ void FTextureManager::LoadHiresTex(int wadnum)
{ {
if (Wads.GetLumpFile(remapLump) == wadnum) if (Wads.GetLumpFile(remapLump) == wadnum)
{ {
FScanner sc(remapLump, "HIRESTEX"); FScanner sc(remapLump);
while (sc.GetString()) while (sc.GetString())
{ {
if (sc.Compare("remap")) // remap an existing texture if (sc.Compare("remap")) // remap an existing texture

View file

@ -150,7 +150,7 @@ void LoadDecorations ()
lastlump = 0; lastlump = 0;
while ((lump = Wads.FindLump ("DECORATE", &lastlump)) != -1) while ((lump = Wads.FindLump ("DECORATE", &lastlump)) != -1)
{ {
FScanner sc(lump, Wads.GetLumpFullName(lump)); FScanner sc(lump);
ParseDecorate (sc); ParseDecorate (sc);
} }
FinishThingdef(); FinishThingdef();

View file

@ -1631,7 +1631,7 @@ void V_InitCustomFonts()
while ((llump = Wads.FindLump ("FONTDEFS", &lastlump)) != -1) while ((llump = Wads.FindLump ("FONTDEFS", &lastlump)) != -1)
{ {
sc.OpenLumpNum(llump, "FONTDEFS"); sc.OpenLumpNum(llump);
while (sc.GetString()) while (sc.GetString())
{ {
memset (lumplist, -1, sizeof(lumplist)); memset (lumplist, -1, sizeof(lumplist));
@ -1759,7 +1759,7 @@ void V_InitFontColors ()
while ((lump = Wads.FindLump ("TEXTCOLO", &lastlump)) != -1) while ((lump = Wads.FindLump ("TEXTCOLO", &lastlump)) != -1)
{ {
FScanner sc(lump, "textcolors.txt"); FScanner sc(lump);
while (sc.GetString()) while (sc.GetString())
{ {
names.Clear(); names.Clear();

View file

@ -1617,6 +1617,25 @@ const char *FWadCollection::GetLumpFullName (int lump) const
return LumpInfo[lump].name; return LumpInfo[lump].name;
} }
//==========================================================================
//
// FWadCollection :: GetLumpFullPath
//
// Returns the name of the lump's wad prefixed to the lump's full name.
//
//==========================================================================
FString FWadCollection::GetLumpFullPath(int lump) const
{
FString foo;
if ((size_t) lump < NumLumps)
{
foo << GetWadName(LumpInfo[lump].wadnum) << ':' << GetLumpFullName(lump);
}
return foo;
}
//========================================================================== //==========================================================================
// //
// GetLumpNamespace // GetLumpNamespace

View file

@ -206,6 +206,7 @@ public:
int GetLumpFlags (int lump); // Return the flags for this lump int GetLumpFlags (int lump); // Return the flags for this lump
void GetLumpName (char *to, int lump) const; // [RH] Copies the lump name to to using uppercopy void GetLumpName (char *to, int lump) const; // [RH] Copies the lump name to to using uppercopy
const char *GetLumpFullName (int lump) const; // [RH] Returns the lump's full name const char *GetLumpFullName (int lump) const; // [RH] Returns the lump's full name
FString GetLumpFullPath (int lump) const; // [RH] Returns wad's name + lump's full name
int GetLumpFile (int lump) const; // [RH] Returns wadnum for a specified lump int GetLumpFile (int lump) const; // [RH] Returns wadnum for a specified lump
int GetLumpNamespace (int lump) const; // [RH] Returns the namespace a lump belongs to int GetLumpNamespace (int lump) const; // [RH] Returns the namespace a lump belongs to
bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match

View file

@ -398,7 +398,7 @@ void WI_LoadBackground(bool isenterpic)
int lumpnum=Wads.GetNumForName(lumpname+1); int lumpnum=Wads.GetNumForName(lumpname+1);
if (lumpnum>=0) if (lumpnum>=0)
{ {
FScanner sc(lumpnum,lumpname+1); FScanner sc(lumpnum);
while (sc.GetString()) while (sc.GetString())
{ {
memset(&an,0,sizeof(an)); memset(&an,0,sizeof(an));