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_.
This commit is contained in:
Kelsi 2026-04-05 03:15:03 -07:00
parent 0e308cf5a1
commit 1dd1a431f4
2 changed files with 15 additions and 2 deletions

View file

@ -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)

View file

@ -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) {