From ef681e4332c176a8fec182de008ef02351712525 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 23 Oct 2015 13:11:11 -0500 Subject: [PATCH] Captives - Fix adding duplicate animEH --- addons/captives/functions/fnc_setHandcuffed.sqf | 11 ++++++----- addons/captives/functions/fnc_setSurrendered.sqf | 9 ++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 00122862eb6..0bc2e85c526 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -56,8 +56,11 @@ if (_state) then { //Adds an animation changed eh //If we get a change in animation then redo the animation (handles people vaulting to break the animation chain) - private "_animChangedEHID"; - + local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; + if (_animChangedEHID != -1) then { + TRACE_1("removing animChanged EH",_animChangedEHID); + _unit removeEventHandler ["AnimChanged", _animChangedEHID]; + }; _animChangedEHID = _unit addEventHandler ["AnimChanged", { params ["_unit", "_newAnimation"]; TRACE_2("AnimChanged",_unit,_newAnimation); @@ -67,7 +70,6 @@ if (_state) then { [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; } else { - _turretPath = []; { _x params ["_xUnit", "", "", "_xTurretPath"]; @@ -90,8 +92,7 @@ if (_state) then { [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); //remove AnimChanged EH - private "_animChangedEHID"; - _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; + local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; TRACE_1("removing animChanged EH",_animChangedEHID); _unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit setVariable [QGVAR(handcuffAnimEHID), -1]; diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index cdba47a406e..171455f3b10 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -48,7 +48,11 @@ if (_state) then { if (_unit getVariable [QGVAR(isSurrendering), false] && {(vehicle _unit) == _unit}) then { //Adds an animation changed eh //If we get a change in animation then redo the animation (handles people vaulting to break the animation chain) - private "_animChangedEHID"; + local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; + if (_animChangedEHID != -1) then { + TRACE_1("removing animChanged EH",_animChangedEHID); + _unit removeEventHandler ["AnimChanged", _animChangedEHID]; + }; _animChangedEHID = _unit addEventHandler ["AnimChanged", { params ["_unit", "_newAnimation"]; if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { @@ -64,8 +68,7 @@ if (_state) then { [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); //remove AnimChanged EH - private "_animChangedEHID"; - _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; + local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; _unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit setVariable [QGVAR(surrenderAnimEHID), -1];