• R/O
  • SSH

Commit

Tags
No Tags

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

Revision005e26e8bfa2d4572b2f996d539ada8283234726 (tree)
Time2021-09-24 11:40:21
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Cleaned up the ACS function "SetCurrentGamemode" and changed it so the name of the new game mode has to match its corresponding GAMEMODE_e enum.

Change Summary

Incremental Difference

diff -r 3d653fcb7a1d -r 005e26e8bfa2 src/p_acs.cpp
--- a/src/p_acs.cpp Sat Sep 25 00:37:05 2021 -0400
+++ b/src/p_acs.cpp Thu Sep 23 22:40:21 2021 -0400
@@ -7298,64 +7298,66 @@
72987298
72997299 case ACSF_SetCurrentGamemode:
73007300 {
7301- const char *name = FBehavior::StaticLookupString( args[0] );
7302- const GAMEMODE_e oldmode = GAMEMODE_GetCurrentMode();
7303- GAMEMODE_e newmode;
7304-
7305- // [AK] Only the server should change the gamemode, but not during the result sequence.
7306- if ( NETWORK_InClientMode() || GAMEMODE_GetState() == GAMESTATE_INRESULTSEQUENCE )
7301+ // [AK] Only the server should change the game mode, but not during the result sequence.
7302+ if (( NETWORK_InClientMode()) || ( GAMEMODE_GetState() == GAMESTATE_INRESULTSEQUENCE ))
73077303 return 0;
73087304
7309- // [AK] No need to change the gamemode if we're already playing it.
7310- if ( stricmp( name, GAMEMODE_GetName( oldmode )) == 0 )
7305+ FString name = "GAMEMODE_";
7306+ name += FBehavior::StaticLookupString( args[0] );
7307+ name.ToUpper( );
7308+
7309+ const GAMEMODE_e oldmode = GAMEMODE_GetCurrentMode();
7310+
7311+ // [AK] Don't accept invalid game mode names.
7312+ int gamemode = GetValueGAMEMODE_e( name );
7313+ if ( gamemode == -1 )
73117314 return 0;
73127315
7313- for ( int i = 0; i < NUM_GAMEMODES; i++ )
7314- {
7315- newmode = static_cast<GAMEMODE_e> ( i );
7316- if ( stricmp( name, GAMEMODE_GetName( newmode )) != 0 )
7317- continue;
7318-
7319- // [AK] Don't change to any team game if there's no team starts on the map!
7320- if (( GAMEMODE_GetFlags( newmode ) & GMF_TEAMGAME ) && TEAM_GetNumTeamsWithStarts() < 1 )
7316+ // [AK] No need to change the game mode if we're already playing it.
7317+ GAMEMODE_e newmode = static_cast<GAMEMODE_e>( gamemode );
7318+ if ( newmode == oldmode )
7319+ return 0;
7320+
7321+ // [AK] Don't change to any team game if there's no team starts on the map!
7322+ if (( GAMEMODE_GetFlags( newmode ) & GMF_TEAMGAME ) && ( TEAM_GetNumTeamsWithStarts() < 1 ))
7323+ return 0;
7324+
7325+ // [AK] Don't change to deathmatch if there's no deathmatch starts on the map!
7326+ if ( GAMEMODE_GetFlags( newmode ) & GMF_DEATHMATCH )
7327+ {
7328+ if ( deathmatchstarts.Size() < 1 )
73217329 return 0;
7322- // [AK] Don't change to deathmatch if there's no deathmatch starts on the map!
7323- if ( GAMEMODE_GetFlags( newmode ) & GMF_DEATHMATCH )
7324- {
7325- if ( deathmatchstarts.Size() < 1 )
7326- return 0;
7327-
7328- // [AK] If we're changing to duel, don't change if there's too many active players.
7329- if ( newmode == GAMEMODE_DUEL && GAME_CountActivePlayers() > 2 )
7330- return 0;
7331- }
7332- // [AK] Don't change to cooperative if there's no cooperative starts on the map!
7333- else if ( GAMEMODE_GetFlags( newmode ) & GMF_COOPERATIVE )
7334- {
7335- ULONG ulNumSpawns = 0;
7336- for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
7330+
7331+ // [AK] If we're changing to duel, don't change if there's too many active players.
7332+ if (( newmode == GAMEMODE_DUEL ) && ( GAME_CountActivePlayers() > 2 ))
7333+ return 0;
7334+ }
7335+ // [AK] Don't change to cooperative if there's no cooperative starts on the map!
7336+ else if ( GAMEMODE_GetFlags( newmode ) & GMF_COOPERATIVE )
7337+ {
7338+ ULONG ulNumSpawns = 0;
7339+ for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
7340+ {
7341+ if ( playerstarts[ulIdx].type != 0 )
73377342 {
7338- if ( playerstarts[ulIdx].type != 0 )
7339- {
7340- ulNumSpawns++;
7341- break;
7342- }
7343+ ulNumSpawns++;
7344+ break;
73437345 }
7344-
7345- if ( ulNumSpawns < 1 )
7346- return 0;
7347- }
7348-
7349- // [AK] If everything's okay now, change the gamemode.
7350- GAMEMODE_SetCurrentMode( newmode );
7351-
7352- // [AK] We should also start a new game, so just execute the "map" CCMD to do this.
7353- FString command;
7354- command.Format( "map %s", level.mapname );
7355- C_DoCommand( command.GetChars());
7356- return 1;
7357- }
7358- return 0;
7346+ }
7347+
7348+ if ( ulNumSpawns < 1 )
7349+ return 0;
7350+ }
7351+
7352+ // [AK] If everything's okay now, change the gamemode.
7353+ GAMEMODE_SetCurrentMode( newmode );
7354+
7355+ // [AK] We should also start a new game, so just execute the "map" CCMD to do this.
7356+ FString command;
7357+ command.Format( "map %s", level.mapname );
7358+ C_DoCommand( command );
7359+
7360+ return 1;
73597361 }
73607362
73617363 case ACSF_GetCurrentGamemode: