Skip to content

Commit

Permalink
Fix bug where used slots weren't cleared between logins
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Mar 29, 2022
1 parent 015b7db commit 83727d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 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
Expand All @@ -15,13 +16,18 @@ public interface IInventorySlotProvider
}

[AutoMappedType(IsSingleton = true)]
public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository
public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository, IResettable
{
public Matrix<bool> FilledSlots { get; set; }

IReadOnlyMatrix<bool> IInventorySlotProvider.FilledSlots => FilledSlots;

public InventorySlotRepository()
{
ResetState();
}

public void ResetState()
{
FilledSlots = new Matrix<bool>(InventoryPanel.InventoryRows, InventoryPanel.InventoryRowSlots, false);
}
Expand Down
4 changes: 4 additions & 0 deletions EndlessClient/HUD/Panels/InventoryPanel.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<bool>(InventoryRows, InventoryRowSlots, false);

SaveInventoryFile(null, EventArgs.Empty);
}

Expand Down

0 comments on commit 83727d7

Please sign in to comment.