Skip to content

Commit

Permalink
Merge pull request #1673 from CBATeam/canAddx
Browse files Browse the repository at this point in the history
Common - Fix `CBA_fnc_canAddItem` when item mass is 0
  • Loading branch information
PabstMirror authored Jul 28, 2024
2 parents 6bd842d + 47e1ae7 commit 6b21914
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions addons/common/fnc_canAddItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
};

0 comments on commit 6b21914

Please sign in to comment.