• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revision3d017bd6119a301b95c59af3b68e959a77495920 (tree)
Time2022-09-29 01:14:59
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added the helper function SERVER_SettingChanged to centralize the "x has changed to" message calls used for many CVars and reduce duplicate code.

Change Summary

Incremental Difference

diff -r 4a2c7d737cb9 -r 3d017bd6119a src/deathmatch.cpp
--- a/src/deathmatch.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/deathmatch.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -69,11 +69,6 @@
6969 #include "g_level.h"
7070
7171 //*****************************************************************************
72-// MISC CRAP THAT SHOULDN'T BE HERE BUT HAS TO BE BECAUSE OF SLOPPY CODING
73-
74-void SERVERCONSOLE_UpdateScoreboard( );
75-
76-//*****************************************************************************
7772 // CONSOLE COMMANDS/VARIABLES
7873
7974 CUSTOM_CVAR( Bool, deathmatch, false, CVAR_SERVERINFO | CVAR_LATCH | CVAR_CAMPAIGNLOCK )
@@ -328,14 +323,8 @@
328323 return;
329324 }
330325
331- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
332- {
333- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
334- SERVERCOMMANDS_SetGameModeLimits( );
335-
336- // Update the scoreboard.
337- SERVERCONSOLE_UpdateScoreboard( );
338- }
326+ // [AK] Update the clients and update the server console.
327+ SERVER_SettingChanged( self, true );
339328 }
340329
341330 //*****************************************************************************
@@ -354,14 +343,8 @@
354343 return;
355344 }
356345
357- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
358- {
359- SERVER_Printf( "%s changed to: %.2f\n", self.GetName( ), static_cast<float>(self) );
360- SERVERCOMMANDS_SetGameModeLimits( );
361-
362- // Update the scoreboard.
363- SERVERCONSOLE_UpdateScoreboard( );
364- }
346+ // [AK] Update the clients and update the server console.
347+ SERVER_SettingChanged( self, true, 2 );
365348 }
366349
367350 // [AM] Set or unset a map as being a "lobby" map.
@@ -388,11 +371,7 @@
388371 }
389372
390373 // Update the client about the lobby map if necessary.
391- if ((NETWORK_GetState() == NETSTATE_SERVER) && (gamestate != GS_STARTUP))
392- {
393- SERVER_Printf(PRINT_HIGH, "%s changed to: %s\n", self.GetName(), *self);
394- SERVERCOMMANDS_SetGameModeLimits();
395- }
374+ SERVER_SettingChanged( self, false );
396375 }
397376 }
398377
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/doomstat.cpp
--- a/src/doomstat.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/doomstat.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -50,11 +50,7 @@
5050 // [WS] Changed CVAR to CUSTOM_CVAR as we need to send clients the updated state of this.
5151 CUSTOM_CVAR (Bool, alwaysapplydmflags, false, CVAR_SERVERINFO)
5252 {
53- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
54- {
55- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (bool)self );
56- SERVERCOMMANDS_SetGameModeLimits( );
57- }
53+ SERVER_SettingChanged( self, false );
5854 }
5955
6056 CUSTOM_CVAR (Float, teamdamage, 0.f, CVAR_SERVERINFO)
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/duel.cpp
--- a/src/duel.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/duel.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -67,11 +67,6 @@
6767 #include "team.h"
6868 #include "v_video.h"
6969
70-//*****************************************************************************
71-// MISC CRAP THAT SHOULDN'T BE HERE BUT HAS TO BE BECAUSE OF SLOPPY CODING
72-
73-void SERVERCONSOLE_UpdateScoreboard( );
74-
7570 EXTERN_CVAR( Int, cl_respawninvuleffect )
7671
7772 //*****************************************************************************
@@ -472,12 +467,6 @@
472467 if ( self < 0 )
473468 self = 0;
474469
475- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
476- {
477- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
478- SERVERCOMMANDS_SetGameModeLimits( );
479-
480- // Update the scoreboard.
481- SERVERCONSOLE_UpdateScoreboard( );
482- }
470+ // [AK] Update the clients and update the server console.
471+ SERVER_SettingChanged( self, true );
483472 }
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/invasion.cpp
--- a/src/invasion.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/invasion.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -79,8 +79,6 @@
7979 #include "farchive.h"
8080 #include "st_hud.h"
8181
82-void SERVERCONSOLE_UpdateScoreboard( );
83-
8482 //*****************************************************************************
8583 // PROTOTYPES
8684
@@ -1639,13 +1637,7 @@
16391637 if ( self < 0 )
16401638 self = 0;
16411639
1642- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
1643- {
1644- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
1645- SERVERCOMMANDS_SetGameModeLimits( );
1646-
1647- // Update the scoreboard.
1648- SERVERCONSOLE_UpdateScoreboard( );
1649- }
1640+ // [AK] Update the clients and update the server console.
1641+ SERVER_SettingChanged( self, true );
16501642 }
16511643 CVAR( Bool, sv_usemapsettingswavelimit, true, CVAR_ARCHIVE | CVAR_GAMEPLAYSETTING );
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/lastmanstanding.cpp
--- a/src/lastmanstanding.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/lastmanstanding.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -74,7 +74,6 @@
7474 //*****************************************************************************
7575 // MISC CRAP THAT SHOULDN'T BE HERE BUT HAS TO BE BECAUSE OF SLOPPY CODING
7676
77-void SERVERCONSOLE_UpdateScoreboard( );
7877 void SERVERCONSOLE_UpdatePlayerInfo( LONG lPlayer, ULONG ulUpdateFlags );
7978
8079 //*****************************************************************************
@@ -700,14 +699,8 @@
700699 if ( self < 0 )
701700 self = 0;
702701
703- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
704- {
705- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
706- SERVERCOMMANDS_SetGameModeLimits( );
707-
708- // Update the scoreboard.
709- SERVERCONSOLE_UpdateScoreboard( );
710- }
702+ // [AK] Update the clients and update the server console.
703+ SERVER_SettingChanged( self, true );
711704 }
712705
713706 // [AK] Added CVAR_GAMEPLAYFLAGSET.
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/p_interaction.cpp
--- a/src/p_interaction.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/p_interaction.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -1118,12 +1118,8 @@
11181118 if (self <= 0)
11191119 self = 1.0f;
11201120
1121- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
1122- {
1123- SERVER_Printf( "%s changed to: %.2f\n", self.GetName( ), (float)self );
1124- SERVERCOMMANDS_SetGameModeLimits( );
1125- SERVERCONSOLE_UpdateScoreboard();
1126- }
1121+ // [AK] Notify the clients about the change and update the server console.
1122+ SERVER_SettingChanged( self, true, 2 );
11271123 }
11281124
11291125 // [TIHan/Spleen] Apply factor for damage dealt to players by monsters.
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/p_mobj.cpp
--- a/src/p_mobj.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/p_mobj.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -154,11 +154,7 @@
154154 level.gravity = self;
155155
156156 // [BB] Notify the clients about the change.
157- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
158- {
159- SERVER_Printf( "%s changed to: %f\n", self.GetName( ), self.GetGenericRep( CVAR_Float ).Float );
160- SERVERCOMMANDS_SetGameModeLimits( );
161- }
157+ SERVER_SettingChanged( self, false );
162158 }
163159
164160
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/p_pspr.cpp
--- a/src/p_pspr.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/p_pspr.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -73,11 +73,8 @@
7373 if ( self < 0 )
7474 self = 0;
7575
76- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
77- {
78- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
79- SERVERCOMMANDS_SetGameModeLimits( );
80- }
76+ // [AK] Notify the clients about the change.
77+ SERVER_SettingChanged( self, false );
8178 }
8279
8380 // [AK] CVars that control how the weapon bobs, sways, or offsets based on the player's pitch.
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/p_user.cpp
--- a/src/p_user.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/p_user.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -2813,11 +2813,7 @@
28132813 G_AirControlChanged ();
28142814
28152815 // [BB] Let the clients know about the change.
2816- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
2817- {
2818- SERVER_Printf( "%s changed to: %f\n", self.GetName( ), (float)self );
2819- SERVERCOMMANDS_SetGameModeLimits( );
2820- }
2816+ SERVER_SettingChanged( self, false );
28212817 }
28222818
28232819 void P_MovePlayer (player_t *player)
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/survival.cpp
--- a/src/survival.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/survival.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -75,11 +75,8 @@
7575 if ( self < 0 )
7676 self = 0;
7777
78- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
79- {
80- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
81- SERVERCOMMANDS_SetGameModeLimits( );
82- }
78+ // [AK] Notify the clients about the change.
79+ SERVER_SettingChanged( self, false );
8380 }
8481
8582 //*****************************************************************************
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/sv_main.cpp
--- a/src/sv_main.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/sv_main.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -448,11 +448,7 @@
448448 }
449449
450450 // [AK] Notify the clients about the change.
451- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
452- {
453- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), self.GetGenericRep( CVAR_Int ).Int );
454- SERVERCOMMANDS_SetGameModeLimits( );
455- }
451+ SERVER_SettingChanged( self, false );
456452 }
457453
458454 //*****************************************************************************
@@ -467,11 +463,7 @@
467463 }
468464
469465 // [AK] Notify the clients about the change.
470- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
471- {
472- SERVER_Printf( "%s changed to: %.1f\n", self.GetName( ), static_cast<float>( self ));
473- SERVERCOMMANDS_SetGameModeLimits( );
474- }
466+ SERVER_SettingChanged( self, false, 1 );
475467 }
476468
477469 //*****************************************************************************
@@ -4495,6 +4487,46 @@
44954487 }
44964488
44974489 //*****************************************************************************
4490+//
4491+// [AK] Prints the name of a CVar and its new value to the console, sends an update
4492+// to the clients, and possibly updates the server console's scoreboard.
4493+//
4494+void SERVER_SettingChanged( FBaseCVar &cvar, bool bUpdateConsole, int maxDecimals )
4495+{
4496+ // [AK] Only continue if we're the server.
4497+ if (( NETWORK_GetState( ) != NETSTATE_SERVER ) || ( gamestate == GS_STARTUP ))
4498+ return;
4499+
4500+ FString result;
4501+
4502+ // [AK] Store the CVar's value into a string so that we can print it.
4503+ switch ( cvar.GetRealType( ))
4504+ {
4505+ case CVAR_Float:
4506+ if ( maxDecimals <= 0 )
4507+ result.Format( "%f", cvar.GetGenericRep( CVAR_Float ).Float );
4508+ else
4509+ result.Format( "%.*f", maxDecimals, cvar.GetGenericRep( CVAR_Float ).Float );
4510+ break;
4511+
4512+ case CVAR_String:
4513+ result = cvar.GetGenericRep( CVAR_String ).String;
4514+ break;
4515+
4516+ default:
4517+ result.Format( "%d", cvar.GetGenericRep( CVAR_Int ).Int );
4518+ break;
4519+ }
4520+
4521+ SERVER_Printf( "%s changed to: %s\n", cvar.GetName( ), result.GetChars( ));
4522+ SERVERCOMMANDS_SetGameModeLimits( );
4523+
4524+ // [AK] Update the server console's score if necessary.
4525+ if ( bUpdateConsole )
4526+ SERVERCONSOLE_UpdateScoreboard( );
4527+}
4528+
4529+//*****************************************************************************
44984530 //*****************************************************************************
44994531 //
45004532 LONG SERVER_STATISTIC_GetTotalSecondsElapsed( void )
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/sv_main.h
--- a/src/sv_main.h Sun Oct 02 10:18:37 2022 -0400
+++ b/src/sv_main.h Wed Sep 28 12:14:59 2022 -0400
@@ -654,6 +654,7 @@
654654 void SERVER_KillCheat( const char* what );
655655 void STACK_ARGS SERVER_PrintWarning( const char* format, ... ) GCCPRINTF( 1, 2 );
656656 void SERVER_FlagsetChanged( FIntCVar& flagset, int maxflags = 2 );
657+void SERVER_SettingChanged( FBaseCVar &cvar, bool bUpdateConsole, int maxDecimals = 0 );
657658 void SERVER_HandleSkipCorrection( ULONG ulClient );
658659 bool SERVER_IsExtrapolatingPlayer( ULONG ulClient );
659660 bool SERVER_IsBacktracingPlayer( ULONG ulClient );
diff -r 4a2c7d737cb9 -r 3d017bd6119a src/team.cpp
--- a/src/team.cpp Sun Oct 02 10:18:37 2022 -0400
+++ b/src/team.cpp Wed Sep 28 12:14:59 2022 -0400
@@ -2239,14 +2239,8 @@
22392239 if ( self < 0 )
22402240 self = 0;
22412241
2242- if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
2243- {
2244- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), (int)self );
2245- SERVERCOMMANDS_SetGameModeLimits( );
2246-
2247- // Update the scoreboard.
2248- SERVERCONSOLE_UpdateScoreboard( );
2249- }
2242+ // [AK] Update the clients and update the server console.
2243+ SERVER_SettingChanged( self, true );
22502244 }
22512245
22522246 // Allow the server to set the return time for flags/skulls.
Show on old repository browser