From 1dd1a431f4c2109159ed36ea23f9cca57e497653 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 5 Apr 2026 03:15:03 -0700 Subject: [PATCH] fix(repair): process item durability updates even when entity missing from manager handleValuesUpdate silently dropped VALUES updates for item GUIDs not in entityManager, causing repair-all durability changes to be lost. Fall through to updateItemOnValuesUpdate for items tracked in onlineItems_. --- src/game/entity_controller.cpp | 15 +++++++++++++-- src/game/inventory_handler.cpp | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/game/entity_controller.cpp b/src/game/entity_controller.cpp index 09afc14c..c1cfe781 100644 --- a/src/game/entity_controller.cpp +++ b/src/game/entity_controller.cpp @@ -1257,7 +1257,7 @@ void EntityController::updateItemOnValuesUpdate(const UpdateBlock& block, } } // Update container slot GUIDs on bag content changes - if (entity->getType() == ObjectType::CONTAINER) { + if (entity && entity->getType() == ObjectType::CONTAINER) { for (const auto& [key, _] : block.fields) { if ((containerNumSlotsField != 0xFFFF && key == containerNumSlotsField) || (containerSlot1Field != 0xFFFF && key >= containerSlot1Field && key < containerSlot1Field + 72)) { @@ -1725,7 +1725,18 @@ void EntityController::handleCreateObject(const UpdateBlock& block, bool& newIte void EntityController::handleValuesUpdate(const UpdateBlock& block) { auto entity = entityManager.getEntity(block.guid); - if (!entity) return; + if (!entity) { + // Item/container entities may be absent from entityManager (e.g. server + // only sent a partial update) but we still track them in onlineItems_. + // Process field updates so durability/stack changes from repair aren't lost. + if (owner_.onlineItems_.count(block.guid)) { + pendingEvents_.clear(); + updateItemOnValuesUpdate(block, entity); + flushPendingEvents(); + LOG_DEBUG("Updated orphan item fields: 0x", std::hex, block.guid, std::dec); + } + return; + } pendingEvents_.clear(); // Position update (common) diff --git a/src/game/inventory_handler.cpp b/src/game/inventory_handler.cpp index ff13788a..f61d2d4c 100644 --- a/src/game/inventory_handler.cpp +++ b/src/game/inventory_handler.cpp @@ -1043,6 +1043,8 @@ void InventoryHandler::repairAll(uint64_t vendorGuid, bool useGuildBank) { packet.writeUInt64(0); packet.writeUInt8(useGuildBank ? 1 : 0); owner_.socket->send(packet); + LOG_INFO("Sent CMSG_REPAIR_ITEM repairAll vendor=0x", std::hex, vendorGuid, + std::dec, " guildBank=", useGuildBank ? 1 : 0); } void InventoryHandler::autoEquipItemBySlot(int backpackIndex) {