From 6d4f58c18ea276bf73080622c4b70d507bed6383 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 13 Jun 2015 18:57:02 +0200 Subject: [PATCH] weapon magazines caching --- addons/hearing/functions/fnc_firedNear.sqf | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index 889b04d24d..92e58143cf 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -48,15 +48,20 @@ if (_silencer != "") then { _audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"); }; +_weaponMagazines = missionNamespace getVariable [QEGVAR(common,weaponMagazines), []]; +if (count _weaponMagazines == 0) then { + _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); + _weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); + { + if (_x != "this") then { + _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines"); + _weaponMagazines append _muzzleMagazines; + }; + } forEach _muzzles; + missionNamespace setVariable [QEGVAR(common,weaponMagazines), _weaponMagazines]; +}; + _magazine = ""; -_muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); -_weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); -{ - if (_x != "this") then { - _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines"); - _weaponMagazines append _muzzleMagazines; - }; -} forEach _muzzles; { _ammoType = getText(configFile >> "CfgMagazines" >> _x >> "ammo"); if (_ammoType == _ammo) exitWith {