Browse Source

Fix `LocalDatabase` not supporting database API changes

core_refactor
Anton Tarasenko 2 years ago
parent
commit
845a6a944a
  1. 19
      sources/Data/Database/Local/DBRecord.uc
  2. 10
      sources/Data/Database/Local/LocalDatabaseInstance.uc

19
sources/Data/Database/Local/DBRecord.uc

@ -7,7 +7,7 @@
* Auxiliary data object that can store either a JSON array or an object in
* the local Acedia database. It is supposed to be saved and loaded
* to / from packages.
* Copyright 2021-2022 Anton Tarasenko
* Copyright 2021-2023 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -184,6 +184,7 @@ private final function DBRecordPointer MakeRecordPointer(
return pointer;
}
// Converts `JSONPointer` into our internal representation.
private final function DBRecordPointer ConvertPointer(JSONPointer jsonPointer)
{
if (jsonPointer == none) {
@ -192,6 +193,8 @@ private final function DBRecordPointer ConvertPointer(JSONPointer jsonPointer)
return ConvertPointerPath(jsonPointer, 0, jsonPointer.GetLength());
}
// Produced out internal pointer representation `DBRecordPointer` to
// the container that stores object, referred to by a given `JSONPointer`.
private final function DBRecordPointer ConvertContainerPointer(
JSONPointer jsonPointer)
{
@ -264,9 +267,9 @@ public static final function Global __()
return class'Global'.static.GetInstance();
}
public static final function ServerGlobal __server()
public static final function CoreGlobal __core()
{
return class'ServerGlobal'.static.GetInstance();
return class'CoreGlobal'.static.GetGenericInstance();
}
/**
@ -304,7 +307,7 @@ private final static function DBRecord NewRecordFor(string dbPackageName)
if (recordCandidate != none) {
continue;
}
recordCandidate = __server().unreal.GetGameType()
recordCandidate = __core().unreal_api().GetGameType()
.CreateDataObject(class'DBRecord', nextName, dbPackageName);
recordCandidate.package = dbPackageName;
return recordCandidate;
@ -330,7 +333,7 @@ private final static function DBRecord LoadRecordFor(
string name,
string package)
{
return __server().unreal.GetGameType()
return __core().unreal_api().GetGameType()
.LoadDataObject(class'DBRecord', name, package);
}
@ -689,7 +692,7 @@ private final function SetItem(
if (oldRecord != none) {
oldRecord.EmptySelf();
}
__server().unreal.GetGameType()
__core().unreal_api().GetGameType()
.DeleteDataObject(class'DBRecord', oldItem.s, package);
}
}
@ -723,7 +726,7 @@ private final function RemoveItem(int index)
if (oldRecord != none) {
oldRecord.EmptySelf();
}
__server().unreal.GetGameType()
__core().unreal_api().GetGameType()
.DeleteDataObject(class'DBRecord', oldItem.s, package);
}
storage.Remove(index, 1);
@ -872,7 +875,7 @@ public final function EmptySelf()
return;
}
lockEraseSelf = true;
game = __server().unreal.GetGameType();
game = __core().unreal_api().GetGameType();
for (i = 0; i < storage.length; i += 1)
{
if (storage[i].t != DBAT_Reference) continue;

10
sources/Data/Database/Local/LocalDatabaseInstance.uc

@ -4,7 +4,7 @@
* This class SHOULD NOT be deallocated manually.
* This name was chosen so that more readable `LocalDatabase` could be
* used in config for defining local databases through per-object-config.
* Copyright 2021-2022 Anton Tarasenko
* Copyright 2021-2023 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -83,7 +83,7 @@ var private int lastTaskLifeVersion;
protected function Constructor()
{
_server.unreal.OnTick(self).connect = CompleteAllTasks;
__core().unreal_api().OnTick(self).connect = CompleteAllTasks;
}
protected function Finalizer()
@ -93,7 +93,7 @@ protected function Finalizer()
CompleteAllTasks();
WriteToDisk();
rootRecord = none;
_server.unreal.OnTick(self).Disconnect();
__core().unreal_api().OnTick(self).Disconnect();
configEntry = none;
}
@ -103,7 +103,7 @@ private final function CompleteAllTasks(
optional float dilationCoefficient)
{
if (lastTask != none && lastTask.GetLifeVersion() == lastTaskLifeVersion) {
lastTask.TryCompleting();
lastTask.TryCompleting(self);
}
lastTask = none;
lastTaskLifeVersion = -1;
@ -130,7 +130,7 @@ public final function WriteToDisk()
packageName = _.text.IntoString(configEntry.GetPackageName());
}
if (packageName != "") {
_server.unreal.GetGameType().SavePackage(packageName);
__core().unreal_api().GetGameType().SavePackage(packageName);
}
}

Loading…
Cancel
Save