# HG changeset patch
# User Binary Code
# Date 1727972059 25200
#      Thu Oct 03 09:14:19 2024 -0700
# Node ID 9a5ae26922baf4840f9f05957db01507d5e71d36
# Parent  b026d28c6ce4b5d693fb6e5a9579d98187419134
Added new SBARINFO top level "AppendStatusBar" to allow for adding extra SBARINFO code onto existing custom SBARINFO definitions.

diff -r b026d28c6ce4 -r 9a5ae26922ba docs/zandronum-history.txt
--- a/docs/zandronum-history.txt	Sun Sep 29 19:20:09 2024 +0000
+++ b/docs/zandronum-history.txt	Thu Oct 03 09:14:19 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 9a5ae26922ba 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	Thu Oct 03 09:14:19 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
 };
 
@@ -623,6 +625,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 +635,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 = (sc.MustMatchString(SBarInfoTopLevel) == SBARINFO_APPENDSTATUSBAR);
+				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;
