Playerbot: log the real reason a quest-source item grant is rejected

'bag full' was misleading — with free slots AddItem can still return false
via CanStoreNewItem/StoreNewItem rejection (bound-item guard etc). Include the
CanStoreNewItem result (ir), noSpace, actual free backpack slots, and current
item count in the failure log so the rejection reason is visible.
This commit is contained in:
devbox
2026-08-17 19:53:51 +10:00
parent ba096ba8d3
commit 4e0240603b
+16 -2
View File
@@ -2992,14 +2992,28 @@ static bool GiveQuestItem(Player* bot, uint32 itemId, uint32 count)
if (proto && proto->GetStartQuest() > 0 && if (proto && proto->GetStartQuest() > 0 &&
bot->GetItemCount(itemId, false) == 0) bot->GetItemCount(itemId, false) == 0)
{ {
ItemPosCountVec dest;
uint32 noSpace = 0;
InventoryResult const ir =
bot->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, 1, &noSpace);
if (bot->AddItem(itemId, 1)) if (bot->AddItem(itemId, 1))
{
TC_LOG_ERROR("playerbot.v2", TC_LOG_ERROR("playerbot.v2",
"[QuestItemCopy] OK {} +1x source item={} (starts quest {})", "[QuestItemCopy] OK {} +1x source item={} (starts quest {})",
bot->GetName(), itemId, proto->GetStartQuest()); bot->GetName(), itemId, proto->GetStartQuest());
}
else else
{
uint32 freeBackpack = 0;
for (uint8 s = INVENTORY_SLOT_ITEM_START; s < INVENTORY_SLOT_ITEM_END; ++s)
if (!bot->GetItemByPos(INVENTORY_SLOT_BAG_0, s))
++freeBackpack;
TC_LOG_ERROR("playerbot.v2", TC_LOG_ERROR("playerbot.v2",
"[QuestItemCopy] FAIL {} source item={} (bag full)", "[QuestItemCopy] FAIL {} source item={} ir={} noSpace={} "
bot->GetName(), itemId); "freeBackpack={} have={} (AddItem rejected — not plain fullness)",
bot->GetName(), itemId, uint32(ir), noSpace, freeBackpack,
bot->GetItemCount(itemId, false));
}
} }
return true; return true;
} }