# HG changeset patch # User Adam Kaminski # Date 1632667599 14400 # Sun Sep 26 10:46:39 2021 -0400 # Node ID 81f94e9cac8f4e9d2aca957a0117bf1e827b6ce0 # Parent dc9b3c616584f1c24a9537e6f203a9ecda8da99d Combined all of the different gameplay/compatibility flagsets in GAMEMODE_s into a single 2D array. diff -r dc9b3c616584 -r 81f94e9cac8f src/gamemode.cpp --- a/src/gamemode.cpp Thu Sep 23 22:40:21 2021 -0400 +++ b/src/gamemode.cpp Sun Sep 26 10:46:39 2021 -0400 @@ -135,7 +135,7 @@ //***************************************************************************** // -FFlagCVar *GAMEMODE_ParserMustGetFlagset ( FScanner &sc, const GAMEMODE_e GameMode, LONG **GameModeFlagset ) +FFlagCVar *GAMEMODE_ParserMustGetFlagset ( FScanner &sc, const GAMEMODE_e GameMode, FLAGSET_e &Flagset ) { sc.MustGetString(); FBaseCVar *cvar = FindCVar( sc.String, NULL ); @@ -149,21 +149,21 @@ // [AK] Make sure the flag belongs to a valid gameplay or compatibility flagset. if ( flagset == &dmflags ) - *GameModeFlagset = &g_GameModes[GameMode].lDMFlags[FLAGSET_VALUE]; + Flagset = FLAGSET_DMFLAGS; else if ( flagset == &dmflags2 ) - *GameModeFlagset = &g_GameModes[GameMode].lDMFlags2[FLAGSET_VALUE]; + Flagset = FLAGSET_DMFLAGS2; else if ( flagset == &compatflags ) - *GameModeFlagset = &g_GameModes[GameMode].lCompatFlags[FLAGSET_VALUE]; + Flagset = FLAGSET_COMPATFLAGS; else if ( flagset == &compatflags2 ) - *GameModeFlagset = &g_GameModes[GameMode].lCompatFlags2[FLAGSET_VALUE]; + Flagset = FLAGSET_COMPATFLAGS2; else if ( flagset == &zadmflags ) - *GameModeFlagset = &g_GameModes[GameMode].lZaDMFlags[FLAGSET_VALUE]; + Flagset = FLAGSET_ZADMFLAGS; else if ( flagset == &zacompatflags ) - *GameModeFlagset = &g_GameModes[GameMode].lZaCompatFlags[FLAGSET_VALUE]; + Flagset = FLAGSET_ZACOMPATFLAGS; else if ( flagset == &lmsallowedweapons ) - *GameModeFlagset = &g_GameModes[GameMode].lLMSAllowedWeapons[FLAGSET_VALUE]; + Flagset = FLAGSET_LMSALLOWEDWEAPONS; else if ( flagset == &lmsspectatorsettings ) - *GameModeFlagset = &g_GameModes[GameMode].lLMSSpectatorSettings[FLAGSET_VALUE]; + Flagset = FLAGSET_LMSSPECTATORSETTINGS; else sc.ScriptError ( "Invalid gameplay or compatibility flag '%s'.", sc.String, sc.Line ); @@ -175,7 +175,7 @@ void GAMEMODE_ParseGamemodeInfoLump ( FScanner &sc, const GAMEMODE_e GameMode ) { TEAMINFO team; - LONG *flagset = NULL; + FLAGSET_e flagset; sc.MustGetStringName("{"); while (!sc.CheckString("}")) @@ -215,7 +215,7 @@ sc.MustGetStringName( "{" ); while ( !sc.CheckString( "}" )) { - FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, &flagset ); + FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, flagset ); ULONG ulBit = flag->GetBitVal(); bool bEnableFlag; @@ -232,25 +232,25 @@ // [AK] Enable or disable the flag as desired. if ( bEnableFlag ) - flagset[FLAGSET_VALUE] |= ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] |= ulBit; else - flagset[FLAGSET_VALUE] &= ~ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] &= ~ulBit; - flagset[FLAGSET_MASK] |= ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_MASK] |= ulBit; // [AK] Lock this flag so it can't be manually changed. if ( bLockFlags ) - flagset[FLAGSET_LOCKEDMASK] |= ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] |= ulBit; } } else if (0 == stricmp (sc.String, "removegamesetting")) { - FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, &flagset ); + FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, flagset ); ULONG ulBit = flag->GetBitVal(); - flagset[FLAGSET_VALUE] &= ~ulBit; - flagset[FLAGSET_MASK] &= ~ulBit; - flagset[FLAGSET_LOCKEDMASK] &= ~ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] &= ~ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_MASK] &= ~ulBit; + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] &= ~ulBit; } else sc.ScriptError ( "Unknown option '%s', on line %d in GAMEMODE.", sc.String, sc.Line ); @@ -280,16 +280,11 @@ // [AK] Before we start parsing any GAMEMODE lumps, initialize the flagset values used by all game modes to zero. for ( unsigned int gamemode = GAMEMODE_COOPERATIVE; gamemode < NUM_GAMEMODES; gamemode++ ) { - for ( unsigned int flagset = FLAGSET_VALUE; flagset <= FLAGSET_LOCKEDMASK; flagset++ ) + for ( unsigned int flagset = FLAGSET_DMFLAGS; flagset < NUM_FLAGSETS; flagset++ ) { - g_GameModes[gamemode].lDMFlags[flagset] = 0; - g_GameModes[gamemode].lDMFlags2[flagset] = 0; - g_GameModes[gamemode].lCompatFlags[flagset] = 0; - g_GameModes[gamemode].lCompatFlags2[flagset] = 0; - g_GameModes[gamemode].lZaDMFlags[flagset] = 0; - g_GameModes[gamemode].lZaCompatFlags[flagset] = 0; - g_GameModes[gamemode].lLMSAllowedWeapons[flagset] = 0; - g_GameModes[gamemode].lLMSSpectatorSettings[flagset] = 0; + g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_VALUE] = 0; + g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_MASK] = 0; + g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] = 0; } } @@ -368,21 +363,21 @@ ULONG ulMask = bLocked ? FLAGSET_LOCKEDMASK : FLAGSET_MASK; if ( Flagset == &dmflags ) - return ( g_GameModes[GameMode].lDMFlags[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_DMFLAGS][ulMask] ); else if ( Flagset == &dmflags2 ) - return ( g_GameModes[GameMode].lDMFlags2[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_DMFLAGS2][ulMask] ); else if ( Flagset == &compatflags ) - return ( g_GameModes[GameMode].lCompatFlags[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_COMPATFLAGS][ulMask] ); else if ( Flagset == &compatflags2 ) - return ( g_GameModes[GameMode].lCompatFlags2[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_COMPATFLAGS2][ulMask] ); else if ( Flagset == &zadmflags ) - return ( g_GameModes[GameMode].lZaDMFlags[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_ZADMFLAGS][ulMask] ); else if ( Flagset == &zacompatflags ) - return ( g_GameModes[GameMode].lZaCompatFlags[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_ZACOMPATFLAGS][ulMask] ); else if ( Flagset == &lmsallowedweapons ) - return ( g_GameModes[GameMode].lLMSAllowedWeapons[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_LMSALLOWEDWEAPONS][ulMask] ); else if ( Flagset == &lmsspectatorsettings ) - return ( g_GameModes[GameMode].lLMSSpectatorSettings[ulMask] ); + return ( g_GameModes[GameMode].lFlagsets[FLAGSET_LMSSPECTATORSETTINGS][ulMask] ); // [AK] We passed an invalid flagset, just return zero. return ( 0 ); @@ -1340,38 +1335,46 @@ void GAMEMODE_ReconfigureGameSettings( bool bLockedOnly ) { ULONG ulMask = bLockedOnly ? FLAGSET_LOCKEDMASK : FLAGSET_MASK; - GAMEMODE_s *GameMode = &g_GameModes[g_CurrentGameMode]; + LONG *flagset; UCVarValue value; // [AK] Apply the mask to dmflags, but don't change the values of any unlocked flags. - value.Int = ( dmflags & ~GameMode->lDMFlags[ulMask] ) | ( GameMode->lDMFlags[FLAGSET_VALUE] & GameMode->lDMFlags[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_DMFLAGS][FLAGSET_VALUE]; + value.Int = ( dmflags & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); dmflags.ForceSet( value, CVAR_Int ); // ...and dmflags2. - value.Int = ( dmflags2 & ~GameMode->lDMFlags2[ulMask] ) | ( GameMode->lDMFlags2[FLAGSET_VALUE] & GameMode->lDMFlags2[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_DMFLAGS2][FLAGSET_VALUE]; + value.Int = ( dmflags2 & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); dmflags2.ForceSet( value, CVAR_Int ); // ...and compatflags. - value.Int = ( compatflags & ~GameMode->lCompatFlags[ulMask] ) | ( GameMode->lCompatFlags[FLAGSET_VALUE] & GameMode->lCompatFlags[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_COMPATFLAGS][FLAGSET_VALUE]; + value.Int = ( compatflags & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); compatflags.ForceSet( value, CVAR_Int ); // ...and compatflags2. - value.Int = ( compatflags2 & ~GameMode->lCompatFlags2[ulMask] ) | ( GameMode->lCompatFlags2[FLAGSET_VALUE] & GameMode->lCompatFlags2[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_COMPATFLAGS2][FLAGSET_VALUE]; + value.Int = ( compatflags2 & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); compatflags2.ForceSet( value, CVAR_Int ); // ...and zadmflags. - value.Int = ( zadmflags & ~GameMode->lZaDMFlags[ulMask] ) | ( GameMode->lZaDMFlags[FLAGSET_VALUE] & GameMode->lZaDMFlags[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_ZADMFLAGS][FLAGSET_VALUE]; + value.Int = ( zadmflags & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); zadmflags.ForceSet( value, CVAR_Int ); // ...and zacompatflags. - value.Int = ( zacompatflags & ~GameMode->lZaCompatFlags[ulMask] ) | ( GameMode->lZaCompatFlags[FLAGSET_VALUE] & GameMode->lZaCompatFlags[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_ZACOMPATFLAGS][FLAGSET_VALUE]; + value.Int = ( zacompatflags & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); zacompatflags.ForceSet( value, CVAR_Int ); // ...and lmsallowedweapons. - value.Int = ( lmsallowedweapons & ~GameMode->lLMSAllowedWeapons[ulMask] ) | ( GameMode->lLMSAllowedWeapons[FLAGSET_VALUE] & GameMode->lLMSAllowedWeapons[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_LMSALLOWEDWEAPONS][FLAGSET_VALUE]; + value.Int = ( lmsallowedweapons & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); lmsallowedweapons.ForceSet( value, CVAR_Int ); // ...and lmsspectatorsettings. - value.Int = ( lmsspectatorsettings & ~GameMode->lLMSSpectatorSettings[ulMask] ) | ( GameMode->lLMSSpectatorSettings[FLAGSET_VALUE] & GameMode->lLMSSpectatorSettings[ulMask] ); + flagset = &g_GameModes[g_CurrentGameMode].lFlagsets[FLAGSET_LMSSPECTATORSETTINGS][FLAGSET_VALUE]; + value.Int = ( lmsspectatorsettings & ~flagset[ulMask] ) | ( flagset[FLAGSET_VALUE] & flagset[ulMask] ); lmsspectatorsettings.ForceSet( value, CVAR_Int ); } \ No newline at end of file diff -r dc9b3c616584 -r 81f94e9cac8f src/gamemode.h --- a/src/gamemode.h Thu Sep 23 22:40:21 2021 -0400 +++ b/src/gamemode.h Sun Sep 26 10:46:39 2021 -0400 @@ -83,6 +83,22 @@ //***************************************************************************** typedef enum { + FLAGSET_DMFLAGS, + FLAGSET_DMFLAGS2, + FLAGSET_COMPATFLAGS, + FLAGSET_COMPATFLAGS2, + FLAGSET_ZADMFLAGS, + FLAGSET_ZACOMPATFLAGS, + FLAGSET_LMSALLOWEDWEAPONS, + FLAGSET_LMSSPECTATORSETTINGS, + + NUM_FLAGSETS + +} FLAGSET_e; + +//***************************************************************************** +typedef enum +{ MODIFIER_NONE, MODIFIER_INSTAGIB, MODIFIER_BUCKSHOT, @@ -147,29 +163,9 @@ // this game mode. char szF1Texture[9]; - // [AK] The dmflags we set for this gamemode. - LONG lDMFlags[3]; - - // [AK] The dmflags2 we set for this gamemode. - LONG lDMFlags2[3]; - - // [AK] The compatflags we set for this gamemode. - LONG lCompatFlags[3]; - - // [AK] The compatflags2 we set for this gamemode. - LONG lCompatFlags2[3]; - - // [AK] The zadmflags we set for this gamemode. - LONG lZaDMFlags[3]; - - // [AK] The zacompatflags we set for this gamemode. - LONG lZaCompatFlags[3]; - - // [AK] The lmsallowedweapons we set for this gamemode. - LONG lLMSAllowedWeapons[3]; - - // [AK] The lmsspectatorsettings we set for this gamemode. - LONG lLMSSpectatorSettings[3]; + // [AK] All of the gameplay or compatibility flags we set for this game mode + // (dmflags, compatflags, lmsallowedweapons, lmsspectatorsettings, etc.). + LONG lFlagsets[NUM_FLAGSETS][3]; } GAMEMODE_s;