General - Use engine hashmaps (#8468)

Co-authored-by: Dedmen Miller <dedmen@users.noreply.github.com>
This commit is contained in:
GhostIsSpooky 2021-10-10 13:55:14 -03:00 committed by GitHub
parent 9479c29b42
commit 97deef5617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 90 additions and 117 deletions

View File

@ -51,7 +51,7 @@ if (_category == 8) then {
_itemsToAdd append _magazines; _itemsToAdd append _magazines;
{ {
_itemsToAdd append ([_magazineGroups, toLower _x] call CBA_fnc_hashGet); _itemsToAdd append (_magazineGroups get (toLower _x));
} forEach getArray (_muzzleConfig >> "magazineWell"); } forEach getArray (_muzzleConfig >> "magazineWell");
} forEach getArray (_weaponConfig >> "muzzles"); } forEach getArray (_weaponConfig >> "muzzles");
} forEach _attributeWeapons; } forEach _attributeWeapons;

View File

@ -90,7 +90,7 @@ private _compatibleMagazines = [[[], []], [[], []], [[], []]];
// Magazine groups // Magazine groups
{ {
private _magazineGroups = uiNamespace getVariable [QGVAR(magazineGroups),["#CBA_HASH#",[],[],[]]]; private _magazineGroups = uiNamespace getVariable [QGVAR(magazineGroups),["#CBA_HASH#",[],[],[]]];
private _magArray = [_magazineGroups, toLower _x] call CBA_fnc_hashGet; private _magArray = _magazineGroups get (toLower _x);
{((_compatibleMagazines select _index) select _subIndex) pushBackUnique _x} forEach _magArray; {((_compatibleMagazines select _index) select _subIndex) pushBackUnique _x} forEach _magArray;
} foreach ([getArray (_weaponConfig >> _x >> "magazineWell"), getArray (_weaponConfig >> "magazineWell")] select (_x == "this")); } foreach ([getArray (_weaponConfig >> _x >> "magazineWell"), getArray (_weaponConfig >> "magazineWell")] select (_x == "this"));

View File

@ -41,13 +41,14 @@ private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in va
private _className = configName _x; private _className = configName _x;
private _hasItemInfo = isClass (_configItemInfo); private _hasItemInfo = isClass (_configItemInfo);
private _itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0}; private _itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
private _isMiscItem = _className isKindOf ["CBA_MiscItem", (_configCfgWeapons)];
switch true do { switch true do {
/* Weapon acc */ /* Weapon acc */
case ( case (
_hasItemInfo && _hasItemInfo &&
{_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} && {_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} &&
{!(configName _x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])} {!_isMiscItem}
): { ): {
//Convert type to array index //Convert type to array index
@ -117,7 +118,7 @@ private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in va
case ( case (
_hasItemInfo && _hasItemInfo &&
(_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD] && (_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD] &&
{(_className isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}) || {_isMiscItem}) ||
{_itemInfoType in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} || {_itemInfoType in [TYPE_FIRST_AID_KIT, TYPE_MEDIKIT, TYPE_TOOLKIT]} ||
{(getText ( _x >> "simulation")) == "ItemMineDetector"} {(getText ( _x >> "simulation")) == "ItemMineDetector"}
): { ): {
@ -140,15 +141,6 @@ private _putList = [];
private _className = configName _x; private _className = configName _x;
switch true do { switch true do {
// Rifle, handgun, secondary weapons mags
case (
((getNumber (_x >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW,TYPE_MAGAZINE_SECONDARY_AND_PUT,1536,TYPE_MAGAZINE_HANDGUN_AND_GL,TYPE_MAGAZINE_MISSILE]) ||
{(getNumber (_x >> QGVAR(hide))) == -1}) &&
{!(_className in _grenadeList)} &&
{!(_className in _putList)}
): {
(_cargo select 2) pushBackUnique _className;
};
// Grenades // Grenades
case (_className in _grenadeList): { case (_className in _grenadeList): {
(_cargo select 15) pushBackUnique _className; (_cargo select 15) pushBackUnique _className;
@ -157,6 +149,13 @@ private _putList = [];
case (_className in _putList): { case (_className in _putList): {
(_cargo select 16) pushBackUnique _className; (_cargo select 16) pushBackUnique _className;
}; };
// Rifle, handgun, secondary weapons mags
case (
((getNumber (_x >> "type") in [TYPE_MAGAZINE_PRIMARY_AND_THROW,TYPE_MAGAZINE_SECONDARY_AND_PUT,1536,TYPE_MAGAZINE_HANDGUN_AND_GL,TYPE_MAGAZINE_MISSILE]) ||
{(getNumber (_x >> QGVAR(hide))) == -1})
): {
(_cargo select 2) pushBackUnique _className;
};
}; };
} foreach configProperties [(configFile >> "CfgMagazines"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; } foreach configProperties [(configFile >> "CfgMagazines"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
@ -170,7 +169,7 @@ private _putList = [];
(_cargo select 7) pushBackUnique (configName _x); (_cargo select 7) pushBackUnique (configName _x);
} foreach configProperties [(configFile >> "CfgGlasses"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; } foreach configProperties [(configFile >> "CfgGlasses"), "isClass _x && {(if (isNumber (_x >> 'scopeArsenal')) then {getNumber (_x >> 'scopeArsenal')} else {getNumber (_x >> 'scope')}) == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true];
private _magazineGroups = [[],[]] call CBA_fnc_hashCreate; private _magazineGroups = createHashMap;
private _cfgMagazines = configFile >> "CfgMagazines"; private _cfgMagazines = configFile >> "CfgMagazines";
@ -182,7 +181,7 @@ private _cfgMagazines = configFile >> "CfgMagazines";
_magList append _magazines; _magList append _magazines;
} foreach configProperties [_x, "isArray _x", true]; } foreach configProperties [_x, "isArray _x", true];
[_magazineGroups, toLower configName _x, _magList arrayIntersect _magList] call CBA_fnc_hashSet; _magazineGroups set [toLower configName _x, _magList arrayIntersect _magList];
} foreach configProperties [(configFile >> "CfgMagazineWells"), "isClass _x", true]; } foreach configProperties [(configFile >> "CfgMagazineWells"), "isClass _x", true];
uiNamespace setVariable [QGVAR(configItems), _cargo]; uiNamespace setVariable [QGVAR(configItems), _cargo];

View File

@ -267,8 +267,7 @@ 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"]; if (GVAR(showHudHash) isNotEqualTo createHashMap) then {
if (_masks isNotEqualTo []) then {
[] call FUNC(showHud); [] call FUNC(showHud);
}; };
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;

View File

@ -7,8 +7,8 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
GVAR(syncedEvents) = [] call CBA_fnc_hashCreate; GVAR(syncedEvents) = createHashMap;
GVAR(showHudHash) = [] call CBA_fnc_hashCreate; GVAR(showHudHash) = createHashMap;
GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon
GVAR(settingsInitFinished) = false; GVAR(settingsInitFinished) = false;

View File

@ -17,12 +17,11 @@
params ["_client"]; params ["_client"];
[GVAR(syncedEvents), { {
//IGNORE_PRIVATE_WARNING ["_key", "_value"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
_value params ["", "_eventLog"]; _y params ["", "_eventlog"];
["ACEs", [_x, _eventLog], _client] call CBA_fnc_targetEvent;
["ACEs", [_key, _eventLog], _client] call CBA_fnc_targetEvent;
false false
}] call CBA_fnc_hashEachPair; } forEach GVAR(syncedEvents);
true true

View File

@ -26,12 +26,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 !([GVAR(syncedEvents), _eventName] call CBA_fnc_hashHasKey) exitWith { if !(_eventName in GVAR(syncedEvents)) exitWith {
ERROR_1("Request for synced event - key [%1] not found.", _eventName); ERROR_1("Request for synced event - key [%1] not found.", _eventName);
false false
}; };
private _eventEntry = [GVAR(syncedEvents), _eventName] call CBA_fnc_hashGet; private _eventEntry = GVAR(syncedEvents) get _eventName;
_eventEntry params ["", "_eventLog"]; _eventEntry params ["", "_eventLog"];
["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent; ["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent;

View File

@ -19,12 +19,12 @@
params ["_name", "_args", "_ttl"]; params ["_name", "_args", "_ttl"];
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith { if !(_name in GVAR(syncedEvents)) exitWith {
ERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name); ERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name);
false false
}; };
private _internalData = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet; private _internalData = GVAR(syncedEvents) get _name;
_internalData params ["_eventCode", "_eventLog"]; _internalData params ["_eventCode", "_eventLog"];
if (isServer) then { if (isServer) then {

View File

@ -19,7 +19,7 @@
params ["_name", "_handler", ["_ttl", 0]]; params ["_name", "_handler", ["_ttl", 0]];
if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith { if (_name in GVAR(syncedEvents)) exitWith {
ERROR_1("Duplicate synced event [%1] creation.",_name); ERROR_1("Duplicate synced event [%1] creation.",_name);
false false
}; };
@ -27,4 +27,4 @@ if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) 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];
[GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet; GVAR(syncedEvents) set [_name, _data];

View File

@ -25,16 +25,16 @@ TRACE_4("arithmeticSetSource",_namespace,_setID,_source,_variable);
private _hash = _namespace getVariable _setID; private _hash = _namespace getVariable _setID;
if (isNil "_hash") then { if (isNil "_hash") then {
_hash = [] call CBA_fnc_hashCreate; _hash = createHashMap;
_namespace setVariable [_setID, _hash]; _namespace setVariable [_setID, _hash];
}; };
if (_variable isEqualTo {}) then { if (_variable isEqualTo {}) then {
TRACE_1("removing",_source); TRACE_1("removing",_source);
[_hash, _source] call CBA_fnc_hashRem; _hash deleteAt _source;
} else { } else {
TRACE_2("adding",_source,_variable); TRACE_2("adding",_source,_variable);
[_hash, _source, _variable] call CBA_fnc_hashSet; _hash set [_source, _variable];
}; };
nil nil

View File

@ -17,13 +17,13 @@
params ["_name"]; params ["_name"];
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith { if !(_name in GVAR(syncedEvents)) exitWith {
ERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name); ERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name);
false false
}; };
private _data = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet; private _data = GVAR(syncedEvents) get _name;
_data params ["", "", "", "_eventId"]; _data params ["", "", "", "_eventId"];
[_eventId] call CBA_fnc_removeEventHandler; [_eventId] call CBA_fnc_removeEventHandler;
[GVAR(syncedEvents), _name] call CBA_fnc_hashRem; GVAR(syncedEvents) deleteAt _name;

View File

@ -42,15 +42,15 @@ if (_reason != "") then {
_reason = toLower _reason; _reason = toLower _reason;
if (_mask isEqualTo []) then { if (_mask isEqualTo []) then {
TRACE_2("Removing", _reason, _mask); TRACE_2("Removing", _reason, _mask);
[GVAR(showHudHash), _reason] call CBA_fnc_hashRem; GVAR(showHudHash) deleteAt _reason;
} else { } else {
while {(count _mask) < 10} do { _mask pushBack true; }; while {(count _mask) < 10} do { _mask pushBack true; };
TRACE_2("Setting", _reason, _mask); TRACE_2("Setting", _reason, _mask);
[GVAR(showHudHash), _reason, _mask] call CBA_fnc_hashSet; GVAR(showHudHash) set [_reason, _mask];
}; };
}; };
GVAR(showHudHash) params ["", "_reasons", "_masks"]; private _masks = values GVAR(showHudHash);
private _resultMask = []; private _resultMask = [];
for "_index" from 0 to 9 do { for "_index" from 0 to 9 do {
@ -63,7 +63,7 @@ for "_index" from 0 to 9 do {
_resultMask pushBack _set; _resultMask pushBack _set;
}; };
TRACE_2("showHud", _resultMask, _reasons); TRACE_2("showHud", _resultMask, keys GVAR(showHudHash));
showHud _resultMask; showHud _resultMask;
_resultMask _resultMask

View File

@ -19,7 +19,7 @@
params ["_name", "_args", ["_ttl", 0]]; params ["_name", "_args", ["_ttl", 0]];
if !([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith { if !(_name in GVAR(syncedEvents)) exitWith {
ERROR_1("Synced event key [%1] not found (syncedEvent).", _name); ERROR_1("Synced event key [%1] not found (syncedEvent).", _name);
false false
}; };

View File

@ -21,9 +21,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), { {
_value params ["_eventTime", "_eventLog", "_globalEventTTL"]; _y params ["_eventTime", "_eventLog", "_globalEventTTL"];
private _newEventLog = []; private _newEventLog = [];
// @TODO: This should be iteration limited to prevent FPS lag // @TODO: This should be iteration limited to prevent FPS lag
@ -52,11 +51,8 @@ if (!isServer) exitWith {false};
if (_ttlReturn) then { if (_ttlReturn) then {
_newEventLog pushBack _x; _newEventLog pushBack _x;
}; };
false } forEach _eventLog;
} count _eventLog; _y set [1, _newEventLog];
} forEach GVAR(syncedEvents);
_value set [1, _newEventLog];
false
}] 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

View File

@ -42,7 +42,7 @@ private _inherited = [];
INFO("------ Logging static magazines with no carry version -------"); INFO("------ Logging static magazines with no carry version -------");
private _hash = [] call CBA_fnc_hashCreate; private _hash = createHashMap;
// private _logAll = true; // logs all possible weapon magazines (even if not used in a static weapon) // private _logAll = true; // logs all possible weapon magazines (even if not used in a static weapon)
private _logAll = false; private _logAll = false;
{ {
@ -57,20 +57,19 @@ private _logAll = false;
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups)); private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
private _carryMag = configName (_groups param [0, configNull]); private _carryMag = configName (_groups param [0, configNull]);
if ((_carryMag == "") && {_logAll || {_xMag in _loadedMags}}) then { if ((_carryMag == "") && {_logAll || {_xMag in _loadedMags}}) then {
private _vehs = [_hash, _xMag] call CBA_fnc_hashGet; private _vehs = _hash getOrDefault [_xMag, []];
if (isNil "_vehs") then {_vehs = [];};
if (_xMag in _loadedMags) then { if (_xMag in _loadedMags) then {
_vehs pushBack _vehicleType; _vehs pushBack _vehicleType;
}; };
[_hash, _xMag, _vehs] call CBA_fnc_hashSet; _hash set [_xMag, _vehs];
}; };
} forEach _weapMags; } forEach _weapMags;
} forEach _weapons; } forEach _weapons;
} forEach _staticWeaponConfigs; } forEach _staticWeaponConfigs;
[_hash, { {
//IGNORE_PRIVATE_WARNING ["_key", "_value"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
INFO_2("[%1] has no carry varient - Used in %2",_key,_value); INFO_2("[%1] has no carry varient - Used in %2",_x,_y);
}] call CBA_fnc_hashEachPair; } forEach _hash;
INFO("------ End -------"); INFO("------ End -------");

View File

@ -8,7 +8,7 @@ if (!hasInterface) exitWith {};
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
GVAR(lastFPTime) = -1; GVAR(lastFPTime) = -1;
GVAR(fingersHash) = [] call CBA_fnc_hashCreate; GVAR(fingersHash) = createHashMap;
GVAR(pfeh_id) = -1; GVAR(pfeh_id) = -1;
[QGVAR(fingered), {_this call FUNC(incomingFinger)}] call CBA_fnc_addEventHandler; [QGVAR(fingered), {_this call FUNC(incomingFinger)}] call CBA_fnc_addEventHandler;

View File

@ -28,7 +28,7 @@ private _fingerPos = if (_sourceUnit == ACE_player) then {
TRACE_3("incoming finger:", _sourceUnit, _fingerPosPrecise, _fingerPos); TRACE_3("incoming finger:", _sourceUnit, _fingerPosPrecise, _fingerPos);
private _data = [diag_tickTime, _fingerPos, ([_sourceUnit, false, true] call EFUNC(common,getName))]; private _data = [diag_tickTime, _fingerPos, ([_sourceUnit, false, true] call EFUNC(common,getName))];
[GVAR(fingersHash), _sourceUnit, _data] call CBA_fnc_hashSet; GVAR(fingersHash) set [hashValue _sourceUnit, _data];
if (GVAR(pfeh_id) == -1) then { if (GVAR(pfeh_id) == -1) then {
GVAR(pfeh_id) = [DFUNC(perFrameEH), 0, []] call CBA_fnc_addPerFrameHandler; GVAR(pfeh_id) = [DFUNC(perFrameEH), 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -15,20 +15,20 @@
* Public: No * Public: No
*/ */
if (!alive ACE_player) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;}; if (!alive ACE_player) then {GVAR(fingersHash) = createHashMap};
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;}; if !([ACE_player, ACE_player, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) then {GVAR(fingersHash) = createHashMap};
// Make sure player is dismounted or in a static weapon: // Make sure player is dismounted or in a static weapon:
if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;}; if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) then {GVAR(fingersHash) = createHashMap};
private _iconSize = BASE_SIZE * 0.10713 * (call EFUNC(common,getZoom)); private _iconSize = BASE_SIZE * 0.10713 * (call EFUNC(common,getZoom));
[+GVAR(fingersHash), { {
//IGNORE_PRIVATE_WARNING ["_key", "_value"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
_value params ["_lastTime", "_pos", "_name"]; _y params ["_lastTime", "_pos", "_name"];
private _timeLeftToShow = _lastTime + FP_TIMEOUT - diag_tickTime; private _timeLeftToShow = _lastTime + FP_TIMEOUT - diag_tickTime;
if (_timeLeftToShow <= 0) then { if (_timeLeftToShow <= 0) then {
[GVAR(fingersHash), _key] call CBA_fnc_hashRem; GVAR(fingersHash) deleteAt _x;
} else { } else {
private _drawColor = + GVAR(indicatorColor); private _drawColor = + GVAR(indicatorColor);
// Fade out: // Fade out:
@ -36,9 +36,9 @@ private _iconSize = BASE_SIZE * 0.10713 * (call EFUNC(common,getZoom));
drawIcon3D [QPATHTOF(UI\fp_icon2.paa), _drawColor, ASLtoAGL _pos, _iconSize, _iconSize, 0, _name, 1, 0.03, "RobotoCondensed"]; drawIcon3D [QPATHTOF(UI\fp_icon2.paa), _drawColor, ASLtoAGL _pos, _iconSize, _iconSize, 0, _name, 1, 0.03, "RobotoCondensed"];
}; };
}] call CBA_fnc_hashEachPair; } forEach GVAR(fingersHash);
if ((GVAR(fingersHash) select 1) isEqualTo []) then { if (GVAR(fingersHash) isEqualTo createHashMap) then {
TRACE_1("Ending PFEH", GVAR(pfeh_id)); TRACE_1("Ending PFEH", GVAR(pfeh_id));
[GVAR(pfeh_id)] call CBA_fnc_removePerFrameHandler; [GVAR(pfeh_id)] call CBA_fnc_removePerFrameHandler;
GVAR(pfeh_id) = -1; GVAR(pfeh_id) = -1;

View File

@ -26,22 +26,20 @@ if (hasInterface) then {
["ace_laserOn", { ["ace_laserOn", {
params ["_uuid", "_args"]; params ["_uuid", "_args"];
TRACE_2("ace_laserOn eh",_uuid,_args); TRACE_2("ace_laserOn eh",_uuid,_args);
[GVAR(laserEmitters), _uuid, _args] call CBA_fnc_hashSet; GVAR(laserEmitters) set [_uuid, _args];
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
["ace_laserOff", { ["ace_laserOff", {
params ["_uuid"]; params ["_uuid"];
TRACE_1("ace_laserOn eh",_uuid); TRACE_1("ace_laserOn eh",_uuid);
if ([GVAR(laserEmitters), _uuid] call CBA_fnc_hashHasKey) then { GVAR(laserEmitters) deleteAt _uuid;
[GVAR(laserEmitters), _uuid] call CBA_fnc_hashRem;
};
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
[QGVAR(updateCode), { [QGVAR(updateCode), {
params ["_uuid", "_newCode"]; params ["_uuid", "_newCode"];
TRACE_2("ace_laser_updateCode eh",_uuid,_newCode); TRACE_2("ace_laser_updateCode eh",_uuid,_newCode);
if ([GVAR(laserEmitters), _uuid] call CBA_fnc_hashHasKey) then { if (_uuid in GVAR(laserEmitters)) then {
private _laserArray = [GVAR(laserEmitters), _uuid] call CBA_fnc_hashGet; private _laserArray = GVAR(laserEmitters) get _uuid;
TRACE_2("updating",_newCode,_laserArray select 4); TRACE_2("updating",_newCode,_laserArray select 4);
_laserArray set [4, _newCode]; _laserArray set [4, _newCode];
}; };

View File

@ -11,7 +11,7 @@ ACE_DEFAULT_LASER_CODE = 1111;
ACE_DEFAULT_LASER_WAVELENGTH = 1550; ACE_DEFAULT_LASER_WAVELENGTH = 1550;
ACE_DEFAULT_LASER_BEAMSPREAD = 1; ACE_DEFAULT_LASER_BEAMSPREAD = 1;
GVAR(laserEmitters) = [] call CBA_fnc_hashCreate; GVAR(laserEmitters) = createHashMap;
GVAR(trackedLaserTargets) = []; GVAR(trackedLaserTargets) = [];
GVAR(pfehID) = -1; GVAR(pfehID) = -1;

View File

@ -42,10 +42,10 @@ private _testSeekerDir = vectorDirVisual _seekerVehicle;
// Draw all lasers // Draw all lasers
[GVAR(laserEmitters), { {
//IGNORE_PRIVATE_WARNING ["_key", "_value"]; //IGNORE_PRIVATE_WARNING ["_x", "_y];
// TRACE_2("",_key,_value); // TRACE_2("",_x,_y);
_value params ["_obj", "_owner", "_laserMethod", "_waveLength", "_laserCode", "_beamSpread"]; _y params ["_obj", "_owner", "_laserMethod", "_waveLength", "_laserCode", "_beamSpread"];
// Draw vanila lasers [RED] // Draw vanila lasers [RED]
if (_laserMethod isEqualTo QFUNC(findLaserSource)) then { // Normal vanilla laserTarget func if (_laserMethod isEqualTo QFUNC(findLaserSource)) then { // Normal vanilla laserTarget func
@ -53,7 +53,7 @@ private _testSeekerDir = vectorDirVisual _seekerVehicle;
private _targetPosASL = getPosASL _targetObject; private _targetPosASL = getPosASL _targetObject;
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoAGL _targetPosASL), 0.5, 0.5, 0, "", 0.5, 0.025, "TahomaB"]; drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoAGL _targetPosASL), 0.5, 0.5, 0, "", 0.5, 0.025, "TahomaB"];
(_value call FUNC(findLaserSource)) params ["_laserPosASL", "_laserDir"]; (_y call FUNC(findLaserSource)) params ["_laserPosASL", "_laserDir"];
private _resultsRay = [_laserPosASL, _laserDir, _obj] call FUNC(shootRay); private _resultsRay = [_laserPosASL, _laserDir, _obj] call FUNC(shootRay);
private _rayPos = _resultsRay select 0; private _rayPos = _resultsRay select 0;
@ -76,4 +76,4 @@ private _testSeekerDir = vectorDirVisual _seekerVehicle;
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,1,0,1], (ASLtoAGL _rayPos), 2, 2, 0, _weaponName, 0.5, 0.025, "TahomaB"]; drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,1,0,1], (ASLtoAGL _rayPos), 2, 2, 0, _weaponName, 0.5, 0.025, "TahomaB"];
}; };
}; };
}] call CBA_fnc_hashEachPair; } forEach GVAR(laserEmitters);

View File

@ -154,7 +154,7 @@ if ((count _spots) > 0) then {
} forEach _buckets; } forEach _buckets;
private _finalBucket = _finalBuckets select _largestIndex; private _finalBucket = _finalBuckets select _largestIndex;
private _ownersHash = [] call CBA_fnc_hashCreate; private _ownersHash = createHashMap;
TRACE_2("",_finalBucket,_finalBuckets); TRACE_2("",_finalBucket,_finalBuckets);
@ -164,24 +164,20 @@ if ((count _spots) > 0) then {
{ {
_x params ["_xPos", "_owner"]; _x params ["_xPos", "_owner"];
_finalPos = _finalPos vectorAdd _xPos; _finalPos = _finalPos vectorAdd _xPos;
if ([_ownersHash, _owner] call CBA_fnc_hashHasKey) then { private _count = _ownersHash getOrDefault [_owner, 0];
private _count = [_ownersHash, _owner] call CBA_fnc_hashGet; _ownersHash set [_owner, _count + 1];
[_ownersHash, _owner, _count + 1] call CBA_fnc_hashSet;
} else {
[_ownersHash, _owner, 1] call CBA_fnc_hashSet;
};
} forEach _finalBucket; } forEach _finalBucket;
_finalPos = _finalPos vectorMultiply (1 / (count _finalBucket)); _finalPos = _finalPos vectorMultiply (1 / (count _finalBucket));
private _maxOwnerCount = -1; private _maxOwnerCount = -1;
[_ownersHash, { {
//IGNORE_PRIVATE_WARNING ["_key", "_value"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
if (_value > _maxOwnerCount) then { if (_y > _maxOwnerCount) then {
_finalOwner = _key; _finalOwner = _x;
}; };
}] call CBA_fnc_hashEachPair; } forEach _ownersHash;
}; };
}; };

View File

@ -32,7 +32,7 @@ if (hasInterface) then {
publicVariable QGVAR(pseudoRandomList); publicVariable QGVAR(pseudoRandomList);
// Keep track of the temperature of stored spare barrels // Keep track of the temperature of stored spare barrels
GVAR(storedSpareBarrels) = [] call CBA_fnc_hashCreate; GVAR(storedSpareBarrels) = createHashMap;
// Install event handlers for spare barrels // Install event handlers for spare barrels
[QGVAR(sendSpareBarrelTemperatureHint), FUNC(sendSpareBarrelsTemperaturesHint)] call CBA_fnc_addEventHandler; [QGVAR(sendSpareBarrelTemperatureHint), FUNC(sendSpareBarrelsTemperaturesHint)] call CBA_fnc_addEventHandler;

View File

@ -37,10 +37,7 @@ if ((count _allBarrels) < 1) exitWith {};
private _coolestTemp = 10000; private _coolestTemp = 10000;
private _coolestMag = _allBarrels select 0; private _coolestMag = _allBarrels select 0;
{ {
private _temp = 0; private _temp = GVAR(storedSpareBarrels) getOrDefault [_x, [0]] select 0;
if ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashHasKey) then {
_temp = ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashGet) select 0;
};
TRACE_2("loadCoolestSpareBarrel4",_x,_temp); TRACE_2("loadCoolestSpareBarrel4",_x,_temp);
if (_temp < _coolestTemp) then { if (_temp < _coolestTemp) then {
_coolestTemp = _temp; _coolestTemp = _temp;
@ -54,7 +51,7 @@ TRACE_3("loadCoolestSpareBarrel5",_coolestTemp,_coolestMag,_weaponTemp);
_gunner setVariable [format [QGVAR(%1_temp), _weapon], _coolestTemp, true]; _gunner setVariable [format [QGVAR(%1_temp), _weapon], _coolestTemp, true];
// Heat up the coolest barrel to the former weapon temperature // Heat up the coolest barrel to the former weapon temperature
[GVAR(storedSpareBarrels), _coolestMag, [_weaponTemp, CBA_missionTime, _barrelMass]] call CBA_fnc_hashSet; GVAR(storedSpareBarrels) set [_coolestMag, [_weaponTemp, CBA_missionTime, _barrelMass]];
// Send an event so the machines of the assistant and gunner can show the hint // Send an event so the machines of the assistant and gunner can show the hint
[QGVAR(showWeaponTemperature), [_gunner, _weapon], [_assistant, _gunner]] call CBA_fnc_targetEvent; [QGVAR(showWeaponTemperature), [_gunner, _weapon], [_assistant, _gunner]] call CBA_fnc_targetEvent;

View File

@ -37,10 +37,7 @@ if ((count _allBarrels) < 1) exitWith {};
// Determine the temp of each barrel // Determine the temp of each barrel
private _temps = []; private _temps = [];
{ {
private _temp = 0; private _temp = GVAR(storedSpareBarrels) getOrDefault [_x, [0]] select 0;
if ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashHasKey) then {
_temp = ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashGet) select 0;
};
_temps pushBack _temp; _temps pushBack _temp;
} forEach _allBarrels; } forEach _allBarrels;
TRACE_1("_temps",_temps); TRACE_1("_temps",_temps);

View File

@ -15,28 +15,21 @@
* Public: No * Public: No
*/ */
private _pairs = [];
TRACE_1("updateSpareBarrelsTemperaturesThread1",GVAR(storedSpareBarrels)); TRACE_1("updateSpareBarrelsTemperaturesThread1",GVAR(storedSpareBarrels));
[GVAR(storedSpareBarrels), {
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
_pairs pushBack [_key, _value];
}] call CBA_fnc_hashEachPair;
TRACE_1("updateSpareBarrelsTemperaturesThread2",_pairs);
{ {
_x params ["_barrelMagazineID","_value"]; _y params ["_initialTemp","_initialTime", "_barrelMass"];
_value params ["_initialTemp","_initialTime", "_barrelMass"];
// Calculate cooling // Calculate cooling
private _finalTemp = [_initialTemp, _barrelMass, CBA_missionTime - _initialTime] call FUNC(calculateCooling); private _finalTemp = [_initialTemp, _barrelMass, CBA_missionTime - _initialTime] call FUNC(calculateCooling);
TRACE_4("updateSpareBarrelsTemperaturesThread3",_barrelMagazineID,_initialTemp,_finalTemp,_barrelMass); TRACE_4("updateSpareBarrelsTemperaturesThread2",_barrelMagazineID,_initialTemp,_finalTemp,_barrelMass);
if (_finalTemp < 5) then { if (_finalTemp < 5) then {
// The barrel is cool enough to keep calculating. Remove it from the hash // The barrel is cool enough to keep calculating. Remove it from the hash
[GVAR(storedSpareBarrels), _barrelMagazineID] call CBA_fnc_hashRem; GVAR(storedSpareBarrels) deleteAt _x;
} else { } else {
// Store the new temp // Store the new temp
[GVAR(storedSpareBarrels), _barrelMagazineID, [_finalTemp, CBA_missionTime, _barrelMass]] call CBA_fnc_hashSet; GVAR(storedSpareBarrels) set [_x, [_finalTemp, CBA_missionTime, _barrelMass]];
}; };
} forEach _pairs; } forEach GVAR(storedSpareBarrels);
// Schedule for execution again after 10 seconds // Schedule for execution again after 10 seconds
[DFUNC(updateSpareBarrelsTemperaturesThread), [], 10] call CBA_fnc_waitAndExecute; [DFUNC(updateSpareBarrelsTemperaturesThread), [], 10] call CBA_fnc_waitAndExecute;