From 5a1b33a5da716a1b67c313d4556738e420c935d8 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 30 Jul 2016 12:28:06 +0200 Subject: [PATCH] convert common to cba hashes --- addons/common/XEH_postInit.sqf | 4 ++-- addons/common/XEH_preInit.sqf | 4 ++-- .../functions/fnc__handleRequestAllSyncedEvents.sqf | 9 ++++----- .../functions/fnc__handleRequestSyncedEvent.sqf | 4 ++-- addons/common/functions/fnc__handleSyncedEvent.sqf | 9 +++------ addons/common/functions/fnc_addSyncedEventHandler.sqf | 4 ++-- .../common/functions/fnc_removeSyncedEventHandler.sqf | 6 +++--- addons/common/functions/fnc_showHud.sqf | 6 +++--- addons/common/functions/fnc_syncedEvent.sqf | 2 +- addons/common/functions/fnc_syncedEventPFH.sqf | 11 ++++------- 10 files changed, 26 insertions(+), 33 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index d9c90f14f8..361a168419 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -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; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 0f0657c4ab..8be20c5e8f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -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) = []; diff --git a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf index 14d17ae118..763874de82 100644 --- a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf +++ b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf @@ -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 diff --git a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf index 2b239ea056..131ae56f7f 100644 --- a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf +++ b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf @@ -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; diff --git a/addons/common/functions/fnc__handleSyncedEvent.sqf b/addons/common/functions/fnc__handleSyncedEvent.sqf index d708178c4f..b818ed257c 100644 --- a/addons/common/functions/fnc__handleSyncedEvent.sqf +++ b/addons/common/functions/fnc__handleSyncedEvent.sqf @@ -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; diff --git a/addons/common/functions/fnc_addSyncedEventHandler.sqf b/addons/common/functions/fnc_addSyncedEventHandler.sqf index 0481f7d11f..58319e89c1 100644 --- a/addons/common/functions/fnc_addSyncedEventHandler.sqf +++ b/addons/common/functions/fnc_addSyncedEventHandler.sqf @@ -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; diff --git a/addons/common/functions/fnc_removeSyncedEventHandler.sqf b/addons/common/functions/fnc_removeSyncedEventHandler.sqf index d3d94aa421..157b9699e4 100644 --- a/addons/common/functions/fnc_removeSyncedEventHandler.sqf +++ b/addons/common/functions/fnc_removeSyncedEventHandler.sqf @@ -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; diff --git a/addons/common/functions/fnc_showHud.sqf b/addons/common/functions/fnc_showHud.sqf index 723c2436ed..98b9801b3f 100644 --- a/addons/common/functions/fnc_showHud.sqf +++ b/addons/common/functions/fnc_showHud.sqf @@ -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 { diff --git a/addons/common/functions/fnc_syncedEvent.sqf b/addons/common/functions/fnc_syncedEvent.sqf index e6c7b43361..7b7a0094cf 100644 --- a/addons/common/functions/fnc_syncedEvent.sqf +++ b/addons/common/functions/fnc_syncedEvent.sqf @@ -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 }; diff --git a/addons/common/functions/fnc_syncedEventPFH.sqf b/addons/common/functions/fnc_syncedEventPFH.sqf index c0c840c894..8fcd143536 100644 --- a/addons/common/functions/fnc_syncedEventPFH.sqf +++ b/addons/common/functions/fnc_syncedEventPFH.sqf @@ -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