Skip to content

Commit 23241e4

Browse files
committed
panda's review
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
1 parent 63b1121 commit 23241e4

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

Intersect.Client.Core/Interface/Game/Bag/BagItem.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,28 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM
5656

5757
protected override void OnContextMenuOpening(ContextMenu contextMenu)
5858
{
59-
// Clear out the old options since we might not show all of them
6059
contextMenu.ClearChildren();
6160

62-
if (Globals.BagSlots[SlotIndex] is not { } bagSlot)
61+
if (Globals.BagSlots is not { Length: > 0 } bagSlots)
62+
{
63+
return;
64+
}
65+
66+
if (bagSlots[SlotIndex] is null)
67+
{
68+
return;
69+
}
70+
71+
if (SlotIndex >= bagSlots.Length)
6372
{
6473
return;
6574
}
6675

67-
if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item))
76+
if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item))
6877
{
6978
return;
7079
}
7180

72-
// update context menu
7381
_withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name));
7482
contextMenu.AddChild(_withdrawContextItem);
7583
base.OnContextMenuOpening(contextMenu);

Intersect.Client.Core/Interface/Game/Bank/BankItem.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,29 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte
5959

6060
protected override void OnContextMenuOpening(ContextMenu contextMenu)
6161
{
62-
// Clear out the old options since we might not show all of them
63-
contextMenu.ClearChildren();
62+
contextMenu.ClearChildren(); // Clear context menu
63+
64+
if (Globals.BankSlots is not { Length: > 0 } bankSlots)
65+
{
66+
return;
67+
}
68+
69+
if (bankSlots[SlotIndex] is null)
70+
{
71+
return;
72+
}
6473

65-
if (Globals.BankSlots[SlotIndex] is not { } bankSlot)
74+
if (SlotIndex >= bankSlots.Length)
6675
{
6776
return;
6877
}
6978

70-
if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item))
79+
if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item))
7180
{
7281
return;
7382
}
7483

75-
// update context menu
84+
// Update context menu
7685
_withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name));
7786
contextMenu.AddChild(_withdrawContextItem);
7887
base.OnContextMenuOpening(contextMenu);

0 commit comments

Comments
 (0)