From 1d4f4b25d74fccc8f4c5e42811707e0606ce7adb Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 24 Feb 2014 19:01:36 -0600 Subject: [PATCH] Don't free replaced textures that are used as patches. - Fixed: If a part of a multipatch texture is replaced by a HIRESTEX version, the original patch must not be deleted, since the multipatch texture still needs it for compositing. --- src/textures/multipatchtexture.cpp | 6 ++++-- src/textures/texture.cpp | 2 +- src/textures/texturemanager.cpp | 2 +- src/textures/textures.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index fd2b59fb1..4f327309d 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -244,7 +244,6 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl Height = SAFESHORT(mtexture.d->height); strncpy (Name, (const char *)mtexture.d->name, 8); Name[8] = 0; - CalcBitSize (); xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT; @@ -280,6 +279,10 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl NumParts--; i--; } + else + { + Parts[i].Texture->bKeepAround = true; + } if (strife) mpatch.s++; else @@ -859,7 +862,6 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d { pnames.Read (patchlookup[i].Name, 8); patchlookup[i].Name[8] = 0; - FTextureID j = CheckForTexture (patchlookup[i].Name, FTexture::TEX_WallPatch); if (j.isValid()) { diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 093bf303b..0434aaaa4 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -146,7 +146,7 @@ FTexture::FTexture (const char *name, int lumpnum) : LeftOffset(0), TopOffset(0), WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT), SourceLump(lumpnum), UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false), - bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), + bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bKeepAround(false), Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0), WidthMask(0), Native(NULL) { id.SetInvalid(); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index f28026f19..48f3ff9e0 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -428,7 +428,7 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, b Textures[index].Texture = newtexture; newtexture->id = oldtexture->id; - if (free) + if (free && !oldtexture->bKeepAround) { delete oldtexture; } diff --git a/src/textures/textures.h b/src/textures/textures.h index 100ba31e9..837c62689 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -177,6 +177,7 @@ public: // fully composited before subjected to any kind of postprocessing instead of // doing it per patch. BYTE bMultiPatch:1; // This is a multipatch texture (we really could use real type info for textures...) + BYTE bKeepAround:1; // This texture was used as part of a multi-patch texture. Do not free it. WORD Rotations; SWORD SkyOffset;