From 845a6a944ab26e2a08e5393589f827e8a56c5b4b Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 6 Mar 2023 03:22:52 +0700 Subject: [PATCH] Fix `LocalDatabase` not supporting database API changes --- sources/Data/Database/Local/DBRecord.uc | 19 +++++++++++-------- .../Database/Local/LocalDatabaseInstance.uc | 10 +++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sources/Data/Database/Local/DBRecord.uc b/sources/Data/Database/Local/DBRecord.uc index 9f343f0..0510ff1 100644 --- a/sources/Data/Database/Local/DBRecord.uc +++ b/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; diff --git a/sources/Data/Database/Local/LocalDatabaseInstance.uc b/sources/Data/Database/Local/LocalDatabaseInstance.uc index 0f8715b..0ccdea6 100644 --- a/sources/Data/Database/Local/LocalDatabaseInstance.uc +++ b/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); } }