From 92bd71496e9df6e23e9edafbb2c61d7148124fcb Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Fri, 25 Aug 2023 21:41:15 +0100
Subject: [PATCH] VC review

- Continue showing up on main in-game pause menu
- Flip to top half of screen, to avoid conflict with Round Queue
- Show over most UI, including menu
---
 src/k_menudraw.c |  7 ++++++
 src/st_stuff.c   | 61 ++++++++++++++++++++++++++----------------------
 src/st_stuff.h   |  2 ++
 3 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/src/k_menudraw.c b/src/k_menudraw.c
index 23c989505d..800ff3c6c5 100644
--- a/src/k_menudraw.c
+++ b/src/k_menudraw.c
@@ -825,6 +825,13 @@ void M_Drawer(void)
 		}
 	}
 
+	if (netgame && Playing())
+	{
+		boolean mainpause_open = menuactive && currentMenu == &PAUSE_MainDef;
+
+		ST_DrawServerSplash(!mainpause_open);
+	}
+
 	// focus lost notification goes on top of everything, even the former everything
 	if (window_notinfocus && cv_showfocuslost.value)
 	{
diff --git a/src/st_stuff.c b/src/st_stuff.c
index 970b6d3771..748d6da1dd 100644
--- a/src/st_stuff.c
+++ b/src/st_stuff.c
@@ -1314,7 +1314,7 @@ static INT32 ST_ServerSplash_OpacityFlag(INT32 opacity)
 	return (NUMTRANSMAPS - opacity) << V_ALPHASHIFT;
 }
 
-static void ST_DrawServerSplash(void)
+void ST_DrawServerSplash(boolean timelimited)
 {
 	static const fixed_t SPLASH_LEN = (FRACUNIT * TICRATE) * 3;
 	static const fixed_t SPLASH_WAIT = (FRACUNIT * TICRATE) / 2;
@@ -1335,7 +1335,8 @@ static void ST_DrawServerSplash(void)
 		return;
 	}
 
-	if (splashTime >= SPLASH_LEN)
+	if (timelimited
+		&& splashTime >= SPLASH_LEN)
 	{
 		// We finished drawing it
 		return;
@@ -1354,29 +1355,35 @@ static void ST_DrawServerSplash(void)
 	{
 		opacity = splashTic;
 	}
-	else if (splashTic > (SPLASH_LEN >> FRACBITS) - NUMTRANSMAPS)
+	else if (timelimited
+		&& splashTic > (SPLASH_LEN >> FRACBITS) - NUMTRANSMAPS)
 	{
 		opacity = (SPLASH_LEN >> FRACBITS) - splashTic;
 	}
+
 	INT32 opacityFlag = ST_ServerSplash_OpacityFlag(opacity);
 
 	patch_t *gridPatch = W_CachePatchName("MOTDBG", PU_CACHE);
-	fixed_t gridX = -splashTime / 3;
-	fixed_t gridY = (BASEVIDHEIGHT - gridPatch->height) * FRACUNIT;
-	INT32 gridOpacity = ST_ServerSplash_OpacityFlag(opacity / 2);
-	fixed_t maxX = (vid.width * FRACUNIT) / vid.dupx;
 
-	while (gridX < maxX)
+	if (gridPatch && gridPatch->width)
 	{
-		V_DrawFixedPatch(
-			gridX, gridY,
-			FRACUNIT,
-			(V_SNAPTOLEFT|V_SNAPTOBOTTOM) | V_SUBTRACT | gridOpacity,
-			gridPatch,
-			NULL
-		);
+		fixed_t gridX = -(splashTime / 3) % (gridPatch->width * FRACUNIT);
+		fixed_t gridY = (gridPatch->height) * FRACUNIT;
+		INT32 gridOpacity = ST_ServerSplash_OpacityFlag(opacity / 2);
+		fixed_t maxX = (vid.width * FRACUNIT) / vid.dupx;
 
-		gridX += (gridPatch->width * FRACUNIT);
+		while (gridX < maxX)
+		{
+			V_DrawFixedPatch(
+				gridX, gridY,
+				FRACUNIT,
+				(V_SNAPTOLEFT|V_SNAPTOBOTTOM) | V_SUBTRACT | V_VFLIP | gridOpacity,
+				gridPatch,
+				NULL
+			);
+
+			gridX += (gridPatch->width * FRACUNIT);
+		}
 	}
 
 	// We're a bit crunched atm to do this but hopefully in the future
@@ -1384,7 +1391,7 @@ static void ST_DrawServerSplash(void)
 	// sends on client join instead.
 	patch_t *iconPatch = W_CachePatchName("MOTDICON", PU_CACHE);
 	fixed_t iconX = (BASEVIDWIDTH - 16 - iconPatch->width) * FRACUNIT;
-	fixed_t iconY = (BASEVIDHEIGHT - 8 - iconPatch->height) * FRACUNIT;
+	fixed_t iconY = (8) * FRACUNIT;
 	V_DrawFixedPatch(
 		iconX, iconY,
 		FRACUNIT,
@@ -1394,7 +1401,15 @@ static void ST_DrawServerSplash(void)
 	);
 
 	fixed_t textX = (BASEVIDWIDTH - 16 - 36) * FRACUNIT;
-	fixed_t textY = (BASEVIDHEIGHT - 24) * FRACUNIT;
+	fixed_t textY = (24 - 8) * FRACUNIT;
+
+	V_DrawRightAlignedStringAtFixed(
+		textX, textY,
+		(V_SNAPTORIGHT|V_SNAPTOBOTTOM) | opacityFlag,
+		connectedservername
+	);
+
+	textY += 10*FRACUNIT;
 
 	if (connectedservercontact[0] != 0)
 	{
@@ -1403,14 +1418,7 @@ static void ST_DrawServerSplash(void)
 			(V_SNAPTORIGHT|V_SNAPTOBOTTOM) | opacityFlag,
 			va("Contact @ %c%s", '\x80' + cv_shoutcolor.value, connectedservercontact)
 		);
-		textY -= (10 * FRACUNIT);
 	}
-
-	V_DrawRightAlignedStringAtFixed(
-		textX, textY,
-		(V_SNAPTORIGHT|V_SNAPTOBOTTOM) | opacityFlag,
-		connectedservername
-	);
 }
 
 void ST_Drawer(void)
@@ -1487,9 +1495,6 @@ void ST_Drawer(void)
 	if (stagetitle)
 		ST_drawTitleCard();
 
-	if (netgame)
-		ST_DrawServerSplash();
-
 	// Replay manual-save stuff
 	if (demo.recording && multiplayer && demo.savebutton && demo.savebutton + 3*TICRATE < leveltime)
 	{
diff --git a/src/st_stuff.h b/src/st_stuff.h
index 44aa5f2518..c406bdcaf8 100644
--- a/src/st_stuff.h
+++ b/src/st_stuff.h
@@ -75,6 +75,8 @@ void ST_preLevelTitleCardDrawer(void);
 extern tic_t lt_ticker, lt_lasttic;
 extern tic_t lt_exitticker, lt_endtime;
 
+void ST_DrawServerSplash(boolean timelimited);
+
 // return if player a is in the same team as player b
 boolean ST_SameTeam(player_t *a, player_t *b);
 
-- 
GitLab