• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a fork of Zandronum used on servers hosted by The Sentinels Playground (TSPG).


Commit MetaInfo

修訂181c3a820c0a324ed5217b582c565348998b0e71 (tree)
時間2021-09-27 00:59:51
作者Adam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added "DefaultGameSettings" and "DefaultLockedGameSettings" blocks to GAMEMODE so that gameplay/compatibility flags can be enabled or disabled across all game modes.

Change Summary

差異

diff -r 8f9120c4c9b2 -r 181c3a820c0a src/gamemode.cpp
--- a/src/gamemode.cpp Sun Sep 26 10:46:39 2021 -0400
+++ b/src/gamemode.cpp Sun Sep 26 11:59:51 2021 -0400
@@ -210,38 +210,7 @@
210210 }
211211 else if ((0 == stricmp (sc.String, "gamesettings")) || (0 == stricmp (sc.String, "lockedgamesettings")))
212212 {
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" ));
245214 }
246215 else if (0 == stricmp (sc.String, "removegamesetting"))
247216 {
@@ -273,28 +242,117 @@
273242
274243 //*****************************************************************************
275244 //
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+//
276321 void GAMEMODE_ParseGamemodeInfo( void )
277322 {
278323 int lastlump = 0, lump;
279324
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-
291325 while ((lump = Wads.FindLump ("GAMEMODE", &lastlump)) != -1)
292326 {
293327 FScanner sc(lump);
328+ bool bParsedDefGameSettings = false;
329+ bool bParsedDefLockedSettings = false;
330+
294331 while (sc.GetString ())
295332 {
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+ }
298356 }
299357 }
300358
diff -r 8f9120c4c9b2 -r 181c3a820c0a src/gamemode.h
--- a/src/gamemode.h Sun Sep 26 10:46:39 2021 -0400
+++ b/src/gamemode.h Sun Sep 26 11:59:51 2021 -0400
@@ -174,6 +174,7 @@
174174
175175 void GAMEMODE_Tick( void );
176176 void GAMEMODE_ParseGamemodeInfoLump ( FScanner &sc, const GAMEMODE_e GameMode );
177+void GAMEMODE_ParseGameSettingBlock ( FScanner &sc, const GAMEMODE_e GameMode, bool bLockFlags, bool bResetFlags = false );
177178 void GAMEMODE_ParseGamemodeInfo( void );
178179 ULONG GAMEMODE_GetFlags( GAMEMODE_e GameMode );
179180 ULONG GAMEMODE_GetCurrentFlags( void );
diff -r 8f9120c4c9b2 -r 181c3a820c0a wadsrc/static/gamemode.txt
--- a/wadsrc/static/gamemode.txt Sun Sep 26 10:46:39 2021 -0400
+++ b/wadsrc/static/gamemode.txt Sun Sep 26 11:59:51 2021 -0400
@@ -1,3 +1,8 @@
1+// [AK] This is just to initialize the flagsets of all game modes to zero.
2+DefaultGameSettings
3+{
4+}
5+
16 // Regular co-op
27 Cooperative
38 {