Update save and load functions to support scheduled/unscheduled execution
Some checks failed
Build / Build (push) Failing after 7s

This commit is contained in:
Jacob Schmidt 2025-02-22 09:07:27 -06:00
parent c9429919bd
commit 3457f24161
3 changed files with 27 additions and 8 deletions

View File

@ -17,7 +17,6 @@
*
* Arguments:
* 0: ID of Slot <SCALAR> (default: 0)
* 1: Unscheduled environment <BOOL> (default: false)
*
* Return Value:
* N/A
@ -46,6 +45,7 @@ private _loadEntries = "true" configClasses (_config);
private _entryName = configName _x;
private _functionName = getText (_x >> "function");
private _args = getArray (_x >> "args");
private _scheduled = getNumber (_x >> "scheduled") == 1;
if (_functionName != "") then {
private _function = call compile _functionName;
@ -53,9 +53,14 @@ private _loadEntries = "true" configClasses (_config);
if (!isNil "_savedData") then {
_args pushBack _savedData;
_args call _function;
if (_scheduled) then {
_args spawn _function;
[EGVAR(db,debug), "xpdb_load_fnc_custom", format ["Loading '%1.%2.%3'", EGVAR(db,prefix), _slot, _entryName], false] call EFUNC(utils,debug);
} else {
_args call _function;
[EGVAR(db,debug), "xpdb_load_fnc_custom", format ["Loading '%1.%2.%3'", EGVAR(db,prefix), _slot, _entryName], false] call EFUNC(utils,debug);
};
};
};
} forEach _loadEntries;

View File

@ -17,7 +17,6 @@
*
* Arguments:
* 0: ID of Slot <SCALAR> (default: 0)
* 1: Unscheduled environment <BOOL> (default: false)
*
* Return Value:
* N/A
@ -45,9 +44,19 @@ private _saveEntries = "true" configClasses (_config);
private _entryName = configName _x;
private _functionName = getText (_x >> "function");
private _args = getArray (_x >> "args");
private _scheduled = getNumber (_x >> "scheduled") == 1;
if (_functionName != "") then {
private _function = call compile _functionName;
if (_scheduled) then {
private _result = _args spawn _function;
if (!isNil "_result") then {
[EGVAR(db,debug), "xpdb_save_fnc_custom", format ["Saving '%1.%2.%3'", EGVAR(db,prefix), _slot, _entryName], false] call EFUNC(utils,debug);
[_entryName, _result, _slot] call EFUNC(core,saveData);
};
} else {
private _result = _args call _function;
if (!isNil "_result") then {
@ -55,6 +64,7 @@ private _saveEntries = "true" configClasses (_config);
[_entryName, _result, _slot] call EFUNC(core,saveData);
};
};
};
} forEach _saveEntries;
[EGVAR(db,debug), "xpdb_save_fnc_custom", "eXtended Persistent Database save completed.", false] call EFUNC(utils,debug);

View File

@ -3,20 +3,24 @@ class CfgXPDB {
class playerStats { // XPDB_ARMADBCORE.0.playerStats
function = "TAG_player_fnc_saveStats";
args[] = {};
scheduled = 0;
};
class world { // XPDB_ARMADBCORE.0.world
function = "TAG_world_fnc_saveNearbyVehicles";
args[] = {};
scheduled = 0;
};
};
class load {
class playerStats { // XPDB_ARMADBCORE.0.playerStats
function = "TAG_player_fnc_loadStats";
args[] = {};
scheduled = 1;
};
class world { // XPDB_ARMADBCORE.0.world
function = "TAG_world_fnc_loadNearbyVehicles";
args[] = {};
scheduled = 1;
};
};
};