Browse Source

Change to account for AcediaCore's refactor

develop
Anton Tarasenko 2 years ago
parent
commit
824a6e270a
  1. 6
      sources/GameModes/BaseGameMode.uc
  2. 77
      sources/Packages.uc

6
sources/GameModes/BaseGameMode.uc

@ -28,7 +28,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. * along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/ */
class BaseGameMode extends AcediaConfig class BaseGameMode extends AcediaConfig
dependson(CoreService) dependson(Packages)
abstract; abstract;
// Name of the game mode players will see in voting (formatted string) // Name of the game mode players will see in voting (formatted string)
@ -205,7 +205,7 @@ public function Text GetDifficulty()
* actually exist. * actually exist.
*/ */
public function ReportIncorrectSettings( public function ReportIncorrectSettings(
array<CoreService.FeatureConfigPair> featuresToEnable) array<Packages.FeatureConfigPair> featuresToEnable)
{ {
local int i; local int i;
local array<string> featureNames, featuresToReplace; local array<string> featureNames, featuresToReplace;
@ -298,7 +298,7 @@ private function ValidateFeatureArray(
* Otherwise it should be enabled with a specified config. * Otherwise it should be enabled with a specified config.
*/ */
public function UpdateFeatureArray( public function UpdateFeatureArray(
out array<CoreService.FeatureConfigPair> featuresToEnable) out array<Packages.FeatureConfigPair> featuresToEnable)
{ {
local int i; local int i;
local Text newConfigName; local Text newConfigName;

77
sources/Packages.uc

@ -20,7 +20,6 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. * along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/ */
class Packages extends Mutator class Packages extends Mutator
dependson(CoreService)
config(Acedia); config(Acedia);
// Default value of this variable will be used to store // Default value of this variable will be used to store
@ -45,6 +44,13 @@ var Mutator_OnModifyLogin_Signal onModifyLoginSignal;
var Mutator_OnCheckReplacement_Signal onCheckReplacementSignal; var Mutator_OnCheckReplacement_Signal onCheckReplacementSignal;
var private LoggerAPI.Definition infoFeatureEnabled; var private LoggerAPI.Definition infoFeatureEnabled;
var private LoggerAPI.Definition errNoServerLevelCore, errorCannotRunTests;
struct FeatureConfigPair
{
var public class<Feature> featureClass;
var public Text configName;
};
static public final function Packages GetInstance() static public final function Packages GetInstance()
{ {
@ -54,8 +60,10 @@ static public final function Packages GetInstance()
// "Constructor" // "Constructor"
event PreBeginPlay() event PreBeginPlay()
{ {
local GameMode currentGameMode; local int i;
local array<CoreService.FeatureConfigPair> availableFeatures; local LevelCore serverCore;
local GameMode currentGameMode;
local array<FeatureConfigPair> availableFeatures;
CheckForGarbage(); CheckForGarbage();
// Enforce one copy rule and remember a reference to that copy // Enforce one copy rule and remember a reference to that copy
if (default.selfReference != none) if (default.selfReference != none)
@ -65,12 +73,25 @@ event PreBeginPlay()
} }
default.selfReference = self; default.selfReference = self;
// Launch and setup core Acedia // Launch and setup core Acedia
class'CoreService'.static.LaunchAcedia(self, package); serverCore = class'ServerLevelCore'.static.CreateLevelCore(self);
_ = class'Global'.static.GetInstance(); _ = class'Global'.static.GetInstance();
for (i = 0; i < package.length; i += 1) {
_.environment.RegisterPackage_S(package[i]);
}
if (serverCore != none) {
_.ConnectServerLevelCore();
}
else
{
_.logger.Auto(errNoServerLevelCore);
return;
}
if (class'TestingService'.default.runTestsOnStartUp) {
RunStartUpTests();
}
SetupMutatorSignals(); SetupMutatorSignals();
// Determine required features and launch them // Determine required features and launch them
availableFeatures = CoreService(class'CoreService'.static.GetInstance()) availableFeatures = GetAutoConfigurationInfo();
.GetAutoConfigurationInfo();
if (useGameModes) if (useGameModes)
{ {
votingAdapter = VotingHandlerAdapter( votingAdapter = VotingHandlerAdapter(
@ -95,7 +116,8 @@ function ServerTraveling(string URL, bool bItems)
votingAdapter = none; votingAdapter = none;
} }
default.selfReference = none; default.selfReference = none;
CoreService(class'CoreService'.static.GetInstance()).ShutdownAcedia(); _.environment.DisableAllFeatures();
class'UnrealService'.static.Require().Destroy();
if (nextMutator != none) { if (nextMutator != none) {
nextMutator.ServerTraveling(URL, bItems); nextMutator.ServerTraveling(URL, bItems);
} }
@ -134,7 +156,25 @@ private function CheckForGarbage()
} }
} }
private function EnableFeatures(array<CoreService.FeatureConfigPair> features) public final function array<FeatureConfigPair> GetAutoConfigurationInfo()
{
local int i;
local array< class<Feature> > availableFeatures;
local FeatureConfigPair nextPair;
local array<FeatureConfigPair> result;
availableFeatures = _.environment.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i += 1)
{
nextPair.featureClass = availableFeatures[i];
nextPair.configName = availableFeatures[i].static
.GetAutoEnabledConfig();
result[result.length] = nextPair;
}
return result;
}
private function EnableFeatures(array<FeatureConfigPair> features)
{ {
local int i; local int i;
for (i = 0; i < features.length; i += 1) for (i = 0; i < features.length; i += 1)
@ -161,6 +201,23 @@ private function SetupMutatorSignals()
service.GetSignal(class'Mutator_OnCheckReplacement_Signal')); service.GetSignal(class'Mutator_OnCheckReplacement_Signal'));
} }
private final function RunStartUpTests()
{
local TestingService testService;
testService = TestingService(class'TestingService'.static.Require());
testService.PrepareTests();
if (testService.filterTestsByName) {
testService.FilterByName(testService.requiredName);
}
if (testService.filterTestsByGroup) {
testService.FilterByGroup(testService.requiredGroup);
}
if (!testService.Run()) {
_.logger.Auto(errorCannotRunTests);
}
}
/** /**
* Below `Mutator` events are redirected into appropriate signals. * Below `Mutator` events are redirected into appropriate signals.
*/ */
@ -198,5 +255,7 @@ defaultproperties
GroupName = "Package loader" GroupName = "Package loader"
FriendlyName = "Acedia loader" FriendlyName = "Acedia loader"
Description = "Launcher for Acedia packages" Description = "Launcher for Acedia packages"
infoFeatureEnabled = (l=LOG_Info,m="Feature `%1` enabled with config \"%2\".") infoFeatureEnabled = (l=LOG_Info,m="Feature `%1` enabled with config \"%2\".")
errNoServerLevelCore = (l=LOG_Error,m="Cannot create `ServerLevelCore`!")
errorCannotRunTests = (l=LOG_Error,m="Could not perform Acedia's tests.")
} }
Loading…
Cancel
Save