diff --git a/sources/CoreRealm/ClientGlobal.uc b/sources/CoreRealm/ClientGlobal.uc new file mode 100644 index 0000000..e4a00ab --- /dev/null +++ b/sources/CoreRealm/ClientGlobal.uc @@ -0,0 +1,45 @@ +/** + * Class for an object that will provide an access to a Acedia's + * client-specific functionality by giving a reference to this object to all + * Acedia's objects and actors, emulating a global API namespace. + * Copyright 2022 Anton Tarasenko + *------------------------------------------------------------------------------ + * This file is part of Acedia. + * + * Acedia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License, or + * (at your option) any later version. + * + * Acedia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Acedia. If not, see . + */ +class ClientGlobal extends Object; + +// `Global` is expected to behave like a singleton and will store it's +// main instance in this variable's default value. +var protected ClientGlobal myself; + +public final static function ClientGlobal GetInstance() +{ + if (default.myself == none) + { + // `...Global`s are special and exist outside main Acedia's + // object infrastructure, so we allocate it without using API methods. + default.myself = new class'ClientGlobal'; + } + return default.myself; +} + +protected function Initialize() +{ +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/sources/CoreRealm/Global.uc b/sources/CoreRealm/Global.uc index 12296b5..5195905 100644 --- a/sources/CoreRealm/Global.uc +++ b/sources/CoreRealm/Global.uc @@ -1,8 +1,8 @@ /** * Class for an object that will provide an access to a Acedia's functionality - * by giving a reference to this object to all Acedia's objects and actors, - * emulating a global API namespace. - * Copyright 2020 - 2021 Anton Tarasenko + * that is common for both clients and servers by giving a reference to this + * object to all Acedia's objects and actors, emulating a global API namespace. + * Copyright 2020-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -50,7 +50,7 @@ var public KFFrontend kf; public final static function Global GetInstance() { if (default.myself == none) { - // `Global` is special and exists outside main Acedia's + // `...Global`s are special and exist outside main Acedia's // object infrastructure, so we allocate it without using API methods. default.myself = new class'Global'; default.myself.Initialize(); diff --git a/sources/CoreRealm/ServerGlobal.uc b/sources/CoreRealm/ServerGlobal.uc new file mode 100644 index 0000000..933ffa1 --- /dev/null +++ b/sources/CoreRealm/ServerGlobal.uc @@ -0,0 +1,45 @@ +/** + * Class for an object that will provide an access to a Acedia's + * server-specific functionality by giving a reference to this object to all + * Acedia's objects and actors, emulating a global API namespace. + * Copyright 2022 Anton Tarasenko + *------------------------------------------------------------------------------ + * This file is part of Acedia. + * + * Acedia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License, or + * (at your option) any later version. + * + * Acedia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Acedia. If not, see . + */ +class ServerGlobal extends Object; + +// `Global` is expected to behave like a singleton and will store it's +// main instance in this variable's default value. +var protected ServerGlobal myself; + +public final static function ServerGlobal GetInstance() +{ + if (default.myself == none) + { + // `...Global`s are special and exist outside main Acedia's + // object infrastructure, so we allocate it without using API methods. + default.myself = new class'ServerGlobal'; + } + return default.myself; +} + +protected function Initialize() +{ +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/sources/Types/AcediaActor.uc b/sources/Types/AcediaActor.uc index f3dbe47..e910bcb 100644 --- a/sources/Types/AcediaActor.uc +++ b/sources/Types/AcediaActor.uc @@ -23,8 +23,10 @@ class AcediaActor extends Actor abstract; -// Reference to Acedia's APIs for simple access. -var protected Global _; +// References to Acedia's APIs for simple access. +var protected Global _; +var protected ServerGlobal _server; +var protected ClientGlobal _client; // To make logic simpler and increase efficiency, we allow storing a reference // to any actors in many different places. To know when we can actually @@ -73,7 +75,9 @@ public function _constructor() if (_isAllocated) return; _isAllocated = true; _refCounter = 1; - _ = class'Global'.static.GetInstance(); + _ = class'Global'.static.GetInstance(); + _server = class'ServerGlobal'.static.GetInstance(); + _client = class'ClientGlobal'.static.GetInstance(); if (!default._staticConstructorWasCalled) { CreateTextCache(); @@ -98,7 +102,9 @@ public function _finalizer() _isAllocated = false; _refCounter = 0; Finalizer(); - _ = none; + _ = none; + _server = none; + _client = none; } /** @@ -409,6 +415,24 @@ public static final function Global __() return class'Global'.static.GetInstance(); } +/** + * Static method accessor to server API namespace, necessary for Acedia's + * implementation. + */ +public static final function ServerGlobal __server() +{ + return class'ServerGlobal'.static.GetInstance(); +} + +/** + * Static method accessor to client API namespace, necessary for Acedia's + * implementation. + */ +public static final function ClientGlobal __client() +{ + return class'ClientGlobal'.static.GetInstance(); +} + /** * If you are overloading this event - you have to first call * `super.PreBeginPlay()`, otherwise Acedia might not function properly. diff --git a/sources/Types/AcediaObject.uc b/sources/Types/AcediaObject.uc index 340fb62..ab1473a 100644 --- a/sources/Types/AcediaObject.uc +++ b/sources/Types/AcediaObject.uc @@ -23,8 +23,10 @@ class AcediaObject extends Object abstract; -// Reference to Acedia's APIs for simple access. -var protected Global _; +// References to Acedia's APIs for simple access. +var protected Global _; +var protected ServerGlobal _server; +var protected ClientGlobal _client; // Object pool to store objects of a particular class var private AcediaObjectPool _objectPool; // Does this class even use object pool? @@ -116,6 +118,8 @@ public final function _constructor() _lifeVersion += 1; _refCounter = 1; _ = class'Global'.static.GetInstance(); + _server = class'ServerGlobal'.static.GetInstance(); + _client = class'ClientGlobal'.static.GetInstance(); if (!default._staticConstructorWasCalled) { CreateTextCache(); @@ -139,7 +143,9 @@ public final function _finalizer() _isAllocated = false; _refCounter = 0; Finalizer(); - _ = none; + _ = none; + _server = none; + _client = none; } /** @@ -483,6 +489,24 @@ public static final function Global __() return class'Global'.static.GetInstance(); } +/** + * Static method accessor to server API namespace, necessary for Acedia's + * implementation. + */ +public static final function ServerGlobal __server() +{ + return class'ServerGlobal'.static.GetInstance(); +} + +/** + * Static method accessor to client API namespace, necessary for Acedia's + * implementation. + */ +public static final function ClientGlobal __client() +{ + return class'ClientGlobal'.static.GetInstance(); +} + /** * This function is called upon Acedia's shutdown, if `StaticConstructor()` * was called for this class.