forge/arma/server/addons/garage/functions/fnc_initGarageStore.sqf
Jacob Schmidt 445a114c1c Refactor org and store services around shared payloads
- Add shared store payload handling in server and extension code
- Remove obsolete org member and treasury service split
- Update client repositories and portal UI/store hydration
2026-04-02 13:56:49 -05:00

98 lines
3.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* File: fnc_initGarageStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-04-01
* Public: No
*
* Description:
* Initializes the Garage store for managing player vehicles.
* Garage hot state is owned by the extension; SQF acts as a thin bridge.
*
* Arguments:
* None
*
* Return Value:
* Garage store object [HASHMAP OBJECT]
*
* Example:
* call forge_server_garage_fnc_initGarageStore
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(GarageBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "GarageBaseStore"],
["#create", compileFinal {
["INFO", "Garage Store Initialized!"] call EFUNC(common,log);
}],
["callHotGarage", compileFinal {
params [["_function", "", [""]], ["_arguments", [], [[]]]];
if (_function isEqualTo "") exitWith { createHashMap };
[_function, _arguments] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
if !(_isSuccess) exitWith { createHashMap };
if !(_result isEqualType "") exitWith { createHashMap };
if ((_result find "Error:") == 0) exitWith {
["ERROR", format ["Garage extension call '%1' failed: %2", _function, _result]] call EFUNC(common,log);
createHashMap
};
private _data = fromJSON _result;
if !(_data isEqualType createHashMap) exitWith { createHashMap };
_data
}],
["loadHotGarage", compileFinal {
params [["_uid", "", [""]], ["_initialize", false, [false]]];
if (_uid isEqualTo "") exitWith { createHashMap };
private _command = ["garage:hot:get", "garage:hot:init"] select _initialize;
_self call ["callHotGarage", [_command, [_uid]]]
}],
["init", compileFinal {
params [["_uid", "", [""]]];
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith { createHashMap };
private _garage = _self call ["loadHotGarage", [_uid, true]];
if (_garage isEqualTo createHashMap) then {
["ERROR", format ["Failed to initialize garage for %1! Using fallback garage.", _uid]] call EFUNC(common,log);
};
[CRPC(garage,responseInitGarage), [_garage], _player] call CFUNC(targetEvent);
_garage
}],
["save", compileFinal {
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { createHashMap };
_self call ["callHotGarage", ["garage:hot:save", [_uid]]]
}],
["storeVehicle", compileFinal {
params [
["_uid", "", [""]],
["_payloadJson", "", [""]]
];
if (_uid isEqualTo "" || { _payloadJson isEqualTo "" }) exitWith { createHashMap };
_self call ["callHotGarage", ["garage:hot:add", [_uid, _payloadJson]]]
}],
["retrieveVehicle", compileFinal {
params [
["_uid", "", [""]],
["_payloadJson", "", [""]]
];
if (_uid isEqualTo "" || { _payloadJson isEqualTo "" }) exitWith { createHashMap };
_self call ["callHotGarage", ["garage:hot:remove_vehicle", [_uid, _payloadJson]]]
}]
];
GVAR(GarageStore) = createHashMapObject [GVAR(GarageBaseStore)];
GVAR(GarageStore)