From 1e8b3ea65d9a29feb121e52e76f324f3b63145fb Mon Sep 17 00:00:00 2001 From: Professor Hastig Date: Thu, 26 Oct 2023 10:31:05 +0200 Subject: [PATCH 1/4] fix map WAD check for savegame validation. --- src/g_game.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 90f12896b..e072d0eee 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1890,12 +1890,12 @@ static bool CheckSingleWad (const char *name, bool &printRequires, bool printwar bool G_CheckSaveGameWads (FSerializer &arc, bool printwarn) { bool printRequires = false; - FString text; + const char* text; text = arc.GetString("Game WAD"); - CheckSingleWad (text.GetChars(), printRequires, printwarn); + CheckSingleWad (text, printRequires, printwarn); text = arc.GetString("Map WAD"); - CheckSingleWad (text.GetChars(), printRequires, printwarn); + if (text != nullptr) CheckSingleWad (text, printRequires, printwarn); if (printRequires) { From a8c1f7a6374df28e7ca32f674962baf9c3300f11 Mon Sep 17 00:00:00 2001 From: Professor Hastig Date: Thu, 26 Oct 2023 10:42:26 +0200 Subject: [PATCH 2/4] always save the map WAD in a savegame's metadata, even if it is from the IWAD Otherwise the savegame loader will not be able to validate an IWAD savegame while the actual level comes from a different file. --- src/g_game.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index e072d0eee..485980a48 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1890,12 +1890,12 @@ static bool CheckSingleWad (const char *name, bool &printRequires, bool printwar bool G_CheckSaveGameWads (FSerializer &arc, bool printwarn) { bool printRequires = false; - const char* text; - text = arc.GetString("Game WAD"); + const char *text = arc.GetString("Game WAD"); CheckSingleWad (text, printRequires, printwarn); - text = arc.GetString("Map WAD"); - if (text != nullptr) CheckSingleWad (text, printRequires, printwarn); + const char *text2 = arc.GetString("Map WAD"); + // do not validate the same file twice. + if (text != nullptr && text2 != nullptr && stricmp(text, text2) != 0) CheckSingleWad (text2, printRequires, printwarn); if (printRequires) { @@ -2268,11 +2268,8 @@ static void PutSaveWads (FSerializer &arc) arc.AddString("Game WAD", name); // Name of wad the map resides in - if (fileSystem.GetFileContainer (primaryLevel->lumpnum) > fileSystem.GetIwadNum()) - { - name = fileSystem.GetResourceFileName (fileSystem.GetFileContainer (primaryLevel->lumpnum)); - arc.AddString("Map WAD", name); - } + name = fileSystem.GetResourceFileName (fileSystem.GetFileContainer (primaryLevel->lumpnum)); + arc.AddString("Map WAD", name); } static void PutSaveComment (FSerializer &arc) From 77e5fd308126aeebfa0f398409831bfd0735f2ba Mon Sep 17 00:00:00 2001 From: Professor Hastig Date: Thu, 26 Oct 2023 08:08:58 +0200 Subject: [PATCH 3/4] fixed skewing for lower tiers. --- src/rendering/hwrenderer/scene/hw_walls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index 33fd42db7..ec865f7e3 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -2407,7 +2407,7 @@ void HWWall::Process(HWWallDispatcher *di, seg_t *seg, sector_t * frontsector, s /* bottom texture */ // the back sector's ceiling obstructs part of this wall (specially important for sky sectors) - float bfh1a = bch1, bfh2a = bch2; + float bfh1a = bfh1, bfh2a = bfh2; if (fch1 < bfh1 && fch2 < bfh2 && (seg->linedef->flags & ML_DRAWFULLHEIGHT) == 0) { bfh1 = fch1; From 4d88e82e32ac2ccf876903dd122e85195fdaa0da Mon Sep 17 00:00:00 2001 From: Professor Hastig Date: Thu, 26 Oct 2023 11:41:45 +0200 Subject: [PATCH 4/4] added Wads.GetLumpLength. --- src/common/scripting/interface/vmnatives.cpp | 7 +++++++ wadsrc/static/zscript/engine/base.zs | 1 + 2 files changed, 8 insertions(+) diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 096722e76..1df737d16 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -848,6 +848,13 @@ DEFINE_ACTION_FUNCTION(_Wads, ReadLump) ACTION_RETURN_STRING(isLumpValid ? GetStringFromLump(lump, false) : FString()); } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpLength) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_INT(fileSystem.FileLength(lump)); +} + //========================================================================== // // CVARs diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index c0754f705..2644dc197 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -862,6 +862,7 @@ struct Wads // todo: make FileSystem an alias to 'Wads' native static int FindLump(string name, int startlump = 0, FindLumpNamespace ns = GlobalNamespace); native static int FindLumpFullName(string name, int startlump = 0, bool noext = false); native static string ReadLump(int lump); + native static int GetLumpLength(int lump); native static int GetNumLumps(); native static string GetLumpName(int lump);