From 21d4aae182a3d35a35e390ec65acf26f6c9dff08 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2022 11:48:39 +0100 Subject: [PATCH] - fixed lookup for tile aliases pointing to non-existent tiles. --- source/core/g_mapinfo.cpp | 16 +++++++++------- source/core/gamecontrol.cpp | 1 - source/core/textures/tilesetbuilder.cpp | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/core/g_mapinfo.cpp b/source/core/g_mapinfo.cpp index db44f8862..fb04cef7d 100644 --- a/source/core/g_mapinfo.cpp +++ b/source/core/g_mapinfo.cpp @@ -59,6 +59,7 @@ static ClusterDef TheDefaultClusterInfo; TArray ParsedLumps(8); +constexpr int texlookupflags = FTextureManager::TEXMAN_ReturnAll | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ForceLookup; //========================================================================== // // @@ -366,7 +367,7 @@ void FMapInfoParser::ParseBreakWall() sc.MustGetString(); FString basename = sc.String; // save for printing error messages. - basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any); + basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); if (!basetile.isValid()) { sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String); @@ -374,8 +375,9 @@ void FMapInfoParser::ParseBreakWall() } ParseAssign(); sc.MustGetString(); - breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any); - if (*sc.String && !breaktile.isValid()) sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String); + breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); + if (*sc.String && !breaktile.isValid()) + sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String); if (sc.CheckString(",")) { sc.MustGetString(); @@ -431,7 +433,7 @@ void FMapInfoParser::ParseBreakCeiling() sc.MustGetString(); FString basename = sc.String; // save for printing error messages. - basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any); + basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); if (!basetile.isValid()) { sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String); @@ -439,7 +441,7 @@ void FMapInfoParser::ParseBreakCeiling() } ParseAssign(); sc.MustGetString(); - breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any); + breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); if (*sc.String && !breaktile.isValid()) sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String); if (sc.CheckString(",")) { @@ -504,7 +506,7 @@ void FMapInfoParser::ParseTextureFlags() { sc.MustGetString(); // this must also get null textures and ones not yet loaded. - auto tex = TexMan.CheckForTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_ReturnAll | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ForceLookup); + auto tex = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); if (!tex.isValid()) { @@ -547,7 +549,7 @@ void FMapInfoParser::ParseSurfaceTypes() { sc.MustGetString(); // this must also get null textures and ones not yet loaded. - auto tex = TexMan.CheckForTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_ReturnAll | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ForceLookup); + auto tex = TexMan.CheckForTexture(sc.String, ETextureType::Any, texlookupflags); if (!tex.isValid()) { diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 3bf5735ab..e7e152019 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -984,7 +984,6 @@ static void InitTextures(TArray& usedgroups) ConstructTileset(); InitFont(); // InitFonts may only be called once all texture data has been initialized. - //TileFiles.SetAliases(); lookups.postLoadTables(); highTileSetup(); diff --git a/source/core/textures/tilesetbuilder.cpp b/source/core/textures/tilesetbuilder.cpp index fa65cd773..f7926ea7a 100644 --- a/source/core/textures/tilesetbuilder.cpp +++ b/source/core/textures/tilesetbuilder.cpp @@ -319,6 +319,6 @@ void ConstructTileset() for (auto& a : info.aliases) { - TexMan.AddAlias(a.first.GetChars(), a.second + firstarttile); + TexMan.AddAlias(a.first.GetChars(), min(maxarttile, a.second) + firstarttile); } }