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

General - Replace CBA_fnc_canAddItem with canAdd #10787

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addons/attach/functions/fnc_detach.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find
private _isChemlight = _attachedObject isKindOf "Chemlight_base";

// Exit if can't add the item
if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith {
if (!_isChemlight && {!(_unit canAdd [_itemName, 1, true])}) exitWith {
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
};

Expand Down
8 changes: 4 additions & 4 deletions addons/captives/functions/fnc_doBlindfoldCaptive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ if (_state) then { // Blindfold target
// Remove target's goggles if it is wearing any and move them to unit's or target's inventory (if they can hold them)
_previousGoggles = goggles _target;
if (_previousGoggles != "") then {
if ([_unit, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
if (_unit canAdd [_previousGoggles, 1, true]) exitWith {
removeGoggles _target;
_unit addItem _previousGoggles;
};
if ([_target, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
if (_target canAdd [_previousGoggles, 1, true]) exitWith {
removeGoggles _target;
_target addItem _previousGoggles;
};
Expand All @@ -52,11 +52,11 @@ if (_state) then { // Blindfold target
// Abort if already not wearing a blindfold
if !(_previousGoggles in GVAR(blindfolds)) exitWith { ERROR("no blindfold"); };

if ([_unit, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
if (_unit canAdd [_previousGoggles, 1, true]) exitWith {
removeGoggles _target;
_unit addItem _previousGoggles;
};
if ([_target, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
if (_target canAdd [_previousGoggles, 1, true]) exitWith {
removeGoggles _target;
_target addItem _previousGoggles;
};
Expand Down
4 changes: 2 additions & 2 deletions addons/csw/functions/fnc_reload_handleReturnAmmo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ private _bulletsRemaining = _ammo % _carryMaxAmmo;
private _unloadToUnit = _unloadTo isKindOf "CAManBase";

if (_unloadToUnit) then {
while {(_fullMagazines > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}} do {
while {(_fullMagazines > 0) && {_unloadTo canAdd [_carryMag, 1, true]}} do {
_unloadTo addMagazine [_carryMag, _carryMaxAmmo];
_fullMagazines = _fullMagazines - 1;
};
if ((_bulletsRemaining > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}) then {
if ((_bulletsRemaining > 0) && {_unloadTo canAdd [_carryMag, 1, true]}) then {
_unloadTo addMagazine [_carryMag, _bulletsRemaining];
_bulletsRemaining = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion addons/hearing/functions/fnc_removeEHP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!GVAR(enableCombatDeafness)) exitWith {};
params ["_unit", ["_displayHint", false]];

// Inventory full
if !([_unit, "ACE_EHP"] call CBA_fnc_canAddItem) exitWith {
if !(_unit canAdd ["ACE_EHP", 1, true]) exitWith {
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
};

Expand Down
2 changes: 1 addition & 1 deletion addons/hearing/functions/fnc_removeEarplugs.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!GVAR(enableCombatDeafness)) exitWith {};
params ["_unit", ["_displayHint", false]];

// Inventory full
if !([_unit, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith {
if !(_unit canAdd ["ACE_EarPlugs", 1, true]) exitWith {
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (_addNew) then {
_unit removeItem _newAttachment;
};

if (_removeOld && {!([_unit, _oldAttachment] call CBA_fnc_canAddItem)}) exitWith {
if (_removeOld && {!(_unit canAdd [_oldAttachment, 1, true])}) exitWith {
LOG("no space");
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
if (_addNew) then {
Expand Down
2 changes: 1 addition & 1 deletion addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >>

_magazineType == _magazine // Magazine is of given type
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
&& {!_isLoaded || {GVAR(repackLoadedMagazines) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
&& {!_isLoaded || {GVAR(repackLoadedMagazines) && {_unit canAdd [_magazineType, 1, true]}}} // In inventory or can be moved into it
} count magazinesAmmoFull _unit > 1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private _unitMagCounts = [];
private _isRepackDisabled = getNumber (_configMagazine >> "ace_disableRepacking") == 1;

//for every partial magazine, that is either in inventory or can be moved there
if ((!_isRepackDisabled) && {_xCount < _xFullMagazineCount} && {_xCount > 0} && {(!_xLoaded) || {GVAR(repackLoadedMagazines) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
if ((!_isRepackDisabled) && {_xCount < _xFullMagazineCount} && {_xCount > 0} && {(!_xLoaded) || {GVAR(repackLoadedMagazines) && {_player canAdd [_xClassname, 1, true]}}}) then {
private _index = _unitMagazines find _xClassname;
if (_index == -1) then {
_unitMagazines pushBack _xClassname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private _startingAmmoCounts = [];
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
if (_xLoaded) then {
//Try to Remove from weapon and add to inventory, otherwise ignore
if (GVAR(repackLoadedMagazines) && {[_player, _magazineClassname] call CBA_fnc_canAddItem}) then {
if (GVAR(repackLoadedMagazines) && {_player canAdd [_magazineClassname, 1, true]}) then {
switch (_xType) do {
case (1): {_player removePrimaryWeaponItem _magazineClassname};
case (2): {_player removeHandgunItem _magazineClassname};
Expand Down