Browse Source

Fix launcher not using selected game mode

develop
Anton Tarasenko 2 years ago
parent
commit
79ccdf76fb
  1. 32
      sources/VotingHandlerAdapter.uc

32
sources/VotingHandlerAdapter.uc

@ -23,7 +23,8 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. * along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/ */
class VotingHandlerAdapter extends AcediaObject class VotingHandlerAdapter extends AcediaObject
dependson(VotingHandler); dependson(VotingHandler)
config(AcediaLauncherData);
/** /**
* All usage of this object should start with `InjectIntoVotingHandler()` * All usage of this object should start with `InjectIntoVotingHandler()`
@ -73,19 +74,19 @@ var private NativeActorRef votingHandlerReference;
// otherwise Acedia will alter its config // otherwise Acedia will alter its config
var private array<VotingHandler.MapVoteGameConfig> backupVotingHandlerConfig; var private array<VotingHandler.MapVoteGameConfig> backupVotingHandlerConfig;
// Setting default value of this flag to `true` indicates that map switching // Setting value of this flag to `true` indicates that map switching just
// just occurred and we need to recover some information from the previous map. // occurred and we need to recover some information from the previous map.
var private bool isServerTraveling; var private config bool isServerTraveling;
// We should not rely on "VotingHandler" to inform us from which game mode its // We should not rely on "VotingHandler" to inform us from which game mode its
// selected config option originated after server travel, so we need to // selected config option originated after server travel, so we need to
// remember it in this default variable before switching maps. // remember it in this config variable before switching maps.
var private string targetGameMode; var private config string targetGameMode;
// Acedia's game modes intend on supporting difficulty switching, but // Acedia's game modes intend on supporting difficulty switching, but
// `KFGameType` does not support appropriate flags, so we enforce default // `KFGameType` does not support appropriate flags, so we enforce default
// difficulty by overwriting default value of its `gameDifficulty` variable. // difficulty by overwriting default value of its `gameDifficulty` variable.
// But to not affect game's configs we must restore old value after new map is // But to not affect game's configs we must restore old value after new map is
// loaded. Store it in default variable for that. // loaded. Store it in config variable for that.
var private float storedGameDifficulty; var private config float storedGameDifficulty;
var private LoggerAPI.Definition fatNoXVotingHandler, fatBadGameConfigIndexVH; var private LoggerAPI.Definition fatNoXVotingHandler, fatBadGameConfigIndexVH;
var private LoggerAPI.Definition fatBadGameConfigIndexAdapter; var private LoggerAPI.Definition fatBadGameConfigIndexAdapter;
@ -232,11 +233,12 @@ public final function PrepareForServerTravel()
nextGameClass = nextGameClass =
class<GameInfo>(_.memory.LoadClass_S(nextGameClassName)); class<GameInfo>(_.memory.LoadClass_S(nextGameClassName));
} }
default.isServerTraveling = true; isServerTraveling = true;
default.targetGameMode = availableGameModes[pickedVHConfig].ToString(); targetGameMode = availableGameModes[pickedVHConfig].ToString();
nextGameMode = GetConfigFromString(default.targetGameMode); nextGameMode = GetConfigFromString(default.targetGameMode);
default.storedGameDifficulty = nextGameClass.default.gameDifficulty; storedGameDifficulty = nextGameClass.default.gameDifficulty;
nextGameClass.default.gameDifficulty = GetNumericDifficulty(nextGameMode); nextGameClass.default.gameDifficulty = GetNumericDifficulty(nextGameMode);
SaveConfig();
} }
/** /**
@ -248,12 +250,12 @@ public final function PrepareForServerTravel()
*/ */
public final function GameMode SetupGameModeAfterTravel() public final function GameMode SetupGameModeAfterTravel()
{ {
if (!default.isServerTraveling) { if (!isServerTraveling) {
return none; return none;
} }
_server.unreal.GetGameType().default.gameDifficulty = _server.unreal.GetGameType().default.gameDifficulty = storedGameDifficulty;
default.storedGameDifficulty; isServerTraveling = false;
default.isServerTraveling = false; SaveConfig();
return GetConfigFromString(targetGameMode); return GetConfigFromString(targetGameMode);
} }

Loading…
Cancel
Save