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. 83
      sources/GameModes/BaseGameMode.uc
  3. 30
      sources/StartUp.uc
  4. 1
      sources/VotingHandlerAdapter.uc

5
sources/AcediaLauncherMut.uc

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

83
sources/GameModes/BaseGameMode.uc

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

30
sources/StartUp.uc

@ -79,6 +79,7 @@ private function InitializeServer()
availableFeatures = GetAutoConfigurationInfo();
if (class'Packages'.default.useGameModes)
{
class'GameMode'.static.Initialize();
votingAdapter = VotingHandlerAdapter(
_.memory.Allocate(class'VotingHandlerAdapter'));
currentGameMode = votingAdapter.SetupGameModeAfterTravel();
@ -127,34 +128,51 @@ private function CheckForGarbage()
public function array<Packages.FeatureConfigPair> GetAutoConfigurationInfo()
{
local int i;
local Text autoConfig;
local array< class<Feature> > availableFeatures;
local Packages.FeatureConfigPair nextPair;
local array<Packages.FeatureConfigPair> result;
availableFeatures = _.environment.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i += 1)
{
autoConfig = availableFeatures[i].static.GetAutoEnabledConfig();
if (autoConfig != none)
{
nextPair.featureClass = availableFeatures[i];
nextPair.configName = availableFeatures[i].static
.GetAutoEnabledConfig();
nextPair.configName = autoConfig;
result[result.length] = nextPair;
}
}
return result;
}
private function EnableFeatures(array<Packages.FeatureConfigPair> features)
{
local int i;
local Text defaultConfigName;
local Text nextConfigName;
defaultConfigName = _.text.FromString("default");
for (i = 0; i < features.length; i += 1)
{
if (features[i].featureClass == none) continue;
if (features[i].configName == none) continue;
features[i].featureClass.static.EnableMe(features[i].configName);
if (features[i].featureClass == none) {
continue;
}
// `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)
.Arg(_.text.FromString(string(features[i].featureClass)))
.Arg(features[i].configName); // consumes `configName`
.Arg(nextConfigName); // consumes `nextConfigName`
}
defaultConfigName.FreeSelf();
}
private final function RunStartUpTests()

1
sources/VotingHandlerAdapter.uc

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

Loading…
Cancel
Save