diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index bbc477c5..2450ec8d 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -4862,6 +4862,7 @@ void GameHandler::handleUpdateObject(network::Packet& packet) { } // Process update blocks + bool newItemCreated = false; for (const auto& block : data.blocks) { switch (block.updateType) { case UpdateType::CREATE_OBJECT: @@ -5178,7 +5179,9 @@ void GameHandler::handleUpdateObject(network::Packet& packet) { OnlineItemInfo info; info.entry = entryIt->second; info.stackCount = (stackIt != block.fields.end()) ? stackIt->second : 1; + bool isNew = (onlineItems_.find(block.guid) == onlineItems_.end()); onlineItems_[block.guid] = info; + if (isNew) newItemCreated = true; queryItemInfo(info.entry, block.guid); } // Extract container slot GUIDs for bags @@ -5696,6 +5699,12 @@ void GameHandler::handleUpdateObject(network::Packet& packet) { tabCycleStale = true; // Entity count logging disabled + // Deferred rebuild: if new item objects were created in this packet, rebuild + // inventory so that slot GUIDs updated earlier in the same packet can resolve. + if (newItemCreated) { + rebuildOnlineInventory(); + } + // Late inventory base detection once items are known if (playerGuid != 0 && invSlotBase_ < 0 && !lastPlayerFields_.empty() && !onlineItems_.empty()) { detectInventorySlotBases(lastPlayerFields_); @@ -7842,7 +7851,7 @@ void GameHandler::rebuildOnlineInventory() { if (guid == 0) { inventory.clearBankSlot(i); continue; } auto itemIt = onlineItems_.find(guid); - if (itemIt == onlineItems_.end()) continue; + if (itemIt == onlineItems_.end()) { inventory.clearBankSlot(i); continue; } ItemDef def; def.itemId = itemIt->second.entry;