From 77779469795bb095ef4a57eec314a3b955f1c0cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 21:05:52 +0100 Subject: [PATCH] noo dont free our realpatch randomly this used to be Z_Unlock which did nothing checked against srb2 and rr and this should not be freed normally --- src/hardware/hw_cache.c | 10 ++++------ src/w_wad.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c06db3891..3822ae37b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -77,9 +77,6 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm (void)patchheight; // This parameter is unused - if (!mipmap) - return; - if (originPatch) // originPatch can be NULL here, unlike in the software version originy = originPatch->originy; @@ -118,11 +115,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm alpha = 0xFF; // Make pixel transparent if chroma keyed - if ((mipmap && mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; //Hurdler: 25/04/2000: now support colormap in hardware mode - if (mipmap && mipmap->colormap) + if (mipmap->colormap) texel = mipmap->colormap[texel]; // hope compiler will get this switch out of the loops (dreams...) @@ -387,10 +384,11 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + if (realpatch != NULL) { HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + //Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } } diff --git a/src/w_wad.c b/src/w_wad.c index 4dc9b068c..571b79c17 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1824,7 +1824,7 @@ void W_UnlockCachedPatch(void *patch) // The hardware code does its own memory management, as its patches // have different lifetimes from software's. #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode == render_opengl) HWR_UnlockCachedPatch((GLPatch_t*)patch); else #endif