From ae2f5764fd3f29c7c39d6e2a17ad621db28bcc62 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 4 Oct 2025 12:57:36 -0700 Subject: [PATCH] fix: inventory items being in the wrong state due to changed IDs Tested that the regenerated ids --- dGame/dInventory/Inventory.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index 98e34f8d..b6933654 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -324,10 +324,13 @@ Inventory::~Inventory() { void Inventory::RegenerateItemIDs() { std::map newItems{}; for (auto* const item : items | std::views::values) { + const bool equipped = item->IsEquipped(); + if (equipped) item->UnEquip(); const auto oldID = item->GetId(); const auto newID = item->GenerateID(); LOG("Updating item ID from %llu to %llu", oldID, newID); newItems.insert_or_assign(newID, item); + if (equipped) item->Equip(); } // We don't want to delete the item pointers, we're just moving from map to map