From 6df5e6f9cb7635bb31fb37bbd33277ee42b8a2b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Jul 2010 09:35:39 +0000 Subject: [PATCH] - added Gez's anti-crossinclude submission but made some changes. Cross-includes overriding core files will produce fatal errors but cross-includes between PWADs will be tolerated. For DECORATE a command line override switch exists so that for testing the error can be disabled. SVN r2400 (trunk) --- src/d_main.cpp | 7 +++++-- src/g_mapinfo.cpp | 21 +++++++++++++++++++-- src/g_shared/sbarinfo.cpp | 31 +++++++++++++++++++------------ src/m_menu.cpp | 3 +++ src/thingdef/thingdef_parse.cpp | 13 +++++++++++++ 5 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index c24b18480..3b1e841a5 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1209,8 +1209,11 @@ void D_DoAdvanceDemo (void) case 2: pagetic = (int)(gameinfo.pageTime * TICRATE); gamestate = GS_DEMOSCREEN; - pagename = gameinfo.creditPages[pagecount]; - pagecount = (pagecount+1) % gameinfo.creditPages.Size(); + if (gameinfo.creditPages.Size() > 0) + { + pagename = gameinfo.creditPages[pagecount]; + pagecount = (pagecount+1) % gameinfo.creditPages.Size(); + } demosequence = 1; break; } diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 2b31f50f8..1eb6363fd 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -51,6 +51,8 @@ #include "doomstat.h" #include "d_player.h" #include "autosegs.h" +#include "version.h" +#include "v_text.h" int FindEndSequence (int type, const char *picname); @@ -1865,6 +1867,15 @@ void FMapInfoParser::ParseMapInfo (int lump, level_info_t &gamedefaults, level_i { sc.ScriptError("include file '%s' not found", sc.String); } + if (Wads.GetLumpFile(sc.LumpNum) != Wads.GetLumpFile(inclump)) + { + // Do not allow overriding includes from the default MAPINFO + if (Wads.GetLumpFile(sc.LumpNum) == 0) + { + I_FatalError("File %s is overriding core lump %s.", + Wads.GetWadFullName(Wads.GetLumpFile(inclump)), sc.String); + } + } FScanner saved_sc = sc; ParseMapInfo(inclump, gamedefaults, defaultinfo); sc = saved_sc; @@ -1956,12 +1967,18 @@ void G_ParseMapInfo (const char *basemapinfo) atterm(ClearEpisodes); - // Parse the default MAPINFO for the current game. + // Parse the default MAPINFO for the current game. This lump *MUST* come from zdoom.pk3. if (basemapinfo != NULL) { FMapInfoParser parse; level_info_t defaultinfo; - parse.ParseMapInfo(Wads.GetNumForFullName(basemapinfo), gamedefaults, defaultinfo); + int baselump = Wads.GetNumForFullName(basemapinfo); + if (Wads.GetLumpFile(baselump) > 0) + { + I_FatalError("File %s is overriding core lump %s.", + Wads.GetWadFullName(Wads.GetLumpFile(baselump)), basemapinfo); + } + parse.ParseMapInfo(baselump, gamedefaults, defaultinfo); } static const char *mapinfonames[] = { "MAPINFO", "ZMAPINFO", NULL }; diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 1966b58f6..6895ce321 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -58,6 +58,7 @@ #include "v_palette.h" #include "p_acs.h" #include "gstrings.h" +#include "version.h" #define ARTIFLASH_OFFSET (statusBar->invBarOffset+6) enum @@ -469,6 +470,7 @@ void SBarInfo::ParseSBarInfo(int lump) ParseSBarInfo(lump); continue; } + int baselump = -2; switch(sc.MustMatchString(SBarInfoTopLevel)) { case SBARINFO_BASE: @@ -477,24 +479,15 @@ void SBarInfo::ParseSBarInfo(int lump) sc.MustGetToken(TK_Identifier); if(sc.Compare("Doom")) { - int lump = Wads.CheckNumForFullName("sbarinfo/doom.txt", true); - if(lump == -1) - sc.ScriptError("Standard Doom Status Bar not found."); - ParseSBarInfo(lump); + baselump = Wads.CheckNumForFullName("sbarinfo/doom.txt", true); } else if(sc.Compare("Heretic")) { - int lump = Wads.CheckNumForFullName("sbarinfo/heretic.txt", true); - if(lump == -1) - sc.ScriptError("Standard Heretic Status Bar not found."); - ParseSBarInfo(lump); + baselump = Wads.CheckNumForFullName("sbarinfo/heretic.txt", true); } else if(sc.Compare("Hexen")) { - int lump = Wads.CheckNumForFullName("sbarinfo/hexen.txt", true); - if(lump == -1) - sc.ScriptError("Standard Hexen Status Bar not found."); - ParseSBarInfo(lump); + baselump = Wads.CheckNumForFullName("sbarinfo/hexen.txt", true); } else if(sc.Compare("Strife")) gameType = GAME_Strife; @@ -502,6 +495,20 @@ void SBarInfo::ParseSBarInfo(int lump) gameType = GAME_Any; else sc.ScriptError("Bad game name: %s", sc.String); + // If one of the standard status bar should be loaded, baselump has been set to a different value. + if (baselump != -2) + { + if(baselump == -1) + { + sc.ScriptError("Standard %s status bar not found.", sc.String); + } + else if (Wads.GetLumpFile(baselump) > 0) + { + I_FatalError("File %s is overriding core lump sbarinfo/%s.txt.", + Wads.GetWadFullName(Wads.GetLumpFile(baselump)), sc.String); + } + ParseSBarInfo(baselump); + } sc.MustGetToken(';'); break; case SBARINFO_HEIGHT: diff --git a/src/m_menu.cpp b/src/m_menu.cpp index 9bc25284e..49d5638ef 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -1293,6 +1293,9 @@ void M_DrawFrame (int left, int top, int width, int height) { FTexture *p; const gameborder_t *border = gameinfo.border; + // Sanity check for incomplete gameinfo + if (border == NULL) + return; int offset = border->offset; int right = left + width; int bottom = top + height; diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 7712fe43b..07f4ca4e2 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -52,6 +52,9 @@ #include "thingdef_exp.h" #include "w_wad.h" #include "v_video.h" +#include "version.h" +#include "v_text.h" +#include "m_argv.h" void ParseOldDecoration(FScanner &sc, EDefinitionType def); @@ -1199,6 +1202,16 @@ void ParseDecorate (FScanner &sc) case TK_Include: { sc.MustGetString(); + // This check needs to remain overridable for testing purposes. + if (Wads.GetLumpFile(sc.LumpNum) == 0 && !Args->CheckParm("-allowdecoratecrossincludes")) + { + int includefile = Wads.GetLumpFile(Wads.CheckNumForFullName(sc.String, true)); + if (includefile != 0) + { + I_FatalError("File %s is overriding core lump %s.", + Wads.GetWadFullName(includefile), sc.String); + } + } FScanner newscanner; newscanner.Open(sc.String); ParseDecorate(newscanner);