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

@ -1460,6 +1460,9 @@ public:
void acceptQuest(); void acceptQuest();
void declineQuest(); void declineQuest();
void closeGossip(); void closeGossip();
// Quest-starting items: right-click triggers quest offer dialog via questgiver protocol
void offerQuestFromItem(uint64_t itemGuid, uint32_t questId);
uint64_t getBagItemGuid(int bagIndex, int slotIndex) const;
bool isGossipWindowOpen() const { return gossipWindowOpen; } bool isGossipWindowOpen() const { return gossipWindowOpen; }
const GossipMessageData& getCurrentGossip() const { return currentGossip; } const GossipMessageData& getCurrentGossip() const { return currentGossip; }
bool isQuestDetailsOpen() { bool isQuestDetailsOpen() {

View file

@ -20552,6 +20552,34 @@ void GameHandler::closeGossip() {
currentGossip = GossipMessageData{}; currentGossip = GossipMessageData{};
} }
void GameHandler::offerQuestFromItem(uint64_t itemGuid, uint32_t questId) {
if (state != WorldState::IN_WORLD || !socket) return;
if (itemGuid == 0 || questId == 0) {
addSystemChatMessage("Cannot start quest right now.");
return;
}
// Send CMSG_QUESTGIVER_QUERY_QUEST with the item GUID as the "questgiver."
// The server responds with SMSG_QUESTGIVER_QUEST_DETAILS which handleQuestDetails()
// picks up and opens the Accept/Decline dialog.
auto queryPkt = packetParsers_
? packetParsers_->buildQueryQuestPacket(itemGuid, questId)
: QuestgiverQueryQuestPacket::build(itemGuid, questId);
socket->send(queryPkt);
LOG_INFO("offerQuestFromItem: itemGuid=0x", std::hex, itemGuid, std::dec,
" questId=", questId);
}
uint64_t GameHandler::getBagItemGuid(int bagIndex, int slotIndex) const {
if (bagIndex < 0 || bagIndex >= inventory.NUM_BAG_SLOTS) return 0;
if (slotIndex < 0) return 0;
uint64_t bagGuid = equipSlotGuids_[19 + bagIndex];
if (bagGuid == 0) return 0;
auto it = containerContents_.find(bagGuid);
if (it == containerContents_.end()) return 0;
if (slotIndex >= static_cast<int>(it->second.numSlots)) return 0;
return it->second.slotGuids[slotIndex];
}
void GameHandler::openVendor(uint64_t npcGuid) { void GameHandler::openVendor(uint64_t npcGuid) {
if (state != WorldState::IN_WORLD || !socket) return; if (state != WorldState::IN_WORLD || !socket) return;
buybackItems_.clear(); buybackItems_.clear();

View file

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