From c85db9baf96357ef688ce6a9cac49d8ec5946774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Sat, 17 Jan 2015 02:24:28 -0300 Subject: [PATCH] hearing: fix PFH in case the game is paused --- addons/hearing/functions/fnc_earRinging.sqf | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index d3382ea26e..dda4082fa8 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -25,11 +25,14 @@ GVAR(newStrength) = GVAR(newStrength) max _strength; if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {}; _fnc_removeEarRinging = { - // Skip first execution - if (diag_tickTime < 1 + ((_this select 0) select 0)) exitWith {}; + EXPLODE_2_PVT(_this,_params,_pfhId); + EXPLODE_2_PVT(_params,_startTime,_duration); + + // Exit if the delay is not met yet + if (time < _startTime + _duration) exitWith {}; GVAR(isEarRingingPlaying) = false; - [(_this select 1)] call cba_fnc_removePerFrameHandler; + [_pfhId] call cba_fnc_removePerFrameHandler; }; if (profileNamespace getVariable [QGVAR(DisableEarRinging), false]) exitWith {}; @@ -37,15 +40,15 @@ if (profileNamespace getVariable [QGVAR(DisableEarRinging), false]) exitWith {}; if (_strength > 0.75) exitWith { playSound "ACE_EarRinging_Heavy"; GVAR(isEarRingingPlaying) = true; - [_fnc_removeEarRinging, 7.0, [diag_tickTime] ] call CBA_fnc_addPerFrameHandler; + [_fnc_removeEarRinging, 0.25, [time, 7.0] ] call CBA_fnc_addPerFrameHandler; }; if (_strength > 0.5) exitWith { playSound "ACE_EarRinging_Medium"; GVAR(isEarRingingPlaying) = true; - [_fnc_removeEarRinging, 5.0, [diag_tickTime] ] call CBA_fnc_addPerFrameHandler; + [_fnc_removeEarRinging, 0.25, [time, 5.0] ] call CBA_fnc_addPerFrameHandler; }; if (_strength > 0.2) exitWith { playSound "ACE_EarRinging_Weak"; GVAR(isEarRingingPlaying) = true; - [_fnc_removeEarRinging, 3.0, [diag_tickTime] ] call CBA_fnc_addPerFrameHandler; + [_fnc_removeEarRinging, 0.25, [time, 3.0] ] call CBA_fnc_addPerFrameHandler; };