From e1d61ed7e897984091e9e7c9638300beec843362 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 25 Jul 2022 02:52:03 +0700 Subject: [PATCH 1/4] Change to use new `TextAPI.IntoString()` name --- sources/VotingHandlerAdapter.uc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sources/VotingHandlerAdapter.uc b/sources/VotingHandlerAdapter.uc index bb73010..c9c3363 100644 --- a/sources/VotingHandlerAdapter.uc +++ b/sources/VotingHandlerAdapter.uc @@ -139,10 +139,10 @@ private function VotingHandler.MapVoteGameConfig BuildVotingHandlerConfig( GameMode gameMode) { local VotingHandler.MapVoteGameConfig result; - result.gameClass = _.text.ToString(gameMode.GetGameTypeClass()); + result.gameClass = _.text.IntoString(gameMode.GetGameTypeClass()); result.gameName = _.text.ToColoredString(gameMode.GetTitle()); - result.prefix = _.text.ToString(gameMode.GetMapPrefix()); - result.acronym = _.text.ToString(gameMode.GetAcronym()); + result.prefix = _.text.IntoString(gameMode.GetMapPrefix()); + result.acronym = _.text.IntoString(gameMode.GetAcronym()); result.mutators = BuildMutatorString(gameMode); result.options = BuildOptionsString(gameMode); return result; @@ -159,7 +159,7 @@ private function string BuildMutatorString(GameMode gameMode) if (i > 0) { result $= ","; } - result $= _.text.ToString(usedMutators[i]); + result $= _.text.IntoString(usedMutators[i]); } return result; } @@ -174,8 +174,8 @@ private function string BuildOptionsString(GameMode gameMode) options = gameMode.GetOptions(); for (iter = options.Iterate(); !iter.HasFinished(); iter.Next()) { - nextKey = _.text.ToString(Text(iter.GetKey())); - nextValue = _.text.ToString(Text(iter.Get())); + nextKey = _.text.IntoString(Text(iter.GetKey())); + nextValue = _.text.IntoString(Text(iter.Get())); if (optionWasAdded) { result $= "?"; } @@ -285,7 +285,7 @@ private final function int GetNumericDifficulty(GameMode gameMode) { local int i; local string difficulty; - difficulty = Locs(_.text.ToString(gameMode.GetDifficulty())); + difficulty = Locs(_.text.IntoString(gameMode.GetDifficulty())); for (i = 0; i < default.beginnerSynonyms.length; i += 1) { if (IsPrefixOf(difficulty, default.beginnerSynonyms[i])) { From 925f9a100d41f1b3eda1963173f276a1cde401e4 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Wed, 3 Aug 2022 10:29:54 +0700 Subject: [PATCH 2/4] Change `LevelCore`s to be loaded after base API --- sources/Packages.uc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sources/Packages.uc b/sources/Packages.uc index e87d703..90a8052 100644 --- a/sources/Packages.uc +++ b/sources/Packages.uc @@ -81,9 +81,8 @@ private simulated function InitializeClient() return; } default.selfReference = self; - // TODO: Swap these around after dealing with aliases - class'ClientLevelCore'.static.CreateLevelCore(self); _ = class'Global'.static.GetInstance(); + class'ClientLevelCore'.static.CreateLevelCore(self); } private function InitializeServer() @@ -104,11 +103,10 @@ private function InitializeServer() } default.selfReference = self; // Launch and setup core Acedia - // TODO: Swap these around after dealing with aliases - serverCore = class'ServerLevelCore'.static.CreateLevelCore(self); _ = class'Global'.static.GetInstance(); _server = class'ServerGlobal'.static.GetInstance(); _client = class'ClientGlobal'.static.GetInstance(); + serverCore = class'ServerLevelCore'.static.CreateLevelCore(self); for (i = 0; i < package.length; i += 1) { _.environment.RegisterPackage_S(package[i]); } From 6a13c509a20a78f62599f8696e94851e2e3478d3 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 8 Aug 2022 04:54:52 +0700 Subject: [PATCH 3/4] Remove `selfReference` from `Packages` mutator This variable didn't serve any really useful purpose, but has led to game crashes. While adding proper cleanup could also solve these crashes, there is no real point to keeping it at all. NOTE: It's only purpose was to make sure only one instance of corresponding mutator exists, but duplicates shouldn't happen in the first place. --- sources/Packages.uc | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/sources/Packages.uc b/sources/Packages.uc index 90a8052..58c11eb 100644 --- a/sources/Packages.uc +++ b/sources/Packages.uc @@ -22,13 +22,6 @@ class Packages extends Mutator config(Acedia); -// Default value of this variable will be used to store -// reference to the active Acedia mutator, -// as well as to ensure there's only one copy of it. -// We can't use 'Singleton' class for that, -// as we have to derive from 'Mutator'. -var private Packages selfReference; - // Acedia's reference to a `Global` object. var private Global _; var private ServerGlobal _server; @@ -56,11 +49,6 @@ struct FeatureConfigPair var public Text configName; }; -static public final function Packages GetInstance() -{ - return default.selfReference; -} - // "Constructor" simulated function PreBeginPlay() { @@ -74,13 +62,6 @@ simulated function PreBeginPlay() private simulated function InitializeClient() { - // Enforce one copy rule and remember a reference to that copy - if (default.selfReference != none) - { - Destroy(); - return; - } - default.selfReference = self; _ = class'Global'.static.GetInstance(); class'ClientLevelCore'.static.CreateLevelCore(self); } @@ -95,13 +76,6 @@ private function InitializeServer() AddToPackageMap("Acedia"); } CheckForGarbage(); - // Enforce one copy rule and remember a reference to that copy - if (default.selfReference != none) - { - Destroy(); - return; - } - default.selfReference = self; // Launch and setup core Acedia _ = class'Global'.static.GetInstance(); _server = class'ServerGlobal'.static.GetInstance(); @@ -147,7 +121,6 @@ function ServerTraveling(string URL, bool bItems) _.memory.Free(votingAdapter); votingAdapter = none; } - default.selfReference = none; _.environment.ShutDown(); if (nextMutator != none) { nextMutator.ServerTraveling(URL, bItems); From 8583bef23d2513cd7ff02acb67e81ddd72e72186 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 8 Aug 2022 13:20:02 +0700 Subject: [PATCH 4/4] Fix formatting --- sources/GameModes/BaseGameMode.uc | 26 +++++++++++++++++++------- sources/GameModes/GameMode.uc | 6 +++++- sources/Packages.uc | 8 +++++++- sources/StartUp.uc | 2 +- sources/VotingHandlerAdapter.uc | 13 ++++++++++--- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/sources/GameModes/BaseGameMode.uc b/sources/GameModes/BaseGameMode.uc index 04b29f6..cb7d8fe 100644 --- a/sources/GameModes/BaseGameMode.uc +++ b/sources/GameModes/BaseGameMode.uc @@ -10,7 +10,7 @@ * be used based on game info's settings; * 3. `Report...()` methods that perform various validation checks * (and log them) on config data. - * Copyright 2021 Anton Tarasenko + * Copyright 2021-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -101,6 +101,7 @@ protected function FromData(HashTable source) local int i; local ArrayList nextArray; local HashTable nextPair; + if (source == none) { return; } @@ -133,6 +134,7 @@ private final function FeatureConfigPair HashTableIntoPair(HashTable source) { local Text nextText; local FeatureConfigPair result; + if (source == none) { return result; } @@ -152,6 +154,7 @@ private final function array DynamicIntoStringArray(ArrayList source) local int i; local Text nextText; local array result; + if (source == none) { return result; } @@ -168,6 +171,7 @@ protected function array StringToTextArray(array input) { local int i; local array result; + for (i = 0; i < input.length; i += 1) { result[i] = _.text.FromString(input[i]); } @@ -209,8 +213,9 @@ public function Text GetDifficulty() public function ReportIncorrectSettings( array featuresToEnable) { - local int i; + local int i; local array featureNames, featuresToReplace; + for (i = 0; i < featuresToEnable.length; i += 1) { featureNames[i] = string(featuresToEnable[i].featureClass); } @@ -233,6 +238,7 @@ public function ReportIncorrectSettings( public function ReportBadMutatorNames() { local int i; + for (i = 0; i < includeMutator.length; i += 1) { if (!ValidateServerURLName(includeMutator[i])) @@ -266,8 +272,9 @@ private function ValidateFeatureArray( array whole, string arrayName) { - local int i, j; - local bool foundItem; + local int i, j; + local bool foundItem; + for (i = 0; i < subset.length; i += 1) { foundItem = false; @@ -302,9 +309,10 @@ private function ValidateFeatureArray( public function UpdateFeatureArray( out array featuresToEnable) { - local int i; - local Text newConfigName; - local string nextFeatureClassName; + local int i; + local Text newConfigName; + local string nextFeatureClassName; + for (i = 0; i < featuresToEnable.length; i += 1) { nextFeatureClassName = string(featuresToEnable[i].featureClass); @@ -334,6 +342,7 @@ public function UpdateFeatureArray( private function bool FeatureExcluded(string featureClassName) { local int i; + for (i = 0; i < excludeFeature.length; i += 1) { if (excludeFeature[i] ~= featureClassName) { @@ -346,6 +355,7 @@ private function bool FeatureExcluded(string featureClassName) private function Text TryReplacingFeatureConfig(string featureClassName) { local int i; + for (i = 0; i < includeFeatureAs.length; i += 1) { if (includeFeatureAs[i].feature ~= featureClassName) { @@ -358,6 +368,7 @@ private function Text TryReplacingFeatureConfig(string featureClassName) private function bool FeatureInIncludedArray(string featureClassName) { local int i; + for (i = 0; i < includeFeature.length; i += 1) { if (includeFeature[i] ~= featureClassName) { @@ -371,6 +382,7 @@ public function array GetIncludedMutators() { local int i; local array validatedMutators; + for (i = 0; i < includeMutator.length; i += 1) { if (ValidateServerURLName(includeMutator[i])) { diff --git a/sources/GameModes/GameMode.uc b/sources/GameModes/GameMode.uc index 7c869be..e314ec3 100644 --- a/sources/GameModes/GameMode.uc +++ b/sources/GameModes/GameMode.uc @@ -1,7 +1,7 @@ /** * The only implementation for `BaseGameMode` suitable for standard * killing floor game types. - * Copyright 2021 Anton Tarasenko + * Copyright 2021-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -59,6 +59,7 @@ protected function HashTable ToData() local int i; local ArrayList nextArray; local HashTable result, nextPair; + result = super.ToData(); if (result == none) { return none; @@ -86,6 +87,7 @@ protected function FromData(HashTable source) local GameOption nextGameOption; local ArrayList nextArray; local HashTable nextPair; + super.FromData(source); if (source == none) { return; @@ -153,6 +155,7 @@ public function Text GetMapPrefix() public function ReportBadOptions() { local int i; + for (i = 0; i < option.length; i += 1) { if ( !ValidateServerURLName(option[i].key) @@ -173,6 +176,7 @@ public function HashTable GetOptions() { local int i; local HashTable result; + result = _.collections.EmptyHashTable(); for (i = 0; i < option.length; i += 1) { diff --git a/sources/Packages.uc b/sources/Packages.uc index 58c11eb..d35e0e5 100644 --- a/sources/Packages.uc +++ b/sources/Packages.uc @@ -72,6 +72,7 @@ private function InitializeServer() local LevelCore serverCore; local GameMode currentGameMode; local array availableFeatures; + if (clientside) { AddToPackageMap("Acedia"); } @@ -132,10 +133,13 @@ function ServerTraveling(string URL, bool bItems) // This can lead to serious problems, so such diagnostic check is warranted. private function CheckForGarbage() { - local int leftoverObjectAmount, leftoverActorAmount, leftoverDBRAmount; + local int leftoverObjectAmount; + local int leftoverActorAmount; + local int leftoverDBRAmount; local AcediaObject nextObject; local AcediaActor nextActor; local DBRecord nextRecord; + foreach AllObjects(class'AcediaObject', nextObject) { leftoverObjectAmount += 1; } @@ -181,6 +185,7 @@ public final function array GetAutoConfigurationInfo() private function EnableFeatures(array features) { local int i; + for (i = 0; i < features.length; i += 1) { if (features[i].featureClass == none) continue; @@ -196,6 +201,7 @@ private function EnableFeatures(array features) private function SetupMutatorSignals() { local ServerUnrealService service; + service = ServerUnrealService(class'ServerUnrealService'.static.Require()); onMutateSignal = Mutator_OnMutate_Signal( service.GetSignal(class'Mutator_OnMutate_Signal')); diff --git a/sources/StartUp.uc b/sources/StartUp.uc index ac40796..0755d39 100644 --- a/sources/StartUp.uc +++ b/sources/StartUp.uc @@ -1,6 +1,6 @@ /** * This actor's role is to add Acedia mutator on listen and dedicated servers. - * Copyright 2019 Anton Tarasenko + * Copyright 2019-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * diff --git a/sources/VotingHandlerAdapter.uc b/sources/VotingHandlerAdapter.uc index c9c3363..69b72ec 100644 --- a/sources/VotingHandlerAdapter.uc +++ b/sources/VotingHandlerAdapter.uc @@ -5,7 +5,7 @@ * data from Acedia's game modes. * Requires `GameInfo`'s voting handler to be derived from * `XVotingHandler`, which is satisfied by pretty much every used handler. - * Copyright 2021 Anton Tarasenko + * Copyright 2021-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -109,6 +109,7 @@ public final function InjectIntoVotingHandler() local GameMode nextGameMode; local XVotingHandler votingHandler; local array newVotingHandlerConfig; + if (votingHandlerReference != none) { return; } @@ -139,6 +140,7 @@ private function VotingHandler.MapVoteGameConfig BuildVotingHandlerConfig( GameMode gameMode) { local VotingHandler.MapVoteGameConfig result; + result.gameClass = _.text.IntoString(gameMode.GetGameTypeClass()); result.gameName = _.text.ToColoredString(gameMode.GetTitle()); result.prefix = _.text.IntoString(gameMode.GetMapPrefix()); @@ -153,6 +155,7 @@ private function string BuildMutatorString(GameMode gameMode) local int i; local string result; local array usedMutators; + usedMutators = gameMode.GetIncludedMutators(); for (i = 0; i < usedMutators.length; i += 1) { @@ -171,6 +174,7 @@ private function string BuildOptionsString(GameMode gameMode) local string nextKey, nextValue; local CollectionIterator iter; local HashTable options; + options = gameMode.GetOptions(); for (iter = options.Iterate(); !iter.HasFinished(); iter.Next()) { @@ -197,6 +201,7 @@ public final function PrepareForServerTravel() local string nextGameClassName; local class nextGameClass; local XVotingHandler votingHandler; + if (votingHandlerReference == none) return; votingHandler = XVotingHandler(votingHandlerReference.Get()); if (votingHandler == none) return; @@ -259,6 +264,7 @@ public final function GameMode SetupGameModeAfterTravel() public final function RestoreVotingHandlerConfigBackup() { local XVotingHandler votingHandler; + if (votingHandlerReference == none) return; votingHandler = XVotingHandler(votingHandlerReference.Get()); if (votingHandler == none) return; @@ -283,8 +289,9 @@ private function GameMode GetConfigFromString(string configName) // KF's numeric one. private final function int GetNumericDifficulty(GameMode gameMode) { - local int i; - local string difficulty; + local int i; + local string difficulty; + difficulty = Locs(_.text.IntoString(gameMode.GetDifficulty())); for (i = 0; i < default.beginnerSynonyms.length; i += 1) {