# HG changeset patch
# User Binary Code
# Date 1728130514 25200
#      Sat Oct 05 05:15:14 2024 -0700
# Node ID b1c873b7d18090c32484b48992f80d675770a3eb
# Parent  b026d28c6ce4b5d693fb6e5a9579d98187419134
Added new SBARINFO top level "AppendStatusBar" to allow for adding extra SBARINFO code onto existing custom SBARINFO definitions.

diff -r b026d28c6ce4 -r b1c873b7d180 docs/zandronum-history.txt
--- a/docs/zandronum-history.txt	Sun Sep 29 19:20:09 2024 +0000
+++ b/docs/zandronum-history.txt	Sat Oct 05 05:15:14 2024 -0700
@@ -72,6 +72,7 @@
 +	- Added the CVar "cl_showscoreleft", which if disabled will turn "x things left" messages on the scoreboard into "x things to win" and show the current score limit instead of how much is left to win. This only affects frags, points, and wins. [Kaminsky]
 +	- Added ACS functions: "GetPlayerJoinQueuePosition" and "SkipJoinQueue", to return the player's position in the join queue and allow true spectators in the join queue to join the game outside of normal game mode rules. Modders can also take advantage of the new GAMEEVENT_JOINQUEUECHANGED EVENT script type to know when players are added or removed from the join queue. [Kaminsky]
 +	- Added over a hundred new text colors recently made by Fuzzball. [Kaminsky]
++	- Added new SBARINFO top level "AppendStatusBar" to allow for adding extra SBARINFO code onto existing custom SBARINFO definitions. [Binary]
 -	- Fixed: clients didn't initialize a sector's friction properly in some cases due to a superfluous check that wasn't removed earlier. [Kaminsky]
 -	- Fixed: the server wouldn't initialize compatflags and compatflags2 properly if entered as command line parameters. [Kaminsky]
 -	- Fixed: serverinfo CVars entered on the command line were restored in reverse order. [Kaminsky]
diff -r b026d28c6ce4 -r b1c873b7d180 src/g_shared/sbarinfo.cpp
--- a/src/g_shared/sbarinfo.cpp	Sun Sep 29 19:20:09 2024 +0000
+++ b/src/g_shared/sbarinfo.cpp	Sat Oct 05 05:15:14 2024 -0700
@@ -373,6 +373,7 @@
 	SBARINFO_STATUSBAR,
 	SBARINFO_MUGSHOT,
 	SBARINFO_CREATEPOPUP,
+	SBARINFO_APPENDSTATUSBAR, // [Binary] Additive SBARINFO implementation.
 };
 
 enum //Bar types
@@ -401,6 +402,7 @@
 	"statusbar",
 	"mugshot",
 	"createpopup",
+	"appendstatusbar", // [Binary] Additive SBARINFO implementation.
 	NULL
 };
 
@@ -482,6 +484,13 @@
 			continue;
 		}
 		int baselump = -2;
+		
+		// [Binary] Store the Top Level string for SBARINFO_APPENDSTATUSBAR.
+		FString SBarInfoTopLevelString;
+		if(sc.GetString(SBarInfoTopLevelString))
+		{ // Store the string if the next token is a string, and revert scanner state afterwards
+			sc.UnGet();
+		}
 		switch(sc.MustMatchString(SBarInfoTopLevel))
 		{
 			case SBARINFO_BASE:
@@ -623,6 +632,7 @@
 				sc.MustGetToken(';');
 				break;
 			case SBARINFO_STATUSBAR:
+			case SBARINFO_APPENDSTATUSBAR: // [Binary] This uses the same code as the above case.
 			{
 				if(!baseSet) //If the user didn't explicitly define a base, do so now.
 					gameType = GAME_Any;
@@ -632,11 +642,16 @@
 					sc.MustGetToken(TK_Identifier);
 					barNum = sc.MustMatchString(StatusBars);
 				}
-				if (this->huds[barNum] != NULL)
+				// [Binary] SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists.
+				const bool append = (SBarInfoTopLevelString.CompareNoCase("appendstatusbar") == 0);
+				if (!append)
 				{
-					delete this->huds[barNum];
+					if (this->huds[barNum] != NULL)
+					{
+						delete this->huds[barNum];
+					}
+					this->huds[barNum] = new SBarInfoMainBlock(this);
 				}
-				this->huds[barNum] = new SBarInfoMainBlock(this);
 				if(barNum == STBAR_AUTOMAP)
 				{
 					automapbar = true;
