Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - Fix CBA_fnc_canAddItem when item mass is 0 #1673

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
};