chore: refactor store and class initialization across addons

Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
Jacob Schmidt 2026-02-13 19:09:58 -06:00
parent 58902f0c29
commit 096418cc78
28 changed files with 479 additions and 603 deletions

View File

@ -20,7 +20,7 @@ graph TD
end
subgraph Server [ArmA 3 SERVER #40;Hot Cache#41;]
ActorRegistry["GVAR(ActorRegistry)<br/>In-Memory HashMap<br/>UID -> {loadout, position, stats...}"]
Registry["GVAR(Registry)<br/>In-Memory HashMap<br/>UID -> {loadout, position, stats...}"]
SessionMgmt[Session Management<br/>- Token Generation<br/>- UID Resolution<br/>- Player State]
end
@ -125,7 +125,7 @@ flowchart TD
subgraph SessionMgmt [SERVER-SIDE #40;Session MGT#41;]
Conn[Player Connection] --> Token[Session Token Generation<br/>#40;Generated on server#41;]
Token --> UID[UID Resolution<br/>#40;Steam UID mapping#41;]
UID --> State[Player State Tracking<br/>#40;Tracked in ActorRegistry#41;]
UID --> State[Player State Tracking<br/>#40;Tracked in Registry#41;]
State --> Access[Data Access Authorized<br/>#40;Authorized via session#41;]
end
```

View File

@ -4,7 +4,7 @@
* File: fnc_initActorClass.sqf
* Author: IDSolutions
* Date: 2026-01-28
* Last Update: 2026-01-31
* Last Update: 2026-02-13
* Public: Yes
*
* Description:
@ -22,22 +22,22 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(ActorClass) = createHashMapObject [[
["#type", "IActorClass"],
["#create", {
GVAR(ActorBaseClass) = compileFinal createHashMapFromArray [
["#type", "ActorBaseClass"],
["#create", compileFinal {
_self set ["uid", getPlayerUID player];
_self set ["actor", createHashMap];
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
[SRPC(actor,requestInitActor), [_uid]] call CFUNC(serverEvent);
systemChat format ["Actor loaded for %1", (name player)];
diag_log "[FORGE:Client:Actor] Actor Class Initialized!";
}],
["save", {
["save", compileFinal {
params [["_sync", false, [false]]];
private _uid = _self get "uid";
@ -45,7 +45,7 @@ GVAR(ActorClass) = createHashMapObject [[
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _actor = _self get "actor";
@ -72,13 +72,13 @@ GVAR(ActorClass) = createHashMapObject [[
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:Actor] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _actor = _self get "actor";
_actor getOrDefault [_key, _default];
}],
["applyPosition", {
["applyPosition", compileFinal {
private _position = _self call ["get", ["position", [0, 0, 0]]];
if (GVAR(enableLoc)) then {
@ -95,23 +95,23 @@ GVAR(ActorClass) = createHashMapObject [[
};
};
}],
["applyDirection", {
["applyDirection", compileFinal {
private _direction = _self call ["get", ["direction", 0]];
if (GVAR(enableLoc)) then { player setDir _direction; };
}],
["applyStance", {
["applyStance", compileFinal {
private _stance = _self call ["get", ["stance", "STAND"]];
if (GVAR(enableLoc)) then { player playAction _stance; };
}],
["applyRank", {
["applyRank", compileFinal {
private _rank = _self call ["get", ["rank", "PRIVATE"]];
player setUnitRank _rank;
}],
["applyLoadout", {
["applyLoadout", compileFinal {
private _loadout = _self call ["get", ["loadout", []]];
if (GVAR(enableGear) && count _loadout > 0) then { player setUnitLoadout _loadout; };
}],
["getNearbyActions", {
["getNearbyActions", compileFinal {
params [["_control", controlNull, [controlNull]]];
private _nearbyActions = [];
@ -136,6 +136,7 @@ GVAR(ActorClass) = createHashMapObject [[
_control ctrlWebBrowserAction ["ExecJS", format ["updateAvailableActions(%1)", (toJSON _nearbyActions)]];
}]
]];
];
GVAR(ActorClass) = createHashMapObject [GVAR(ActorBaseClass)];
GVAR(ActorClass)

View File

@ -4,7 +4,7 @@
* File: fnc_handleUIEvents.sqf
* Author: IDSolutions
* Date: 2025-12-16
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -27,13 +27,13 @@ params ["_control", "_isConfirmDialog", "_message"];
private _alert = fromJSON _message;
private _event = _alert get "event";
private _data = _alert get "data";
// private _display = displayChild findDisplay 46;
private _uid = GVAR(BankClass) get "uid";
private _account = GVAR(BankClass) get "account";
private _cash = _account get "cash";
private _bank = _account get "bank";
private _cash = _account get "cash";
private _pin = _account get "pin";
private _funds = EGVAR(org,OrgClass) get "funds";
diag_log format ["[FORGE:Client:Bank] Handling UI event: %1 with data: %2", _event, _data];
@ -42,13 +42,12 @@ switch (_event) do {
// DATA REQUESTS
// ========================================================================
case "bank::sync": {
private _org = 0; // TODO: Get org balance
private _players = SREG(bank,IndexRegistry);
private _accountData = createHashMapFromArray [
["uid", _uid],
["cash", _cash],
["bank", _bank],
["org", _org],
["org", _funds],
["pin", _pin],
["players", _players]
];

View File

@ -4,7 +4,7 @@
* File: fnc_initBankClass.sqf
* Author: IDSolutions
* Date: 2025-12-16
* Last Update: 2026-01-31
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -21,15 +21,15 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(BankClass) = createHashMapObject [[
["#type", "IBankClass"],
["#create", {
GVAR(BankBaseClass) = compileFinal createHashMapFromArray [
["#type", "BankBaseClass"],
["#create", compileFinal {
_self set ["uid", getPlayerUID player];
_self set ["account", createHashMap];
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
[SRPC(bank,requestInitBank), [_uid]] call CFUNC(serverEvent);
@ -37,7 +37,7 @@ GVAR(BankClass) = createHashMapObject [[
systemChat format ["Bank loaded for %1", (name player)];
diag_log "[FORGE:Client:Bank] Bank Class Initialized!";
}],
["save", {
["save", compileFinal {
params [["_sync", false, [false]]];
private _uid = _self get "uid";
@ -45,27 +45,25 @@ GVAR(BankClass) = createHashMapObject [[
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _account = _self get "account";
private _isLoaded = _self get "isLoaded";
{
_account set [_x, _y];
} forEach _data;
{ _account set [_x, _y]; } forEach _data;
_self set ["account", _account];
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:Bank] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _account = _self get "account";
_account getOrDefault [_key, _default];
}]
]];
];
GVAR(BankClass) = createHashMapObject [GVAR(BankBaseClass)];
GVAR(BankClass)

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
if (isNil QGVAR(GarageClass)) then { call FUNC(initGarageClass); };
if (isNil QGVAR(VGarageClass)) then { call FUNC(initVGClass); };
if (isNil QGVAR(VGClass)) then { call FUNC(initVGClass); };
[QGVAR(initGarage), {
GVAR(GarageClass) call ["init", []];
@ -20,19 +20,19 @@ if (isNil QGVAR(VGarageClass)) then { call FUNC(initVGClass); };
}] call CFUNC(addEventHandler);
[QGVAR(initVG), {
GVAR(VGarageClass) call ["init", []];
GVAR(VGClass) call ["init", []];
}] call CFUNC(addEventHandler);
[QGVAR(responseInitVG), {
params [["_data", createHashMap, [createHashMap]]];
GVAR(VGarageClass) call ["sync", [_data, true]];
GVAR(VGClass) call ["sync", [_data, true]];
}] call CFUNC(addEventHandler);
[QGVAR(responseSyncVG), {
params [["_data", createHashMap, [createHashMap, []]], ["_jip", false, [false]]];
GVAR(VGarageClass) call ["sync", [_data, _jip]];
GVAR(VGClass) call ["sync", [_data, _jip]];
}] call CFUNC(addEventHandler);
[{

View File

@ -1,3 +1,2 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

View File

@ -4,7 +4,7 @@
* File: fnc_initGarageClass.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-31
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -22,15 +22,15 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(GarageClass) = createHashMapObject [[
["#type", "IGarageClass"],
["#create", {
GVAR(GarageBaseClass) = compileFinal createHashMapFromArray [
["#type", "GarageBaseClass"],
["#create", compileFinal {
_self set ["uid", (getPlayerUID player)];
_self set ["garage", createHashMap];
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
private _garage = _self get "garage";
@ -39,13 +39,13 @@ GVAR(GarageClass) = createHashMapObject [[
systemChat format ["Garage loaded for %1", (name player)];
diag_log "[FORGE:Client:Garage] Garage Class Initialized!";
}],
["save", {
["save", compileFinal {
private _uid = _self get "uid";
[SRPC(garage,requestSaveGarage), [_uid]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]]];
private _garage = _self get "garage";
@ -57,12 +57,13 @@ GVAR(GarageClass) = createHashMapObject [[
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:Garage] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _garage = _self get "garage";
_garage getOrDefault [_key, _default];
}]
]];
];
GVAR(GarageClass) = createHashMapObject [GVAR(GarageBaseClass)];
GVAR(GarageClass)

View File

@ -4,7 +4,7 @@
* File: fnc_initVGClass.sqf
* Author: IDSolutions
* Date: 2025-12-16
* Last Update: 2026-01-31
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -22,9 +22,9 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(VGarageClass) = createHashMapObject [[
["#type", "IVGarageClass"],
["#create", {
GVAR(VGBaseClass) = compileFinal createHashMapFromArray [
["#type", "VGBaseClass"],
["#create", compileFinal {
GVAR(isPreLoaded) = false;
_self set ["uid", (getPlayerUID player)];
@ -32,7 +32,7 @@ GVAR(VGarageClass) = createHashMapObject [[
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
private _vGarage = _self get "vGarage";
@ -41,13 +41,13 @@ GVAR(VGarageClass) = createHashMapObject [[
systemChat format ["VGarage loaded for %1", (name player)];
diag_log "[FORGE:Client:VGarage] VGarage Class Initialized!";
}],
["save", {
["save", compileFinal {
private _uid = _self get "uid";
[SRPC(garage,requestSaveVG), [_uid]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _vGarage = _self get "vGarage";
@ -74,13 +74,13 @@ GVAR(VGarageClass) = createHashMapObject [[
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:VGarage] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _vGarage = _self get "vGarage";
_vGarage getOrDefault [_key, _default];
}],
["apply", {
["apply", compileFinal {
params [["_key", "", [""]]];
private _vehicles = _self call ["get", [_key, []]];
@ -98,6 +98,7 @@ GVAR(VGarageClass) = createHashMapObject [[
_array append [getText (configFile >> "CfgVehicles" >> _x >> "model"), [configFile >> "CfgVehicles" >> _x]];
} forEach _vehicles;
}]
]];
];
GVAR(VGarageClass)
GVAR(VGClass) = createHashMapObject [GVAR(VGBaseClass)];
GVAR(VGClass)

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
if (isNil QGVAR(LockerClass)) then { call FUNC(initLockerClass); };
if (isNil QGVAR(VArsenalClass)) then { call FUNC(initVAClass); };
if (isNil QGVAR(VAClass)) then { call FUNC(initVAClass); };
[QGVAR(initLocker), {
GVAR(LockerClass) call ["init", []];
@ -20,19 +20,19 @@ if (isNil QGVAR(VArsenalClass)) then { call FUNC(initVAClass); };
}] call CFUNC(addEventHandler);
[QGVAR(initVA), {
GVAR(VArsenalClass) call ["init", []];
GVAR(VAClass) call ["init", []];
}] call CFUNC(addEventHandler);
[QGVAR(responseInitVA), {
params [["_data", createHashMap, [createHashMap]]];
GVAR(VArsenalClass) call ["sync", [_data, true]];
GVAR(VAClass) call ["sync", [_data, true]];
}] call CFUNC(addEventHandler);
[QGVAR(responseSyncVA), {
params [["_data", createHashMap, [createHashMap, []]], ["_jip", false, [false]]];
GVAR(VArsenalClass) call ["sync", [_data, _jip]];
GVAR(VAClass) call ["sync", [_data, _jip]];
}] call CFUNC(addEventHandler);
[{

View File

@ -4,7 +4,7 @@
* File: fnc_initLockerClass.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-02-05
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -22,15 +22,29 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(LockerRepository) = compileFinal createHashMapFromArray [
["#type", "LockerRepository"],
["get", {
GVAR(LockerBaseClass) = compileFinal createHashMapFromArray [
["#type", "LockerBaseClass"],
["#create", compileFinal {
_self set ["uid", (getPlayerUID player)];
_self set ["isLoaded", false];
_self set ["lastSave", time];
_self set ["locker", createHashMap];
}],
["init", compileFinal {
private _uid = _self get "uid";
[SRPC(locker,requestInitLocker), [_uid]] call CFUNC(serverEvent);
systemChat format ["Locker loaded for %1", (name player)];
diag_log "[FORGE:Client:Locker] Locker Class Initialized!";
}],
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _locker = _self get "locker";
_locker getOrDefault [_key, _default];
}],
["getCargo", {
["getCargo", compileFinal {
params [["_container", objNull, [objNull]], ["_locker", createHashMap, [createHashMap]]];
private _cargoData = [
@ -58,7 +72,7 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
_locker
}],
["getContainerItems", {
["getContainerItems", compileFinal {
params [["_container", objNull, [objNull]], ["_locker", createHashMap, [createHashMap]]];
private _allContainers = everyContainer _container;
@ -122,7 +136,7 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
_locker
}],
["getAttachments", {
["getAttachments", compileFinal {
params [["_container", objNull, [objNull]], ["_locker", createHashMap, [createHashMap]]];
private _weaponItems = weaponsItemsCargo _container;
@ -178,13 +192,13 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
_locker
}],
["save", {
["save", compileFinal {
private _uid = _self get "uid";
[SRPC(locker,requestSaveLocker), [_uid]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["setEventHandlers", {
["setEventHandlers", compileFinal {
params [["_locker", objNull, [objNull]]];
_locker addEventHandler ["ContainerOpened", {
@ -235,7 +249,7 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
};
}];
}],
["setup", {
["setup", compileFinal {
private _lockers = (allVariables missionNamespace) select {
private _var = missionNamespace getVariable _x;
("locker" in _x) && { _var isEqualType objNull } && { !isNull _var } && { _x isNotEqualTo "forge_locker_box" }
@ -267,7 +281,7 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
_self call ["setEventHandlers", [_localLocker]];
} forEach _lockers;
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]]];
private _isLoaded = _self get "isLoaded";
@ -281,23 +295,5 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
}]
];
GVAR(LockerClass) = createHashMapObject [[
["#base", GVAR(LockerRepository)],
["#type", "ILockerClass"],
["#create", {
_self set ["uid", (getPlayerUID player)];
_self set ["isLoaded", false];
_self set ["lastSave", time];
_self set ["locker", createHashMap];
}],
["init", {
private _uid = _self get "uid";
[SRPC(locker,requestInitLocker), [_uid]] call CFUNC(serverEvent);
systemChat format ["Locker loaded for %1", (name player)];
diag_log "[FORGE:Client:Locker] Locker Class Initialized!";
}]
]];
GVAR(LockerClass) = createHashMapObject [GVAR(LockerBaseClass)];
GVAR(LockerClass)

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp"
/*
* File: fnc_initVAClass.sqf
* File: fnc_init.sqf
* Author: IDSolutions
* Date: 2025-12-16
* Last Update: 2026-02-05
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -18,34 +18,33 @@
* vArsenal class object [HASHMAP OBJECT]
*
* Example:
* call forge_client_locker_fnc_initVAClass;
* call forge_client_locker_fnc_init;
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(VArsenalClass) = createHashMapObject [[
["#type", "IVArsenalClass"],
["#create", {
GVAR(VABaseClass) = compileFinal createHashMapFromArray [
["#type", "VABaseClass"],
["#create", compileFinal {
_self set ["uid", (getPlayerUID player)];
_self set ["vArsenal", createHashMap];
_self set ["isLoaded", false];
_self set ["lastSave", time];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
FORGE_Locker_Box = "ReammoBox_F" createVehicleLocal [0, 0, -999];
[SRPC(locker,requestInitVA), [_uid]] call CFUNC(serverEvent);
systemChat format ["VArsenal loaded for %1", (name player)];
diag_log "[FORGE:Client:VArsenal] VArsenal Class Initialized!";
}],
["save", {
["save", compileFinal {
private _uid = _self get "uid";
[SRPC(locker,requestSaveVA), [_uid]] call CFUNC(serverEvent);
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _vArsenal = _self get "vArsenal";
@ -70,28 +69,29 @@ GVAR(VArsenalClass) = createHashMapObject [[
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:VArsenal] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _vArsenal = _self get "vArsenal";
_vArsenal getOrDefault [_key, _default];
}],
["applyItems", {
["applyItems", compileFinal {
private _items = _self call ["get", ["items", []]];
[FORGE_Locker_Box, _items] call AFUNC(arsenal,addVirtualItems);
}],
["applyWeapons", {
["applyWeapons", compileFinal {
private _weapons = _self call ["get", ["weapons", []]];
[FORGE_Locker_Box, _weapons] call AFUNC(arsenal,addVirtualItems);
}],
["applyMagazines", {
["applyMagazines", compileFinal {
private _magazines = _self call ["get", ["magazines", []]];
[FORGE_Locker_Box, _magazines] call AFUNC(arsenal,addVirtualItems);
}],
["applyBackpacks", {
["applyBackpacks", compileFinal {
private _backpacks = _self call ["get", ["backpacks", []]];
[FORGE_Locker_Box, _backpacks] call AFUNC(arsenal,addVirtualItems);
}]
]];
];
GVAR(VArsenalClass)
GVAR(VAClass) = createHashMapObject [GVAR(VABaseClass)];
GVAR(VAClass)

View File

@ -1,25 +1,29 @@
#include "..\script_component.hpp"
/*
* File: fnc_initOrgClass.sqf
* Author: IDSolutions
* Date: 2026-02-13
* Last Update: 2026-02-13
* Public: No
*
* Description:
* Initializes the org class.
*
* Arguments:
* None
*
* Return Value:
* None
* Org class object [HASHMAP OBJECT]
*
* Examples:
* call forge_client_org_fnc_initOrgClass
*
* Public: Yes
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(OrgClass) = createHashMapObject [[
["#type", "IOrgClass"],
["#create", {
GVAR(OrgBaseClass) = compileFinal createHashMapFromArray [
["#type", "OrgBaseClass"],
["#create", compileFinal {
_self set ["uid", getPlayerUID player];
_self set ["org", createHashMap];
_self set ["isLoaded", false];
@ -36,7 +40,7 @@ GVAR(OrgClass) = createHashMapObject [[
_self set ["org", _org];
}],
["init", {
["init", compileFinal {
private _uid = _self get "uid";
private _org = _self get "org";
@ -45,7 +49,7 @@ GVAR(OrgClass) = createHashMapObject [[
systemChat format ["Org loaded for %1", (name player)];
diag_log "[FORGE:Client:Org] Org Class Initialized!";
}],
["save", {
["save", compileFinal {
params [["_sync", false, [false]]];
private _uid = _self get "uid";
@ -53,7 +57,7 @@ GVAR(OrgClass) = createHashMapObject [[
_self set ["lastSave", time];
}],
["sync", {
["sync", compileFinal {
params [["_data", createHashMap, [createHashMap]], ["_jip", false, [false]]];
private _isLoaded = _self get "isLoaded";
@ -65,12 +69,13 @@ GVAR(OrgClass) = createHashMapObject [[
if !(_isLoaded) then { _self set ["isLoaded", true]; };
diag_log "[FORGE:Client:Org] Sync completed";
}],
["get", {
["get", compileFinal {
params [["_key", "", [""]], ["_default", nil, [[], "", 0, false, createHashMap]]];
private _org = _self get "org";
_org getOrDefault [_key, _default];
}]
]];
];
GVAR(OrgClass) = createHashMapObject [GVAR(OrgBaseClass)];
GVAR(OrgClass)

View File

@ -14,22 +14,22 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetActor), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
private _finalData = GVAR(ActorStore) call ["get", [GVAR(ActorRegistry), "actor:get", _uid, _sync]];
private _finalData = GVAR(ActorStore) call ["get", [GVAR(Registry), _uid, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(actor,responseSyncActor), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetActor), {
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID or Key!" };
if (_uid isEqualTo "" || _field isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID or Key!" };
private _hashMap = GVAR(ActorStore) call ["set", [GVAR(ActorRegistry), "actor:update", _uid, _key, _value, _sync]];
private _hashMap = GVAR(ActorStore) call ["set", [GVAR(Registry), "actor:update", _uid, _field, _value, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(actor,responseSyncActor), [_hashMap], _player] call CFUNC(targetEvent);
@ -41,18 +41,18 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid field pairs!" };
private _hashMap = GVAR(ActorStore) call ["mset", [GVAR(ActorRegistry), "actor:update", _uid, _fieldValuePairs, _sync]];
private _hashMap = GVAR(ActorStore) call ["mset", [GVAR(Registry), "actor:update", _uid, _fieldValuePairs, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(actor,responseSyncActor), [_hashMap], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSaveActor), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
private _finalData = GVAR(ActorStore) call ["save", [GVAR(ActorRegistry), "actor:update", _uid, _sync]];
private _finalData = GVAR(ActorStore) call ["save", [GVAR(Registry), "actor:update", _uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(actor,responseSyncActor), [_finalData], _player] call CFUNC(targetEvent);
@ -62,5 +62,5 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
GVAR(ActorStore) call ["remove", [GVAR(ActorRegistry), _uid]];
GVAR(ActorStore) call ["remove", [GVAR(Registry), _uid]];
}] call CFUNC(addEventHandler);

View File

@ -4,7 +4,7 @@
* File: fnc_initActorStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: Yes
*
* Description:
@ -24,7 +24,7 @@
#pragma hemtt ignore_variables ["_self"]
GVAR(ActorModel) = compileFinal createHashMapObject [[
["#type", "ActorModel"],
["defaults", {
["defaults", compileFinal {
private _actor = createHashMap;
_actor set ["uid", ""];
@ -42,7 +42,7 @@ GVAR(ActorModel) = compileFinal createHashMapObject [[
_actor
}],
["fromPlayer", {
["fromPlayer", compileFinal {
params [["_player", objNull, [objNull]]];
if (_player isEqualTo objNull) exitWith { _self call ["defaults", []] };
@ -59,7 +59,7 @@ GVAR(ActorModel) = compileFinal createHashMapObject [[
_actor
}],
["migrate", {
["migrate", compileFinal {
params [["_actor", createHashMap, [createHashMap]]];
private _defaults = _self call ["defaults", []];
@ -70,7 +70,7 @@ GVAR(ActorModel) = compileFinal createHashMapObject [[
_actor
}],
["validate", {
["validate", compileFinal {
params [["_actor", createHashMap, [createHashMap]]];
private _uid = _actor getOrDefault ["uid", ""];
@ -104,17 +104,17 @@ GVAR(ActorModel) = compileFinal createHashMapObject [[
}]
]];
GVAR(ActorRepository) = compileFinal createHashMapFromArray [
GVAR(ActorBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "ActorRepository"],
["#create", {
GVAR(ActorRegistry) = createHashMap;
["INFO", "Actor Repository Initialized!"] call EFUNC(common,log);
["#type", "ActorBaseStore"],
["#create", compileFinal {
GVAR(Registry) = createHashMap;
["INFO", "Actor Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(ActorRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(Registry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
private _player = [_uid] call EFUNC(common,getPlayer);
@ -145,27 +145,12 @@ GVAR(ActorRepository) = compileFinal createHashMapFromArray [
};
_finalActor = GVAR(ActorModel) call ["migrate", [_finalActor]];
GVAR(ActorRegistry) set [_uid, _finalActor];
_finalActor
GVAR(Registry) set [_uid, _finalActor];
[CRPC(actor,responseInitActor), [_finalActor], _player] call CFUNC(targetEvent);
_finalActor
}]
];
GVAR(ActorStore) = createHashMapObject [[
["#base", GVAR(ActorRepository)],
["#type", "IActorStore"],
["#create", {
["INFO", "Actor Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _actor = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(actor,responseInitActor), [_actor], _player] call CFUNC(targetEvent);
_actor
}]
]];
GVAR(ActorStore) = createHashMapObject [GVAR(ActorBaseStore)];
GVAR(ActorStore)

View File

@ -14,18 +14,22 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetBank), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
GVAR(BankStore) call ["get", [GVAR(BankRegistry), "bank:get", _uid, _sync]];
private _finalData = GVAR(BankStore) call ["get", [GVAR(Registry), _uid, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetBank), {
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID or Key!" };
if (_uid isEqualTo "" || _field isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID or Key!" };
private _hashMap = GVAR(BankStore) call ["set", [GVAR(BankRegistry), "bank:update", _uid, _key, _value, _sync]];
private _hashMap = GVAR(BankStore) call ["set", [GVAR(Registry), "bank:update", _uid, _field, _value, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_hashMap], _player] call CFUNC(targetEvent);
@ -37,18 +41,18 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid field pairs!" };
private _hashMap = GVAR(BankStore) call ["mset", [GVAR(BankRegistry), "bank:update", _uid, _fieldValuePairs, _sync]];
private _hashMap = GVAR(BankStore) call ["mset", [GVAR(Registry), "bank:update", _uid, _fieldValuePairs, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_hashMap], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSaveBank), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
private _finalData = GVAR(BankStore) call ["save", [GVAR(BankRegistry), "bank:update", _uid, _sync]];
private _finalData = GVAR(BankStore) call ["save", [GVAR(Registry), "bank:update", _uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_finalData], _player] call CFUNC(targetEvent);
@ -58,7 +62,7 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
GVAR(BankStore) call ["remove", [GVAR(BankRegistry), _uid]];
GVAR(BankStore) call ["remove", [GVAR(Registry), _uid]];
}] call CFUNC(addEventHandler);
[QGVAR(requestDeposit), {

View File

@ -4,7 +4,7 @@
* File: fnc_initBankStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: Yes
*
* Description:
@ -24,7 +24,7 @@
#pragma hemtt ignore_variables ["_self"]
GVAR(BankModel) = compileFinal createHashMapObject [[
["#type", "BankModel"],
["defaults", {
["defaults", compileFinal {
private _account = createHashMap;
_account set ["uid", ""];
@ -37,7 +37,7 @@ GVAR(BankModel) = compileFinal createHashMapObject [[
_account
}],
["fromPlayer", {
["fromPlayer", compileFinal {
params [["_player", objNull, [objNull]]];
if (_player isEqualTo objNull) exitWith { _self call ["defaults", []] };
@ -54,7 +54,7 @@ GVAR(BankModel) = compileFinal createHashMapObject [[
_account
}],
["migrate", {
["migrate", compileFinal {
params [["_account", createHashMap, [createHashMap]]];
private _defaults = _self call ["defaults", []];
@ -65,7 +65,7 @@ GVAR(BankModel) = compileFinal createHashMapObject [[
_account
}],
["validate", {
["validate", compileFinal {
params [["_account", createHashMap, [createHashMap]]];
private _uid = _account getOrDefault ["uid", ""];
@ -91,18 +91,18 @@ GVAR(BankModel) = compileFinal createHashMapObject [[
}]
]];
GVAR(BankRepository) = compileFinal createHashMapFromArray [
GVAR(BankBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "BankRepository"],
["#create", {
GVAR(BankRegistry) = createHashMap;
["#type", "BankBaseStore"],
["#create", compileFinal {
GVAR(IndexRegistry) = createHashMap;
["INFO", "Bank Repository Initialized!"] call EFUNC(common,log);
GVAR(Registry) = createHashMap;
["INFO", "Bank Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(BankRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(Registry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
private _player = [_uid] call EFUNC(common,getPlayer);
@ -137,15 +137,17 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
GVAR(IndexRegistry) set [_uid, _regEntry];
// _finalAccount = GVAR(BankModel) call ["migrate", [_finalAccount]];
GVAR(BankRegistry) set [_uid, _finalAccount];
GVAR(Registry) set [_uid, _finalAccount];
[CRPC(bank,responseInitBank), [_finalAccount], _player] call CFUNC(targetEvent);
_finalAccount
}],
["deposit", {
["deposit", compileFinal {
params [["_uid", "", [""]], ["_amount", 0, [0]]];
["INFO", format ["Deposit %1, for %2", _amount, _uid]] call EFUNC(common,log);
private _account = GVAR(BankRegistry) getOrDefault [_uid, nil];
private _account = GVAR(Registry) getOrDefault [_uid, nil];
if (isNil "_account") exitWith { ["ERROR", "Empty/Invalid Account!"] call EFUNC(common,log); };
private _bank = _account getOrDefault ["bank", 0];
@ -153,42 +155,37 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
if (_cash < _amount) exitWith { ["WARNING", "Insufficient Funds!"] call EFUNC(common,log); };
private _finalAccount = createHashMapFromArray [["bank", (_bank + _amount)], ["cash", (_cash - _amount)]];
_self call ["mset", [_uid, _finalAccount]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_finalAccount], _player] call CFUNC(targetEvent);
[CRPC(notifications,recieveNotification), ["info", "Bank", format ["Deposited $%1", _amount]], _player] call CFUNC(targetEvent);
}],
["payment", {
["payment", compileFinal {
params [["_uid", "", [""]], ["_amount", 0, [0]]];
["INFO", format ["Payment %1, for %2", _amount, _uid]] call EFUNC(common,log);
private _account = GVAR(BankRegistry) getOrDefault [_uid, nil];
private _account = GVAR(Registry) getOrDefault [_uid, nil];
if (isNil "_account") exitWith { ["ERROR", "Empty/Invalid Account!"] call EFUNC(common,log); };
private _bank = _account getOrDefault ["bank", 0];
private _finalAccount = createHashMapFromArray [["bank", (_bank + _amount)]];
_self call ["mset", [_uid, _finalAccount]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_finalAccount], _player] call CFUNC(targetEvent);
[CRPC(notifications,recieveNotification), ["info", "Bank", format ["Paid $%1", _amount]], _player] call CFUNC(targetEvent);
}],
["transfer", {
["transfer", compileFinal {
params [["_uid", "", [""]], ["_target", "", [""]], ["_from", "", [""]], ["_amount", 0, [0]]];
if (_uid isEqualTo _target) exitWith {
["WARNING", format ["Self-transfer attempt blocked for %1", _uid]] call EFUNC(common,log);
};
private _account = GVAR(BankRegistry) getOrDefault [_uid, nil];
private _account = GVAR(Registry) getOrDefault [_uid, nil];
if (isNil "_account") exitWith { ["ERROR", "Empty/Invalid Account!"] call EFUNC(common,log); };
private _targetAccount = GVAR(BankRegistry) getOrDefault [_target, nil];
private _targetAccount = GVAR(Registry) getOrDefault [_target, nil];
if (isNil "_targetAccount") exitWith { ["ERROR", "Empty/Invalid Target Account!"] call EFUNC(common,log); };
private _bank = _account getOrDefault [_from, 0];
@ -198,9 +195,6 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
private _finalAccount = createHashMapFromArray [[_from, (_bank - _amount)]];
private _finalTargetBank = createHashMapFromArray [["bank", (_targetBank + _amount)]];
_self call ["mset", [_uid, _finalAccount]];
_self call ["mset", [_target, _finalTargetBank]];
private _player = [_uid] call EFUNC(common,getPlayer);
private _targetPlayer = [_target] call EFUNC(common,getPlayer);
@ -209,12 +203,12 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
[CRPC(notifications,recieveNotification), ["info", "Bank", format ["Transferred $%1 to %2", _amount, (name _targetPlayer)]], _player] call CFUNC(targetEvent);
[CRPC(notifications,recieveNotification), ["info", "Bank", format ["Received $%1 from %2", _amount, (name _player)]], _targetPlayer] call CFUNC(targetEvent);
}],
["withdraw", {
["withdraw", compileFinal {
params [["_uid", "", [""]], ["_amount", 0, [0]]];
["INFO", format ["Withdraw %1, for %2", _amount, _uid]] call EFUNC(common,log);
private _account = GVAR(BankRegistry) getOrDefault [_uid, nil];
private _account = GVAR(Registry) getOrDefault [_uid, nil];
if (isNil "_account") exitWith { ["ERROR", "Empty/Invalid Account!"] call EFUNC(common,log); };
private _bank = _account getOrDefault ["bank", 0];
@ -222,8 +216,6 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
if (_bank < _amount) exitWith { ["WARNING", "Insufficient Funds!"] call EFUNC(common,log); };
private _finalAccount = createHashMapFromArray [["bank", (_bank - _amount)], ["cash", (_cash + _amount)]];
_self call ["mset", [_uid, _finalAccount]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseSyncBank), [_finalAccount], _player] call CFUNC(targetEvent);
@ -231,20 +223,5 @@ GVAR(BankRepository) = compileFinal createHashMapFromArray [
}]
];
GVAR(BankStore) = createHashMapObject [[
["#base", GVAR(BankRepository)],
["#type", "IBankStore"],
["#create", {
["INFO", "Bank Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _account = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(bank,responseInitBank), [_account], _player] call CFUNC(targetEvent);
}]
]];
GVAR(BankStore) = createHashMapObject [GVAR(BankBaseStore)];
GVAR(BankStore)

View File

@ -4,7 +4,7 @@
* File: fnc_baseStore.sqf
* Author: IDSolutions
* Date: 2026-01-08
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -24,69 +24,83 @@
GVAR(BaseStore) = compileFinal createHashMapFromArray [
["#type", "IBaseStore"],
["fetch", {
params [["_function", "", [""]], ["_uid", "", [""]]];
params [["_function", "", [""]], ["_key", "", [""]]];
private _data = createHashMap;
[_function, [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
[_function, [_key]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
["INFO", format ["Data: %1", _result]] call EFUNC(common,log);
if (count _result > 0) then { _data = _self call ["toHashMap", [_result]] };
if (_result isNotEqualTo []) then { _data = _self call ["toHashMap", [_result]] };
_data
}],
["set", {
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [0, "", [], false, createHashMap, objNull, grpNull]], ["_sync", false, [false]]];
["get", {
params [["_registry", createHashMap, [createHashMap]], ["_key", "", [""]], ["_field", "", [""]]];
private _existingData = _registry get _uid;
private _existingData = _registry get _key;
private _finalData = createHashMap;
if (_field isNotEqualTo "") then {
_finalData = _existingData get _field
} else {
_finalData = _existingData
};
_finalData
}],
["set", {
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_key", "", [""]], ["_field", "", [""]], ["_value", nil, [0, "", [], false, createHashMap, objNull, grpNull]], ["_sync", false, [false]]];
private _existingData = _registry get _key;
private _finalData = +_existingData;
private _hashMap = createHashMap;
_finalData set [_field, _value];
_hashMap set [_field, _value];
_registry set [_uid, _finalData];
_registry set [_key, _finalData];
if (_sync) then {
private _json = _self call ["toJSON", [_hashMap]];
[_function, [_uid, _json]] call EFUNC(extension,extCall);
[_function, [_key, _json]] call EFUNC(extension,extCall);
};
_hashMap
}],
["mset", {
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_key", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
private _existingData = _registry get _uid;
private _existingData = _registry get _key;
private _finalData = +_existingData;
private _hashMap = createHashMap;
{ _finalData set [_x, _y]; } forEach _fieldValuePairs;
{ _hashMap set [_x, _y]; } forEach _fieldValuePairs;
_registry set [_uid, _finalData];
_registry set [_key, _finalData];
if (_sync) then {
private _json = _self call ["toJSON", [_hashMap]];
[_function, [_uid, _json]] call EFUNC(extension,extCall);
[_function, [_key, _json]] call EFUNC(extension,extCall);
};
_hashMap
}],
["save", {
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_uid", "", [""]]];
params [["_registry", createHashMap, [createHashMap]], ["_function", "", [""]], ["_key", "", [""]]];
private _existingData = _registry get _uid;
private _existingData = _registry get _key;
private _finalData = +_existingData;
private _json = _self call ["toJSON", [_finalData]];
[_function, [_uid, _json]] call EFUNC(extension,extCall);
[_function, [_key, _json]] call EFUNC(extension,extCall);
_finalData
}],
["remove", {
params [["_registry", createHashMap, [createHashMap]], ["_uid", "", [""]]];
params [["_registry", createHashMap, [createHashMap]], ["_key", "", [""]]];
_registry deleteAt _uid;
_registry deleteAt _key;
}],
["toHashMap", {
params [["_data", "", [""]]];

View File

@ -4,7 +4,7 @@
* File: fnc_initMEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-01-03
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -69,7 +69,7 @@ GVAR(MEconomyStore) = createHashMapObject [[
if (isNull _unit) exitWith { ["WARNING", format ["Invalid unit provided: %1", (name _unit)], nil, nil] call EFUNC(common,log); };
private _uid = getPlayerUID _unit;
private _account = EGVAR(bank,BankRegistry) get _uid;
private _account = EGVAR(bank,Registry) get _uid;
if (isNil "_account") exitWith { ["ERROR", format ["No account found for %1. UID: %2", (name _unit), _uid], nil, nil] call EFUNC(common,log); };

View File

@ -14,10 +14,14 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetGarage), {
params [["_uid", "", [""]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
GVAR(GarageStore) call ["get", [GVAR(GarageRegistry), "garage:get", _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), {
@ -25,7 +29,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID or Key!" };
private _hashMap = GVAR(GarageStore) call ["set", [GVAR(GarageRegistry), "garage:update", _uid, _key, _value, _sync]];
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);
@ -37,7 +41,7 @@ PREP_RECOMPILE_END;
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(GarageRegistry), "garage:update", _uid, _fieldValuePairs, _sync]];
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);
@ -48,7 +52,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
private _finalData = GVAR(GarageStore) call ["save", [GVAR(GarageRegistry), "garage:update", _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);
@ -58,7 +62,7 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Garage] Empty/Invalid UID!" };
GVAR(GarageStore) call ["remove", [GVAR(GarageRegistry), _uid]];
GVAR(GarageStore) call ["remove", [GVAR(Registry), _uid]];
}] call CFUNC(addEventHandler);
[QGVAR(requestInitVG), {
@ -69,14 +73,14 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetVG), {
params [["_uid", "", [""]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
private _hashMap = GVAR(VGarageStore) call ["get", [GVAR(VGarageRegistry), "owned:garage:fetch", _uid]];
private _finalData = GVAR(VGarageStore) call ["get", [GVAR(VGRegistry), "owned:garage:fetch", _uid, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(garage,responseSyncVG), [_hashMap], _player] call CFUNC(targetEvent);
[CRPC(garage,responseSyncVG), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetVG), {
@ -84,7 +88,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID or Key!" };
private _hashMap = GVAR(VGarageStore) call ["set", [GVAR(VGarageRegistry), "", _uid, _key, _value, _sync]];
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);
@ -96,7 +100,7 @@ PREP_RECOMPILE_END;
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(VGarageRegistry), "", _uid, _fieldValuePairs, _sync]];
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);
@ -107,7 +111,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
private _finalData = GVAR(VGarageStore) call ["save", [GVAR(VGarageRegistry), "", _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);
@ -117,5 +121,5 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VGarage] Empty/Invalid UID!" };
GVAR(VGarageStore) call ["remove", [GVAR(VGarageRegistry), _uid]];
GVAR(VGarageStore) call ["remove", [GVAR(VGRegistry), _uid]];
}] call CFUNC(addEventHandler);

View File

@ -4,7 +4,7 @@
* File: fnc_initGarageStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -22,17 +22,17 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(GarageRepository) = compileFinal createHashMapFromArray [
GVAR(GarageBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "GarageRepository"],
["#create", {
GVAR(GarageRegistry) = createHashMap;
["INFO", "Garage Repository Initialized!"] call EFUNC(common,log);
["#type", "GarageBaseStore"],
["#create", compileFinal {
GVAR(Registry) = createHashMap;
["INFO", "Garage Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(GarageRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(Registry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
["garage:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
@ -56,25 +56,14 @@ GVAR(GarageRepository) = compileFinal createHashMapFromArray [
["INFO", format ["Created new garage for %1", _uid]] call EFUNC(common,log);
};
GVAR(GarageRegistry) set [_uid, _finalGarage];
private _player = [_uid] call EFUNC(common,getPlayer);
GVAR(Registry) set [_uid, _finalGarage];
[CRPC(garage,responseInitGarage), [_finalGarage], _player] call CFUNC(targetEvent);
_finalGarage
}]
];
GVAR(GarageStore) = createHashMapObject [[
["#base", GVAR(GarageRepository)],
["#type", "IGarageStore"],
["#create", {
["INFO", "Garage Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _garage = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(garage,responseInitGarage), [_garage], _player] call CFUNC(targetEvent);
}]
]];
GVAR(GarageStore) = createHashMapObject [GVAR(GarageBaseStore)];
GVAR(GarageStore)

View File

@ -4,7 +4,7 @@
* File: fnc_initVGStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-31
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -24,7 +24,7 @@
#pragma hemtt ignore_variables ["_self"]
GVAR(VGarageModel) = compileFinal createHashMapObject [[
["#type", "VGarageModel"],
["defaults", {
["defaults", compileFinal {
private _vGarage = createHashMap;
_vGarage set ["armor", []];
@ -38,17 +38,17 @@ GVAR(VGarageModel) = compileFinal createHashMapObject [[
}]
]];
GVAR(VGarageRepository) = compileFinal createHashMapFromArray [
GVAR(VGBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "VGarageRepository"],
["#create", {
GVAR(VGarageRegistry) = createHashMap;
["INFO", "VGarage Repository Initialized!"] call EFUNC(common,log);
["#type", "VGBaseStore"],
["#create", compileFinal {
GVAR(VGRegistry) = createHashMap;
["INFO", "VGarage Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(VGarageRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(VGRegistry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
["owned:garage:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
@ -74,25 +74,14 @@ GVAR(VGarageRepository) = compileFinal createHashMapFromArray [
["INFO", format ["Created new virtual garage for %1", _uid]] call EFUNC(common,log);
};
GVAR(VGarageRegistry) set [_uid, _finalVGarage];
private _player = [_uid] call EFUNC(common,getPlayer);
GVAR(VGRegistry) set [_uid, _finalVGarage];
[CRPC(garage,responseInitVG), [_finalVGarage], _player] call CFUNC(targetEvent);
_finalVGarage
}]
];
GVAR(VGarageStore) = createHashMapObject [[
["#base", GVAR(VGarageRepository)],
["#type", "VGarageStore"],
["#create", {
["INFO", "VGarage Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _vGarage = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(garage,responseInitVG), [_vGarage], _player] call CFUNC(targetEvent);
}]
]];
GVAR(VGarageStore) = createHashMapObject [GVAR(VGBaseStore)];
GVAR(VGarageStore)

View File

@ -14,18 +14,22 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetLocker), {
params [["_uid", "", [""]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID!" };
GVAR(LockerStore) call ["get", [GVAR(LockerRegistry), "locker:get", _uid]];
private _finalData = GVAR(LockerStore) call ["get", [GVAR(Registry), "locker:get", _uid, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncLocker), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetLocker), {
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID or Key!" };
if (_uid isEqualTo "" || _field isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID or Field!" };
private _hashMap = GVAR(LockerStore) call ["set", [GVAR(LockerRegistry), "locker:update", _uid, _key, _value, _sync]];
private _hashMap = GVAR(LockerStore) call ["set", [GVAR(Registry), "locker:update", _uid, _field, _value, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncLocker), [_hashMap], _player] call CFUNC(targetEvent);
@ -37,7 +41,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID!" };
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid field pairs!" };
private _hashMap = GVAR(LockerStore) call ["mset", [GVAR(LockerRegistry), "locker:update", _uid, _fieldValuePairs, _sync]];
private _hashMap = GVAR(LockerStore) call ["mset", [GVAR(Registry), "locker:update", _uid, _fieldValuePairs, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncLocker), [_hashMap], _player] call CFUNC(targetEvent);
@ -48,7 +52,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID!" };
private _finalData = GVAR(LockerStore) call ["save", [GVAR(LockerRegistry), "locker:update", _uid]];
private _finalData = GVAR(LockerStore) call ["save", [GVAR(Registry), "locker:update", _uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncLocker), [_finalData], _player] call CFUNC(targetEvent);
@ -58,7 +62,7 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]], ["_data", createHashMap, [createHashMap]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Locker] Empty/Invalid UID!" };
GVAR(LockerRegistry) set [_uid, _data];
GVAR(Registry) set [_uid, _data];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncLocker), [_data], _player] call CFUNC(targetEvent);
@ -75,22 +79,26 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID!" };
GVAR(VArsenalStore) call ["init", [_uid]];
GVAR(VAStore) call ["init", [_uid]];
}] call CFUNC(addEventHandler);
[QGVAR(requestGetVA), {
params [["_uid", "", [""]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID!" };
GVAR(VArsenalStore) call ["get", [GVAR(VArsenalRegistry), "owned:locker:fetch", _uid]];
private _finalData = GVAR(VAStore) call ["get", [GVAR(VARegistry), "owned:locker:fetch", _uid, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncVArsenal), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetVA), {
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID or Key!" };
if (_uid isEqualTo "" || _field isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID or Field!" };
private _hashMap = GVAR(VArsenalStore) call ["set", [GVAR(VArsenalRegistry), "owned:locker:update", _uid, _key, _value, _sync]];
private _hashMap = GVAR(VAStore) call ["set", [GVAR(VARegistry), "owned:locker:update", _uid, _field, _value, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncVArsenal), [_hashMap], _player] call CFUNC(targetEvent);
@ -102,7 +110,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID!" };
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid field pairs!" };
private _hashMap = GVAR(VArsenalStore) call ["mset", [GVAR(VArsenalRegistry), "owned:locker:update", _uid, _fieldValuePairs, _sync]];
private _hashMap = GVAR(VAStore) call ["mset", [GVAR(VARegistry), "owned:locker:update", _uid, _fieldValuePairs, _sync]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncVArsenal), [_hashMap], _player] call CFUNC(targetEvent);
@ -113,7 +121,7 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID!" };
private _finalData = GVAR(VArsenalStore) call ["save", [GVAR(VArsenalRegistry), "owned:locker:update", _uid]];
private _finalData = GVAR(VAStore) call ["save", [GVAR(VARegistry), "owned:locker:update", _uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseSyncVArsenal), [_finalData], _player] call CFUNC(targetEvent);
@ -123,5 +131,5 @@ PREP_RECOMPILE_END;
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:VArsenal] Empty/Invalid UID!" };
GVAR(VArsenalStore) call ["remove", [GVAR(VArsenalRegistry), _uid]];
GVAR(VAStore) call ["remove", [GVAR(VARegistry), _uid]];
}] call CFUNC(addEventHandler);

View File

@ -4,7 +4,7 @@
* File: fnc_initLockerStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-30
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -22,17 +22,17 @@
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(LockerRepository) = compileFinal createHashMapFromArray [
GVAR(LockerBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "LockerRepository"],
["#create", {
GVAR(LockerRegistry) = createHashMap;
["INFO", "Locker Repository Initialized!"] call EFUNC(common,log);
["#type", "LockerBaseStore"],
["#create", compileFinal {
GVAR(Registry) = createHashMap;
["INFO", "Locker Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(LockerRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(Registry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
["locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
@ -56,25 +56,14 @@ GVAR(LockerRepository) = compileFinal createHashMapFromArray [
["INFO", format ["Created new locker for %1", _uid]] call EFUNC(common,log);
};
GVAR(LockerRegistry) set [_uid, _finalLocker];
private _player = [_uid] call EFUNC(common,getPlayer);
GVAR(Registry) set [_uid, _finalLocker];
[CRPC(locker,responseInitLocker), [_finalLocker], _player] call CFUNC(targetEvent);
_finalLocker
}]
];
GVAR(LockerStore) = createHashMapObject [[
["#base", GVAR(LockerRepository)],
["#type", "LockerStore"],
["#create", {
["INFO", "Locker Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _locker = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseInitLocker), [_locker], _player] call CFUNC(targetEvent);
}]
]];
GVAR(LockerStore) = createHashMapObject [GVAR(LockerBaseStore)];
GVAR(LockerStore)

View File

@ -4,7 +4,7 @@
* File: fnc_initVAStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-02-05
* Last Update: 2026-02-13
* Public: No
*
* Description:
@ -24,7 +24,7 @@
#pragma hemtt ignore_variables ["_self"]
GVAR(VArsenalModel) = compileFinal createHashMapObject [[
["#type", "VArsenalModel"],
["defaults", {
["defaults", compileFinal {
private _vArsenal = createHashMap;
_vArsenal set ["backpacks", ["B_AssaultPack_rgr"]];
@ -36,17 +36,17 @@ GVAR(VArsenalModel) = compileFinal createHashMapObject [[
}]
]];
GVAR(VArsenalRepository) = compileFinal createHashMapFromArray [
GVAR(VABaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "VArsenalRepository"],
["#create", {
GVAR(VArsenalRegistry) = createHashMap;
["INFO", "VArsenal Repository Initialized!"] call EFUNC(common,log);
["#type", "VABaseStore"],
["#create", compileFinal {
GVAR(VARegistry) = createHashMap;
["INFO", "VArsenal Store Initialized!"] call EFUNC(common,log);
}],
["get", {
["init", compileFinal {
params [["_uid", "", [""]]];
private _cached = GVAR(VArsenalRegistry) getOrDefault [_uid, nil];
private _cached = GVAR(VARegistry) getOrDefault [_uid, nil];
if !(isNil { _cached }) exitWith { _cached };
["owned:locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
@ -72,25 +72,14 @@ GVAR(VArsenalRepository) = compileFinal createHashMapFromArray [
["INFO", format ["Created new virtual arsenal for %1", _uid]] call EFUNC(common,log);
};
GVAR(VArsenalRegistry) set [_uid, _finalVArsenal];
private _player = [_uid] call EFUNC(common,getPlayer);
GVAR(VARegistry) set [_uid, _finalVArsenal];
[CRPC(locker,responseInitVA), [_finalVArsenal], _player] call CFUNC(targetEvent);
_finalVArsenal
}]
];
GVAR(VArsenalStore) = createHashMapObject [[
["#base", GVAR(VArsenalRepository)],
["#type", "VArsenalStore"],
["#create", {
["INFO", "VArsenal Store Initialized!"] call EFUNC(common,log);
}],
["init", {
params [["_uid", "", [""]]];
private _vArsenal = _self call ["get", [_uid]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(locker,responseInitVA), [_vArsenal], _player] call CFUNC(targetEvent);
}]
]];
GVAR(VArsenalStore)
GVAR(VAStore) = createHashMapObject [GVAR(VABaseStore)];
GVAR(VAStore)

View File

@ -35,7 +35,7 @@ if (isNil QEGVAR(garage,VGarageStore)) then { call EFUNC(garage,initVGStore); };
if (isNil QEGVAR(locker,LockerStore)) then { call EFUNC(locker,initLockerStore); };
// VArsenal
if (isNil QEGVAR(locker,VArsenalStore)) then { call EFUNC(locker,initVAStore); };
if (isNil QEGVAR(locker,VAStore)) then { call EFUNC(locker,initVAStore); };
// Org
if (isNil QEGVAR(org,OrgStore)) then { call EFUNC(org,initOrgStore); };

View File

@ -16,17 +16,26 @@ PREP_RECOMPILE_END;
}] call CFUNC(addEventHandler);
[QGVAR(requestGetOrg), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID!" };
GVAR(OrgStore) call ["get", [_uid, _sync]];
private _index = GVAR(IndexRegistry) get _uid;
private _key = _index get "orgID";
private _finalData = GVAR(OrgStore) call ["get", [GVAR(Registry), _key, _field]];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(org,responseSyncOrg), [_finalData], _player] call CFUNC(targetEvent);
}] call CFUNC(addEventHandler);
[QGVAR(requestSetOrg), {
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID or Key!" };
GVAR(OrgStore) call ["set", [_uid, _key, _value, _sync]];
if (_uid isEqualTo "" || _field isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID or Field!" };
private _index = GVAR(IndexRegistry) get _uid;
private _key = _index get "orgID";
GVAR(OrgStore) call ["set", [GVAR(Registry), "org:update", _key, _field, _value, _sync]];
}] call CFUNC(addEventHandler);
[QGVAR(requestMSetOrg), {
@ -35,19 +44,28 @@ PREP_RECOMPILE_END;
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID!" };
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid field pairs!" };
GVAR(OrgStore) call ["mset", [_uid, _fieldValuePairs, _sync]];
private _index = GVAR(IndexRegistry) get _uid;
private _key = _index get "orgID";
GVAR(OrgStore) call ["mset", [GVAR(Registry), "org:update", _key, _fieldValuePairs, _sync]];
}] call CFUNC(addEventHandler);
[QGVAR(requestSaveOrg), {
params [["_uid", "", [""]], ["_sync", false, [false]]];
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID!" };
GVAR(OrgStore) call ["save", [_uid, _sync]];
private _index = GVAR(IndexRegistry) get _uid;
private _key = _index get "orgID";
GVAR(OrgStore) call ["save", [GVAR(Registry), "org:update", _key]];
}] call CFUNC(addEventHandler);
[QGVAR(requestRemoveOrg), {
params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Org] Empty/Invalid UID!" };
GVAR(OrgStore) call ["remove", [_uid]];
private _index = GVAR(IndexRegistry) get _uid;
private _key = _index get "orgID";
GVAR(OrgStore) call ["remove", [GVAR(Registry), "org:update", _key]];
}] call CFUNC(addEventHandler);

View File

@ -1,251 +1,161 @@
#include "..\script_component.hpp"
/*
* File: fnc_initOrgStore.sqf
* Author: IDSolutions
* Initializes the org store.
* Date: 2026-02-13
* Last Update: 2026-02-13
* Public: Yes
*
* Description:
* Initializes the org store for managing player organizations.
* Provides methods for creating, fetching, and updating organizations.
*
* Arguments:
* None
*
* Return Value:
* None
* Org store object [HASHMAP OBJECT]
*
* Examples:
* call forge_server_org_fnc_initOrgStore
*
* Public: Yes
*/
#pragma hemtt ignore_variables ["_self"]
GVAR(OrgStore) = createHashMapObject [[
["#type", "IOrgStore"],
["#create", {
GVAR(IndexRegistry) = createHashMap;
GVAR(OrgRegistry) = createHashMap;
GVAR(OrgModel) = compileFinal createHashMapObject [[
["#type", "OrgModel"],
["defaults", compileFinal {
private _org = createHashMap;
private _hashMap = createHashMap;
_hashMap set ["id", "default"];
_hashMap set ["owner", "server"];
_hashMap set ["name", "Forge Dynamics"];
_hashMap set ["funds", 200000];
_hashMap set ["reputation", 0];
_org set ["id", ""];
_org set ["owner", ""];
_org set ["name", ""];
_org set ["funds", 0];
_org set ["reputation", 0];
private _json = _self call ["toJSON", [_hashMap]];
["org:create", ["default", _json]] call EFUNC(extension,extCall);
["INFO", "Org Store Initialized!", nil, nil] call EFUNC(common,log);
_org
}],
["init", {
params [["_uid", "", [""]], ["_defaultOrg", createHashMap, [createHashMap]]];
["migrate", compileFinal {
params [["_org", createHashMap, [createHashMap]]];
private _actor = EGVAR(actor,ActorRegistry) get _uid;
private _orgID = _actor get "organization";
["org:exists", [_orgID]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
private _exists = _result == "true";
private _player = [_uid] call EFUNC(common,getPlayer);
if !(_exists) exitWith {
_self call ["default", [_uid, (name _player)]];
["WARNING", format ["No existing org found for %1, using default org.", _uid], nil, nil] call EFUNC(common,log);
};
private _regEntry = createHashMapFromArray [["orgID", _orgID]];
GVAR(IndexRegistry) set [_uid, _regEntry];
private _organization = _self call ["fetch", [_uid]];
private _members = _self call ["fetchMembers", [_uid]];
// private _assets = _self call ["fetchAssets", [_uid]];
private _finalOrg = GVAR(OrgRegistry) getOrDefault [_orgID, _organization];
_finalOrg set ["members", _members];
// _finalOrg set ["assets", _assets];
GVAR(OrgRegistry) set [_orgID, _finalOrg, true];
[CRPC(org,responseInitOrg), [_finalOrg], _player] call CFUNC(targetEvent);
["INFO", format ["Found org for %1", _uid], nil, nil] call EFUNC(common,log);
_finalOrg
}],
["default", {
params [["_uid", "", [""]], ["_name", "", [""]]];
private _assets = createHashMap;
private _members = createHashMap;
private _member = createHashMapFromArray [["uid", _uid], ["name", _name]];
private _regEntry = createHashMapFromArray [["orgID", "default"]];
GVAR(IndexRegistry) set [_uid, _regEntry];
private _organization = _self call ["fetch", ["default"]];
_members set [_uid, _member];
private _finalOrg = GVAR(OrgRegistry) getOrDefault ["default", _organization];
_finalOrg set ["members", _members];
_finalOrg set ["assets", _assets];
GVAR(OrgRegistry) set ["default", _finalOrg];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(org,responseInitOrg), [_finalOrg], _player] call CFUNC(targetEvent);
_finalOrg
}],
["fetch", {
params [["_uid", "", [""]]];
private _index = "";
private _organization = createHashMap;
private _orgID = "default";
if (_uid isNotEqualTo "default") then {
_index = GVAR(IndexRegistry) get _uid;
_orgID = _index get "orgID";
};
["org:get", [_orgID]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
["INFO", format ["Data: %1", _result], nil, nil] call EFUNC(common,log);
if (count _result > 0) then { _organization = _self call ["toHashMap", [_result]]; };
_organization
}],
["fetchAssets", {
params [["_uid", "", [""]]];
private _assets = createHashMap;
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
["org:assets:get", [_orgID]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
["INFO", format ["Assets: %1", _result], nil, nil] call EFUNC(common,log);
if (count _result > 0) then { _assets = _self call ["toHashMap", [_result]]; };
_assets
}],
["fetchMembers", {
params [["_uid", "", [""]]];
private _members = createHashMap;
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
["org:members:get", [_orgID]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
["INFO", format ["Members: %1", _result], nil, nil] call EFUNC(common,log);
private _raw_members = _self call ["toHashMap", [_result]];
private _defaults = _self call ["defaults", []];
{
private _uid = _x get "uid";
_members set [_uid, _x];
} forEach _raw_members;
if !(_x in _org) then { _org set [_x, _y]; };
} forEach _defaults;
_members
_org
}],
["get", {
params [["_uid", "", [""]], ["_sync", false, [false]]];
["validate", compileFinal {
params [["_org", createHashMap, [createHashMap]]];
private _finalOrg = createHashMap;
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
private _id = _org get "id";
private _owner = _org get "owner";
private _name = _org get "name";
private _funds = _org get "funds";
private _reputation = _org get "reputation";
if (_sync) then {
_finalOrg = _self call ["fetch", [_uid]];
GVAR(OrgRegistry) set [_orgID, _finalOrg];
} else {
_finalOrg = GVAR(OrgRegistry) getOrDefault [_orgID, createHashMap];
[_id, _owner, _name, _funds, _reputation] try {
if (_id isEqualTo "" || !(_id isEqualType "")) then { throw "Invalid ID!"; };
if (_owner isEqualTo "" || !(_owner isEqualType "")) then { throw "Invalid Owner!"; };
if (_name isEqualTo "" || !(_name isEqualType "")) then { throw "Invalid Name!"; };
if (_funds isEqualTo 0 || !(_funds isEqualType 0)) then { throw "Invalid Funds!"; };
if (_reputation isEqualTo 0 || !(_reputation isEqualType 0)) then { throw "Invalid Reputation!"; };
} catch {
["ERROR", format ["Failed to validate org %1!", _exception]] call EFUNC(common,log);
false
};
_finalOrg
}],
["set", {
params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil], ["_sync", false, [false]]];
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
private _organization = GVAR(OrgRegistry) get _orgID;
private _finalOrg = +_organization;
private _hashMap = createHashMap;
_finalOrg set [_field, _value];
_hashMap set [_field, _value];
GVAR(OrgRegistry) set [_orgID, _finalOrg];
if (_sync) then {
private _json = _self call ["toJSON", [_hashMap]];
["org:update", [_orgID, _json]] call EFUNC(extension,extCall);
};
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(org,responseSyncOrg), [_hashMap], _player] call CFUNC(targetEvent);
_hashMap
}],
["mset", {
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
private _organization = GVAR(OrgRegistry) get _orgID;
private _finalOrg = +_organization;
private _hashMap = createHashMap;
{ _finalOrg set [_x, _y]; } forEach _fieldValuePairs;
{ _hashMap set [_x, _y]; } forEach _fieldValuePairs;
GVAR(OrgRegistry) set [_orgID, _finalOrg];
if (_sync) then {
private _json = _self call ["toJSON", [_hashMap]];
["org:update", [_orgID, _json]] call EFUNC(extension,extCall);
};
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(org,responseSyncOrg), [_hashMap], _player] call CFUNC(targetEvent);
_hashMap
}],
["save", {
params [["_uid", "", [""]], ["_sync", false, [false]]];
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
private _organization = GVAR(OrgRegistry) get _orgID;
private _finalOrg = +_organization;
private _json = _self call ["toJSON", [_finalOrg]];
["org:update", [_orgID, _json]] call EFUNC(extension,extCall);
if (_sync) then {
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(org,responseSyncOrg), [_finalOrg], _player] call CFUNC(targetEvent);
};
_finalOrg
}],
["remove", {
params [["_uid", "", [""]]];
private _index = GVAR(IndexRegistry) get _uid;
private _orgID = _index get "orgID";
GVAR(OrgRegistry) deleteAt _orgID;
}],
["toHashMap", {
params [["_data", "", [""]]];
private _hashMap = fromJSON _data;
_hashMap
}],
["toJSON", {
params [["_data", createHashMap, [createHashMap]]];
private _json = toJSON _data;
_json
true
}]
]];
SETMVAR(FORGE_OrgStore,GVAR(OrgStore));
GVAR(OrgBaseStore) = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "OrgBaseStore"],
["#create", compileFinal {
GVAR(IndexRegistry) = createHashMap;
GVAR(Registry) = createHashMap;
["INFO", "Org Store Initialized!"] call EFUNC(common,log);
["org:exists", ["default"]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
if !(_isSuccess) exitWith {
["ERROR", "Failed to check for default org!"] call EFUNC(common,log);
createHashMap;
};
private _finalOrg = createHashMap;
if (_result == "true") then {
_finalOrg = _self call ["fetch", ["org:get", "default"]];
} else {
_finalOrg set ["id", "default"];
_finalOrg set ["owner", "server"];
_finalOrg set ["name", "Forge Dynamics"];
_finalOrg set ["funds", 200000];
_finalOrg set ["reputation", 0];
private _json = _self call ["toJSON", [_finalOrg]];
["org:create", ["default", _json]] call EFUNC(extension,extCall);
};
GVAR(Registry) set ["default", _finalOrg];
}],
["init", compileFinal {
params [["_uid", "", [""]]];
private _actor = EGVAR(actor,Registry) get _uid;
private _orgID = _actor get "organization";
if (_orgID isEqualTo "") then { _orgID = "default" };
private _cached = GVAR(Registry) getOrDefault [_orgID, nil];
if !(isNil { _cached }) exitWith { _cached };
["org:exists", [_orgID]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
if !(_isSuccess) exitWith {
["ERROR", format ["Failed to check for org %1!", _orgID]] call EFUNC(common,log);
createHashMap;
};
private _finalOrg = createHashMap;
private _finalMembers = createHashMap;
// private _finalAssets = createHashMap;
private _player = [_uid] call EFUNC(common,getPlayer);
if (_result == "true") then {
_finalOrg = _self call ["fetch", ["org:get", _orgID]];
["INFO", format ["Found org for %1", _orgID]] call EFUNC(common,log);
} else {
["WARNING", format ["No existing org found for %1, using default org.", _uid]] call EFUNC(common,log);
};
private _entry = createHashMapFromArray [["orgID", _orgID]];
GVAR(IndexRegistry) set [_uid, _entry];
private _members = _self call ["fetch", ["org:members:get", _orgID]];
// private _assets = _self call ["fetch", ["org:assets:get", _orgID]];
{
private _key = _x get "uid";
private _value = _x;
_finalMembers set [_key, _value];
} forEach _members;
// {
// private _key = _x get "classname";
// private _value = _x;
// _finalAssets set [_key, _value];
// } forEach _assets;
_finalOrg set ["members", _finalMembers];
// _finalOrg set ["assets", _finalAssets];
GVAR(Registry) set [_orgID, _finalOrg, true];
[CRPC(org,responseInitOrg), [_finalOrg], _player] call CFUNC(targetEvent);
_finalOrg
}]
];
GVAR(OrgStore) = createHashMapObject [GVAR(OrgBaseStore)];
GVAR(OrgStore)

View File

@ -20,7 +20,7 @@
[["_SP_PLAYER_",[["30Rnd_65x39_caseless_mag",[["amount",4],["classname","30Rnd_65x39_caseless_mag"],["category","magazine"]]],["arifle_MX_F",[["amount",1],["classname","arifle_MX_F"],["category","weapon"]]],["NVGoggles",[["amount",1],["classname","NVGoggles"],["category","hmd"]]]]]];
// Org Registry
[["0160566824",[["assets",[]],["name","Black Rifle Company"],["id","0160566824"],["funds",0],["reputation",0],["owner","_SP_PLAYER_"],["members",[["_SP_PLAYER_",[["name","Jacob Schmidt"],["uid","_SP_PLAYER_"]]]]]]]];
[["default",[["name","Forge Dynamics"],["id","default"],["funds",200000],["reputation",0],["owner","server"]]],["0160566824",[["name","Black Rifle Company"],["id","0160566824"],["funds",0],["reputation",0],["owner","_SP_PLAYER_"],["members",[["_SP_PLAYER_",[["name","Jacob Schmidt"],["uid","_SP_PLAYER_"]]]]]]]];
// Org Index Registry
[["_SP_PLAYER_",[["orgID","0160566824"]]]];