Commit MetaInfo

Revision1bf40bcf61ab191e214fefc1b9fc3daab7e828c6 (tree)
Time2021-03-24 00:20:53
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Gameplay and compatibility flags added in the "gamesettings" block in GAMEMODE aren't locked anymore, so they can still be changed manually from the console. To lock them, the "lockedgamesettings" block should be used instead.

Change Summary

Incremental Difference

diff -r 7a99ba8fd93a -r 1bf40bcf61ab src/c_cvars.cpp
--- a/src/c_cvars.cpp Mon Mar 22 18:05:27 2021 -0400
+++ b/src/c_cvars.cpp Tue Mar 23 11:20:53 2021 -0400
@@ -198,7 +198,7 @@
198198 // [AK] Check if we (indirectly) changed any flags locked in the current game mode.
199199 else if ( Flags & CVAR_GAMEMODELOCK )
200200 {
201- int mask = GAMEMODE_GetCurrentFlagsetMask( static_cast<FIntCVar *>( this ));
201+ int mask = GAMEMODE_GetCurrentFlagsetMask( static_cast<FIntCVar *>( this ), true );
202202 int oldValue = GetGenericRep( CVAR_Int ).Int;
203203 int newValue = ToInt( value, type );
204204
diff -r 7a99ba8fd93a -r 1bf40bcf61ab src/g_level.cpp
--- a/src/g_level.cpp Mon Mar 22 18:05:27 2021 -0400
+++ b/src/g_level.cpp Tue Mar 23 11:20:53 2021 -0400
@@ -421,6 +421,9 @@
421421 S_ResumeSound (false);
422422 }
423423
424+ // [AK] Set any flags to what the need to be in the new game mode.
425+ GAMEMODE_ReconfigureGameSettings( );
426+
424427 // [BC] Reset the end level delay.
425428 GAME_SetEndLevelDelay( 0 );
426429
@@ -1068,7 +1071,7 @@
10681071 NETTRAFFIC_Reset();
10691072
10701073 // [AK] Reset all locked gameplay/compatibility flags to what they're supposed to be, in case they somehow changed.
1071- GAMEMODE_ReconfigureGameSettings();
1074+ GAMEMODE_ReconfigureGameSettings( true );
10721075
10731076 // Loop through the teams, and reset the scores.
10741077 for ( i = 0; i < teams.Size( ); i++ )
diff -r 7a99ba8fd93a -r 1bf40bcf61ab src/gamemode.cpp
--- a/src/gamemode.cpp Mon Mar 22 18:05:27 2021 -0400
+++ b/src/gamemode.cpp Tue Mar 23 11:20:53 2021 -0400
@@ -304,8 +304,10 @@
304304 {
305305 g_GameModes[GameMode].ulFlags |= GAMEMODE_ParserMustGetEnumName( sc, "flag", "GMF_", GetValueGMF );
306306 }
307- else if (0 == stricmp (sc.String, "gamesettings"))
307+ else if ((0 == stricmp (sc.String, "gamesettings")) || (0 == stricmp (sc.String, "lockedgamesettings")))
308308 {
309+ bool bLockFlags = !stricmp( sc.String, "lockedgamesettings" );
310+
309311 sc.MustGetStringName( "{" );
310312 while ( !sc.CheckString( "}" ))
311313 {
@@ -331,6 +333,10 @@
331333 flagset[FLAGSET_VALUE] &= ~ulBit;
332334
333335 flagset[FLAGSET_MASK] |= ulBit;
336+
337+ // [AK] Lock this flag so it can't be manually changed.
338+ if ( bLockFlags )
339+ flagset[FLAGSET_LOCKEDMASK] |= ulBit;
334340 }
335341 }
336342 else if (0 == stricmp (sc.String, "removegamesetting"))
@@ -340,6 +346,7 @@
340346
341347 flagset[FLAGSET_VALUE] &= ~ulBit;
342348 flagset[FLAGSET_MASK] &= ~ulBit;
349+ flagset[FLAGSET_LOCKEDMASK] &= ~ulBit;
343350 }
344351 else
345352 sc.ScriptError ( "Unknown option '%s', on line %d in GAMEMODE.", sc.String, sc.Line );
@@ -412,20 +419,22 @@
412419
413420 //*****************************************************************************
414421 //
415-int GAMEMODE_GetFlagsetMask( GAMEMODE_e GameMode, FIntCVar *Flagset )
422+int GAMEMODE_GetFlagsetMask( GAMEMODE_e GameMode, FIntCVar *Flagset, bool bLocked )
416423 {
424+ ULONG ulMask = bLocked ? FLAGSET_LOCKEDMASK : FLAGSET_MASK;
425+
417426 if ( Flagset == &dmflags )
418- return ( g_GameModes[GameMode].lDMFlags[FLAGSET_MASK] );
427+ return ( g_GameModes[GameMode].lDMFlags[ulMask] );
419428 else if ( Flagset == &dmflags2 )
420- return ( g_GameModes[GameMode].lDMFlags2[FLAGSET_MASK] );
429+ return ( g_GameModes[GameMode].lDMFlags2[ulMask] );
421430 else if ( Flagset == &compatflags )
422- return ( g_GameModes[GameMode].lCompatFlags[FLAGSET_MASK] );
431+ return ( g_GameModes[GameMode].lCompatFlags[ulMask] );
423432 else if ( Flagset == &compatflags2 )
424- return ( g_GameModes[GameMode].lCompatFlags2[FLAGSET_MASK] );
433+ return ( g_GameModes[GameMode].lCompatFlags2[ulMask] );
425434 else if ( Flagset == &zadmflags )
426- return ( g_GameModes[GameMode].lZaDMFlags[FLAGSET_MASK] );
435+ return ( g_GameModes[GameMode].lZaDMFlags[ulMask] );
427436 else if ( Flagset == &zacompatflags )
428- return ( g_GameModes[GameMode].lZaCompatFlags[FLAGSET_MASK] );
437+ return ( g_GameModes[GameMode].lZaCompatFlags[ulMask] );
429438
430439 // [AK] We passed an invalid flagset, just return zero.
431440 return ( 0 );
@@ -433,9 +442,9 @@
433442
434443 //*****************************************************************************
435444 //
436-int GAMEMODE_GetCurrentFlagsetMask( FIntCVar *Flagset )
445+int GAMEMODE_GetCurrentFlagsetMask( FIntCVar *Flagset, bool bLocked )
437446 {
438- return ( GAMEMODE_GetFlagsetMask( g_CurrentGameMode, Flagset ) );
447+ return ( GAMEMODE_GetFlagsetMask( g_CurrentGameMode, Flagset, bLocked ) );
439448 }
440449
441450 //*****************************************************************************
@@ -1322,32 +1331,33 @@
13221331
13231332 //*****************************************************************************
13241333 //
1325-void GAMEMODE_ReconfigureGameSettings( void )
1334+void GAMEMODE_ReconfigureGameSettings( bool bLockedOnly )
13261335 {
1336+ ULONG ulMask = bLockedOnly ? FLAGSET_LOCKEDMASK : FLAGSET_MASK;
13271337 GAMEMODE_s *GameMode = &g_GameModes[g_CurrentGameMode];
13281338 UCVarValue value;
13291339
13301340 // [AK] Apply the mask to dmflags, but don't change the values of any unlocked flags.
1331- value.Int = ( dmflags & ~GameMode->lDMFlags[FLAGSET_MASK] ) | GameMode->lDMFlags[FLAGSET_VALUE];
1341+ value.Int = ( dmflags & ~GameMode->lDMFlags[ulMask] ) | ( GameMode->lDMFlags[FLAGSET_VALUE] & GameMode->lDMFlags[ulMask] );
13321342 dmflags.ForceSet( value, CVAR_Int );
13331343
13341344 // ...and dmflags2.
1335- value.Int = ( dmflags2 & ~GameMode->lDMFlags2[FLAGSET_MASK] ) | GameMode->lDMFlags2[FLAGSET_VALUE];
1345+ value.Int = ( dmflags2 & ~GameMode->lDMFlags2[ulMask] ) | ( GameMode->lDMFlags2[FLAGSET_VALUE] & GameMode->lDMFlags2[ulMask] );
13361346 dmflags2.ForceSet( value, CVAR_Int );
13371347
13381348 // ...and compatflags.
1339- value.Int = ( compatflags & ~GameMode->lCompatFlags[FLAGSET_MASK] ) | GameMode->lCompatFlags[FLAGSET_VALUE];
1349+ value.Int = ( compatflags & ~GameMode->lCompatFlags[ulMask] ) | ( GameMode->lCompatFlags[FLAGSET_VALUE] & GameMode->lCompatFlags[ulMask] );
13401350 compatflags.ForceSet( value, CVAR_Int );
13411351
13421352 // ...and compatflags2.
1343- value.Int = ( compatflags2 & ~GameMode->lCompatFlags2[FLAGSET_MASK] ) | GameMode->lCompatFlags2[FLAGSET_VALUE];
1353+ value.Int = ( compatflags2 & ~GameMode->lCompatFlags2[ulMask] ) | ( GameMode->lCompatFlags2[FLAGSET_VALUE] & GameMode->lCompatFlags2[ulMask] );
13441354 compatflags2.ForceSet( value, CVAR_Int );
13451355
13461356 // ...and zadmflags.
1347- value.Int = ( zadmflags & ~GameMode->lZaDMFlags[FLAGSET_MASK] ) | GameMode->lZaDMFlags[FLAGSET_VALUE];
1357+ value.Int = ( zadmflags & ~GameMode->lZaDMFlags[ulMask] ) | ( GameMode->lZaDMFlags[FLAGSET_VALUE] & GameMode->lZaDMFlags[ulMask] );
13481358 zadmflags.ForceSet( value, CVAR_Int );
13491359
13501360 // ...and zacompatflags.
1351- value.Int = ( zacompatflags & ~GameMode->lZaCompatFlags[FLAGSET_MASK] ) | GameMode->lZaCompatFlags[FLAGSET_VALUE];
1361+ value.Int = ( zacompatflags & ~GameMode->lZaCompatFlags[ulMask] ) | ( GameMode->lZaCompatFlags[FLAGSET_VALUE] & GameMode->lZaCompatFlags[ulMask] );
13521362 zacompatflags.ForceSet( value, CVAR_Int );
13531363 }
\ No newline at end of file
diff -r 7a99ba8fd93a -r 1bf40bcf61ab src/gamemode.h
--- a/src/gamemode.h Mon Mar 22 18:05:27 2021 -0400
+++ b/src/gamemode.h Tue Mar 23 11:20:53 2021 -0400
@@ -68,10 +68,12 @@
6868 #define GAMEEVENT_RETURN_TIMEOUTRETURN 0
6969 #define GAMEEVENT_RETURN_PLAYERRETURN 1
7070
71-// [AK] The combined bit values of all flags that are locked in a game mode.
71+// [AK] The combined values of all flags set in a game mode.
7272 #define FLAGSET_VALUE 0
73-// [AK] All the bits of a flagset to be locked in a game mode.
73+// [AK] The bits of a flagset to be set.
7474 #define FLAGSET_MASK 1
75+// [AK] The bits of a flagset that are locked and cannot be changed.
76+#define FLAGSET_LOCKEDMASK 2
7577
7678 //*****************************************************************************
7779 // EXTERNAL CONSOLE VARIABLES
@@ -143,22 +145,22 @@
143145 char szF1Texture[9];
144146
145147 // [AK] The dmflags we set for this gamemode.
146- LONG lDMFlags[2];
148+ LONG lDMFlags[3];
147149
148150 // [AK] The dmflags2 we set for this gamemode.
149- LONG lDMFlags2[2];
151+ LONG lDMFlags2[3];
150152
151153 // [AK] The compatflags we set for this gamemode.
152- LONG lCompatFlags[2];
154+ LONG lCompatFlags[3];
153155
154156 // [AK] The compatflags2 we set for this gamemode.
155- LONG lCompatFlags2[2];
157+ LONG lCompatFlags2[3];
156158
157159 // [AK] The zadmflags we set for this gamemode.
158- LONG lZaDMFlags[2];
160+ LONG lZaDMFlags[3];
159161
160162 // [AK] The zacompatflags we set for this gamemode.
161- LONG lZaCompatFlags[2];
163+ LONG lZaCompatFlags[3];
162164
163165 } GAMEMODE_s;
164166
@@ -174,8 +176,8 @@
174176 char *GAMEMODE_GetShortName( GAMEMODE_e GameMode );
175177 char *GAMEMODE_GetName( GAMEMODE_e GameMode );
176178 char *GAMEMODE_GetF1Texture( GAMEMODE_e GameMode );
177-int GAMEMODE_GetFlagsetMask( GAMEMODE_e GameMode, FIntCVar *Flagset );
178-int GAMEMODE_GetCurrentFlagsetMask( FIntCVar *Flagset );
179+int GAMEMODE_GetFlagsetMask( GAMEMODE_e GameMode, FIntCVar *Flagset, bool bLocked = false );
180+int GAMEMODE_GetCurrentFlagsetMask( FIntCVar *Flagset, bool bLocked = false );
179181 void GAMEMODE_DetermineGameMode( void );
180182 bool GAMEMODE_IsGameInCountdown( void );
181183 bool GAMEMODE_IsGameInProgress( void );
@@ -219,6 +221,6 @@
219221 void GAMEMODE_SetCountdownTicks( const ULONG Ticks );
220222 void GAMEMODE_SetLimit( GAMELIMIT_e GameLimit, int value );
221223
222-void GAMEMODE_ReconfigureGameSettings( void );
224+void GAMEMODE_ReconfigureGameSettings( bool bLockedOnly = false );
223225
224226 #endif // __GAMEMODE_H__
Show on old repository browser