convert common to cba hashes

This commit is contained in:
commy2 2016-07-30 12:28:06 +02:00
parent c117a79431
commit 5a1b33a5da
10 changed files with 26 additions and 33 deletions

View File

@ -274,8 +274,8 @@ enableCamShake true;
//FUNC(showHud) needs to be refreshed if it was set during mission init //FUNC(showHud) needs to be refreshed if it was set during mission init
["ace_infoDisplayChanged", { ["ace_infoDisplayChanged", {
GVAR(showHudHash) params ["", "_masks"]; GVAR(showHudHash) params ["", "", "_masks"];
if (!(_masks isEqualTo [])) then { if !(_masks isEqualTo []) then {
[] call FUNC(showHud); [] call FUNC(showHud);
}; };
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;

View File

@ -16,8 +16,8 @@ DFUNC(selectWeaponMode) = {
_this call CBA_fnc_selectWeapon; _this call CBA_fnc_selectWeapon;
}; };
GVAR(syncedEvents) = HASH_CREATE; GVAR(syncedEvents) = [] call CBA_fnc_hashCreate;
GVAR(showHudHash) = [] call FUNC(hashCreate); GVAR(showHudHash) = [] call CBA_fnc_hashCreate;
GVAR(settingsInitFinished) = false; GVAR(settingsInitFinished) = false;
GVAR(runAtSettingsInitialized) = []; GVAR(runAtSettingsInitialized) = [];

View File

@ -14,12 +14,11 @@
params ["_client"]; params ["_client"];
{ [GVAR(syncedEvents), {
private _eventEntry = HASH_GET(GVAR(syncedEvents),_x); _value params ["", "_eventLog"];
_eventEntry params ["", "_eventLog"];
["ACEs", [_x, _eventLog], _client] call CBA_fnc_targetEvent; ["ACEs", [_key, _eventLog], _client] call CBA_fnc_targetEvent;
false false
} count (GVAR(syncedEvents) select 0); }] call CBA_fnc_hashEachPair;
true true

View File

@ -22,12 +22,12 @@ if (isServer) then {
// Find the event name, and shovel out the events to the client // Find the event name, and shovel out the events to the client
params ["_eventName", "_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); ACE_LOGERROR_1("Request for synced event - key [%1] not found.", _eventName);
false false
}; };
private _eventEntry = HASH_GET(GVAR(syncedEvents),_eventName); private _eventEntry = [GVAR(syncedEvents), _eventName] call CBA_fnc_hashGet;
_eventEntry params ["", "_eventLog"]; _eventEntry params ["", "_eventLog"];
["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent; ["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent;

View File

@ -16,22 +16,19 @@
params ["_name", "_args", "_ttl"]; 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); ACE_LOGERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name);
false false
}; };
private _internalData = HASH_GET(GVAR(syncedEvents),_name); private _internalData = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
_internalData params ["_eventCode", "_eventLog"];
if (isServer) then { if (isServer) then {
// Server needs to internally log it for synchronization // Server needs to internally log it for synchronization
if (_ttl > -1) then { if (_ttl > -1) then {
_internalData = HASH_GET(GVAR(syncedEvents),_name);
_internalData params ["", "_eventLog"];
_eventLog pushBack [diag_tickTime, _args, _ttl]; _eventLog pushBack [diag_tickTime, _args, _ttl];
}; };
}; };
_internalData params ["_eventCode"];
_args call _eventCode; _args call _eventCode;

View File

@ -19,7 +19,7 @@
params ["_name", "_handler", ["_ttl", 0]]; 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); ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name);
false false
}; };
@ -27,4 +27,4 @@ if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler; private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
private _data = [_handler, [], _ttl, _eventId]; private _data = [_handler, [], _ttl, _eventId];
HASH_SET(GVAR(syncedEvents),_name,_data); [GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet;

View File

@ -14,13 +14,13 @@
params ["_name"]; 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); ACE_LOGERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name);
false false
}; };
private _data = HASH_GET(GVAR(syncedEvents),_name); private _data = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
_data params ["", "", "", "_eventId"]; _data params ["", "", "", "_eventId"];
[_eventId] call CBA_fnc_removeEventHandler; [_eventId] call CBA_fnc_removeEventHandler;
HASH_REM(GVAR(syncedEvents),_name); [GVAR(syncedEvents), _name] call CBA_fnc_hashRem;

View File

@ -40,14 +40,14 @@ if (_reason != "") then {
_reason = toLower _reason; _reason = toLower _reason;
if (_mask isEqualTo []) then { if (_mask isEqualTo []) then {
TRACE_2("Setting", _reason, _mask); TRACE_2("Setting", _reason, _mask);
[GVAR(showHudHash), _reason] call FUNC(hashRem); [GVAR(showHudHash), _reason] call CBA_fnc_hashRem;
} else { } else {
TRACE_2("Removing", _reason, _mask); 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 = []; private _resultMask = [];
for "_index" from 0 to 7 do { for "_index" from 0 to 7 do {

View File

@ -16,7 +16,7 @@
params ["_name", "_args", ["_ttl", 0]]; 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); ACE_LOGERROR_1("Synced event key [%1] not found (syncedEvent).", _name);
false false
}; };

View File

@ -18,11 +18,8 @@ if (!isServer) exitWith {false};
// Walk through the local synced events and clean up anything thats already EOL // Walk through the local synced events and clean up anything thats already EOL
// @TODO: This should be iteration limited to prevent FPS lag // @TODO: This should be iteration limited to prevent FPS lag
{ [GVAR(syncedEvents), {
private _name = _x; _value params ["_eventTime", "_eventLog", "_globalEventTTL"];
private _data = HASH_GET(GVAR(syncedEvents),_name);
_data params ["_eventTime", "_eventLog", "_globalEventTTL"];
private _newEventLog = []; private _newEventLog = [];
@ -55,8 +52,8 @@ if (!isServer) exitWith {false};
false false
} count _eventLog; } count _eventLog;
_data set [1, _newEventLog]; _value set [1, _newEventLog];
false 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 // @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events