86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
PREP_RECOMPILE_START;
|
|
#include "XEH_PREP.hpp"
|
|
PREP_RECOMPILE_END;
|
|
|
|
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
|
|
|
|
if (isNil QGVAR(ActorStore)) then { [] call FUNC(initActorStore); };
|
|
|
|
[QGVAR(requestInitActor), {
|
|
params [["_uid", "", [""]], ["_actor", createHashMap, [createHashMap]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
|
|
if (_actor isEqualTo createHashMap) exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Actor data!" };
|
|
|
|
GVAR(ActorStore) call ["init", [_uid, _actor]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestGetActor), {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
|
|
|
|
private _session = GVAR(PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Session!" };
|
|
|
|
GVAR(ActorStore) call ["get", [_uid, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSetActor), {
|
|
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID or Key!" };
|
|
|
|
private _session = GVAR(PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Session!" };
|
|
|
|
GVAR(ActorStore) call ["set", [_uid, _key, _value, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestMSetActor), {
|
|
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
|
|
|
|
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 _session = GVAR(PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Session!" };
|
|
|
|
GVAR(ActorStore) call ["mset", [_uid, _fieldValuePairs, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSaveActor), {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
|
|
|
|
private _session = GVAR(PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Session!" };
|
|
|
|
GVAR(ActorStore) call ["save", [_uid, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestRemoveActor), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid UID!" };
|
|
|
|
GVAR(ActorStore) call ["remove", [_uid]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestResync), {
|
|
params ["_player"];
|
|
|
|
private _uid = getPlayerUID _player;
|
|
private _actor = GVAR(ActorStore) call ["get", [_uid, true]];
|
|
|
|
private _session = GVAR(PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Actor] Empty/Invalid Session!" };
|
|
|
|
[CRPC(actor,responseSyncActor), [_actor, true], _player] call CFUNC(targetEvent);
|
|
|
|
diag_log format ["[FORGE:Server:Actor] Resync completed for %1", _uid];
|
|
}] call CFUNC(addEventHandler);
|