From fa8e05d56d908d0eb654770685eb9b904152a99c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Oct 2016 22:40:58 +0200 Subject: [PATCH 1/5] - do not allow a multipatch texture to use itself as patch. Instead, look for an older texture with the same name. --- src/textures/multipatchtexture.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 340376a25..cb2d5d803 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1323,6 +1323,24 @@ void FMultiPatchTexture::ResolvePatches() for (int i = 0; i < NumParts; i++) { FTextureID texno = TexMan.CheckForTexture(Inits[i].TexName, Inits[i].UseType); + if (texno == id) // we found ourselves. Try looking for another one with the same name which is not a multipatch texture itself. + { + TArray list; + TexMan.ListTextures(Inits[i].TexName, list); + for (int i = list.Size() - 1; i >= 0; i--) + { + if (list[i] != id && !TexMan[list[i]]->bMultiPatch) + { + texno = list[i]; + break; + } + } + if (texno == id) + { + if (Inits[i].HasLine) Inits[i].sc.Message(MSG_WARNING, "Texture '%s' references itself as patch\n", Inits[i].TexName.GetChars()); + else Printf(TEXTCOLOR_YELLOW "Texture '%s' references itself as patch\n", Inits[i].TexName.GetChars()); + } + } if (!texno.isValid()) { From 316e3395adec1fea9965317339a4641620979eaa Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 26 Oct 2016 12:08:03 +0300 Subject: [PATCH 2/5] Fixed crash on loading multipatch texture with height of 256 http://forum.zdoom.org/viewtopic.php?t=53953 --- src/textures/multipatchtexture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index cb2d5d803..e1e6faf3e 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -297,8 +297,6 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl Printf ("Texture %s is left without any patches\n", Name.GetChars()); } - CheckForHacks (); - DefinitionLump = deflumpnum; } @@ -1370,6 +1368,8 @@ void FMultiPatchTexture::ResolvePatches() delete[] Inits; Inits = nullptr; + CheckForHacks(); + // If this texture is just a wrapper around a single patch, we can simply // forward GetPixels() and GetColumn() calls to that patch. From 28fefdabc76efef99d81f53e63552a9e570b6786 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Oct 2016 11:56:15 +0200 Subject: [PATCH 3/5] - added a 'listall' option to FTextureManager::ListTextures, so that the multipatchtexture lookup can find multiple older versions with the same use type. This fixes an issue with DUMP 2 which looked for patches of the same name as the texture currently being defined and where the patches had the same use type as the composite texture. The function as implemented would only find the newly added composite and print an error. --- src/textures/multipatchtexture.cpp | 2 +- src/textures/texturemanager.cpp | 13 ++++++++----- src/textures/textures.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index e1e6faf3e..12cc02ea9 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1324,7 +1324,7 @@ void FMultiPatchTexture::ResolvePatches() if (texno == id) // we found ourselves. Try looking for another one with the same name which is not a multipatch texture itself. { TArray list; - TexMan.ListTextures(Inits[i].TexName, list); + TexMan.ListTextures(Inits[i].TexName, list, true); for (int i = list.Size() - 1; i >= 0; i--) { if (list[i] != id && !TexMan[list[i]]->bMultiPatch) diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 07ed71a3b..aa760c221 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -267,7 +267,7 @@ FTextureID FTextureManager::CheckForTexture (const char *name, int usetype, BITF // //========================================================================== -int FTextureManager::ListTextures (const char *name, TArray &list) +int FTextureManager::ListTextures (const char *name, TArray &list, bool listall) { int i; @@ -293,11 +293,14 @@ int FTextureManager::ListTextures (const char *name, TArray &list) // NULL textures must be ignored. if (tex->UseType!=FTexture::TEX_Null) { - unsigned int j; - for(j = 0; j < list.Size(); j++) + unsigned int j = list.Size(); + if (!listall) { - // Check for overriding definitions from newer WADs - if (Textures[list[j].GetIndex()].Texture->UseType == tex->UseType) break; + for (j = 0; j < list.Size(); j++) + { + // Check for overriding definitions from newer WADs + if (Textures[list[j].GetIndex()].Texture->UseType == tex->UseType) break; + } } if (j==list.Size()) list.Push(FTextureID(i)); } diff --git a/src/textures/textures.h b/src/textures/textures.h index 407500f18..064610f50 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -350,7 +350,7 @@ public: FTextureID CheckForTexture (const char *name, int usetype, BITFIELD flags=TEXMAN_TryAny); FTextureID GetTexture (const char *name, int usetype, BITFIELD flags=0); - int ListTextures (const char *name, TArray &list); + int ListTextures (const char *name, TArray &list, bool listall = false); void AddTexturesLump (const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup=0, bool texture1=false); void AddTexturesLumps (int lump1, int lump2, int patcheslump); From 5309209039be90040306786a6e0478fcd9389227 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Oct 2016 12:03:28 +0200 Subject: [PATCH 4/5] - print a developer warning if the texture manager had to resolve a circular reference. --- src/textures/multipatchtexture.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 12cc02ea9..860c59b3a 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1338,6 +1338,11 @@ void FMultiPatchTexture::ResolvePatches() if (Inits[i].HasLine) Inits[i].sc.Message(MSG_WARNING, "Texture '%s' references itself as patch\n", Inits[i].TexName.GetChars()); else Printf(TEXTCOLOR_YELLOW "Texture '%s' references itself as patch\n", Inits[i].TexName.GetChars()); } + else + { + // If it could be resolved, just print a developer warning. + DPrintf(DMSG_WARNING, "Resolved self-referencing texture by picking an older entry for %s", Inits[i].TexName.GetChars()); + } } if (!texno.isValid()) From 12ce76426e7902238f85b3bd4318a77cd7889f04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Oct 2016 12:13:57 +0200 Subject: [PATCH 5/5] Revert "Allows loading directories as IWADs using "-iwad" command line parameter." This reverts commit 81449728d7a6217460e9e451eca20232e86a3316. Reverted because it compromises the IWAD file lookup and fixing it properly is not so trivial. The skipping of adding the file name extension was not only broken, but even after fixing the code does not work if the IWADs are located outside the working directory. --- src/d_iwad.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 6fa8604a0..1fc63e03d 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -292,7 +292,6 @@ void FIWadManager::ParseIWadInfos(const char *fn) int FIWadManager::ScanIWAD (const char *iwad) { FResourceFile *iwadfile = FResourceFile::OpenResourceFile(iwad, NULL, true); - if (iwadfile == NULL) iwadfile = FResourceFile::OpenDirectory(iwad, true); //mxd. A directory can also work as an IWAD if (iwadfile != NULL) { @@ -345,7 +344,7 @@ int FIWadManager::CheckIWAD (const char *doomwaddir, WadStuff *wads) iwad.Format ("%s%s%s", doomwaddir, slash, mIWadNames[i].GetChars()); FixPathSeperator (iwad); - if (DirEntryExists(iwad)) + if (FileExists (iwad)) { wads[i].Type = ScanIWAD (iwad); if (wads[i].Type != -1) @@ -414,7 +413,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, } else { - if(FileExists(custwad)) DefaultExtension (custwad, ".wad"); //mxd. Don't treat folders as .wads + DefaultExtension (custwad, ".wad"); iwadparm = custwad; mIWadNames[0] = custwad; CheckIWAD ("", &wads[0]);