From 87cfd9632e369dcd7529700f0f2e5bdd332697ab Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Thu, 28 Oct 2021 16:03:09 +0200 Subject: [PATCH] Vehicles - Stop calling `setCruiseControl` every frame (#8643) * Speedlimit - Stop calling setCruiseControl every frame * Added TRACE logging for cruiseControl changes --- addons/vehicles/functions/fnc_speedLimiter.sqf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/vehicles/functions/fnc_speedLimiter.sqf b/addons/vehicles/functions/fnc_speedLimiter.sqf index 6d76293bff..ba3928e3e0 100644 --- a/addons/vehicles/functions/fnc_speedLimiter.sqf +++ b/addons/vehicles/functions/fnc_speedLimiter.sqf @@ -32,7 +32,7 @@ if (_speedLimit != 0) exitWith { TRACE_1("speed limit set by external source",_s playSound "ACE_Sound_Click"; GVAR(isSpeedLimiter) = true; -GVAR(speedLimit) = speed _vehicle max 5; +GVAR(speedLimit) = round (speed _vehicle max 5); [{ params ["_args", "_idPFH"]; @@ -42,11 +42,13 @@ GVAR(speedLimit) = speed _vehicle max 5; private _uavControll = UAVControl _vehicle; if ((_uavControll select 0) != _driver || _uavControll select 1 != "DRIVER") then { GVAR(isSpeedLimiter) = false; + TRACE_1("UAV driver changed, disabling speedlimit",_vehicle); _vehicle setCruiseControl [0, false]; }; } else { if (_driver != driver _vehicle) then { GVAR(isSpeedLimiter) = false; + TRACE_3("Vehicle driver changed, disabling speedlimit",_driver,driver _vehicle,_vehicle); _vehicle setCruiseControl [0, false]; }; }; @@ -57,7 +59,8 @@ GVAR(speedLimit) = speed _vehicle max 5; }; getCruiseControl _vehicle params ["_currentSpeedLimit"]; - if (_currentSpeedLimit != GVAR(speedLimit)) then { + if (round _currentSpeedLimit != GVAR(speedLimit)) then { + TRACE_2("Updating speed limit",GVAR(speedLimit),_vehicle); _vehicle setCruiseControl [GVAR(speedLimit), false]; };