- replace placeholder garage interaction with real UI open flow - add catalog/session/UI bridge services for hydrate, sync, store, and retrieve actions - migrate garage web UI bundle to new app shell/runtime structure - align org/store function naming with shared init and UI bridge patterns
204 lines
8.3 KiB
Plaintext
204 lines
8.3 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
PREP_RECOMPILE_START;
|
|
#include "XEH_PREP.hpp"
|
|
PREP_RECOMPILE_END;
|
|
|
|
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
|
|
|
|
[QGVAR(requestInitGarage), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
|
|
GVAR(GarageStore) call ["init", [_uid]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestGetGarage), {
|
|
params [["_uid", "", [""]], ["_field", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
|
|
|
|
private _finalData = GVAR(GarageStore) call ["get", [GVAR(Registry), "garage:get", _uid, _field]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncGarage), [_finalData], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSetGarage), {
|
|
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID or Key!" };
|
|
|
|
private _hashMap = GVAR(GarageStore) call ["set", [GVAR(Registry), "garage:update", _uid, _key, _value, _sync]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncGarage), [_hashMap], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestMSetGarage), {
|
|
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
|
|
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid field pairs!" };
|
|
|
|
private _hashMap = GVAR(GarageStore) call ["mset", [GVAR(Registry), "garage:update", _uid, _fieldValuePairs, _sync]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncGarage), [_hashMap], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSaveGarage), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
|
|
|
|
private _finalData = GVAR(GarageStore) call ["save", [GVAR(Registry), "garage:update", _uid]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncGarage), [_finalData], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestRemoveGarage), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
|
|
GVAR(GarageStore) call ["remove", [GVAR(Registry), _uid]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestStoreVehicle), {
|
|
params [
|
|
["_uid", "", [""]],
|
|
["_className", "", [""]],
|
|
["_fuel", 0, [0]],
|
|
["_damage", 0, [0]],
|
|
["_hitPointsJson", "", [""]]
|
|
];
|
|
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
if (_uid isEqualTo "" || { _className isEqualTo "" } || { _hitPointsJson isEqualTo "" }) exitWith {
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "store"],
|
|
["success", false],
|
|
["message", "Missing vehicle data for garage storage."]
|
|
]], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
private _payloadJson = toJSON (createHashMapFromArray [
|
|
["classname", _className],
|
|
["fuel", _fuel],
|
|
["damage", _damage],
|
|
["hit_points", fromJSON _hitPointsJson]
|
|
]);
|
|
|
|
["garage:add", [_uid, _payloadJson]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
|
|
if !(_isSuccess) exitWith {
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "store"],
|
|
["success", false],
|
|
["message", format ["Failed to store vehicle: %1", _result]]
|
|
]], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
private _garage = fromJSON _result;
|
|
GVAR(Registry) set [_uid, _garage];
|
|
|
|
[CRPC(garage,responseSyncGarage), [_garage], _player] call CFUNC(targetEvent);
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "store"],
|
|
["success", true],
|
|
["message", "Vehicle stored in garage."]
|
|
]], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestRetrieveVehicle), {
|
|
params [["_uid", "", [""]], ["_plate", "", [""]]];
|
|
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
if (_uid isEqualTo "" || { _plate isEqualTo "" }) exitWith {
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "retrieve"],
|
|
["success", false],
|
|
["message", "Select a stored vehicle to retrieve."]
|
|
]], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
private _payloadJson = toJSON (createHashMapFromArray [["plate", _plate]]);
|
|
["garage:remove", [_uid, _payloadJson]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
|
|
if !(_isSuccess) exitWith {
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "retrieve"],
|
|
["success", false],
|
|
["message", format ["Failed to retrieve vehicle: %1", _result]]
|
|
]], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
private _garage = fromJSON _result;
|
|
GVAR(Registry) set [_uid, _garage];
|
|
|
|
[CRPC(garage,responseSyncGarage), [_garage], _player] call CFUNC(targetEvent);
|
|
[CRPC(garage,responseGarageAction), [createHashMapFromArray [
|
|
["action", "retrieve"],
|
|
["success", true],
|
|
["message", "Vehicle retrieved from garage."]
|
|
]], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestInitVG), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
|
|
GVAR(VGarageStore) call ["init", [_uid]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestGetVG), {
|
|
params [["_uid", "", [""]], ["_field", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
|
|
|
|
private _finalData = GVAR(VGarageStore) call ["get", [GVAR(VGRegistry), "owned:garage:fetch", _uid, _field]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncVG), [_finalData], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSetVG), {
|
|
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID or Key!" };
|
|
|
|
private _hashMap = GVAR(VGarageStore) call ["set", [GVAR(VGRegistry), "", _uid, _key, _value, _sync]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncVG), [_hashMap], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestMSetVG), {
|
|
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
|
|
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid field pairs!" };
|
|
|
|
private _hashMap = GVAR(VGarageStore) call ["mset", [GVAR(VGRegistry), "", _uid, _fieldValuePairs, _sync]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncVG), [_hashMap], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSaveVG), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
|
|
|
|
private _finalData = GVAR(VGarageStore) call ["save", [GVAR(VGRegistry), "", _uid]];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
|
|
[CRPC(garage,responseSyncVG), [_finalData], _player] call CFUNC(targetEvent);
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestRemoveVG), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
|
|
GVAR(VGarageStore) call ["remove", [GVAR(VGRegistry), _uid]];
|
|
}] call CFUNC(addEventHandler);
|