From 2b5957fd1cce23bdbd12a96d154a3b7ba00d9107 Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Thu, 5 Dec 2019 09:47:29 +0000
Subject: [PATCH] Fix #457 and another bug I just realised in one fell swoop.

That is to say, MV_PERFECT can be applied in singleplayer, but that doesn't update your best rings on the map in record attack, so the thing being yellow doesn't make sense if your rings are (none). Therefore, make it a two-flag, two-bit process.
---
 src/doomstat.h | 3 ++-
 src/g_game.c   | 6 +++++-
 src/m_menu.c   | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/doomstat.h b/src/doomstat.h
index 877f5b50b..b25f8b846 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -466,7 +466,8 @@ extern recorddata_t *mainrecords[NUMMAPS];
 #define MV_ALLEMERALDS  4
 #define MV_ULTIMATE     8
 #define MV_PERFECT     16
-#define MV_MAX         31 // used in gamedata check
+#define MV_PERFECTRA   32
+#define MV_MAX         63 // used in gamedata check, update whenever MV's are added
 #define MV_MP         128
 extern UINT8 mapvisited[NUMMAPS];
 
diff --git a/src/g_game.c b/src/g_game.c
index b754e88ae..9b0e9d408 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -3233,9 +3233,13 @@ static void G_UpdateVisited(void)
 		// eh, what the hell
 		if (ultimatemode)
 			mapvisited[gamemap-1] |= MV_ULTIMATE;
-		// may seem incorrect but IS possible in what the main game uses as special stages, and nummaprings will be -1 in NiGHTS
+		// may seem incorrect but IS possible in what the main game uses as mp special stages, and nummaprings will be -1 in NiGHTS
 		if (nummaprings > 0 && players[consoleplayer].rings >= nummaprings)
+		{
 			mapvisited[gamemap-1] |= MV_PERFECT;
+			if (modeattacking)
+				mapvisited[gamemap-1] |= MV_PERFECTRA;
+		}
 		if (!spec)
 		{
 			// not available to special stages because they can only really be done in one order in an unmodified game, so impossible for first six and trivial for seventh
diff --git a/src/m_menu.c b/src/m_menu.c
index edba61f30..ae3204726 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -9233,7 +9233,7 @@ void M_DrawTimeAttackMenu(void)
 
 		V_DrawString(104-72, 73+lsheadingheight/2, V_YELLOWMAP, "RINGS:");
 
-		V_DrawRightAlignedString(104+64, 73+lsheadingheight/2, V_ALLOWLOWERCASE|((mapvisited[cv_nextmap.value-1] & MV_PERFECT) ? V_YELLOWMAP : 0), beststr);
+		V_DrawRightAlignedString(104+64, 73+lsheadingheight/2, V_ALLOWLOWERCASE|((mapvisited[cv_nextmap.value-1] & MV_PERFECTRA) ? V_YELLOWMAP : 0), beststr);
 
 		V_DrawRightAlignedString(104+72, 83+lsheadingheight/2, V_ALLOWLOWERCASE, reqrings);
 	}
-- 
GitLab