Browse Source

Fix launcher not adding `Feature`s through game types

develop
Anton Tarasenko 2 years ago
parent
commit
bb936f5e76
  1. 5
      sources/AcediaLauncherMut.uc
  2. 93
      sources/GameModes/BaseGameMode.uc
  3. 36
      sources/StartUp.uc
  4. 1
      sources/VotingHandlerAdapter.uc

5
sources/AcediaLauncherMut.uc

@ -34,6 +34,7 @@ simulated function PreBeginPlay()
{ {
local StartUp startUpActor; local StartUp startUpActor;
_ = class'Global'.static.GetInstance();
if (level.netMode == NM_DedicatedServer) if (level.netMode == NM_DedicatedServer)
{ {
foreach AllActors(class'StartUp', startUpActor) foreach AllActors(class'StartUp', startUpActor)
@ -47,9 +48,7 @@ simulated function PreBeginPlay()
} }
SetupMutatorSignals(); SetupMutatorSignals();
} }
else else {
{
_ = class'Global'.static.GetInstance();
class'ClientLevelCore'.static.CreateLevelCore(self); class'ClientLevelCore'.static.CreateLevelCore(self);
} }
} }

93
sources/GameModes/BaseGameMode.uc

@ -322,69 +322,84 @@ private function ValidateFeatureArray(
public function UpdateFeatureArray( public function UpdateFeatureArray(
out array<Packages.FeatureConfigPair> featuresToEnable) out array<Packages.FeatureConfigPair> featuresToEnable)
{ {
local int i; local int i;
local Text newConfigName; local HashTable includedFeaturesMap;
local string nextFeatureClassName; local Text nextKey, nextConfig;
local string nextFeatureClassName;
for (i = 0; i < featuresToEnable.length; i += 1) local CollectionIterator iter;
local Packages.FeatureConfigPair newPair;
// Exclude features we're told to exclude
while (i < featuresToEnable.length)
{ {
nextFeatureClassName = string(featuresToEnable[i].featureClass); nextFeatureClassName = string(featuresToEnable[i].featureClass);
// `excludeFeature` if (IsFeatureExcluded(nextFeatureClassName))
if (FeatureExcluded(nextFeatureClassName))
{ {
_.memory.Free(featuresToEnable[i].configName); _.memory.Free(featuresToEnable[i].configName);
featuresToEnable[i].configName = none; featuresToEnable.Remove(i, 1);
continue;
} }
// `includeFeatureAs` else {
newConfigName = TryReplacingFeatureConfig(nextFeatureClassName); i += 1;
if (newConfigName != none)
{
_.memory.Free(featuresToEnable[i].configName);
featuresToEnable[i].configName = newConfigName;
} }
// `includeFeature` }
if ( featuresToEnable[i].configName == none // Rewrite auto-enabled configs if different config was specified
&& FeatureInIncludedArray(nextFeatureClassName)) includedFeaturesMap = BuildIncludedFeaturesMap();
for (i = 0; i < featuresToEnable.length; i += 1)
{
nextKey =
_.text.FromString(Locs(string(featuresToEnable[i].featureClass)));
nextConfig = Text(includedFeaturesMap.TakeItem(nextKey));
if (nextConfig != none)
{ {
featuresToEnable[i].configName = P("default").Copy(); _.memory.Free(featuresToEnable[i].configName);
featuresToEnable[i].configName = nextConfig;
} }
nextKey.FreeSelf();
} }
} // Add features that are included, but weren't auto-enabled in
// the first place
private function bool FeatureExcluded(string featureClassName) for (iter = includedFeaturesMap.Iterate(); !iter.HasFinished(); iter.Next())
{
local int i;
for (i = 0; i < excludeFeature.length; i += 1)
{ {
if (excludeFeature[i] ~= featureClassName) { nextKey = Text(iter.GetKey());
return true; newPair.featureClass = class<Feature>(_.memory.LoadClass(nextKey));
} newPair.configName = Text(iter.Get());
nextKey.FreeSelf();
featuresToEnable[featuresToEnable.length] = newPair;
} }
return false; includedFeaturesMap.FreeSelf();
} }
private function Text TryReplacingFeatureConfig(string featureClassName) private function HashTable BuildIncludedFeaturesMap()
{ {
local int i; local int i;
local Text nextKey;
local HashTable result;
result = _.collections.EmptyHashTable();
// First fill `HashTable` with non-specified conmfigs from `includeFeature`
for (i = 0; i < includeFeature.length; i += 1)
{
nextKey = _.text.FromString(Locs(includeFeature[i]));
result.SetItem(nextKey, none);
nextKey.FreeSelf();
}
// Then add/rewrite configs from `includeFeatureAs`
for (i = 0; i < includeFeatureAs.length; i += 1) for (i = 0; i < includeFeatureAs.length; i += 1)
{ {
if (includeFeatureAs[i].feature ~= featureClassName) { nextKey = _.text.FromString(Locs(includeFeatureAs[i].feature));
return _.text.FromString(includeFeatureAs[i].config); result.SetString(nextKey, Locs(includeFeatureAs[i].config));
} nextKey.FreeSelf();
} }
return none; return result;
} }
private function bool FeatureInIncludedArray(string featureClassName) private function bool IsFeatureExcluded(string featureClassName)
{ {
local int i; local int i;
for (i = 0; i < includeFeature.length; i += 1) for (i = 0; i < excludeFeature.length; i += 1)
{ {
if (includeFeature[i] ~= featureClassName) { if (excludeFeature[i] ~= featureClassName) {
return true; return true;
} }
} }

36
sources/StartUp.uc

@ -79,6 +79,7 @@ private function InitializeServer()
availableFeatures = GetAutoConfigurationInfo(); availableFeatures = GetAutoConfigurationInfo();
if (class'Packages'.default.useGameModes) if (class'Packages'.default.useGameModes)
{ {
class'GameMode'.static.Initialize();
votingAdapter = VotingHandlerAdapter( votingAdapter = VotingHandlerAdapter(
_.memory.Allocate(class'VotingHandlerAdapter')); _.memory.Allocate(class'VotingHandlerAdapter'));
currentGameMode = votingAdapter.SetupGameModeAfterTravel(); currentGameMode = votingAdapter.SetupGameModeAfterTravel();
@ -127,6 +128,7 @@ private function CheckForGarbage()
public function array<Packages.FeatureConfigPair> GetAutoConfigurationInfo() public function array<Packages.FeatureConfigPair> GetAutoConfigurationInfo()
{ {
local int i; local int i;
local Text autoConfig;
local array< class<Feature> > availableFeatures; local array< class<Feature> > availableFeatures;
local Packages.FeatureConfigPair nextPair; local Packages.FeatureConfigPair nextPair;
local array<Packages.FeatureConfigPair> result; local array<Packages.FeatureConfigPair> result;
@ -134,27 +136,43 @@ public function array<Packages.FeatureConfigPair> GetAutoConfigurationInfo()
availableFeatures = _.environment.GetAvailableFeatures(); availableFeatures = _.environment.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i += 1) for (i = 0; i < availableFeatures.length; i += 1)
{ {
nextPair.featureClass = availableFeatures[i]; autoConfig = availableFeatures[i].static.GetAutoEnabledConfig();
nextPair.configName = availableFeatures[i].static if (autoConfig != none)
.GetAutoEnabledConfig(); {
result[result.length] = nextPair; nextPair.featureClass = availableFeatures[i];
nextPair.configName = autoConfig;
result[result.length] = nextPair;
}
} }
return result; return result;
} }
private function EnableFeatures(array<Packages.FeatureConfigPair> features) private function EnableFeatures(array<Packages.FeatureConfigPair> features)
{ {
local int i; local int i;
local Text defaultConfigName;
local Text nextConfigName;
defaultConfigName = _.text.FromString("default");
for (i = 0; i < features.length; i += 1) for (i = 0; i < features.length; i += 1)
{ {
if (features[i].featureClass == none) continue; if (features[i].featureClass == none) {
if (features[i].configName == none) continue; continue;
features[i].featureClass.static.EnableMe(features[i].configName); }
// `configName` being `none` here means that config name was not
// specified through config and we should fallback to "default"
if (features[i].configName == none) {
nextConfigName = defaultConfigName.Copy();
}
else {
nextConfigName = features[i].configName.Copy();
}
features[i].featureClass.static.EnableMe(nextConfigName);
_.logger.Auto(infoFeatureEnabled) _.logger.Auto(infoFeatureEnabled)
.Arg(_.text.FromString(string(features[i].featureClass))) .Arg(_.text.FromString(string(features[i].featureClass)))
.Arg(features[i].configName); // consumes `configName` .Arg(nextConfigName); // consumes `nextConfigName`
} }
defaultConfigName.FreeSelf();
} }
private final function RunStartUpTests() private final function RunStartUpTests()

1
sources/VotingHandlerAdapter.uc

@ -120,7 +120,6 @@ public final function InjectIntoVotingHandler()
return; return;
} }
votingHandlerReference = _server.unreal.ActorRef(votingHandler); votingHandlerReference = _server.unreal.ActorRef(votingHandler);
class'GameMode'.static.Initialize();
availableGameModes = class'GameMode'.static.AvailableConfigs(); availableGameModes = class'GameMode'.static.AvailableConfigs();
for (i = 0; i < availableGameModes.length; i += 1) for (i = 0; i < availableGameModes.length; i += 1)
{ {

Loading…
Cancel
Save