mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
General - Use engine hashmaps (#8468)
Co-authored-by: Dedmen Miller <dedmen@users.noreply.github.com>
This commit is contained in:
parent
9479c29b42
commit
97deef5617
@ -51,7 +51,7 @@ if (_category == 8) then {
|
||||
_itemsToAdd append _magazines;
|
||||
|
||||
{
|
||||
_itemsToAdd append ([_magazineGroups, toLower _x] call CBA_fnc_hashGet);
|
||||
_itemsToAdd append (_magazineGroups get (toLower _x));
|
||||
} forEach getArray (_muzzleConfig >> "magazineWell");
|
||||
} forEach getArray (_weaponConfig >> "muzzles");
|
||||
} forEach _attributeWeapons;
|
||||
|
@ -90,7 +90,7 @@ private _compatibleMagazines = [[[], []], [[], []], [[], []]];
|
||||
// Magazine groups
|
||||
{
|
||||
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;
|
||||
} foreach ([getArray (_weaponConfig >> _x >> "magazineWell"), getArray (_weaponConfig >> "magazineWell")] select (_x == "this"));
|
||||
|
||||
|
@ -41,13 +41,14 @@ private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in va
|
||||
private _className = configName _x;
|
||||
private _hasItemInfo = isClass (_configItemInfo);
|
||||
private _itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
|
||||
private _isMiscItem = _className isKindOf ["CBA_MiscItem", (_configCfgWeapons)];
|
||||
|
||||
switch true do {
|
||||
/* Weapon acc */
|
||||
case (
|
||||
_hasItemInfo &&
|
||||
{_itemInfoType in [TYPE_MUZZLE, TYPE_OPTICS, TYPE_FLASHLIGHT, TYPE_BIPOD]} &&
|
||||
{!(configName _x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}
|
||||
{!_isMiscItem}
|
||||
): {
|
||||
|
||||
//Convert type to array index
|
||||
@ -117,7 +118,7 @@ private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in va
|
||||
case (
|
||||
_hasItemInfo &&
|
||||
(_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]} ||
|
||||
{(getText ( _x >> "simulation")) == "ItemMineDetector"}
|
||||
): {
|
||||
@ -140,15 +141,6 @@ private _putList = [];
|
||||
private _className = configName _x;
|
||||
|
||||
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
|
||||
case (_className in _grenadeList): {
|
||||
(_cargo select 15) pushBackUnique _className;
|
||||
@ -157,6 +149,13 @@ private _putList = [];
|
||||
case (_className in _putList): {
|
||||
(_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];
|
||||
|
||||
@ -170,7 +169,7 @@ private _putList = [];
|
||||
(_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];
|
||||
|
||||
private _magazineGroups = [[],[]] call CBA_fnc_hashCreate;
|
||||
private _magazineGroups = createHashMap;
|
||||
|
||||
private _cfgMagazines = configFile >> "CfgMagazines";
|
||||
|
||||
@ -182,7 +181,7 @@ private _cfgMagazines = configFile >> "CfgMagazines";
|
||||
_magList append _magazines;
|
||||
} 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];
|
||||
|
||||
uiNamespace setVariable [QGVAR(configItems), _cargo];
|
||||
|
@ -267,8 +267,7 @@ enableCamShake true;
|
||||
|
||||
//FUNC(showHud) needs to be refreshed if it was set during mission init
|
||||
["ace_infoDisplayChanged", {
|
||||
GVAR(showHudHash) params ["", "", "_masks"];
|
||||
if (_masks isNotEqualTo []) then {
|
||||
if (GVAR(showHudHash) isNotEqualTo createHashMap) then {
|
||||
[] call FUNC(showHud);
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
@ -7,8 +7,8 @@ PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
GVAR(syncedEvents) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(showHudHash) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(syncedEvents) = createHashMap;
|
||||
GVAR(showHudHash) = createHashMap;
|
||||
GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon
|
||||
|
||||
GVAR(settingsInitFinished) = false;
|
||||
|
@ -17,12 +17,11 @@
|
||||
|
||||
params ["_client"];
|
||||
|
||||
[GVAR(syncedEvents), {
|
||||
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
|
||||
_value params ["", "_eventLog"];
|
||||
|
||||
["ACEs", [_key, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_x", "_y"];
|
||||
_y params ["", "_eventlog"];
|
||||
["ACEs", [_x, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
false
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
} forEach GVAR(syncedEvents);
|
||||
|
||||
true
|
||||
|
@ -26,12 +26,12 @@ if (isServer) then {
|
||||
// Find the event name, and shovel out the events to the 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);
|
||||
false
|
||||
};
|
||||
|
||||
private _eventEntry = [GVAR(syncedEvents), _eventName] call CBA_fnc_hashGet;
|
||||
private _eventEntry = GVAR(syncedEvents) get _eventName;
|
||||
_eventEntry params ["", "_eventLog"];
|
||||
|
||||
["ACEs", [_eventName, _eventLog], _client] call CBA_fnc_targetEvent;
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
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);
|
||||
false
|
||||
};
|
||||
|
||||
private _internalData = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
|
||||
private _internalData = GVAR(syncedEvents) get _name;
|
||||
_internalData params ["_eventCode", "_eventLog"];
|
||||
|
||||
if (isServer) then {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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);
|
||||
false
|
||||
};
|
||||
@ -27,4 +27,4 @@ if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
||||
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
|
||||
private _data = [_handler, [], _ttl, _eventId];
|
||||
|
||||
[GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet;
|
||||
GVAR(syncedEvents) set [_name, _data];
|
||||
|
@ -25,16 +25,16 @@ TRACE_4("arithmeticSetSource",_namespace,_setID,_source,_variable);
|
||||
private _hash = _namespace getVariable _setID;
|
||||
|
||||
if (isNil "_hash") then {
|
||||
_hash = [] call CBA_fnc_hashCreate;
|
||||
_hash = createHashMap;
|
||||
_namespace setVariable [_setID, _hash];
|
||||
};
|
||||
|
||||
if (_variable isEqualTo {}) then {
|
||||
TRACE_1("removing",_source);
|
||||
[_hash, _source] call CBA_fnc_hashRem;
|
||||
_hash deleteAt _source;
|
||||
} else {
|
||||
TRACE_2("adding",_source,_variable);
|
||||
[_hash, _source, _variable] call CBA_fnc_hashSet;
|
||||
_hash set [_source, _variable];
|
||||
};
|
||||
|
||||
nil
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
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);
|
||||
false
|
||||
};
|
||||
|
||||
private _data = [GVAR(syncedEvents), _name] call CBA_fnc_hashGet;
|
||||
private _data = GVAR(syncedEvents) get _name;
|
||||
_data params ["", "", "", "_eventId"];
|
||||
|
||||
[_eventId] call CBA_fnc_removeEventHandler;
|
||||
[GVAR(syncedEvents), _name] call CBA_fnc_hashRem;
|
||||
GVAR(syncedEvents) deleteAt _name;
|
||||
|
@ -42,15 +42,15 @@ if (_reason != "") then {
|
||||
_reason = toLower _reason;
|
||||
if (_mask isEqualTo []) then {
|
||||
TRACE_2("Removing", _reason, _mask);
|
||||
[GVAR(showHudHash), _reason] call CBA_fnc_hashRem;
|
||||
GVAR(showHudHash) deleteAt _reason;
|
||||
} else {
|
||||
while {(count _mask) < 10} do { _mask pushBack true; };
|
||||
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 = [];
|
||||
|
||||
for "_index" from 0 to 9 do {
|
||||
@ -63,7 +63,7 @@ for "_index" from 0 to 9 do {
|
||||
_resultMask pushBack _set;
|
||||
};
|
||||
|
||||
TRACE_2("showHud", _resultMask, _reasons);
|
||||
TRACE_2("showHud", _resultMask, keys GVAR(showHudHash));
|
||||
showHud _resultMask;
|
||||
|
||||
_resultMask
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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);
|
||||
false
|
||||
};
|
||||
|
@ -21,9 +21,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
|
||||
|
||||
[GVAR(syncedEvents), {
|
||||
_value params ["_eventTime", "_eventLog", "_globalEventTTL"];
|
||||
|
||||
{
|
||||
_y params ["_eventTime", "_eventLog", "_globalEventTTL"];
|
||||
private _newEventLog = [];
|
||||
|
||||
// @TODO: This should be iteration limited to prevent FPS lag
|
||||
@ -52,11 +51,8 @@ if (!isServer) exitWith {false};
|
||||
if (_ttlReturn) then {
|
||||
_newEventLog pushBack _x;
|
||||
};
|
||||
false
|
||||
} count _eventLog;
|
||||
|
||||
_value set [1, _newEventLog];
|
||||
false
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
} forEach _eventLog;
|
||||
_y set [1, _newEventLog];
|
||||
} forEach GVAR(syncedEvents);
|
||||
|
||||
// @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events
|
||||
|
@ -42,7 +42,7 @@ private _inherited = [];
|
||||
|
||||
|
||||
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 = false;
|
||||
{
|
||||
@ -57,20 +57,19 @@ private _logAll = false;
|
||||
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
|
||||
private _carryMag = configName (_groups param [0, configNull]);
|
||||
if ((_carryMag == "") && {_logAll || {_xMag in _loadedMags}}) then {
|
||||
private _vehs = [_hash, _xMag] call CBA_fnc_hashGet;
|
||||
if (isNil "_vehs") then {_vehs = [];};
|
||||
private _vehs = _hash getOrDefault [_xMag, []];
|
||||
if (_xMag in _loadedMags) then {
|
||||
_vehs pushBack _vehicleType;
|
||||
};
|
||||
[_hash, _xMag, _vehs] call CBA_fnc_hashSet;
|
||||
_hash set [_xMag, _vehs];
|
||||
};
|
||||
} forEach _weapMags;
|
||||
} forEach _weapons;
|
||||
} forEach _staticWeaponConfigs;
|
||||
|
||||
[_hash, {
|
||||
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
|
||||
INFO_2("[%1] has no carry varient - Used in %2",_key,_value);
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_x", "_y"];
|
||||
INFO_2("[%1] has no carry varient - Used in %2",_x,_y);
|
||||
} forEach _hash;
|
||||
|
||||
INFO("------ End -------");
|
||||
|
@ -8,7 +8,7 @@ if (!hasInterface) exitWith {};
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
GVAR(lastFPTime) = -1;
|
||||
GVAR(fingersHash) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(fingersHash) = createHashMap;
|
||||
GVAR(pfeh_id) = -1;
|
||||
|
||||
[QGVAR(fingered), {_this call FUNC(incomingFinger)}] call CBA_fnc_addEventHandler;
|
||||
|
@ -28,7 +28,7 @@ private _fingerPos = if (_sourceUnit == ACE_player) then {
|
||||
TRACE_3("incoming finger:", _sourceUnit, _fingerPosPrecise, _fingerPos);
|
||||
|
||||
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 {
|
||||
GVAR(pfeh_id) = [DFUNC(perFrameEH), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -15,20 +15,20 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (!alive ACE_player) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;};
|
||||
if (!alive ACE_player) then {GVAR(fingersHash) = createHashMap};
|
||||
// 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:
|
||||
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));
|
||||
|
||||
[+GVAR(fingersHash), {
|
||||
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
|
||||
_value params ["_lastTime", "_pos", "_name"];
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_x", "_y"];
|
||||
_y params ["_lastTime", "_pos", "_name"];
|
||||
private _timeLeftToShow = _lastTime + FP_TIMEOUT - diag_tickTime;
|
||||
if (_timeLeftToShow <= 0) then {
|
||||
[GVAR(fingersHash), _key] call CBA_fnc_hashRem;
|
||||
GVAR(fingersHash) deleteAt _x;
|
||||
} else {
|
||||
private _drawColor = + GVAR(indicatorColor);
|
||||
// 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"];
|
||||
};
|
||||
}] 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));
|
||||
[GVAR(pfeh_id)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(pfeh_id) = -1;
|
||||
|
@ -26,22 +26,20 @@ if (hasInterface) then {
|
||||
["ace_laserOn", {
|
||||
params ["_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;
|
||||
|
||||
["ace_laserOff", {
|
||||
params ["_uuid"];
|
||||
TRACE_1("ace_laserOn eh",_uuid);
|
||||
if ([GVAR(laserEmitters), _uuid] call CBA_fnc_hashHasKey) then {
|
||||
[GVAR(laserEmitters), _uuid] call CBA_fnc_hashRem;
|
||||
};
|
||||
GVAR(laserEmitters) deleteAt _uuid;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(updateCode), {
|
||||
params ["_uuid", "_newCode"];
|
||||
TRACE_2("ace_laser_updateCode eh",_uuid,_newCode);
|
||||
if ([GVAR(laserEmitters), _uuid] call CBA_fnc_hashHasKey) then {
|
||||
private _laserArray = [GVAR(laserEmitters), _uuid] call CBA_fnc_hashGet;
|
||||
if (_uuid in GVAR(laserEmitters)) then {
|
||||
private _laserArray = GVAR(laserEmitters) get _uuid;
|
||||
TRACE_2("updating",_newCode,_laserArray select 4);
|
||||
_laserArray set [4, _newCode];
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ ACE_DEFAULT_LASER_CODE = 1111;
|
||||
ACE_DEFAULT_LASER_WAVELENGTH = 1550;
|
||||
ACE_DEFAULT_LASER_BEAMSPREAD = 1;
|
||||
|
||||
GVAR(laserEmitters) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(laserEmitters) = createHashMap;
|
||||
GVAR(trackedLaserTargets) = [];
|
||||
GVAR(pfehID) = -1;
|
||||
|
||||
|
@ -42,10 +42,10 @@ private _testSeekerDir = vectorDirVisual _seekerVehicle;
|
||||
|
||||
|
||||
// Draw all lasers
|
||||
[GVAR(laserEmitters), {
|
||||
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
|
||||
// TRACE_2("",_key,_value);
|
||||
_value params ["_obj", "_owner", "_laserMethod", "_waveLength", "_laserCode", "_beamSpread"];
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_x", "_y];
|
||||
// TRACE_2("",_x,_y);
|
||||
_y params ["_obj", "_owner", "_laserMethod", "_waveLength", "_laserCode", "_beamSpread"];
|
||||
|
||||
// Draw vanila lasers [RED]
|
||||
if (_laserMethod isEqualTo QFUNC(findLaserSource)) then { // Normal vanilla laserTarget func
|
||||
@ -53,7 +53,7 @@ private _testSeekerDir = vectorDirVisual _seekerVehicle;
|
||||
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"];
|
||||
|
||||
(_value call FUNC(findLaserSource)) params ["_laserPosASL", "_laserDir"];
|
||||
(_y call FUNC(findLaserSource)) params ["_laserPosASL", "_laserDir"];
|
||||
private _resultsRay = [_laserPosASL, _laserDir, _obj] call FUNC(shootRay);
|
||||
|
||||
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"];
|
||||
};
|
||||
};
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
} forEach GVAR(laserEmitters);
|
||||
|
@ -154,7 +154,7 @@ if ((count _spots) > 0) then {
|
||||
} forEach _buckets;
|
||||
|
||||
private _finalBucket = _finalBuckets select _largestIndex;
|
||||
private _ownersHash = [] call CBA_fnc_hashCreate;
|
||||
private _ownersHash = createHashMap;
|
||||
|
||||
TRACE_2("",_finalBucket,_finalBuckets);
|
||||
|
||||
@ -164,24 +164,20 @@ if ((count _spots) > 0) then {
|
||||
{
|
||||
_x params ["_xPos", "_owner"];
|
||||
_finalPos = _finalPos vectorAdd _xPos;
|
||||
if ([_ownersHash, _owner] call CBA_fnc_hashHasKey) then {
|
||||
private _count = [_ownersHash, _owner] call CBA_fnc_hashGet;
|
||||
[_ownersHash, _owner, _count + 1] call CBA_fnc_hashSet;
|
||||
} else {
|
||||
[_ownersHash, _owner, 1] call CBA_fnc_hashSet;
|
||||
};
|
||||
private _count = _ownersHash getOrDefault [_owner, 0];
|
||||
_ownersHash set [_owner, _count + 1];
|
||||
} forEach _finalBucket;
|
||||
|
||||
_finalPos = _finalPos vectorMultiply (1 / (count _finalBucket));
|
||||
|
||||
private _maxOwnerCount = -1;
|
||||
|
||||
[_ownersHash, {
|
||||
//IGNORE_PRIVATE_WARNING ["_key", "_value"];
|
||||
if (_value > _maxOwnerCount) then {
|
||||
_finalOwner = _key;
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_x", "_y"];
|
||||
if (_y > _maxOwnerCount) then {
|
||||
_finalOwner = _x;
|
||||
};
|
||||
}] call CBA_fnc_hashEachPair;
|
||||
} forEach _ownersHash;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@ if (hasInterface) then {
|
||||
publicVariable QGVAR(pseudoRandomList);
|
||||
|
||||
// Keep track of the temperature of stored spare barrels
|
||||
GVAR(storedSpareBarrels) = [] call CBA_fnc_hashCreate;
|
||||
GVAR(storedSpareBarrels) = createHashMap;
|
||||
|
||||
// Install event handlers for spare barrels
|
||||
[QGVAR(sendSpareBarrelTemperatureHint), FUNC(sendSpareBarrelsTemperaturesHint)] call CBA_fnc_addEventHandler;
|
||||
|
@ -37,10 +37,7 @@ if ((count _allBarrels) < 1) exitWith {};
|
||||
private _coolestTemp = 10000;
|
||||
private _coolestMag = _allBarrels select 0;
|
||||
{
|
||||
private _temp = 0;
|
||||
if ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashHasKey) then {
|
||||
_temp = ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashGet) select 0;
|
||||
};
|
||||
private _temp = GVAR(storedSpareBarrels) getOrDefault [_x, [0]] select 0;
|
||||
TRACE_2("loadCoolestSpareBarrel4",_x,_temp);
|
||||
if (_temp < _coolestTemp) then {
|
||||
_coolestTemp = _temp;
|
||||
@ -54,7 +51,7 @@ TRACE_3("loadCoolestSpareBarrel5",_coolestTemp,_coolestMag,_weaponTemp);
|
||||
_gunner setVariable [format [QGVAR(%1_temp), _weapon], _coolestTemp, true];
|
||||
|
||||
// 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
|
||||
[QGVAR(showWeaponTemperature), [_gunner, _weapon], [_assistant, _gunner]] call CBA_fnc_targetEvent;
|
||||
|
@ -37,10 +37,7 @@ if ((count _allBarrels) < 1) exitWith {};
|
||||
// Determine the temp of each barrel
|
||||
private _temps = [];
|
||||
{
|
||||
private _temp = 0;
|
||||
if ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashHasKey) then {
|
||||
_temp = ([GVAR(storedSpareBarrels), _x] call CBA_fnc_hashGet) select 0;
|
||||
};
|
||||
private _temp = GVAR(storedSpareBarrels) getOrDefault [_x, [0]] select 0;
|
||||
_temps pushBack _temp;
|
||||
} forEach _allBarrels;
|
||||
TRACE_1("_temps",_temps);
|
||||
|
@ -15,28 +15,21 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
private _pairs = [];
|
||||
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"];
|
||||
_value params ["_initialTemp","_initialTime", "_barrelMass"];
|
||||
_y params ["_initialTemp","_initialTime", "_barrelMass"];
|
||||
|
||||
// Calculate cooling
|
||||
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 {
|
||||
// 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 {
|
||||
// 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
|
||||
[DFUNC(updateSpareBarrelsTemperaturesThread), [], 10] call CBA_fnc_waitAndExecute;
|
||||
|
Loading…
Reference in New Issue
Block a user