From 83727d7cb192127fc08bf53f77f685edb146f4a4 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Tue, 29 Mar 2022 13:02:26 -0700 Subject: [PATCH] Fix bug where used slots weren't cleared between logins --- EndlessClient/HUD/Inventory/InventorySlotRepository.cs | 8 +++++++- EndlessClient/HUD/Panels/InventoryPanel.cs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/EndlessClient/HUD/Inventory/InventorySlotRepository.cs b/EndlessClient/HUD/Inventory/InventorySlotRepository.cs index 1da3bc145..1f1b6811a 100644 --- a/EndlessClient/HUD/Inventory/InventorySlotRepository.cs +++ b/EndlessClient/HUD/Inventory/InventorySlotRepository.cs @@ -1,5 +1,6 @@ using AutomaticTypeMapper; using EndlessClient.HUD.Panels; +using EOLib; using EOLib.IO.Map; namespace EndlessClient.HUD.Inventory @@ -15,13 +16,18 @@ public interface IInventorySlotProvider } [AutoMappedType(IsSingleton = true)] - public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository + public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository, IResettable { public Matrix FilledSlots { get; set; } IReadOnlyMatrix IInventorySlotProvider.FilledSlots => FilledSlots; public InventorySlotRepository() + { + ResetState(); + } + + public void ResetState() { FilledSlots = new Matrix(InventoryPanel.InventoryRows, InventoryPanel.InventoryRowSlots, false); } diff --git a/EndlessClient/HUD/Panels/InventoryPanel.cs b/EndlessClient/HUD/Panels/InventoryPanel.cs index 4cc7f4a6e..f3ff79aba 100644 --- a/EndlessClient/HUD/Panels/InventoryPanel.cs +++ b/EndlessClient/HUD/Panels/InventoryPanel.cs @@ -11,6 +11,7 @@ using EOLib.Graphics; using EOLib.IO; using EOLib.IO.Extensions; +using EOLib.IO.Map; using EOLib.IO.Pub; using EOLib.IO.Repositories; using EOLib.Localization; @@ -230,6 +231,9 @@ protected override void Dispose(bool disposing) _junk.OnMouseEnter -= MouseOverButton; Game.Exiting -= SaveInventoryFile; + // todo: IResettable should work but it doesn't + _inventorySlotRepository.FilledSlots = new Matrix(InventoryRows, InventoryRowSlots, false); + SaveInventoryFile(null, EventArgs.Empty); }