From 92d199e6abb00b6b4565d6286b1e672a2fcf3636 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 31 Dec 2023 01:30:52 +0100 Subject: [PATCH] Arsenal - Fix displaying virtual items & weapon attachments in cargo (#9692) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Unique items fix * attachment lookup Co-authored-by: Jouni Järvinen * container item lookup Co-authored-by: Jouni Järvinen --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: Jouni Järvinen --- addons/arsenal/functions/fnc_buttonCargo.sqf | 14 ++++++------- .../arsenal/functions/fnc_fillRightPanel.sqf | 15 ++++++------- .../functions/fnc_updateUniqueItemsList.sqf | 21 +++++++++++++++---- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/addons/arsenal/functions/fnc_buttonCargo.sqf b/addons/arsenal/functions/fnc_buttonCargo.sqf index 48c5ee477e..d7713a2518 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 c562e8727d..67a6cb133c 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,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 (_containerItems getOrDefault [_ctrlPanel lnbData [_lbIndex, 0], 0])]; + 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 diff --git a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf index ccbf7b7abb..eb7ee409e8 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,14 @@ private _itemInfoType = 0; // Unknown default { // Don't add items that are part of the arsenal - if !(_x in GVAR(virtualItemsFlatAll)) then { + private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS; + if ( + !(_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]; }; }; @@ -277,4 +290,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);