From 3e7be585ca35a625bb426bef270f8bfcb1bc859c Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Sat, 9 Nov 2019 12:22:18 -0300
Subject: [PATCH] WORK!!

---
 src/r_data.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/r_data.c b/src/r_data.c
index d271e28f3e..38c711b7b7 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -752,7 +752,6 @@ void R_LoadTextures(void)
 	for (w = 0, numtextures = 0; w < numwadfiles; w++)
 	{
 		// Count the textures from TEXTURES lumps
-
 		texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
 		while (texturesLumpPos != INT16_MAX)
 		{
@@ -761,7 +760,6 @@ void R_LoadTextures(void)
 		}
 
 		// Count single-patch textures
-
 		if (wadfiles[w]->type == RET_PK3)
 		{
 			texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
@@ -774,7 +772,11 @@ void R_LoadTextures(void)
 		}
 
 		if (texstart == INT16_MAX || texend == INT16_MAX)
+#ifdef WALLFLATS
+			goto countflats;
+#else
 			continue;
+#endif
 
 		texstart++; // Do not count the first marker
 
@@ -793,6 +795,7 @@ void R_LoadTextures(void)
 		}
 
 #ifdef WALLFLATS
+countflats:
 		// Count flats
 		if (wadfiles[w]->type == RET_PK3)
 		{
@@ -802,7 +805,7 @@ void R_LoadTextures(void)
 		else
 		{
 			texstart = W_CheckNumForNamePwad("F_START", (UINT16)w, 0);
-			texend = W_CheckNumForNamePwad("F_END", (UINT16)w, 0);
+			texend = W_CheckNumForNamePwad("F_END", (UINT16)w, texstart);
 		}
 
 		if (texstart == INT16_MAX || texend == INT16_MAX)
@@ -873,7 +876,11 @@ void R_LoadTextures(void)
 		}
 
 		if (texstart == INT16_MAX || texend == INT16_MAX)
+#ifdef WALLFLATS
+			goto checkflats;
+#else
 			continue;
+#endif
 
 		texstart++; // Do not count the first marker
 
@@ -939,6 +946,7 @@ void R_LoadTextures(void)
 		}
 
 #ifdef WALLFLATS
+checkflats:
 		// Yes
 		if (wadfiles[w]->type == RET_PK3)
 		{
@@ -948,7 +956,7 @@ void R_LoadTextures(void)
 		else
 		{
 			texstart = W_CheckNumForNamePwad("F_START", (UINT16)w, 0);
-			texend = W_CheckNumForNamePwad("F_END", (UINT16)w, 0);
+			texend = W_CheckNumForNamePwad("F_END", (UINT16)w, texstart);
 		}
 
 		if (texstart == INT16_MAX || texend == INT16_MAX)
-- 
GitLab