From b151148542a44237445581f96609325689c3d096 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 27 Feb 2021 20:26:12 +0400 Subject: [PATCH] Replace canAdd with CBA_fnc_canAddItem (#8012) --- addons/attach/functions/fnc_detach.sqf | 2 +- addons/common/functions/fnc_addToInventory.sqf | 8 ++++---- addons/csw/functions/fnc_reload_handleReturnAmmo.sqf | 4 ++-- addons/hearing/functions/fnc_removeEarplugs.sqf | 2 +- addons/interaction/functions/fnc_canPassMagazine.sqf | 2 +- addons/interaction/functions/fnc_passMagazine.sqf | 2 +- addons/magazinerepack/functions/fnc_canRepackMagazine.sqf | 2 +- .../magazinerepack/functions/fnc_getMagazineChildren.sqf | 2 +- .../functions/fnc_startRepackingMagazine.sqf | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/attach/functions/fnc_detach.sqf b/addons/attach/functions/fnc_detach.sqf index 5ff12967ce..38acbc1883 100644 --- a/addons/attach/functions/fnc_detach.sqf +++ b/addons/attach/functions/fnc_detach.sqf @@ -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 canAdd _itemName) && {!_isChemlight}) exitWith { +if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith { [localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured); }; diff --git a/addons/common/functions/fnc_addToInventory.sqf b/addons/common/functions/fnc_addToInventory.sqf index b8b5f93635..de5eb9b4af 100644 --- a/addons/common/functions/fnc_addToInventory.sqf +++ b/addons/common/functions/fnc_addToInventory.sqf @@ -28,16 +28,16 @@ private _addedToUnit = false; switch (_container) do { case "vest": { - _canAdd = _unit canAddItemToVest _classname; + _canAdd = [_unit, _classname, 1, false, true, false] call CBA_fnc_canAddItem; }; case "backpack": { - _canAdd = _unit canAddItemToBackpack _classname; + _canAdd = [_unit, _classname, 1, false, false, true] call CBA_fnc_canAddItem; }; case "uniform": { - _canAdd = _unit canAddItemToUniform _classname; + _canAdd = [_unit, _classname, 1, true, false, false] call CBA_fnc_canAddItem; }; default { - _canAdd = _unit canAdd _classname; + _canAdd = [_unit, _classname] call CBA_fnc_canAddItem; }; }; diff --git a/addons/csw/functions/fnc_reload_handleReturnAmmo.sqf b/addons/csw/functions/fnc_reload_handleReturnAmmo.sqf index 1d288b863f..464a7fc65d 100644 --- a/addons/csw/functions/fnc_reload_handleReturnAmmo.sqf +++ b/addons/csw/functions/fnc_reload_handleReturnAmmo.sqf @@ -25,11 +25,11 @@ private _fullMagazines = floor (_ammo / _carryMaxAmmo); private _bulletsRemaining = _ammo % _carryMaxAmmo; if (_unloadTo isKindOf "CaManBase") then { - while {(_fullMagazines > 0) && {_unloadTo canAdd _carryMag}} do { + while {(_fullMagazines > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}} do { _unloadTo addMagazine [_carryMag, _carryMaxAmmo]; _fullMagazines = _fullMagazines - 1; }; - if ((_bulletsRemaining > 0) && {_unloadTo canAdd _carryMag}) then { + if ((_bulletsRemaining > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}) then { _unloadTo addMagazine [_carryMag, _bulletsRemaining]; _bulletsRemaining = 0; }; diff --git a/addons/hearing/functions/fnc_removeEarplugs.sqf b/addons/hearing/functions/fnc_removeEarplugs.sqf index 5e8064e767..55ba422beb 100644 --- a/addons/hearing/functions/fnc_removeEarplugs.sqf +++ b/addons/hearing/functions/fnc_removeEarplugs.sqf @@ -20,7 +20,7 @@ params ["_player", ["_displayHint", false, [false]]]; if (!GVAR(EnableCombatDeafness)) exitWith {}; -if !(_player canAdd "ACE_EarPlugs") exitWith { // inventory full +if !([_player, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith { // inventory full [localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured); }; diff --git a/addons/interaction/functions/fnc_canPassMagazine.sqf b/addons/interaction/functions/fnc_canPassMagazine.sqf index 5cc1ed96e2..a76e7fb409 100644 --- a/addons/interaction/functions/fnc_canPassMagazine.sqf +++ b/addons/interaction/functions/fnc_canPassMagazine.sqf @@ -26,5 +26,5 @@ private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines; (magazinesAmmoFull _player) findIf { _x params ["_className", "", "_loaded"]; - (_className in _compatibleMags) && {!_loaded} && {_target canAdd _className} + (_className in _compatibleMags) && {!_loaded} && {[_target, _className] call CBA_fnc_canAddItem} } > -1 diff --git a/addons/interaction/functions/fnc_passMagazine.sqf b/addons/interaction/functions/fnc_passMagazine.sqf index 07db3dba3c..f6438211fa 100644 --- a/addons/interaction/functions/fnc_passMagazine.sqf +++ b/addons/interaction/functions/fnc_passMagazine.sqf @@ -21,7 +21,7 @@ params ["_player", "_target", "_weapon"]; private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines; private _filteredMags = magazinesAmmoFull _player select { _x params ["_className", "", "_loaded"]; - (_className in _compatibleMags) && {!_loaded} && {_target canAdd _className} + (_className in _compatibleMags) && {!_loaded} && {[_target, _className] call CBA_fnc_canAddItem} }; //select magazine with most ammo diff --git a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf index 034de578be..f448b91b64 100644 --- a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf +++ b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf @@ -25,5 +25,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> _magazineType == _magazine // Magazine is of given type && {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine - && {!_isLoaded || {_unit canAdd _magazineType}} // In inventory or can be moved into it + && {!_isLoaded || {[_unit, _magazineType] call CBA_fnc_canAddItem}} // In inventory or can be moved into it } count magazinesAmmoFull _unit > 1 diff --git a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf index b1cdef9829..3c87b434a7 100644 --- a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf +++ b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf @@ -27,7 +27,7 @@ private _unitMagCounts = []; private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count"); //for every partial magazine, that is either in inventory or can be moved there - if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {_player canAdd _xClassname}}) then { + if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {[_player, _xClassname] call CBA_fnc_canAddItem}}) then { private _index = _unitMagazines find _xClassname; if (_index == -1) then { _unitMagazines pushBack _xClassname; diff --git a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf index cd9df9b2a9..b776d4bcdb 100644 --- a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf +++ b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf @@ -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 (_player canAdd _magazineClassname) then { + if ([_player, _magazineClassname] call CBA_fnc_canAddItem) then { switch (_xType) do { case (1): {_player removePrimaryWeaponItem _magazineClassname}; case (2): {_player removeHandgunItem _magazineClassname};