From 63b1121d9d7c2c5251fc36ed418f66fe2f6bb153 Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Sun, 1 Feb 2026 21:02:08 -0300 Subject: [PATCH 1/4] fix: OnContextMenuOpening crash with empty bag and bank slots Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- Intersect.Client.Core/Interface/Game/Bag/BagItem.cs | 10 ++++++---- .../Interface/Game/Bank/BankItem.cs | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index c2c83e97a1..5aa6037017 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -56,18 +56,20 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM protected override void OnContextMenuOpening(ContextMenu contextMenu) { - if (Globals.BagSlots is not { Length: > 0 } bagSlots) + // Clear out the old options since we might not show all of them + contextMenu.ClearChildren(); + + if (Globals.BagSlots[SlotIndex] is not { } bagSlot) { return; } - if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item)) { return; } - // Clear the context menu and add the withdraw item with updated item name - contextMenu.ClearChildren(); + // update context menu _withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index a9c7194737..371fd7b608 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -59,21 +59,22 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte protected override void OnContextMenuOpening(ContextMenu contextMenu) { - if (Globals.BankSlots is not { Length: > 0 } bankSlots) + // Clear out the old options since we might not show all of them + contextMenu.ClearChildren(); + + if (Globals.BankSlots[SlotIndex] is not { } bankSlot) { return; } - if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item)) { return; } - // Clear the context menu and add the withdraw item with updated item name - contextMenu.ClearChildren(); - contextMenu.AddChild(_withdrawContextItem); + // update context menu _withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name)); - + contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); } From 23241e4baed33ac311ce0245cbd2e3524b2cc842 Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:16:13 -0300 Subject: [PATCH 2/4] panda's review Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- .../Interface/Game/Bag/BagItem.cs | 16 ++++++++++++---- .../Interface/Game/Bank/BankItem.cs | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index 5aa6037017..3f8c939d3b 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -56,20 +56,28 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM protected override void OnContextMenuOpening(ContextMenu contextMenu) { - // Clear out the old options since we might not show all of them contextMenu.ClearChildren(); - if (Globals.BagSlots[SlotIndex] is not { } bagSlot) + if (Globals.BagSlots is not { Length: > 0 } bagSlots) + { + return; + } + + if (bagSlots[SlotIndex] is null) + { + return; + } + + if (SlotIndex >= bagSlots.Length) { return; } - if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item)) + if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item)) { return; } - // update context menu _withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index 371fd7b608..753fd07b9e 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -59,20 +59,29 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte protected override void OnContextMenuOpening(ContextMenu contextMenu) { - // Clear out the old options since we might not show all of them - contextMenu.ClearChildren(); + contextMenu.ClearChildren(); // Clear context menu + + if (Globals.BankSlots is not { Length: > 0 } bankSlots) + { + return; + } + + if (bankSlots[SlotIndex] is null) + { + return; + } - if (Globals.BankSlots[SlotIndex] is not { } bankSlot) + if (SlotIndex >= bankSlots.Length) { return; } - if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item)) + if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item)) { return; } - // update context menu + // Update context menu _withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); From c82d7a43be410e15a95eeab56a120a4e418b1a92 Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:32:00 -0300 Subject: [PATCH 3/4] panda's review (II) - tested and working as intended with both: bag and bank item slots Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- Intersect.Client.Core/Interface/Game/Bag/BagItem.cs | 6 +++--- Intersect.Client.Core/Interface/Game/Bank/BankItem.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index 3f8c939d3b..ea66c9c66b 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -63,17 +63,17 @@ protected override void OnContextMenuOpening(ContextMenu contextMenu) return; } - if (bagSlots[SlotIndex] is null) + if (SlotIndex >= bagSlots.Length) { return; } - if (SlotIndex >= bagSlots.Length) + if (bagSlots[SlotIndex] is not { } bagSlot) { return; } - if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item)) { return; } diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index 753fd07b9e..59c249591b 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -66,17 +66,17 @@ protected override void OnContextMenuOpening(ContextMenu contextMenu) return; } - if (bankSlots[SlotIndex] is null) + if (SlotIndex >= bankSlots.Length) { return; } - if (SlotIndex >= bankSlots.Length) + if (bankSlots[SlotIndex] is not { } bankSlot) { return; } - if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item)) { return; } From 8e31de3fd4ae361cf7f1d30b8a75e16ffee3719d Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:32:45 -0300 Subject: [PATCH 4/4] pandas's review (III) Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- Intersect.Client.Core/Interface/Game/Bag/BagItem.cs | 6 ++++-- Intersect.Client.Core/Interface/Game/Bank/BankItem.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index ea66c9c66b..72695b4b45 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -63,12 +63,14 @@ protected override void OnContextMenuOpening(ContextMenu contextMenu) return; } - if (SlotIndex >= bagSlots.Length) + var slotIndex = SlotIndex; + + if (slotIndex >= bagSlots.Length) { return; } - if (bagSlots[SlotIndex] is not { } bagSlot) + if (bagSlots[slotIndex] is not { } bagSlot) { return; } diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index 59c249591b..8a82002ae5 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -66,12 +66,14 @@ protected override void OnContextMenuOpening(ContextMenu contextMenu) return; } - if (SlotIndex >= bankSlots.Length) + var slotIndex = SlotIndex; + + if (slotIndex >= bankSlots.Length) { return; } - if (bankSlots[SlotIndex] is not { } bankSlot) + if (bankSlots[slotIndex] is not { } bankSlot) { return; }