mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo - setSpace checks for existing cargo (#7133)
This commit is contained in:
parent
bcbffcff26
commit
b3c5a72dae
@ -125,6 +125,7 @@ PiZZADOX <509thParachuteInfantry@gmail.com>
|
|||||||
Phyma <sethramstrom@gmail.com>
|
Phyma <sethramstrom@gmail.com>
|
||||||
pokertour
|
pokertour
|
||||||
Professor <lukas.trneny@wo.cz>
|
Professor <lukas.trneny@wo.cz>
|
||||||
|
Pterolatypus <pterolatypus@gmail.com>
|
||||||
QuickDagger
|
QuickDagger
|
||||||
rakowozz
|
rakowozz
|
||||||
ramius86 <pasini86@hotmail.com>
|
ramius86 <pasini86@hotmail.com>
|
||||||
|
@ -31,14 +31,23 @@ TRACE_2("setSpace",_vehicle,_size);
|
|||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
if (
|
if (
|
||||||
(isNil "_space") ||
|
(isNil "_space") ||
|
||||||
{isNull _vehicle} ||
|
{isNull _vehicle}
|
||||||
{_space == _vehicle getVariable [QGVAR(space), CARGO_SPACE(typeOf _vehicle)]}
|
|
||||||
) exitWith {};
|
) 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
|
// Apply new space globally
|
||||||
|
_vehicle setVariable [QGVAR(space), _newSpace, true];
|
||||||
// Necessary to update value, even if no space, as API could be used again
|
// Necessary to update value, even if no space, as API could be used again
|
||||||
_vehicle setVariable [QGVAR(hasCargo), _space > 0, true];
|
_vehicle setVariable [QGVAR(hasCargo), _space > 0, true];
|
||||||
_vehicle setVariable [QGVAR(space), _space, true];
|
|
||||||
|
|
||||||
// If no cargo space no need for cargo menu
|
// If no cargo space no need for cargo menu
|
||||||
if (_space <= 0) exitWith {};
|
if (_space <= 0) exitWith {};
|
||||||
|
Loading…
Reference in New Issue
Block a user