Skip to content

Commit

Permalink
Vehicles - Stop calling setCruiseControl every frame (acemod#8643)
Browse files Browse the repository at this point in the history
* Speedlimit - Stop calling setCruiseControl every frame

* Added TRACE logging for cruiseControl changes
  • Loading branch information
dedmen authored and AndreasBrostrom committed Dec 3, 2021
1 parent 6eee870 commit 40f54c3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions addons/vehicles/functions/fnc_speedLimiter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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];
};
};
Expand All @@ -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];
};

Expand Down

0 comments on commit 40f54c3

Please sign in to comment.