From 57904ad124156220083d6ad34a3b60dbfd772e9a Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Wed, 30 Oct 2024 17:11:33 +0100 Subject: [PATCH] set quest to rewarded instead of complete when targetted by SPELL_EFFECT_QUEST_COMPLETE Prevents people from ending up with strange quests in their quest logs. https://github.com/TrinityCore/TrinityCore/commit/6d62f852acf3e1a3ee57cde2442832280aee814 Co-authored-by: SnapperRy --- src/server/game/Entities/Player/Player.h | 1 + src/server/game/Entities/Player/PlayerQuest.cpp | 9 +++++++-- src/server/game/Spells/SpellEffects.cpp | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index b00468be5bd220..778ae0a83940da 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1433,6 +1433,7 @@ class Player : public Unit, public GridObject void CompleteQuest(uint32 quest_id); void IncompleteQuest(uint32 quest_id); void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true, bool isLFGReward = false); + void SetRewardedQuest(uint32 quest_id); void FailQuest(uint32 quest_id); bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const; bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const; diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index b566d2d7630e39..ef2bbb9ed2c1e5 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -819,8 +819,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, SetSeasonalQuestStatus(quest_id); RemoveActiveQuest(quest_id, false); - m_RewardedQuests.insert(quest_id); - m_RewardedQuestsSave[quest_id] = true; + SetRewardedQuest(quest_id); if (announce) SendQuestReward(quest, XP); @@ -877,6 +876,12 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, sScriptMgr->OnPlayerCompleteQuest(this, quest); } +void Player::SetRewardedQuest(uint32 quest_id) +{ + m_RewardedQuests.insert(quest_id); + m_RewardedQuestsSave[quest_id] = true; +} + void Player::FailQuest(uint32 questId) { if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId)) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 8b7699a783bff9..800a2280df7150 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -4744,8 +4744,8 @@ void Spell::EffectQuestComplete(SpellEffIndex effIndex) uint16 logSlot = player->FindQuestSlot(questId); if (logSlot < MAX_QUEST_LOG_SIZE) player->AreaExploredOrEventHappens(questId); - else if (player->CanTakeQuest(quest, false)) // never rewarded before - player->CompleteQuest(questId); // quest not in log - for internal use + else if (player->CanTakeQuest(quest, false)) // Check if the quest has already been turned in. + player->SetRewardedQuest(questId); // If not, set status to rewarded without broadcasting it to client. } }