From 8390184839fa61df1651bbf50ff406ea07037606 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Oct 2009 14:08:32 +0000 Subject: [PATCH] - fixed: FMultiPatchTexture::MakeTexture was missing a range check for the special colormap index. SVN r1928 (trunk) --- docs/rh-log.txt | 4 ++++ src/textures/multipatchtexture.cpp | 2 +- src/textures/texture.cpp | 1 + src/textures/texturemanager.cpp | 7 ++++++- src/textures/textures.h | 8 ++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index ad60418f0..44f80a49c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +October 18, 2009 (Changes by Graf Zahl) +- fixed: FMultiPatchTexture::MakeTexture was missing a range check for the + special colormap index. + October 17, 2009 (Changes by Graf Zahl) - Fixed: 3DMidtex checks were treating the Null texture as a valid texture. - Fixed: The rail sound's position was not clamped to the actual range between diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 984135e97..34956dff7 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -429,7 +429,7 @@ BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) return TranslationToTable(TRANSLATION(TRANSLATION_Standard, 7))->Remap; default: - if (blend >= BLEND_SPECIALCOLORMAP1) + if (blend >= BLEND_SPECIALCOLORMAP1 && blend < BLEND_SPECIALCOLORMAP1 + SpecialColormaps.Size()) { return SpecialColormaps[blend - BLEND_SPECIALCOLORMAP1].Colormap; } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index df680a507..690a59421 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -146,6 +146,7 @@ FTexture::FTexture (const char *name, int lumpnum) bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), Rotations(0xFFFF), Width(0), Height(0), WidthMask(0), Native(NULL) { + id.SetInvalid(); if (name != NULL) { uppercopy(Name, name); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 7a66a7202..2d3e2fc9f 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -320,7 +320,7 @@ FTextureID FTextureManager::AddTexture (FTexture *texture) int trans = Textures.Push (hasher); Translation.Push (trans); if (bucket >= 0) HashFirst[bucket] = trans; - return FTextureID(trans); + return (texture->id = FTextureID(trans)); } //========================================================================== @@ -365,10 +365,15 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, b newtexture->UseType = oldtexture->UseType; Textures[index].Texture = newtexture; + newtexture->id = oldtexture->id; if (free) { delete oldtexture; } + else + { + oldtexture->id.SetInvalid(); + } } //========================================================================== diff --git a/src/textures/textures.h b/src/textures/textures.h index 06d373f1f..0f595b5cb 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -100,6 +100,7 @@ public: fixed_t yScale; int SourceLump; + FTextureID id; union { @@ -156,6 +157,7 @@ public: virtual bool UseBasePalette(); virtual int GetSourceLump() { return SourceLump; } virtual FTexture *GetRedirect(bool wantwarped); + FTextureID GetID() const { return id; } virtual void Unload () = 0; @@ -278,6 +280,12 @@ public: return Textures[Translation[texnum.texnum]].Texture; } + FTexture *ByIndexTranslated(int i) + { + if (unsigned(i) >= Textures.Size()) return NULL; + return Textures[Translation[i]].Texture; + } + void SetTranslation (FTextureID fromtexnum, FTextureID totexnum) { if ((size_t)fromtexnum.texnum < Translation.Size())