From 0a49340ae11f4deab9e089079dc6e6ba22f2f64a Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Mon, 28 Oct 2019 23:46:33 -0300
Subject: [PATCH] Fix warnings when NOPNG=1

---
 src/hardware/hw_cache.c | 4 +++-
 src/r_data.c            | 6 +++++-
 src/w_wad.c             | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c
index 02df290b8c..5cfd0f61c5 100644
--- a/src/hardware/hw_cache.c
+++ b/src/hardware/hw_cache.c
@@ -690,7 +690,9 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
 	// Composite the columns together.
 	for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
 	{
+#ifndef NO_PNG_LUMPS
 		size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump);
+#endif
 		realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
 #ifndef NO_PNG_LUMPS
 		if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
@@ -929,9 +931,9 @@ static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
 {
 	UINT8 *flat;
 	patch_t *patch = (patch_t *)W_CacheLumpNum(flatlumpnum, PU_STATIC);
+#ifndef NO_PNG_LUMPS
 	size_t lumplength = W_LumpLength(flatlumpnum);
 
-#ifndef NO_PNG_LUMPS
 	if (R_IsLumpPNG((UINT8 *)patch, lumplength))
 		patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL, false);
 #endif
diff --git a/src/r_data.c b/src/r_data.c
index 524baad151..74cbf6ad41 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -831,7 +831,9 @@ void R_LoadTextures(void)
 		{
 			UINT16 wadnum = (UINT16)w;
 			lumpnum_t lumpnum = texstart + j;
+#ifndef NO_PNG_LUMPS
 			size_t lumplength;
+#endif
 
 			if (wadfiles[w]->type == RET_PK3)
 			{
@@ -839,8 +841,10 @@ void R_LoadTextures(void)
 					continue; // If it is then SKIP IT
 			}
 
-			lumplength = W_LumpLengthPwad(wadnum, lumpnum);
 			patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
+#ifndef NO_PNG_LUMPS
+			lumplength = W_LumpLengthPwad(wadnum, lumpnum);
+#endif
 
 			//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);
diff --git a/src/w_wad.c b/src/w_wad.c
index 4d08b26dc0..51c77fd878 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -1531,7 +1531,10 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
 		if (!lumpcache[lump])
 		{
 			size_t len = W_LumpLengthPwad(wad, lump);
-			void *ptr, *lumpdata, *srcdata = NULL;
+			void *ptr, *lumpdata;
+#ifndef NO_PNG_LUMPS
+			void *srcdata = NULL;
+#endif
 
 			ptr = Z_Malloc(len, tag, &lumpcache[lump]);
 			lumpdata = Z_Malloc(len, tag, NULL);
-- 
GitLab