fix: right-clicking a quest-starting item now opens the quest offer dialog

Items with startQuestId != 0 were calling useItemBySlot()/useItemInBag()
which sends CMSG_USE_ITEM — but quest-starting items have no on-use spell,
so the server silently ignored the packet and no quest dialog appeared.

Fix:
- offerQuestFromItem(itemGuid, questId): sends CMSG_QUESTGIVER_QUERY_QUEST
  with the item's own GUID as the questgiver GUID. The server responds with
  SMSG_QUESTGIVER_QUEST_DETAILS which handleQuestDetails() already picks up
  and opens the Accept/Decline dialog with full rewards/description.
- getBagItemGuid(bagIndex, slotIndex): resolves the per-slot item GUID from
  the bag's containerContents_ map (mirrors the logic inside useItemInBag).
- inventory_screen.cpp right-click handler: checks item.startQuestId != 0
  before the equip/use branch; if set, resolves item GUID and calls
  offerQuestFromItem. Works for both backpack slots and bag slots.
This commit is contained in:
Kelsi 2026-03-17 21:38:08 -07:00
parent c70740fcdf
commit a731223e47
3 changed files with 43 additions and 4 deletions

View file

@ -2335,8 +2335,12 @@ void InventoryScreen::renderItemSlot(game::Inventory& inventory, const game::Ite
} else if (kind == SlotKind::BACKPACK && backpackIndex >= 0) {
LOG_INFO("Right-click backpack item: name='", item.name,
"' inventoryType=", (int)item.inventoryType,
" itemId=", item.itemId);
if (item.inventoryType > 0) {
" itemId=", item.itemId,
" startQuestId=", item.startQuestId);
if (item.startQuestId != 0) {
uint64_t iGuid = gameHandler_->getBackpackItemGuid(backpackIndex);
gameHandler_->offerQuestFromItem(iGuid, item.startQuestId);
} else if (item.inventoryType > 0) {
gameHandler_->autoEquipItemBySlot(backpackIndex);
} else {
gameHandler_->useItemBySlot(backpackIndex);
@ -2344,8 +2348,12 @@ void InventoryScreen::renderItemSlot(game::Inventory& inventory, const game::Ite
} else if (kind == SlotKind::BACKPACK && isBagSlot) {
LOG_INFO("Right-click bag item: name='", item.name,
"' inventoryType=", (int)item.inventoryType,
" bagIndex=", bagIndex, " slotIndex=", bagSlotIndex);
if (item.inventoryType > 0) {
" bagIndex=", bagIndex, " slotIndex=", bagSlotIndex,
" startQuestId=", item.startQuestId);
if (item.startQuestId != 0) {
uint64_t iGuid = gameHandler_->getBagItemGuid(bagIndex, bagSlotIndex);
gameHandler_->offerQuestFromItem(iGuid, item.startQuestId);
} else if (item.inventoryType > 0) {
gameHandler_->autoEquipItemInBag(bagIndex, bagSlotIndex);
} else {
gameHandler_->useItemInBag(bagIndex, bagSlotIndex);