From 38aac1a77acbd63c293750aaaecd75e4259ec8bd Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Fri, 25 Sep 2009 16:01:57 +0200 Subject: [PATCH] [8533] Not remove timed quest and correctly fail when time runs out. Add function to remove timed quest instead of direct access to set. Signed-off-by: NoFantasy --- src/game/Player.cpp | 20 +++++++------------- src/game/Player.h | 2 ++ src/game/QuestHandler.cpp | 6 ++++++ src/shared/revision_nr.h | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c47cfd79b..6d08b8e63 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12602,9 +12602,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver DestroyItemCount( pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true); } - //if( qInfo->HasSpecialFlag( QUEST_FLAGS_TIMED ) ) - // SetTimedQuest( 0 ); - m_timedquests.erase(pQuest->GetQuestId()); + RemoveTimedQuest(quest_id); if (pQuest->GetRewChoiceItemsCount() > 0) { @@ -12811,6 +12809,7 @@ void Player::FailQuest(uint32 questId) { QuestStatusData& q_status = mQuestStatus[questId]; + RemoveTimedQuest(questId); q_status.m_timer = 0; SendQuestTimerFailed(questId); @@ -13036,12 +13035,13 @@ bool Player::SatisfyQuestStatus( Quest const* qInfo, bool msg ) return true; } -bool Player::SatisfyQuestTimed( Quest const* qInfo, bool msg ) +bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) { - if ( (find(m_timedquests.begin(), m_timedquests.end(), qInfo->GetQuestId()) != m_timedquests.end()) && qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED) ) + if (!m_timedquests.empty() && qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED)) { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_QUEST_ONLY_ONE_TIMED ); + if (msg) + SendCanTakeQuestResponse(INVALIDREASON_QUEST_ONLY_ONE_TIMED); + return false; } return true; @@ -13269,12 +13269,6 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) { if (Quest const* qInfo = objmgr.GetQuestTemplate(quest_id)) { - if (status == QUEST_STATUS_NONE || status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_FAILED) - { - if (qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED)) - m_timedquests.erase(qInfo->GetQuestId()); - } - QuestStatusData& q_status = mQuestStatus[quest_id]; q_status.m_status = status; diff --git a/src/game/Player.h b/src/game/Player.h index b8973fb9c..89a6421d3 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1363,6 +1363,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SetInGameTime( uint32 time ) { m_ingametime = time; }; void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); } + void RemoveTimedQuest( uint32 quest_id ) { m_timedquests.erase(quest_id); } /*********************************************************/ /*** LOAD SYSTEM ***/ @@ -2249,6 +2250,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*** QUEST SYSTEM ***/ /*********************************************************/ + //We allow only one timed quest active at the same time. Below can then be simple value instead of set. std::set m_timedquests; uint64 m_divider; diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index c886a2a0d..1cef7dd22 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -350,6 +350,12 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) if(!_player->TakeQuestSourceItem( quest, true )) return; // can't un-equip some items, reject quest cancel + if (const Quest *pQuest = objmgr.GetQuestTemplate(quest)) + { + if (pQuest->HasFlag(QUEST_MANGOS_FLAGS_TIMED)) + _player->RemoveTimedQuest(quest); + } + _player->SetQuestStatus( quest, QUEST_STATUS_NONE); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7773ed4ec..deab694c5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8532" + #define REVISION_NR "8533" #endif // __REVISION_NR_H__