This is a fork of Zandronum used on servers hosted by The Sentinels Playground (TSPG).
Revision | 181c3a820c0a324ed5217b582c565348998b0e71 (tree) |
---|---|
Time | 2021-09-27 00:59:51 |
Author | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Added "DefaultGameSettings" and "DefaultLockedGameSettings" blocks to GAMEMODE so that gameplay/compatibility flags can be enabled or disabled across all game modes.
@@ -210,38 +210,7 @@ | ||
210 | 210 | } |
211 | 211 | else if ((0 == stricmp (sc.String, "gamesettings")) || (0 == stricmp (sc.String, "lockedgamesettings"))) |
212 | 212 | { |
213 | - bool bLockFlags = !stricmp( sc.String, "lockedgamesettings" ); | |
214 | - | |
215 | - sc.MustGetStringName( "{" ); | |
216 | - while ( !sc.CheckString( "}" )) | |
217 | - { | |
218 | - FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, flagset ); | |
219 | - ULONG ulBit = flag->GetBitVal(); | |
220 | - bool bEnableFlag; | |
221 | - | |
222 | - // [AK] There must be an equal sign following the name of the flag. | |
223 | - sc.MustGetStringName( "=" ); | |
224 | - sc.GetString(); | |
225 | - | |
226 | - if ( stricmp( sc.String, "true" ) == 0 ) | |
227 | - bEnableFlag = true; | |
228 | - else if ( stricmp( sc.String, "false" ) == 0 ) | |
229 | - bEnableFlag = false; | |
230 | - else | |
231 | - bEnableFlag = !!atoi( sc.String ); | |
232 | - | |
233 | - // [AK] Enable or disable the flag as desired. | |
234 | - if ( bEnableFlag ) | |
235 | - g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] |= ulBit; | |
236 | - else | |
237 | - g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] &= ~ulBit; | |
238 | - | |
239 | - g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_MASK] |= ulBit; | |
240 | - | |
241 | - // [AK] Lock this flag so it can't be manually changed. | |
242 | - if ( bLockFlags ) | |
243 | - g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] |= ulBit; | |
244 | - } | |
213 | + GAMEMODE_ParseGameSettingBlock( sc, GameMode, !stricmp( sc.String, "lockedgamesettings" )); | |
245 | 214 | } |
246 | 215 | else if (0 == stricmp (sc.String, "removegamesetting")) |
247 | 216 | { |
@@ -273,28 +242,117 @@ | ||
273 | 242 | |
274 | 243 | //***************************************************************************** |
275 | 244 | // |
245 | +void GAMEMODE_ParseGameSettingBlock ( FScanner &sc, const GAMEMODE_e GameMode, bool bLockFlags, bool bResetFlags ) | |
246 | +{ | |
247 | + FLAGSET_e flagset; | |
248 | + sc.MustGetStringName( "{" ); | |
249 | + | |
250 | + // [AK] If this is the start of a "defaultgamesettings" or "defaultlockedgamesettings" block, reset the | |
251 | + // flagsets of all game modes to zero. We don't want to do this more than once in a single GAMEMODE lump, | |
252 | + // in case both blocks are declared in the same lump. | |
253 | + if (( GameMode == NUM_GAMEMODES ) && ( bResetFlags )) | |
254 | + { | |
255 | + for ( unsigned int mode = GAMEMODE_COOPERATIVE; mode < NUM_GAMEMODES; mode++ ) | |
256 | + { | |
257 | + for ( unsigned int set = FLAGSET_DMFLAGS; set < NUM_FLAGSETS; set++ ) | |
258 | + { | |
259 | + g_GameModes[mode].lFlagsets[set][FLAGSET_VALUE] = 0; | |
260 | + g_GameModes[mode].lFlagsets[set][FLAGSET_MASK] = 0; | |
261 | + g_GameModes[mode].lFlagsets[set][FLAGSET_LOCKEDMASK] = 0; | |
262 | + } | |
263 | + } | |
264 | + } | |
265 | + | |
266 | + while ( !sc.CheckString( "}" )) | |
267 | + { | |
268 | + FFlagCVar *flag = GAMEMODE_ParserMustGetFlagset( sc, GameMode, flagset ); | |
269 | + ULONG ulBit = flag->GetBitVal(); | |
270 | + bool bEnableFlag; | |
271 | + | |
272 | + // [AK] There must be an equal sign following the name of the flag. | |
273 | + sc.MustGetStringName( "=" ); | |
274 | + sc.GetString(); | |
275 | + | |
276 | + if ( stricmp( sc.String, "true" ) == 0 ) | |
277 | + bEnableFlag = true; | |
278 | + else if ( stricmp( sc.String, "false" ) == 0 ) | |
279 | + bEnableFlag = false; | |
280 | + else | |
281 | + bEnableFlag = !!atoi( sc.String ); | |
282 | + | |
283 | + // [AK] If this flag was added inside a "defaultgamesettings" or "defaultlockedgamesettings" block, apply | |
284 | + // it to all the game modes. Otherwise, just apply it to the one we specified. | |
285 | + if ( GameMode == NUM_GAMEMODES ) | |
286 | + { | |
287 | + for ( unsigned int mode = GAMEMODE_COOPERATIVE; mode < NUM_GAMEMODES; mode++ ) | |
288 | + { | |
289 | + // [AK] Enable or disable the flag as desired. | |
290 | + if ( bEnableFlag ) | |
291 | + g_GameModes[mode].lFlagsets[flagset][FLAGSET_VALUE] |= ulBit; | |
292 | + else | |
293 | + g_GameModes[mode].lFlagsets[flagset][FLAGSET_VALUE] &= ~ulBit; | |
294 | + | |
295 | + g_GameModes[mode].lFlagsets[flagset][FLAGSET_MASK] |= ulBit; | |
296 | + | |
297 | + // [AK] Lock this flag so it can't be manually changed. | |
298 | + if ( bLockFlags ) | |
299 | + g_GameModes[mode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] |= ulBit; | |
300 | + } | |
301 | + } | |
302 | + else | |
303 | + { | |
304 | + // [AK] Enable or disable the flag as desired. | |
305 | + if ( bEnableFlag ) | |
306 | + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] |= ulBit; | |
307 | + else | |
308 | + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_VALUE] &= ~ulBit; | |
309 | + | |
310 | + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_MASK] |= ulBit; | |
311 | + | |
312 | + // [AK] Lock this flag so it can't be manually changed. | |
313 | + if ( bLockFlags ) | |
314 | + g_GameModes[GameMode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] |= ulBit; | |
315 | + } | |
316 | + } | |
317 | +} | |
318 | + | |
319 | +//***************************************************************************** | |
320 | +// | |
276 | 321 | void GAMEMODE_ParseGamemodeInfo( void ) |
277 | 322 | { |
278 | 323 | int lastlump = 0, lump; |
279 | 324 | |
280 | - // [AK] Before we start parsing any GAMEMODE lumps, initialize the flagset values used by all game modes to zero. | |
281 | - for ( unsigned int gamemode = GAMEMODE_COOPERATIVE; gamemode < NUM_GAMEMODES; gamemode++ ) | |
282 | - { | |
283 | - for ( unsigned int flagset = FLAGSET_DMFLAGS; flagset < NUM_FLAGSETS; flagset++ ) | |
284 | - { | |
285 | - g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_VALUE] = 0; | |
286 | - g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_MASK] = 0; | |
287 | - g_GameModes[gamemode].lFlagsets[flagset][FLAGSET_LOCKEDMASK] = 0; | |
288 | - } | |
289 | - } | |
290 | - | |
291 | 325 | while ((lump = Wads.FindLump ("GAMEMODE", &lastlump)) != -1) |
292 | 326 | { |
293 | 327 | FScanner sc(lump); |
328 | + bool bParsedDefGameSettings = false; | |
329 | + bool bParsedDefLockedSettings = false; | |
330 | + | |
294 | 331 | while (sc.GetString ()) |
295 | 332 | { |
296 | - GAMEMODE_e GameMode = static_cast<GAMEMODE_e>( GAMEMODE_ParserMustGetEnumName( sc, "gamemode", "GAMEMODE_", GetValueGAMEMODE_e, true ) ); | |
297 | - GAMEMODE_ParseGamemodeInfoLump ( sc, GameMode ); | |
333 | + if (stricmp(sc.String, "defaultgamesettings") == 0) | |
334 | + { | |
335 | + // [AK] Don't allow more than one "defaultgamesettings" block in the same lump. | |
336 | + if ( bParsedDefGameSettings ) | |
337 | + sc.ScriptError( "There is already a \"DefaultGameSettings\" block defined in this lump." ); | |
338 | + | |
339 | + GAMEMODE_ParseGameSettingBlock( sc, NUM_GAMEMODES, false, !( bParsedDefGameSettings || bParsedDefLockedSettings ) ); | |
340 | + bParsedDefGameSettings = true; | |
341 | + } | |
342 | + else if (stricmp(sc.String, "defaultlockedgamesettings") == 0) | |
343 | + { | |
344 | + // [AK] Don't allow more than one "defaultlockedgamesettings" block in the same lump. | |
345 | + if ( bParsedDefLockedSettings ) | |
346 | + sc.ScriptError( "There is already a \"DefaultLockedGameSettings\" block defined in this lump." ); | |
347 | + | |
348 | + GAMEMODE_ParseGameSettingBlock( sc, NUM_GAMEMODES, true, !( bParsedDefGameSettings || bParsedDefLockedSettings ) ); | |
349 | + bParsedDefLockedSettings = true; | |
350 | + } | |
351 | + else | |
352 | + { | |
353 | + GAMEMODE_e GameMode = static_cast<GAMEMODE_e>( GAMEMODE_ParserMustGetEnumName( sc, "gamemode", "GAMEMODE_", GetValueGAMEMODE_e, true ) ); | |
354 | + GAMEMODE_ParseGamemodeInfoLump ( sc, GameMode ); | |
355 | + } | |
298 | 356 | } |
299 | 357 | } |
300 | 358 |
@@ -174,6 +174,7 @@ | ||
174 | 174 | |
175 | 175 | void GAMEMODE_Tick( void ); |
176 | 176 | void GAMEMODE_ParseGamemodeInfoLump ( FScanner &sc, const GAMEMODE_e GameMode ); |
177 | +void GAMEMODE_ParseGameSettingBlock ( FScanner &sc, const GAMEMODE_e GameMode, bool bLockFlags, bool bResetFlags = false ); | |
177 | 178 | void GAMEMODE_ParseGamemodeInfo( void ); |
178 | 179 | ULONG GAMEMODE_GetFlags( GAMEMODE_e GameMode ); |
179 | 180 | ULONG GAMEMODE_GetCurrentFlags( void ); |
@@ -1,3 +1,8 @@ | ||
1 | +// [AK] This is just to initialize the flagsets of all game modes to zero. | |
2 | +DefaultGameSettings | |
3 | +{ | |
4 | +} | |
5 | + | |
1 | 6 | // Regular co-op |
2 | 7 | Cooperative |
3 | 8 | { |