forge/arma/server/addons/locker/functions/fnc_initLockerStore.sqf
Jacob Schmidt 096418cc78 chore: refactor store and class initialization across addons
Co-Authored-By: Warp <agent@warp.dev>
2026-02-13 19:09:58 -06:00

70 lines
2.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* File: fnc_initLockerStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-02-13
* Public: No
*
* Description:
* Initializes the Locker store for managing player locker items.
* Provides methods for syncing, saving, and applying locker items to the player's locker.
*
* Arguments:
* None
*
* Return Value:
* Locker store object [HASHMAP OBJECT]
*
* Example:
* call forge_server_locker_fnc_initLockerStore
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(LockerBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "LockerBaseStore"],
["#create", compileFinal {
GVAR(Registry) = createHashMap;
["INFO", "Locker Store Initialized!"] call EFUNC(common,log);
}],
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(Registry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
["locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
if !(_isSuccess) exitWith {
["ERROR", format ["Failed to check if locker %1 exists!", _uid]] call EFUNC(common,log);
createHashMap
};
private _finalLocker = createHashMap;
if (_result == "true") then {
_finalLocker = _self call ["fetch", ["locker:get", _uid]];
["INFO", format ["Found locker for %1", _uid]] call EFUNC(common,log);
} else {
["locker:create", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
if !(_isSuccess) exitWith {
["ERROR", format ["Failed to create locker for %1!", _uid]] call EFUNC(common,log);
createHashMap
};
["INFO", format ["Created new locker for %1", _uid]] call EFUNC(common,log);
};
private _player = [_uid] call EFUNC(common,getPlayer);
GVAR(Registry) set [_uid, _finalLocker];
[CRPC(locker,responseInitLocker), [_finalLocker], _player] call CFUNC(targetEvent);
_finalLocker
}]
];
GVAR(LockerStore) = createHashMapObject [GVAR(LockerBaseStore)];
GVAR(LockerStore)