From 32d30d38ec51284a50b1c1c36c7b4f71ccca5c81 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 27 Sep 2020 17:47:21 -0600 Subject: [PATCH] off by one errors sure are nice the item gets added to the vec before len is calculated, and since its 0-indexed we want to subtract 1 --- src/ship/items/inventory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index 89d1c9e..0e5ef61 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -494,7 +494,7 @@ impl CharacterInventory { self.items.push(new_stacked_item); if let Some(InventoryItem::Stacked(new_item)) = self.items.last() { - Some((new_item, InventorySlot(self.count()))) + Some((new_item, InventorySlot(self.count()-1))) } else { None