From 47e1ae78244c8c37072cca8c59c2cce1c2716e03 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 19 Jul 2024 22:49:53 -0500 Subject: [PATCH] Common - Fix `CBA_fnc_canAddItem` when item mass is 0 --- addons/common/fnc_canAddItem.sqf | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/common/fnc_canAddItem.sqf b/addons/common/fnc_canAddItem.sqf index cd7ac35e4..c3eacbb57 100644 --- a/addons/common/fnc_canAddItem.sqf +++ b/addons/common/fnc_canAddItem.sqf @@ -102,10 +102,12 @@ if (_unit isKindOf "CAManBase") then { _checkUniform && {TYPE_UNIFORM in _allowedSlots} && { + private _maxLoad = maxLoad uniformContainer _unit; + if (_maxLoad == 0) exitWith { false }; _mass == 0 || { // each time subtract whole number of items which can be put in container - _count = _count - floor (maxLoad uniformContainer _unit * (1 - loadUniform _unit) / _mass); + _count = _count - floor (_maxLoad * (1 - loadUniform _unit) / _mass); _count <= 0 } } @@ -115,9 +117,11 @@ if (_unit isKindOf "CAManBase") then { _checkVest && {TYPE_VEST in _allowedSlots} && { + private _maxLoad = maxLoad vestContainer _unit; + if (_maxLoad == 0) exitWith { false }; _mass == 0 || { - _count = _count - floor (maxLoad vestContainer _unit * (1 - loadVest _unit) / _mass); + _count = _count - floor (_maxLoad * (1 - loadVest _unit) / _mass); _count <= 0 } } @@ -127,9 +131,11 @@ if (_unit isKindOf "CAManBase") then { _checkBackpack && {TYPE_BACKPACK in _allowedSlots} && { + private _maxLoad = maxLoad backpackContainer _unit; + if (_maxLoad == 0) exitWith { false }; _mass == 0 || { - _count = _count - floor (maxLoad backpackContainer _unit * (1 - loadBackpack _unit) / _mass); + _count = _count - floor (_maxLoad * (1 - loadBackpack _unit) / _mass); _count <= 0 } } @@ -138,9 +144,11 @@ if (_unit isKindOf "CAManBase") then { false } else { // is a vehicle, crate etc. + private _maxLoad = maxLoad _unit; + if (_maxLoad == 0) exitWith { false }; _mass == 0 || { - _count = _count - floor (maxLoad _unit * (1 - load _unit) / _mass); + _count = _count - floor (_maxLoad * (1 - load _unit) / _mass); _count <= 0 } };