From 0bb7f8904036369d26e590f104a1f59bcd26f0b7 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Tue, 12 Jul 2022 04:49:37 +0700 Subject: [PATCH] Change to support new AcediaCore changes --- sources/Packages.uc | 45 ++++++++++++++++++++++++++++----- sources/VotingHandlerAdapter.uc | 6 +++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/sources/Packages.uc b/sources/Packages.uc index 2bd5d4a..cfe9ce4 100644 --- a/sources/Packages.uc +++ b/sources/Packages.uc @@ -2,7 +2,7 @@ * Main and only Acedia mutator used for loading Acedia packages * and providing access to mutator events' calls. * Name is chosen to make config files more readable. - * Copyright 2020-2021 Anton Tarasenko + * Copyright 2020-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -30,8 +30,12 @@ class Packages extends Mutator var private Packages selfReference; // Acedia's reference to a `Global` object. -var private Global _; +var private Global _; +var private ServerGlobal _server; +var private ClientGlobal _client; +// Load Acedia on the client as well? +var private config bool clientside; // Array of predefined services that must be started along with Acedia mutator. var private config array package; // Set to `true` to activate Acedia's game modes system @@ -58,12 +62,38 @@ static public final function Packages GetInstance() } // "Constructor" -event PreBeginPlay() +simulated function PreBeginPlay() +{ + if (level.netMode == NM_DedicatedServer) { + InitializeServer(); + } + else { + InitializeClient(); + } +} + +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'ClientLevelCore'.static.CreateLevelCore(self); + _ = class'Global'.static.GetInstance(); +} + +private function InitializeServer() { local int i; local LevelCore serverCore; local GameMode currentGameMode; local array availableFeatures; + if (clientside) { + AddToPackageMap("Acedia"); + } CheckForGarbage(); // Enforce one copy rule and remember a reference to that copy if (default.selfReference != none) @@ -74,12 +104,14 @@ event PreBeginPlay() default.selfReference = self; // Launch and setup core Acedia serverCore = class'ServerLevelCore'.static.CreateLevelCore(self); - _ = class'Global'.static.GetInstance(); + _ = class'Global'.static.GetInstance(); + _server = class'ServerGlobal'.static.GetInstance(); + _client = class'ClientGlobal'.static.GetInstance(); for (i = 0; i < package.length; i += 1) { _.environment.RegisterPackage_S(package[i]); } if (serverCore != none) { - _.ConnectServerLevelCore(); + _server.ConnectServerLevelCore(); } else { @@ -248,9 +280,10 @@ function ModifyLogin(out string portal, out string options) defaultproperties { + clientside = false useGameModes = false // This is a server-only mutator - remoteRole = ROLE_None + remoteRole = ROLE_SimulatedProxy bAlwaysRelevant = true // Mutator description GroupName = "Package loader" diff --git a/sources/VotingHandlerAdapter.uc b/sources/VotingHandlerAdapter.uc index 7e02f9c..89c89ee 100644 --- a/sources/VotingHandlerAdapter.uc +++ b/sources/VotingHandlerAdapter.uc @@ -223,8 +223,10 @@ public final function PrepareForServerTravel() if (string(_.unreal.GetGameType().class) ~= nextGameClassName) { nextGameClass = _.unreal.GetGameType().class; } - else { - nextGameClass = class(_.memory.LoadClassS(nextGameClassName)); + else + { + nextGameClass = + class(_.memory.LoadClass_S(nextGameClassName)); } default.isServerTraveling = true; default.targetGameMode = availableGameModes[pickedVHConfig].ToString();