From 1c921674a98e8c023f27ef5ebf92e83bb02c0990 Mon Sep 17 00:00:00 2001 From: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> Date: Mon, 11 Oct 2021 02:47:54 -0300 Subject: [PATCH] Fixed jerry can madness (#8348) Fixed refueling vehicles with high input rates when using fuel sources with low fuel capacity. --- addons/refuel/functions/fnc_refuel.sqf | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/refuel/functions/fnc_refuel.sqf b/addons/refuel/functions/fnc_refuel.sqf index 0104c45a5c..92a654e295 100644 --- a/addons/refuel/functions/fnc_refuel.sqf +++ b/addons/refuel/functions/fnc_refuel.sqf @@ -74,13 +74,19 @@ if (_maxFuel == 0) then { private _rateTime = _rate * (CBA_missionTime - (_nozzle getVariable [QGVAR(lastTickMissionTime), CBA_missionTime])); _nozzle setVariable [QGVAR(lastTickMissionTime), CBA_missionTime]; - if !(_fuelInSource == REFUEL_INFINITE_FUEL) then { - _fuelInSource = _fuelInSource - _rateTime; + if (_fuelInSource != REFUEL_INFINITE_FUEL) then { + if (_rateTime > _fuelInSource) then { + _rateTime = _fuelInSource; + _fuelInSource = 0; + } else { + _fuelInSource = _fuelInSource - _rateTime; + }; } else { _source setVariable [QGVAR(fuelCounter), (_source getVariable [QGVAR(fuelCounter), 0]) + _rateTime, true]; }; - if (_fuelInSource < 0 && {_fuelInSource > REFUEL_INFINITE_FUEL}) then { + if (_fuelInSource <= 0 && {_fuelInSource != REFUEL_INFINITE_FUEL}) then { _fuelInSource = 0; + [_source, _fuelInSource] call FUNC(setFuel); _finished = true; [LSTRING(Hint_SourceEmpty), 2, _unit] call EFUNC(common,displayTextStructured); };