Skip to content

Commit

Permalink
Fix item use handler to handle correct packet type. Fix inventory amo…
Browse files Browse the repository at this point in the history
…unt update
  • Loading branch information
ethanmoffat committed May 9, 2021
1 parent 7ded0ec commit be69c44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions EOLib/PacketHandlers/Items/UseItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class UseItemHandler : InGameOnlyPacketHandler

public override PacketFamily Family => PacketFamily.Item;

public override PacketAction Action => PacketAction.Use;
public override PacketAction Action => PacketAction.Reply;

public UseItemHandler(IPlayerInfoProvider playerInfoProvider,
ICharacterInventoryRepository characterInventoryRepository,
Expand All @@ -48,7 +48,11 @@ public override bool HandlePacket(IPacket packet)
var weight = packet.ReadChar();
var maxWeight = packet.ReadChar();

_characterInventoryRepository.ItemInventory.RemoveAll(x => x.ItemID == itemId);
var oldItem = _characterInventoryRepository.ItemInventory.SingleOrDefault(x => x.ItemID == itemId);
if (oldItem == null)
return false;

_characterInventoryRepository.ItemInventory.Remove(oldItem);
_characterInventoryRepository.ItemInventory.Add(new InventoryItem(itemId, amount));

var character = _characterRepository.MainCharacter;
Expand Down

0 comments on commit be69c44

Please sign in to comment.