diff --git a/AUTHORS.txt b/AUTHORS.txt index e05d1d7d11..26979b22ea 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -125,6 +125,7 @@ PiZZADOX <509thParachuteInfantry@gmail.com> Phyma pokertour Professor +Pterolatypus QuickDagger rakowozz ramius86 diff --git a/addons/cargo/functions/fnc_setSpace.sqf b/addons/cargo/functions/fnc_setSpace.sqf index 1b3743cf9f..ed34914fdc 100644 --- a/addons/cargo/functions/fnc_setSpace.sqf +++ b/addons/cargo/functions/fnc_setSpace.sqf @@ -31,14 +31,23 @@ TRACE_2("setSpace",_vehicle,_size); // Nothing to do here if ( (isNil "_space") || - {isNull _vehicle} || - {_space == _vehicle getVariable [QGVAR(space), CARGO_SPACE(typeOf _vehicle)]} + {isNull _vehicle} ) exitWith {}; +// Account for cargo already in the vehicle +private _loaded = _vehicle getVariable [QGVAR(loaded), []]; +private _newSpace = _space; +{ + _newSpace = _newSpace - ([_x] call FUNC(getSizeItem)); +} forEach _loaded; + +// If the new value is the same as the old, do nothing +if (_newSpace == (_vehicle getVariable [QGVAR(space), CARGO_SPACE(typeOf _vehicle)])) exitwith {}; + // Apply new space globally +_vehicle setVariable [QGVAR(space), _newSpace, true]; // Necessary to update value, even if no space, as API could be used again _vehicle setVariable [QGVAR(hasCargo), _space > 0, true]; -_vehicle setVariable [QGVAR(space), _space, true]; // If no cargo space no need for cargo menu if (_space <= 0) exitWith {};