Implemented features: - High-performance Rust extension with Redis persistence - Actor/player management with loadout, position, and state tracking - Banking system with deposit, withdraw, and transfer operations - Physical and virtual garage/locker systems for vehicle and equipment storage - Organization management with member tracking and permissions - Client-side UI with React-like state management - Server-side event-driven architecture with CBA Events - Security: Self-transfer prevention at multiple layers - Logging system with per-module log files - ICOM module for inter-server communication Co-Authored-By: Warp <agent@warp.dev>
155 lines
4.8 KiB
Plaintext
155 lines
4.8 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* Author: IDSolutions
|
|
* Initializes the base store.
|
|
*
|
|
* Arguments:
|
|
* None
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Examples:
|
|
* [] call forge_server_common_fnc_initBaseStore
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
#pragma hemtt ignore_variables ["_self"]
|
|
GVAR(BaseStore) = createHashMapObject [[
|
|
["#type", "IBaseStore"],
|
|
["fetch", {
|
|
params [["_uid", "", [""]]];
|
|
|
|
private _extCallPrefix = _self get "_extCallPrefix";
|
|
private _readMethod = _self getOrDefault ["_readMethod", "get"];
|
|
private _funcName = format ["%1:%2", _extCallPrefix, _readMethod];
|
|
private _store = createHashMap;
|
|
|
|
[_funcName, [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
|
|
["INFO", format ["Data: %1", _result], nil, nil] call EFUNC(common,log);
|
|
|
|
if (count _result > 0) then { _store = _self call ["toHashMap", [_result]]; };
|
|
|
|
_store
|
|
}],
|
|
["get", {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
private _finalData = createHashMap;
|
|
private _registry = _self get "_registry";
|
|
|
|
if (_sync) then {
|
|
private _existingData = _self call ["fetch", [_uid]];
|
|
|
|
_finalData = _existingData;
|
|
_registry set [_uid, _finalData];
|
|
} else {
|
|
_finalData = _registry get _uid;
|
|
};
|
|
|
|
_finalData
|
|
}],
|
|
["set", {
|
|
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil], ["_sync", false, [false]]];
|
|
|
|
private _registry = _self get "_registry";
|
|
private _existingData = _registry get _uid;
|
|
private _finalData = +_existingData;
|
|
private _hashMap = createHashMap;
|
|
|
|
_finalData set [_field, _value];
|
|
_hashMap set [_field, _value];
|
|
_registry set [_uid, _finalData];
|
|
|
|
if (_sync) then {
|
|
private _extCallPrefix = _self get "_extCallPrefix";
|
|
private _funcName = format ["%1:update", _extCallPrefix];
|
|
private _json = _self call ["toJSON", [_hashMap]];
|
|
|
|
[_funcName, [_uid, _json]] call EFUNC(extension,extCall);
|
|
};
|
|
|
|
private _syncEventName = _self getOrDefault ["_syncEventName", ""];
|
|
if (_syncEventName isNotEqualTo "") then {
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
[_syncEventName, [_hashMap], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
_hashMap
|
|
}],
|
|
["mset", {
|
|
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
|
|
|
|
private _registry = _self get "_registry";
|
|
private _existingData = _registry get _uid;
|
|
private _finalData = +_existingData;
|
|
private _hashMap = createHashMap;
|
|
|
|
{ _finalData set [_x, _y]; } forEach _fieldValuePairs;
|
|
{ _hashMap set [_x, _y]; } forEach _fieldValuePairs;
|
|
|
|
_registry set [_uid, _finalData];
|
|
|
|
if (_sync) then {
|
|
private _extCallPrefix = _self get "_extCallPrefix";
|
|
private _funcName = format ["%1:update", _extCallPrefix];
|
|
private _json = _self call ["toJSON", [_hashMap]];
|
|
|
|
[_funcName, [_uid, _json]] call EFUNC(extension,extCall);
|
|
};
|
|
|
|
private _syncEventName = _self getOrDefault ["_syncEventName", ""];
|
|
if (_syncEventName isNotEqualTo "") then {
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
[_syncEventName, [_hashMap], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
_hashMap
|
|
}],
|
|
["save", {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
private _registry = _self get "_registry";
|
|
private _existingData = _registry get _uid;
|
|
private _finalData = +_existingData;
|
|
private _extCallPrefix = _self get "_extCallPrefix";
|
|
private _funcName = format ["%1:update", _extCallPrefix];
|
|
private _json = _self call ["toJSON", [_finalData]];
|
|
|
|
[_funcName, [_uid, _json]] call EFUNC(extension,extCall);
|
|
|
|
if (_sync) then {
|
|
private _syncEventName = _self getOrDefault ["_syncEventName", ""];
|
|
if (_syncEventName isNotEqualTo "") then {
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
[_syncEventName, [_finalData], _player] call CFUNC(targetEvent);
|
|
};
|
|
};
|
|
|
|
_finalData
|
|
}],
|
|
["remove", {
|
|
params [["_uid", "", [""]]];
|
|
|
|
private _registry = _self get "_registry";
|
|
_registry deleteAt _uid;
|
|
}],
|
|
["toHashMap", {
|
|
params [["_data", "", [""]]];
|
|
|
|
private _hashMap = fromJSON _data;
|
|
_hashMap
|
|
}],
|
|
["toJSON", {
|
|
params [["_data", createHashMap, [createHashMap]]];
|
|
|
|
private _json = toJSON _data;
|
|
_json
|
|
}]
|
|
]];
|
|
|
|
SETMVAR(FORGE_BaseStore,GVAR(BaseStore));
|
|
GVAR(BaseStore)
|