mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #4188 from acemod/cba-hash-synchedEvent
Convert common to CBA hashes
This commit is contained in:
commit
439a85924c
@ -274,8 +274,8 @@ enableCamShake true;
|
||||
|
||||
//FUNC(showHud) needs to be refreshed if it was set during mission init
|
||||
["ace_infoDisplayChanged", {
|
||||
GVAR(showHudHash) params ["", "_masks"];
|
||||
if (!(_masks isEqualTo [])) then {
|
||||
GVAR(showHudHash) params ["", "", "_masks"];
|
||||
if !(_masks isEqualTo []) then {
|
||||
[] call FUNC(showHud);
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
@ -16,8 +16,8 @@ DFUNC(selectWeaponMode) = {
|
||||
_this call CBA_fnc_selectWeapon;
|
||||
};
|
||||
|
||||
GVAR(syncedEvents) = HASH_CREATE;
|
||||
GVAR(showHudHash) = [] call FUNC(hashCreate);
|
||||
GVAR(syncedEvents) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(showHudHash) = [] call CBA_fnc_hashCreate;
|
||||
|
||||
GVAR(settingsInitFinished) = false;
|
||||
GVAR(runAtSettingsInitialized) = [];
|
||||
|
@ -14,12 +14,11 @@
|
||||
|
||||
params ["_client"];
|
||||
|
||||
{
|
||||
private _eventEntry = HASH_GET(GVAR(syncedEvents),_x);
|
||||
_eventEntry params ["", "_eventLog"];
|
||||
[GVAR(syncedEvents), {
|
||||
_value params ["", "_eventLog"];
|
||||
|
||||
["ACEs", [_x, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
["ACEs", [_key, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
false
|
||||
} count (GVAR(syncedEvents) select 0);
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
|
||||
true
|
||||
|
@ -22,12 +22,12 @@ if (isServer) then {
|
||||
// Find the event name, and shovel out the events to the client
|
||||
params ["_eventName", "_client"];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_eventName)) exitWith {
|
||||
if !([GVAR(syncedEvents), _eventName] call CBA_fnc_hashHasKey) exitWith {
|
||||
ACE_LOGERROR_1("Request for synced event - key [%1] not found.", _eventName);
|
||||
false
|
||||
};
|
||||
|
||||
private _eventEntry = HASH_GET(GVAR(syncedEvents),_eventName);
|
||||
private _eventEntry = [GVAR(syncedEvents), _eventName] call CBA_fnc_hashGet;
|
||||
_eventEntry params ["", "_eventLog"];
|
||||
|
||||
["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
|
@ -16,22 +16,19 @@
|
||||
|
||||
params ["_name", "_args", "_ttl"];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
||||
ACE_LOGERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name);
|
||||
false
|
||||
};
|
||||
|
||||
private _internalData = HASH_GET(GVAR(syncedEvents),_name);
|
||||
private _internalData = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
|
||||
_internalData params ["_eventCode", "_eventLog"];
|
||||
|
||||
if (isServer) then {
|
||||
// Server needs to internally log it for synchronization
|
||||
if (_ttl > -1) then {
|
||||
_internalData = HASH_GET(GVAR(syncedEvents),_name);
|
||||
|
||||
_internalData params ["", "_eventLog"];
|
||||
_eventLog pushBack [diag_tickTime, _args, _ttl];
|
||||
};
|
||||
};
|
||||
|
||||
_internalData params ["_eventCode"];
|
||||
_args call _eventCode;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
params ["_name", "_handler", ["_ttl", 0]];
|
||||
|
||||
if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
||||
ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name);
|
||||
false
|
||||
};
|
||||
@ -27,4 +27,4 @@ if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
|
||||
private _data = [_handler, [], _ttl, _eventId];
|
||||
|
||||
HASH_SET(GVAR(syncedEvents),_name,_data);
|
||||
[GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet;
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
params ["_name"];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
||||
ACE_LOGERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name);
|
||||
false
|
||||
};
|
||||
|
||||
private _data = HASH_GET(GVAR(syncedEvents),_name);
|
||||
private _data = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
|
||||
_data params ["", "", "", "_eventId"];
|
||||
|
||||
[_eventId] call CBA_fnc_removeEventHandler;
|
||||
HASH_REM(GVAR(syncedEvents),_name);
|
||||
[GVAR(syncedEvents), _name] call CBA_fnc_hashRem;
|
||||
|
@ -40,14 +40,14 @@ if (_reason != "") then {
|
||||
_reason = toLower _reason;
|
||||
if (_mask isEqualTo []) then {
|
||||
TRACE_2("Setting", _reason, _mask);
|
||||
[GVAR(showHudHash), _reason] call FUNC(hashRem);
|
||||
[GVAR(showHudHash), _reason] call CBA_fnc_hashRem;
|
||||
} else {
|
||||
TRACE_2("Removing", _reason, _mask);
|
||||
[GVAR(showHudHash), _reason, _mask] call FUNC(hashSet);
|
||||
[GVAR(showHudHash), _reason, _mask] call CBA_fnc_hashSet;
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(showHudHash) params ["_reasons", "_masks"];
|
||||
GVAR(showHudHash) params ["", "_reasons", "_masks"];
|
||||
private _resultMask = [];
|
||||
|
||||
for "_index" from 0 to 7 do {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
params ["_name", "_args", ["_ttl", 0]];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
||||
ACE_LOGERROR_1("Synced event key [%1] not found (syncedEvent).", _name);
|
||||
false
|
||||
};
|
||||
|
@ -18,11 +18,8 @@ if (!isServer) exitWith {false};
|
||||
// Walk through the local synced events and clean up anything thats already EOL
|
||||
// @TODO: This should be iteration limited to prevent FPS lag
|
||||
|
||||
{
|
||||
private _name = _x;
|
||||
|
||||
private _data = HASH_GET(GVAR(syncedEvents),_name);
|
||||
_data params ["_eventTime", "_eventLog", "_globalEventTTL"];
|
||||
[GVAR(syncedEvents), {
|
||||
_value params ["_eventTime", "_eventLog", "_globalEventTTL"];
|
||||
|
||||
private _newEventLog = [];
|
||||
|
||||
@ -55,8 +52,8 @@ if (!isServer) exitWith {false};
|
||||
false
|
||||
} count _eventLog;
|
||||
|
||||
_data set [1, _newEventLog];
|
||||
_value set [1, _newEventLog];
|
||||
false
|
||||
} count (GVAR(syncedEvents) select 0);
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
|
||||
// @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events
|
||||
|
Loading…
Reference in New Issue
Block a user