From c532849dffefc5d9a1a1b41b4e2e143dad2a4780 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:26:26 +0100 Subject: [PATCH 1/4] Unique items fix --- addons/arsenal/functions/fnc_buttonCargo.sqf | 14 ++++++------- .../arsenal/functions/fnc_fillRightPanel.sqf | 14 ++++++------- .../functions/fnc_updateUniqueItemsList.sqf | 20 +++++++++++++++---- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/addons/arsenal/functions/fnc_buttonCargo.sqf b/addons/arsenal/functions/fnc_buttonCargo.sqf index 48c5ee477e4..d7713a2518f 100644 --- a/addons/arsenal/functions/fnc_buttonCargo.sqf +++ b/addons/arsenal/functions/fnc_buttonCargo.sqf @@ -47,8 +47,8 @@ private _container = switch (GVAR(currentLeftPanel)) do { }; }; - /// Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = uniformItems GVAR(center); // Update currentItems GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_UNIFORM) param [1, []]]; @@ -75,8 +75,8 @@ private _container = switch (GVAR(currentLeftPanel)) do { }; }; - // Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = vestItems GVAR(center); // Update currentItems GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_VEST) param [1, []]]; @@ -103,8 +103,8 @@ private _container = switch (GVAR(currentLeftPanel)) do { }; }; - // Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = backpackItems GVAR(center); // Update currentItems GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_BACKPACK) param [1, []]]; @@ -117,7 +117,7 @@ private _container = switch (GVAR(currentLeftPanel)) do { }; // Find out how many items of that type there are and update the number displayed -_ctrlList lnbSetText [[_lnbCurSel, 2], str (_containerItems getOrDefault [_item, 0])]; +_ctrlList lnbSetText [[_lnbCurSel, 2], str ({_item == _x} count _containerItems)]; [QGVAR(cargoChanged), [_display, _item, _addOrRemove, GVAR(shiftState)]] call CBA_fnc_localEvent; diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index c562e8727d0..04e03309fcc 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -389,8 +389,8 @@ if (_isContainer) then { // Update load bar (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadUniform GVAR(center)); - // Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = uniformItems GVAR(center); uniformContainer GVAR(center) }; @@ -399,8 +399,8 @@ if (_isContainer) then { // Update load bar (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadVest GVAR(center)); - // Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = vestItems GVAR(center); vestContainer GVAR(center) }; @@ -409,8 +409,8 @@ if (_isContainer) then { // Update load bar (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadBackpack GVAR(center)); - // Get all items from container (excluding container itself) - _containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems); + // Get all items from container + _containerItems = backpackItems GVAR(center); backpackContainer GVAR(center) }; @@ -418,7 +418,7 @@ if (_isContainer) then { // Find out how many items of a type there are and update the number displayed for "_lbIndex" from 0 to (lnbSize _ctrlPanel select 0) - 1 do { - _ctrlPanel lnbSetText [[_lbIndex, 2], str (_containerItems getOrDefault [_ctrlPanel lnbData [_lbIndex, 0], 0])]; + _ctrlPanel lnbSetText [[_lbIndex, 2], str ({_ctrlPanel lnbData [_lbIndex, 0] == _x} count _containerItems)]; }; // Refresh availibility of items based on space remaining in container diff --git a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf index ccbf7b7abb8..33057b2ac3a 100644 --- a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf +++ b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf @@ -125,7 +125,8 @@ private _fnc_uniqueEquipment = { }; } forEach (getUnitLoadout GVAR(center)); // Only need items, not extended loadout - +// Get all items from unit +_items = itemsWithMagazines GVAR(center); private _isMagazine = false; private _isWeapon = false; private _isGrenade = false; @@ -184,7 +185,12 @@ private _itemInfoType = 0; // Unknown default { // Don't add items that are part of the arsenal - if !(_x in GVAR(virtualItemsFlatAll)) then { + if ( + !(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) && + {!(_x in (GVAR(virtualItems) get IDX_VIRT_GRENADES))} && + {!(_x in (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES))} && + {!(_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL))} + ) then { (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil]; }; }; @@ -255,7 +261,13 @@ private _itemInfoType = 0; // Unknown default { // Don't add items that are part of the arsenal - if !(_x in GVAR(virtualItemsFlatAll)) then { + if ( + !(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)) && + {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} && + {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS))} && + {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS))} && + {!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS))} + ) then { (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil]; }; }; @@ -277,4 +289,4 @@ private _itemInfoType = 0; }; }; }; -} forEach (keys ([GVAR(center), 0, 3, 3, 3, false] call EFUNC(common,uniqueUnitItems))); // Get all items from unit +} forEach (_items arrayIntersect _items); From 36a5a5bc558b3a5c66f450ce1772489cc5bf086b Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 30 Dec 2023 20:39:39 -0300 Subject: [PATCH 2/4] attachment lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/arsenal/functions/fnc_updateUniqueItemsList.sqf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf index 33057b2ac3a..eb7ee409e8a 100644 --- a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf +++ b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf @@ -261,11 +261,12 @@ private _itemInfoType = 0; // Unknown default { // Don't add items that are part of the arsenal + private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS; if ( - !(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)) && - {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} && - {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS))} && - {!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS))} && + !(_x in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS)) && + {!(_x in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} && + {!(_x in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS))} && + {!(_x in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS))} && {!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS))} ) then { (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil]; From 08a01469ef29647f8c6a1fc43308f8d91e9e92bb Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 30 Dec 2023 20:40:29 -0300 Subject: [PATCH 3/4] container item lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/arsenal/functions/fnc_fillRightPanel.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index 04e03309fcc..67a6cb133ca 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -418,7 +418,8 @@ if (_isContainer) then { // Find out how many items of a type there are and update the number displayed for "_lbIndex" from 0 to (lnbSize _ctrlPanel select 0) - 1 do { - _ctrlPanel lnbSetText [[_lbIndex, 2], str ({_ctrlPanel lnbData [_lbIndex, 0] == _x} count _containerItems)]; + private _xItem = _ctrlPanel lnbData [_lbIndex, 0]; + _ctrlPanel lnbSetText [[_lbIndex, 2], str ({_xItem == _x} count _containerItems)]; }; // Refresh availibility of items based on space remaining in container From a813d6736e8a1d2d049c756b6985f7797adf6985 Mon Sep 17 00:00:00 2001 From: LinkIsGrim Date: Sat, 30 Dec 2023 21:29:18 -0300 Subject: [PATCH 4/4] allow increasing quantity of misplaced virtual items --- addons/arsenal/functions/fnc_fillRightPanel.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index 67a6cb133ca..3541bb480ab 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -333,9 +333,9 @@ switch (_ctrlIDC) do { // Unknown items { if !(_x in _items) then { - ["CfgWeapons", _x, true, true, true] call _fnc_fillRightContainer; + ["CfgWeapons", _x, true, !(_x in GVAR(virtualItemsFlat)), true] call _fnc_fillRightContainer; }; - } forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)); + } forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)); // if an item is here but in virtual items, it's just in the wrong place }; // Custom buttons default { @@ -363,7 +363,7 @@ switch (_ctrlIDC) do { }; // Unknown items case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)): { - ["CfgWeapons", _x, true, true, true] call _fnc_fillRightContainer; + ["CfgWeapons", _x, true, !(_x in GVAR(virtualItemsFlat)), true] call _fnc_fillRightContainer; }; }; } forEach _items;