Browse Source

Change globals to load KF API only in _server

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
1f4d0aa960
  1. 32
      sources/CoreRealm/Global.uc
  2. 40
      sources/CoreRealm/ServerGlobal.uc
  3. 2
      sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc
  4. 7
      sources/ServerLevelCore.uc

32
sources/CoreRealm/Global.uc

@ -45,8 +45,6 @@ var public AvariceAPI avarice;
var public AcediaEnvironment environment; var public AcediaEnvironment environment;
var public KFFrontend kf;
public final static function Global GetInstance() public final static function Global GetInstance()
{ {
if (default.myself == none) { if (default.myself == none) {
@ -80,40 +78,10 @@ protected function Initialize()
json = JSONAPI(memory.Allocate(class'JSONAPI')); json = JSONAPI(memory.Allocate(class'JSONAPI'));
db = DBAPI(memory.Allocate(class'DBAPI')); db = DBAPI(memory.Allocate(class'DBAPI'));
avarice = AvariceAPI(memory.Allocate(class'AvariceAPI')); avarice = AvariceAPI(memory.Allocate(class'AvariceAPI'));
kf = KFFrontend(memory.Allocate(class'KF1_Frontend'));
environment = AcediaEnvironment(memory.Allocate(class'AcediaEnvironment')); environment = AcediaEnvironment(memory.Allocate(class'AcediaEnvironment'));
class'InfoQueryHandler'.static.StaticConstructor(); class'InfoQueryHandler'.static.StaticConstructor();
} }
public final function bool ConnectServerLevelCore()
{
if (class'ServerLevelCore'.static.GetInstance() == none) {
return false;
}
class'UnrealService'.static.Require();
class'ConnectionService'.static.Require();
// TODO: this is hack as fuck, needs to be redone
unreal.mutator.OnMutate(
ServiceAnchor(memory.Allocate(class'ServiceAnchor')))
.connect = EnableCommandsFeature;
return true;
}
public function DropGameplayAPI()
{
memory.Free(kf);
kf = none;
}
private final function EnableCommandsFeature(
string command,
PlayerController sendingPlayer)
{
if (command ~= "acediacommands") {
class'Commands_Feature'.static.EmergencyEnable();
}
}
public function DropCoreAPI() public function DropCoreAPI()
{ {
memory = none; memory = none;

40
sources/CoreRealm/ServerGlobal.uc

@ -21,10 +21,13 @@
*/ */
class ServerGlobal extends Object; class ServerGlobal extends Object;
var protected bool initialized;
// `Global` is expected to behave like a singleton and will store it's // `Global` is expected to behave like a singleton and will store it's
// main instance in this variable's default value. // main instance in this variable's default value.
var protected ServerGlobal myself; var protected ServerGlobal myself;
var public KFFrontend kf;
public final static function ServerGlobal GetInstance() public final static function ServerGlobal GetInstance()
{ {
if (default.myself == none) if (default.myself == none)
@ -38,6 +41,43 @@ public final static function ServerGlobal GetInstance()
protected function Initialize() protected function Initialize()
{ {
local Global _;
if (initialized) {
return;
}
_ = class'Global'.static.GetInstance();
kf = KFFrontend(_.memory.Allocate(class'KF1_Frontend'));
// TODO: this is hack, needs to be redone later
KF1_HealthComponent(kf.health).PseudoConstructor();
initialized = true;
}
public final function bool ConnectServerLevelCore()
{
local Global _;
if (class'ServerLevelCore'.static.GetInstance() == none) {
return false;
}
Initialize();
class'UnrealService'.static.Require();
class'ConnectionService'.static.Require();
// TODO: this is hack as fuck, needs to be redone
_ = class'Global'.static.GetInstance();
_.unreal.mutator.OnMutate(
ServiceAnchor(_.memory.Allocate(class'ServiceAnchor')))
.connect = EnableCommandsFeature;
return true;
}
private final function EnableCommandsFeature(
string command,
PlayerController sendingPlayer)
{
if (command ~= "acediacommands") {
class'Commands_Feature'.static.EmergencyEnable();
}
} }
defaultproperties defaultproperties

2
sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc

@ -205,7 +205,7 @@ protected function UpdateShopList()
local KF1_Trader nextTrader; local KF1_Trader nextTrader;
local array<ShopVolume> shopVolumes; local array<ShopVolume> shopVolumes;
local array<ETrader> availableTraders; local array<ETrader> availableTraders;
availableTraders = _.kf.trading.GetTraders(); availableTraders = _server.kf.trading.GetTraders();
for (i = 0; i < availableTraders.length; i += 1) for (i = 0; i < availableTraders.length; i += 1)
{ {
nextTrader = KF1_Trader(availableTraders[i]); nextTrader = KF1_Trader(availableTraders[i]);

7
sources/ServerLevelCore.uc

@ -18,13 +18,6 @@
*/ */
class ServerLevelCore extends LevelCore; class ServerLevelCore extends LevelCore;
protected function Constructor()
{
super.Constructor();
// TODO: this is hack, needs to be redone later
KF1_HealthComponent(_.kf.health).PseudoConstructor();
}
public static function LevelCore CreateLevelCore(Actor source) public static function LevelCore CreateLevelCore(Actor source)
{ {
if (source == none) return none; if (source == none) return none;

Loading…
Cancel
Save