@ -2,7 +2,7 @@
* Object that is supposed to store a persistent data about the
* certain player. That is data that will be remembered even after player
* reconnects or server changes map/restarts.
* Copyright 2020 - 2021 Anton Tarasenko
* Copyright 2020-2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -34,10 +34,20 @@ var private JSONPointer persistentSettingsPointer;
var private LoggerAPI.Definition errNoUserDataDatabase;
// TODO: redo this comment
protected function Finalizer()
{
if (id != none) {
id.FreeSelf();
}
if (persistentSettingsPointer != none) {
persistentSettingsPointer.FreeSelf();
}
id = none;
persistentSettingsPointer = none;
}
/**
* Initializes caller `User` with id and it's session key. Should be called
* right after `EPlayer` was created.
* Initializes caller `User` with id and it's session key.
*
* Initialization should (and can) only be done once.
* Before a `Initialize()` call, any other method calls on such `User`
@ -47,6 +57,9 @@ public final function Initialize(UserID initID, int initKey)
{
id = initID;
key = initKey;
if (initID != none) {
initID.NewRef();
}
}
/**
@ -56,6 +69,9 @@ public final function Initialize(UserID initID, int initKey)
*/
public final function UserID GetID()
{
if (id != none) {
id.NewRef();
}
return id;
}
@ -88,6 +104,7 @@ public final function int GetKey()
public final function DBReadTask ReadGroupOfPersistentData(BaseText groupName)
{
local DBReadTask task;
if (groupName == none) return none;
if (!SetupDatabaseVariables()) return none;
@ -120,6 +137,7 @@ public final function DBReadTask ReadPersistentData(
BaseText dataName)
{
local DBReadTask task;
if (groupName == none) return none;
if (dataName == none) return none;
if (!SetupDatabaseVariables()) return none;
@ -157,6 +175,7 @@ public final function DBWriteTask WritePersistentData(
{
local DBWriteTask task;
local HashTable emptyObject;
if (groupName == none) return none;
if (dataName == none) return none;
if (!SetupDatabaseVariables()) return none;