From 561a0fe76880455a97079a4a171c1cefad7fc70c Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Thu, 3 Nov 2016 21:06:23 +0000
Subject: [PATCH] Attempt loading of an MD2 only once; if we failed then don't
 bother again

This keeps my new error messages from flooding the console and log.txt
---
 src/hardware/hw_md2.c | 5 +++++
 src/hardware/hw_md2.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c
index 8e2b9a5b5..2fcf252d2 100644
--- a/src/hardware/hw_md2.c
+++ b/src/hardware/hw_md2.c
@@ -782,6 +782,7 @@ void HWR_InitMD2(void)
 		md2_playermodels[s].grpatch = NULL;
 		md2_playermodels[s].skin = -1;
 		md2_playermodels[s].notfound = true;
+		md2_playermodels[s].error = false;
 	}
 	for (i = 0; i < NUMSPRITES; i++)
 	{
@@ -790,6 +791,7 @@ void HWR_InitMD2(void)
 		md2_models[i].grpatch = NULL;
 		md2_models[i].skin = -1;
 		md2_models[i].notfound = true;
+		md2_models[s].error = false;
 	}
 
 	// read the md2.dat file
@@ -1282,6 +1284,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
 		else
 			md2 = &md2_models[spr->mobj->sprite];
 
+		if (md2->error)
+			return; // we already failed loading this before :(
 		if (!md2->model)
 		{
 			//CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]);
@@ -1295,6 +1299,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
 			else
 			{
 				//CONS_Debug(DBG_RENDER, " FAILED\n");
+				md2->error = true; // prevent endless fail
 				return;
 			}
 		}
diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h
index 36078268b..5a7e6d2b3 100644
--- a/src/hardware/hw_md2.h
+++ b/src/hardware/hw_md2.h
@@ -123,6 +123,7 @@ typedef struct
 	void        *blendgrpatch;
 	boolean     notfound;
 	INT32       skin;
+	boolean     error;
 } md2_t;
 
 extern md2_t md2_models[NUMSPRITES];
-- 
GitLab