From f6842a80b462ff9ec0c7a58fd598dc94a0d3f2e1 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Sun, 14 Jul 2019 21:58:48 +0100
Subject: [PATCH] Fixes for menus: * add gamestate != GS_TIMEATTACK checks to
 prevent Record Attack or NiGHTS Mode losing their backgrounds * increase
 bgname to 9 to include the extra NULL byte? (is this a good idea actually) *
 make M_IterateMenuTree ignore menu levels without a menutype value

---
 src/f_finale.c | 2 +-
 src/f_finale.h | 2 +-
 src/m_menu.c   | 8 +++++---
 src/m_menu.h   | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/f_finale.c b/src/f_finale.c
index 27c9ebd681..134bc9fcc2 100644
--- a/src/f_finale.c
+++ b/src/f_finale.c
@@ -67,7 +67,7 @@ static INT32 menuanimtimer; // Title screen: background animation timing
 mobj_t *titlemapcameraref = NULL;
 
 // menu presentation state
-char curbgname[8];
+char curbgname[9];
 SINT8 curfadevalue;
 boolean curhidepics;
 INT32 curbgcolor;
diff --git a/src/f_finale.h b/src/f_finale.h
index c0c6360c31..663a454128 100644
--- a/src/f_finale.h
+++ b/src/f_finale.h
@@ -84,7 +84,7 @@ typedef enum
 
 extern UINT8 titlemapinaction;
 extern mobj_t *titlemapcameraref;
-extern char curbgname[8];
+extern char curbgname[9];
 extern SINT8 curfadevalue;
 extern boolean curhidepics;
 extern INT32 curbgcolor;
diff --git a/src/m_menu.c b/src/m_menu.c
index dca2e552d7..53e0182fdd 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -2247,6 +2247,8 @@ static INT32 M_IterateMenuTree(menutree_iterator itfunc, void *input)
 	{
 		bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i);
 		menutype = (activeMenuId & bitmask) >> (MENUBITS*i);
+		if (!menutype)
+			continue;
 		if (itfunc(menutype, i, &retval, &input, false))
 			break;
 	}
@@ -2300,7 +2302,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval,
 		curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed;
 		return true;
 	}
-	else if (menupres[menutype].bghide && titlemapinaction) // hide the background
+	else if (gamestate != GS_TIMEATTACK && menupres[menutype].bghide && titlemapinaction) // hide the background
 	{
 		curbghide = true;
 		return true;
@@ -2309,7 +2311,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval,
 	{
 		if (M_GetYoungestChildMenu() == MN_SP_PLAYER || !defaultname || !defaultname[0])
 			curbgcolor = 31;
-		else if (titlemapinaction) // hide the background by default in titlemap
+		else if (gamestate != GS_TIMEATTACK && titlemapinaction) // hide the background by default in titlemap
 			curbghide = true;
 		else
 		{
@@ -2469,7 +2471,7 @@ static void M_HandleMenuPresState(menu_t *newMenu)
 	curbgcolor = -1;
 	curbgxspeed = titlescrollxspeed;
 	curbgyspeed = titlescrollyspeed;
-	curbghide = true;
+	curbghide = (gamestate != GS_TIMEATTACK); // show in time attack, hide in other menus
 
 	// don't do the below during the in-game menus
 	if (gamestate != GS_TITLESCREEN && gamestate != GS_TIMEATTACK)
diff --git a/src/m_menu.h b/src/m_menu.h
index 04146ebdc7..06631dc393 100644
--- a/src/m_menu.h
+++ b/src/m_menu.h
@@ -123,7 +123,7 @@ typedef enum
 
 typedef struct
 {
-	char bgname[8]; // name for background gfx lump; lays over titlemap if this is set
+	char bgname[9]; // name for background gfx lump; lays over titlemap if this is set
 	SINT8 hidetitlepics; // hide title gfx per menu; -1 means undefined, inherits global setting
 	INT32 titlescrollxspeed; // background gfx scroll per menu; inherits global setting
 	INT32 titlescrollyspeed; // y scroll
-- 
GitLab