From ec120465456b49a216eb6a4e4d4fc0820db697a4 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jan 2018 14:33:22 -0600 Subject: [PATCH 1/3] Pylons - Fix old weapons not being removed Fix #6088 - Use removeWeaponTurret instead of removeWeaponGlobal - Fix "Too Far" warning showing on completion --- addons/pylons/XEH_postInit.sqf | 11 ++++++++++- addons/pylons/functions/fnc_configurePylons.sqf | 7 +++++-- addons/pylons/functions/fnc_showDialog.sqf | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/addons/pylons/XEH_postInit.sqf b/addons/pylons/XEH_postInit.sqf index 8dae8d4552a..5375bdcfeff 100644 --- a/addons/pylons/XEH_postInit.sqf +++ b/addons/pylons/XEH_postInit.sqf @@ -28,8 +28,17 @@ } forEach GVAR(aircraftWithPylons); [QGVAR(setPylonLoadOutEvent), { - params ["_aircraft", "_pylonIndex", "_pylon", "_turret"]; + params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_removeWeapon"]; + TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_removeWeapon); _aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret]; + if (_removeWeapon != "") then { + { + if (_aircraft turretLocal _x) then { + TRACE_3("removing",_aircraft,_x,_removeWeapon); + _aircraft removeWeaponTurret [_removeWeapon, [-1]]; + }; + } forEach [[-1], [0]]; + }; }] call CBA_fnc_addEventHandler; [QGVAR(setAmmoOnPylonEvent), { diff --git a/addons/pylons/functions/fnc_configurePylons.sqf b/addons/pylons/functions/fnc_configurePylons.sqf index 2fbc91e9493..5ba3c763fd7 100644 --- a/addons/pylons/functions/fnc_configurePylons.sqf +++ b/addons/pylons/functions/fnc_configurePylons.sqf @@ -27,8 +27,10 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; { (_this select 0) params ["_pylonsToConfigure", "_currentPylon"]; private _pylonIndex = _pylonsToConfigure select _currentPylon; + TRACE_2("",_currentPylon,_pylonIndex); // Remove the weapon of current pylon from aircraft IF weapon is only on this pylon + private _removeWeapon = ""; private _currentPylonMagazine = (getPylonMagazines GVAR(currentAircraft)) select _pylonIndex; if (_currentPylonMagazine != "") then { private _allPylonWeapons = (getPylonMagazines GVAR(currentAircraft)) apply { @@ -36,7 +38,8 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; }; private _pylonWeapon = _allPylonWeapons select _pylonIndex; if (({_x == _pylonWeapon} count _allPylonWeapons) == 1) then { - GVAR(currentAircraft) removeWeaponGlobal _pylonWeapon; + TRACE_2("Removing unused weapon",_pylonWeapon,_allPylonWeapons); + _removeWeapon = _pylonWeapon; }; }; @@ -47,7 +50,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; [ QGVAR(setPylonLoadOutEvent), - [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret] + [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret, _removeWeapon] ] call CBA_fnc_globalEvent; private _count = if (GVAR(rearmNewPylons) || {GVAR(isCurator)}) then { diff --git a/addons/pylons/functions/fnc_showDialog.sqf b/addons/pylons/functions/fnc_showDialog.sqf index 47b6585c897..eb0d46ff85c 100644 --- a/addons/pylons/functions/fnc_showDialog.sqf +++ b/addons/pylons/functions/fnc_showDialog.sqf @@ -149,7 +149,10 @@ if (!GVAR(isCurator)) then { isNull (GVAR(currentAircraft) getVariable [QGVAR(currentUser), objNull]) || {(ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)} }, { - [localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText); + TRACE_3("disconnect/far",GVAR(currentAircraft), ace_player distance GVAR(currentAircraft),GVAR(currentAircraft) getVariable QGVAR(currentUser)); + if ((ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)) then { + [localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText); + }; call FUNC(onButtonClose); }] call CBA_fnc_waitUntilAndExecute; }; From 84673eeb92a406029319ac7b2167ea7d2909a8ae Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jan 2018 16:04:57 -0600 Subject: [PATCH 2/3] Fix _x --- addons/pylons/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/pylons/XEH_postInit.sqf b/addons/pylons/XEH_postInit.sqf index 5375bdcfeff..4b94c34364f 100644 --- a/addons/pylons/XEH_postInit.sqf +++ b/addons/pylons/XEH_postInit.sqf @@ -35,7 +35,7 @@ { if (_aircraft turretLocal _x) then { TRACE_3("removing",_aircraft,_x,_removeWeapon); - _aircraft removeWeaponTurret [_removeWeapon, [-1]]; + _aircraft removeWeaponTurret [_removeWeapon, _x]; }; } forEach [[-1], [0]]; }; From 7886942c1cf9d689f45b36ad4706da5421a0b3f5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jan 2018 21:47:15 -0600 Subject: [PATCH 3/3] Fix var name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Ozan Eğitmen --- addons/pylons/XEH_postInit.sqf | 10 +++++----- addons/pylons/functions/fnc_configurePylons.sqf | 6 +++--- addons/pylons/functions/fnc_showDialog.sqf | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/pylons/XEH_postInit.sqf b/addons/pylons/XEH_postInit.sqf index 4b94c34364f..72a07078d0e 100644 --- a/addons/pylons/XEH_postInit.sqf +++ b/addons/pylons/XEH_postInit.sqf @@ -28,14 +28,14 @@ } forEach GVAR(aircraftWithPylons); [QGVAR(setPylonLoadOutEvent), { - params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_removeWeapon"]; - TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_removeWeapon); + params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_weaponToRemove"]; + TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_weaponToRemove); _aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret]; - if (_removeWeapon != "") then { + if (_weaponToRemove != "") then { { if (_aircraft turretLocal _x) then { - TRACE_3("removing",_aircraft,_x,_removeWeapon); - _aircraft removeWeaponTurret [_removeWeapon, _x]; + TRACE_3("removing",_aircraft,_x,_weaponToRemove); + _aircraft removeWeaponTurret [_weaponToRemove, _x]; }; } forEach [[-1], [0]]; }; diff --git a/addons/pylons/functions/fnc_configurePylons.sqf b/addons/pylons/functions/fnc_configurePylons.sqf index 5ba3c763fd7..401063f8a91 100644 --- a/addons/pylons/functions/fnc_configurePylons.sqf +++ b/addons/pylons/functions/fnc_configurePylons.sqf @@ -30,7 +30,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; TRACE_2("",_currentPylon,_pylonIndex); // Remove the weapon of current pylon from aircraft IF weapon is only on this pylon - private _removeWeapon = ""; + private _weaponToRemove = ""; private _currentPylonMagazine = (getPylonMagazines GVAR(currentAircraft)) select _pylonIndex; if (_currentPylonMagazine != "") then { private _allPylonWeapons = (getPylonMagazines GVAR(currentAircraft)) apply { @@ -39,7 +39,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; private _pylonWeapon = _allPylonWeapons select _pylonIndex; if (({_x == _pylonWeapon} count _allPylonWeapons) == 1) then { TRACE_2("Removing unused weapon",_pylonWeapon,_allPylonWeapons); - _removeWeapon = _pylonWeapon; + _weaponToRemove = _pylonWeapon; }; }; @@ -50,7 +50,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; [ QGVAR(setPylonLoadOutEvent), - [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret, _removeWeapon] + [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret, _weaponToRemove] ] call CBA_fnc_globalEvent; private _count = if (GVAR(rearmNewPylons) || {GVAR(isCurator)}) then { diff --git a/addons/pylons/functions/fnc_showDialog.sqf b/addons/pylons/functions/fnc_showDialog.sqf index eb0d46ff85c..5be18d20e81 100644 --- a/addons/pylons/functions/fnc_showDialog.sqf +++ b/addons/pylons/functions/fnc_showDialog.sqf @@ -149,7 +149,7 @@ if (!GVAR(isCurator)) then { isNull (GVAR(currentAircraft) getVariable [QGVAR(currentUser), objNull]) || {(ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)} }, { - TRACE_3("disconnect/far",GVAR(currentAircraft), ace_player distance GVAR(currentAircraft),GVAR(currentAircraft) getVariable QGVAR(currentUser)); + TRACE_3("disconnect/far",GVAR(currentAircraft),ace_player distance GVAR(currentAircraft),GVAR(currentAircraft) getVariable QGVAR(currentUser)); if ((ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)) then { [localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText); };