Harden quest accept state and resync quest log on login

- add idempotent pending-accept tracking with timeout and per-quest cleanup hooks
- stop optimistic local quest insertion on accept; rely on server-authoritative updates
- handle QUEST_INVALID already-on/completed as reconciliation paths for pending accepts
- trigger quest metadata + status resync when accept state drifts
- add login-time quest log rebuild from PLAYER_QUEST_LOG server slots
- query quest metadata for server-slot quests to hydrate titles/objectives
- clear stale pending quest accept/query state on fresh world entry
- improve gossip quest selection fallback by trusting server quest slots when local cache is missing

This reduces duplicate accept/state mismatch loops (notably reason=13) and stabilizes WotLK quest behavior after relogs.
This commit is contained in:
Kelsi 2026-02-20 17:14:13 -08:00
parent ebaeea43cb
commit 954edc91b8
2 changed files with 189 additions and 15 deletions

View file

@ -1127,6 +1127,11 @@ private:
void handleQuestDetails(network::Packet& packet);
void handleQuestRequestItems(network::Packet& packet);
void handleQuestOfferReward(network::Packet& packet);
void clearPendingQuestAccept(uint32_t questId);
void triggerQuestAcceptResync(uint32_t questId, uint64_t npcGuid, const char* reason);
bool hasQuestInLog(uint32_t questId) const;
void addQuestToLocalLogIfMissing(uint32_t questId, const std::string& title, const std::string& objectives);
bool resyncQuestLogFromServerSlots(bool forceQueryMetadata);
void handleListInventory(network::Packet& packet);
void addMoneyCopper(uint32_t amount);
@ -1487,12 +1492,16 @@ private:
uint32_t pendingTurnInQuestId_ = 0;
uint64_t pendingTurnInNpcGuid_ = 0;
bool pendingTurnInRewardRequest_ = false;
std::unordered_map<uint32_t, float> pendingQuestAcceptTimeouts_;
std::unordered_map<uint32_t, uint64_t> pendingQuestAcceptNpcGuids_;
bool questOfferRewardOpen_ = false;
QuestOfferRewardData currentQuestOfferReward_;
// Quest log
std::vector<QuestLogEntry> questLog_;
std::unordered_set<uint32_t> pendingQuestQueryIds_;
bool pendingLoginQuestResync_ = false;
float pendingLoginQuestResyncTimeout_ = 0.0f;
// Quest giver status per NPC
std::unordered_map<uint64_t, QuestGiverStatus> npcQuestStatus_;