# HG changeset patch # User Adam Kaminski # Date 1623559812 14400 # Sun Jun 13 00:50:12 2021 -0400 # Node ID 37fbc524ced925581be8bc37aa54471fa7b361c6 # Parent 2e11b023bf1415cae78aee11eb40ada7acbb37e8 Prevent GAMEMODE from removing all or adding more than one game type. diff -r 2e11b023bf14 -r 37fbc524ced9 src/gamemode.cpp --- a/src/gamemode.cpp Sun Jun 13 00:30:39 2021 -0400 +++ b/src/gamemode.cpp Sun Jun 13 00:50:12 2021 -0400 @@ -352,14 +352,18 @@ sc.ScriptError ( "Unknown option '%s', on line %d in GAMEMODE.", sc.String, sc.Line ); } + // [AK] Get the game mode type (cooperative, deathmatch, or team game). There shouldn't be more than one enabled or none at all. + ULONG ulFlags = g_GameModes[GameMode].ulFlags & ( GMF_COOPERATIVE | GMF_DEATHMATCH | GMF_TEAMGAME ); + if (( ulFlags == 0 ) || (( ulFlags & ( ulFlags - 1 )) != 0 )) + sc.ScriptError( "Can't determine if '%s' is cooperative, deathmatch, or team-based.", g_GameModes[GameMode].szName ); + // [AK] Get the type of "players earn" flag this game mode is currently using. - ULONG ulMask = GMF_PLAYERSEARNKILLS | GMF_PLAYERSEARNFRAGS | GMF_PLAYERSEARNPOINTS | GMF_PLAYERSEARNWINS; - ULONG ulEarnFlags = g_GameModes[GameMode].ulFlags & ulMask; + ulFlags = g_GameModes[GameMode].ulFlags & ( GMF_PLAYERSEARNKILLS | GMF_PLAYERSEARNFRAGS | GMF_PLAYERSEARNPOINTS | GMF_PLAYERSEARNWINS ); // [AK] If all of these flags were removed or if more than one was added, then throw an error. - if ( ulEarnFlags == 0 ) + if ( ulFlags == 0 ) sc.ScriptError( "Players have no way of earning kills, frags, points, or wins in '%s'.", g_GameModes[GameMode].szName ); - else if (( ulEarnFlags & ( ulEarnFlags - 1 )) != 0 ) + else if (( ulFlags & ( ulFlags - 1 )) != 0 ) sc.ScriptError( "There is more than one PLAYERSEARN flag enabled in '%s'.", g_GameModes[GameMode].szName ); }