forge/arma/server/addons/garage/functions/fnc_initGarageStore.sqf
Jacob Schmidt 4532e7b73d Add SurrealDB-backed phone storage and message deletion
- Wire phone, garage, and locker stores to the new storage layer
- Add delete flows for messages and emails in the phone UI
- Update contact, mail, and message views for the new data model
2026-04-11 22:36:11 -05:00

95 lines
3.0 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]];
[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)