From d2c275bbb320b2fe52a7297ae576f4bbe5ff9795 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 3 Apr 2008 03:19:21 +0000 Subject: [PATCH] - 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) --- docs/rh-log.txt | 9 +++++++++ src/decallib.cpp | 2 +- src/g_level.cpp | 2 +- src/g_shared/a_keys.cpp | 2 +- src/g_shared/sbarinfo_parser.cpp | 2 +- src/g_shared/shared_hud.cpp | 2 +- src/m_options.cpp | 2 +- src/p_acs.cpp | 2 +- src/p_terrain.cpp | 2 +- src/r_anim.cpp | 2 +- src/r_things.cpp | 2 +- src/s_advsound.cpp | 2 +- src/s_environment.cpp | 6 +++--- src/s_sndseq.cpp | 12 ++++++++---- src/sc_man.cpp | 10 +++++----- src/sc_man.h | 4 ++-- src/stringtable.cpp | 2 +- src/teaminfo.cpp | 2 +- src/textures/texturemanager.cpp | 2 +- src/thingdef/thingdef_main.cpp | 2 +- src/v_font.cpp | 4 ++-- src/w_wad.cpp | 19 +++++++++++++++++++ src/w_wad.h | 1 + src/wi_stuff.cpp | 2 +- 24 files changed, 65 insertions(+), 32 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0dc335988a..030cba0024 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,13 @@ 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 can be played as OPL can also be dumped. - Removed the opl_enable cvar, since OPL playback is now selectable as just diff --git a/src/decallib.cpp b/src/decallib.cpp index 1a0e193e74..d58eb794b0 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -346,7 +346,7 @@ void FDecalLib::ReadAllDecals () while ((lump = Wads.FindLump ("DECALDEF", &lastlump)) != -1) { - FScanner sc(lump, "DECALDEF"); + FScanner sc(lump); ReadDecals (sc); } // Supporting code to allow specifying decals directly in the DECORATE lump diff --git a/src/g_level.cpp b/src/g_level.cpp index 1b7710af08..81e080aff0 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -632,7 +632,7 @@ static void G_DoParseMapInfo (int lump) int clusterindex; QWORD levelflags; - FScanner sc(lump, Wads.GetLumpFullName(lump)); + FScanner sc(lump); SetLevelDefaults (&defaultinfo); HexenHack = false; diff --git a/src/g_shared/a_keys.cpp b/src/g_shared/a_keys.cpp index 5b280db3ca..37c9ee88d2 100644 --- a/src/g_shared/a_keys.cpp +++ b/src/g_shared/a_keys.cpp @@ -344,7 +344,7 @@ void P_InitKeyMessages() ClearLocks(); while ((lump = Wads.FindLump ("LOCKDEFS", &lastlump)) != -1) { - FScanner sc(lump, "LOCKDEFS"); + FScanner sc(lump); while (sc.GetString ()) { if (sc.Compare("LOCK")) diff --git a/src/g_shared/sbarinfo_parser.cpp b/src/g_shared/sbarinfo_parser.cpp index 27cde16cbb..08839b19c9 100644 --- a/src/g_shared/sbarinfo_parser.cpp +++ b/src/g_shared/sbarinfo_parser.cpp @@ -130,7 +130,7 @@ void SBarInfo::ParseSBarInfo(int lump) { gameType = gameinfo.gametype; bool baseSet = false; - FScanner sc(lump, Wads.GetLumpFullName(lump)); + FScanner sc(lump); sc.SetCMode(true); while(sc.CheckToken(TK_Identifier) || sc.CheckToken(TK_Include)) { diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index aebe001009..323b3c0f47 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -928,7 +928,7 @@ void HUD_InitHud() while ((lump = Wads.FindLump ("ALTHUDCF", &lastlump)) != -1) { - FScanner sc(lump, "ALTHUDCF"); + FScanner sc(lump); while (sc.GetString()) { if (sc.Compare("Health")) diff --git a/src/m_options.cpp b/src/m_options.cpp index 2707350604..f2a4b930ae 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -3438,7 +3438,7 @@ void InitCrosshairsList() while ((lump = Wads.FindLump("XHAIRS", &lastlump)) != -1) { - FScanner sc(lump, "XHAIRS"); + FScanner sc(lump); while (sc.GetNumber()) { value.value = float(sc.Number); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index c7f99b136b..825a2a6af9 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -556,7 +556,7 @@ void FBehavior::StaticLoadDefaultModules () while ((lump = Wads.FindLump ("LOADACS", &lastlump)) != -1) { - FScanner sc(lump, "LOADACS"); + FScanner sc(lump); while (sc.GetString()) { int acslump = Wads.CheckNumForName (sc.String, ns_acslibrary); diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index c8ff8dacb7..e8fff3be72 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -267,7 +267,7 @@ void P_InitTerrainTypes () lastlump = 0; while (-1 != (lump = Wads.FindLump ("TERRAIN", &lastlump)) ) { - FScanner sc(lump, "TERRAIN"); + FScanner sc(lump); ParseOuter (sc); } Splashes.ShrinkToFit (); diff --git a/src/r_anim.cpp b/src/r_anim.cpp index e2be495cbb..14b701334a 100644 --- a/src/r_anim.cpp +++ b/src/r_anim.cpp @@ -289,7 +289,7 @@ static void R_InitAnimDefs () while ((lump = Wads.FindLump ("ANIMDEFS", &lastlump)) != -1) { - FScanner sc(lump, "ANIMDEFS"); + FScanner sc(lump); while (sc.GetString ()) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 0eb53ef9a6..e4be056ce4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -453,7 +453,7 @@ void R_InitSkins (void) sndlumps[j] = -1; skins[i].namespc = Wads.GetLumpNamespace (base); - FScanner sc(base, "S_SKIN"); + FScanner sc(base); intname = 0; crouchname = 0; diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index c38744e9d8..f0bda6aad0 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -895,7 +895,7 @@ static void S_AddSNDINFO (int lump) bool skipToEndIf; TArray list; - FScanner sc(lump, "SNDINFO"); + FScanner sc(lump); skipToEndIf = false; while (sc.GetString ()) diff --git a/src/s_environment.cpp b/src/s_environment.cpp index ac48f414c7..d6bf7d6a9f 100644 --- a/src/s_environment.cpp +++ b/src/s_environment.cpp @@ -465,7 +465,7 @@ FArchive &operator<< (FArchive &arc, ReverbContainer *&env) return arc; } -static void ReadEAX (int lump, const char *lumpname) +static void ReadEAX (int lump) { FScanner sc; const ReverbContainer *def; @@ -476,7 +476,7 @@ static void ReadEAX (int lump, const char *lumpname) bool inited[NUM_EAX_FIELDS]; BYTE bools[32]; - sc.OpenLumpNum(lump, lumpname); + sc.OpenLumpNum(lump); while (sc.GetString ()) { name = copystring (sc.String); @@ -576,7 +576,7 @@ void S_ParseSndEax () while ((lump = Wads.FindLump ("SNDEAX", &lastlump)) != -1) { - ReadEAX (lump, "SNDEAX"); + ReadEAX (lump); } } diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 2af2d4bb1f..282e5961a7 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -432,7 +432,7 @@ static void AssignHexenTranslations (void) { 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; } if (seq == Sequences.Size()) @@ -499,7 +499,7 @@ void S_ParseSndSeq (int levellump) lump = levellump; levellump = -2; } - FScanner sc(lump, "SNDSEQ"); + FScanner sc(lump); while (sc.GetString ()) { bool bDoorSound = false; @@ -514,7 +514,7 @@ void S_ParseSndSeq (int levellump) seqtype = sc.String[0]; 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]); Sequences[curseq] = NULL; @@ -684,6 +684,10 @@ void S_ParseSndSeq (int levellump) break; } } + if (curseq > 0) + { + sc.ScriptError("End of file encountered before the final sequence ended."); + } } if (gameinfo.gametype == GAME_Hexen) @@ -883,7 +887,7 @@ static int FindSequence (FName seqname) for (i = Sequences.Size(); i-- > 0; ) { - if (seqname == Sequences[i]->SeqName) + if (Sequences[i] != NULL && seqname == Sequences[i]->SeqName) { return i; } diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 31d4745878..7c590abc04 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -91,10 +91,10 @@ FScanner::FScanner(const FScanner &other) // //========================================================================== -FScanner::FScanner(int lumpnum, const char *name) +FScanner::FScanner(int lumpnum) { 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); } - 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 (); { FMemLump mem = Wads.ReadLump(lump); ScriptBuffer = mem.GetString(); } - ScriptName = name; + ScriptName = Wads.GetLumpFullPath(lump); PrepareScript (); } diff --git a/src/sc_man.h b/src/sc_man.h index 245adbff15..cbfc00096e 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -13,7 +13,7 @@ public: // Methods ------------------------------------------------------ FScanner(); FScanner(const FScanner &other); - FScanner(int lumpnum, const char *name); + FScanner(int lumpnum); ~FScanner(); FScanner &operator=(const FScanner &other); @@ -21,7 +21,7 @@ public: void Open(const char *lumpname); void OpenFile(const char *filename); void OpenMem(const char *name, char *buffer, int size); - void OpenLumpNum(int lump, const char *name); + void OpenLumpNum(int lump); void Close(); void SetCMode(bool cmode); diff --git a/src/stringtable.cpp b/src/stringtable.cpp index f4108a5bd9..79b55da9f1 100644 --- a/src/stringtable.cpp +++ b/src/stringtable.cpp @@ -149,7 +149,7 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p code |= orMask; - FScanner sc(lumpnum, "LANGUAGE"); + FScanner sc(lumpnum); sc.SetCMode (true); while (sc.GetString ()) { diff --git a/src/teaminfo.cpp b/src/teaminfo.cpp index 04157eb2f6..fa7316c0d8 100644 --- a/src/teaminfo.cpp +++ b/src/teaminfo.cpp @@ -84,7 +84,7 @@ void TEAMINFO_Init () while ((lump = Wads.FindLump ("TEAMINFO", &lastlump)) != -1) { - FScanner sc(lump, "TEAMINFO"); + FScanner sc(lump); while (sc.GetString ()) { if (sc.Compare("CLEARTEAMS")) diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 114657eb37..fd428d1dd7 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -508,7 +508,7 @@ void FTextureManager::LoadHiresTex(int wadnum) { if (Wads.GetLumpFile(remapLump) == wadnum) { - FScanner sc(remapLump, "HIRESTEX"); + FScanner sc(remapLump); while (sc.GetString()) { if (sc.Compare("remap")) // remap an existing texture diff --git a/src/thingdef/thingdef_main.cpp b/src/thingdef/thingdef_main.cpp index d19bd4c25d..5339356a4a 100644 --- a/src/thingdef/thingdef_main.cpp +++ b/src/thingdef/thingdef_main.cpp @@ -150,7 +150,7 @@ void LoadDecorations () lastlump = 0; while ((lump = Wads.FindLump ("DECORATE", &lastlump)) != -1) { - FScanner sc(lump, Wads.GetLumpFullName(lump)); + FScanner sc(lump); ParseDecorate (sc); } FinishThingdef(); diff --git a/src/v_font.cpp b/src/v_font.cpp index 4db45c3c11..3f83aadca2 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -1631,7 +1631,7 @@ void V_InitCustomFonts() while ((llump = Wads.FindLump ("FONTDEFS", &lastlump)) != -1) { - sc.OpenLumpNum(llump, "FONTDEFS"); + sc.OpenLumpNum(llump); while (sc.GetString()) { memset (lumplist, -1, sizeof(lumplist)); @@ -1759,7 +1759,7 @@ void V_InitFontColors () while ((lump = Wads.FindLump ("TEXTCOLO", &lastlump)) != -1) { - FScanner sc(lump, "textcolors.txt"); + FScanner sc(lump); while (sc.GetString()) { names.Clear(); diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 544e5944df..8bd452e268 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1617,6 +1617,25 @@ const char *FWadCollection::GetLumpFullName (int lump) const 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 diff --git a/src/w_wad.h b/src/w_wad.h index e4f351128c..7d84a4dda3 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -206,6 +206,7 @@ public: 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 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 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 diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index ae247ccb45..e6f2c783ed 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -398,7 +398,7 @@ void WI_LoadBackground(bool isenterpic) int lumpnum=Wads.GetNumForName(lumpname+1); if (lumpnum>=0) { - FScanner sc(lumpnum,lumpname+1); + FScanner sc(lumpnum); while (sc.GetString()) { memset(&an,0,sizeof(an));