From ab6b716e78e4f55bf592cdccf14f0cda5f87db98 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Mar 2024 21:31:45 +0100 Subject: [PATCH] Read only header bytes when creating textures list --- src/r_data.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 179c88492..0900ed2c1 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -384,7 +384,7 @@ Rloadtextures (INT32 i, INT32 w) UINT16 j; INT32 k; UINT16 texstart, texend, texturesLumpPos; - patch_t *patchlump; + patch_t patchlump; texpatch_t *patch; texture_t *texture; @@ -422,8 +422,7 @@ Rloadtextures (INT32 i, INT32 w) if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder continue; // If it is then SKIP IT } - - patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, 8, 0); // #define PNG_HEADER_SIZE (8) //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); @@ -431,8 +430,8 @@ Rloadtextures (INT32 i, INT32 w) // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); texture->hash = quickncasehash(texture->name, 8); - texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height); + texture->width = SHORT(patchlump.width); + texture->height = SHORT(patchlump.height); texture->patchcount = 1; texture->holes = false; @@ -443,8 +442,6 @@ Rloadtextures (INT32 i, INT32 w) patch->wad = (UINT16)w; patch->lump = texstart + j; - Z_Free(patchlump); - k = 1; while (k << 1 <= texture->width) k <<= 1;