From bb859274ee3c5207389be5adda5f0bb2dcb76fbe Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 30 Jan 2025 00:11:24 +0100 Subject: [PATCH] Fix false target id when fire mission is canceled (#130) --- addons/zeus/XEH_postInit.sqf | 6 ++++-- addons/zeus/functions/fnc_execFireMission.sqf | 6 +++--- addons/zeus/functions/fnc_initFireMission.sqf | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index f3ecb95..876597c 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -36,9 +36,11 @@ if (hasInterface) then { [QGVAR(fireMissionComplete), { if (isNull curatorCamera) exitWith {}; - params ["_targetLogic", "_canceled"]; + params ["_id", "_canceled"]; + TRACE_2("fireMissionComplete EH",_id,_canceled); + + if (_id <= 0) exitWith {}; - private _id = _targetLogic getVariable [QGVAR(targetID), 0]; if (_canceled) then { [LLSTRING(artillery_fireMissionCanceled), _id] call zen_common_fnc_showMessage; } else { diff --git a/addons/zeus/functions/fnc_execFireMission.sqf b/addons/zeus/functions/fnc_execFireMission.sqf index 4e056bc..67268be 100644 --- a/addons/zeus/functions/fnc_execFireMission.sqf +++ b/addons/zeus/functions/fnc_execFireMission.sqf @@ -63,12 +63,12 @@ if (_firstImpactDelay > 5) then { _args params ["_targetLogic", "_t0", "_shellReverseQueue"]; if (_shellReverseQueue isEqualTo [] || isNull _targetLogic) exitWith { - LOG("Fire mission completed normally."); [_handle] call CBA_fnc_removePerFrameHandler; if (!isNull _targetLogic) then { - [QGVAR(fireMissionComplete), [_targetLogic, false]] call CBA_fnc_globalEvent; - deleteVehicle _targetLogic; + LOG("Fire mission completed normally."); + _targetLogic setVariable [QGVAR(fireMissionComplete), true, true]; + deleteVehicle _targetLogic; // Will trigger deleted EH and broadcast complete event }; }; diff --git a/addons/zeus/functions/fnc_initFireMission.sqf b/addons/zeus/functions/fnc_initFireMission.sqf index 322635d..a32a226 100644 --- a/addons/zeus/functions/fnc_initFireMission.sqf +++ b/addons/zeus/functions/fnc_initFireMission.sqf @@ -49,7 +49,11 @@ private _jipID = [QGVAR(visualizeArtyTargetArea), _targetArea] call CBA_fnc_glob // Handle canceling fire mission _targetLogic addEventHandler ["Deleted", { params ["_targetLogic"]; - [QGVAR(fireMissionComplete), [_targetLogic, true]] call CBA_fnc_globalEvent; + + private _targetID = _targetLogic getVariable [QGVAR(targetID), -1]; + private _complete = _targetLogic getVariable [QGVAR(fireMissionComplete), false]; + + [QGVAR(fireMissionComplete), [_targetID, !_complete]] call CBA_fnc_globalEvent; }]; // Begin fire mission