diff --git a/sources/GameModes/BaseGameMode.uc b/sources/GameModes/BaseGameMode.uc index 80c7027..7f7b309 100644 --- a/sources/GameModes/BaseGameMode.uc +++ b/sources/GameModes/BaseGameMode.uc @@ -28,7 +28,7 @@ * along with Acedia. If not, see . */ class BaseGameMode extends AcediaConfig - dependson(CoreService) + dependson(Packages) abstract; // Name of the game mode players will see in voting (formatted string) @@ -205,7 +205,7 @@ public function Text GetDifficulty() * actually exist. */ public function ReportIncorrectSettings( - array featuresToEnable) + array featuresToEnable) { local int i; local array featureNames, featuresToReplace; @@ -298,7 +298,7 @@ private function ValidateFeatureArray( * Otherwise it should be enabled with a specified config. */ public function UpdateFeatureArray( - out array featuresToEnable) + out array featuresToEnable) { local int i; local Text newConfigName; diff --git a/sources/Packages.uc b/sources/Packages.uc index 91cd66a..efe5251 100644 --- a/sources/Packages.uc +++ b/sources/Packages.uc @@ -20,7 +20,6 @@ * along with Acedia. If not, see . */ class Packages extends Mutator - dependson(CoreService) config(Acedia); // 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 private LoggerAPI.Definition infoFeatureEnabled; +var private LoggerAPI.Definition errNoServerLevelCore, errorCannotRunTests; + +struct FeatureConfigPair +{ + var public class featureClass; + var public Text configName; +}; static public final function Packages GetInstance() { @@ -54,8 +60,10 @@ static public final function Packages GetInstance() // "Constructor" event PreBeginPlay() { - local GameMode currentGameMode; - local array availableFeatures; + local int i; + local LevelCore serverCore; + local GameMode currentGameMode; + local array availableFeatures; CheckForGarbage(); // Enforce one copy rule and remember a reference to that copy if (default.selfReference != none) @@ -65,12 +73,25 @@ event PreBeginPlay() } default.selfReference = self; // Launch and setup core Acedia - class'CoreService'.static.LaunchAcedia(self, package); + serverCore = class'ServerLevelCore'.static.CreateLevelCore(self); _ = 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(); // Determine required features and launch them - availableFeatures = CoreService(class'CoreService'.static.GetInstance()) - .GetAutoConfigurationInfo(); + availableFeatures = GetAutoConfigurationInfo(); if (useGameModes) { votingAdapter = VotingHandlerAdapter( @@ -95,7 +116,8 @@ function ServerTraveling(string URL, bool bItems) votingAdapter = none; } default.selfReference = none; - CoreService(class'CoreService'.static.GetInstance()).ShutdownAcedia(); + _.environment.DisableAllFeatures(); + class'UnrealService'.static.Require().Destroy(); if (nextMutator != none) { nextMutator.ServerTraveling(URL, bItems); } @@ -134,7 +156,25 @@ private function CheckForGarbage() } } -private function EnableFeatures(array features) +public final function array GetAutoConfigurationInfo() +{ + local int i; + local array< class > availableFeatures; + local FeatureConfigPair nextPair; + local array 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 features) { local int i; for (i = 0; i < features.length; i += 1) @@ -161,6 +201,23 @@ private function SetupMutatorSignals() 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. */ @@ -198,5 +255,7 @@ defaultproperties GroupName = "Package loader" FriendlyName = "Acedia loader" 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.") } \ No newline at end of file