diff --git a/addons/csw/functions/fnc_aceRearmGetCarryMagazines.sqf b/addons/csw/functions/fnc_aceRearmGetCarryMagazines.sqf index ac51d03347..05cfe1461a 100644 --- a/addons/csw/functions/fnc_aceRearmGetCarryMagazines.sqf +++ b/addons/csw/functions/fnc_aceRearmGetCarryMagazines.sqf @@ -18,27 +18,33 @@ params ["_vehicle", ["_targetTurret", true, [[], true]]]; -if (!(_vehicle isKindOf "StaticWeapon")) exitWith { [[],[]] }; // limit to statics for now -// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default] -if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}) exitWith { [[],[]] }; +private _return = [[], []]; + +if !(_vehicle isKindOf "StaticWeapon") exitWith {_return}; // limit to statics for now +// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default] +if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}) exitWith {_return}; + +private _turretMagsCSW = _return select 0; +private _allCarryMags = _return select 1; + +private _turrets = allTurrets _vehicle; +if (_targetTurret isNotEqualTo true) then { + _turrets = _turrets select {_x isEqualTo _targetTurret}; +}; -private _turretMagsCSW = []; -private _allCarryMags = []; { private _turretPath = _x; - if ((_targetTurret isEqualTo true) || {_turretPath isEqualTo _targetTurret}) then { + { + private _weapon = _x; { - private _weapon = _x; - { - private _xMag = _x; - private _carryMag = _xMag call FUNC(getCarryMagazine); - if (_carryMag != "") then { - _turretMagsCSW pushBackUnique _xMag; - _allCarryMags pushBackUnique _carryMag; - }; - } forEach ([_weapon] call CBA_fnc_compatibleMagazines); - } forEach (_vehicle weaponsTurret _turretPath); - }; -} forEach (allTurrets _vehicle); + private _xMag = _x; + private _carryMag = _xMag call FUNC(getCarryMagazine); + if (_carryMag != "") then { + _turretMagsCSW pushBackUnique _xMag; + _allCarryMags pushBackUnique _carryMag; + }; + } forEach (compatibleMagazines _weapon); + } forEach (_vehicle weaponsTurret _turretPath); +} forEach _turrets; -[_turretMagsCSW, _allCarryMags] +_return diff --git a/addons/csw/functions/fnc_proxyWeapon.sqf b/addons/csw/functions/fnc_proxyWeapon.sqf index d49e77d620..1c9f48dd89 100644 --- a/addons/csw/functions/fnc_proxyWeapon.sqf +++ b/addons/csw/functions/fnc_proxyWeapon.sqf @@ -37,6 +37,9 @@ if ((missionNamespace getVariable [_proxyWeapon, objNull]) isEqualType {}) then }; if (!_needed) exitWith { TRACE_2("not needed",_needed,_proxyWeapon); }; +// Rearm compatibility, prevent reloading entire static and breaking CSW +_staticWeapon setVariable [QEGVAR(rearm,scriptedLoadout), true, true]; + TRACE_2("swapping to proxy weapon",_currentWeapon,_proxyWeapon); _staticWeapon removeWeaponTurret [_currentWeapon, _turret]; _staticWeapon addWeaponTurret [_proxyWeapon, _turret];