From a50606d22583e93b5d1be32da9c28eaf048ea4a1 Mon Sep 17 00:00:00 2001 From: Triply Date: Mon, 2 Mar 2009 09:50:31 +0100 Subject: [PATCH] [7370] Fixed crash in CheckSkirmishForSameFaction() function, when we erased iterator which shouldn't be erased Fixed crash in BattleGroundQueue::Update() by changing BGFreeSlotQueueType from deque to list. Signed-off-by: Triply --- src/game/BattleGroundMgr.cpp | 12 ++++++------ src/game/BattleGroundMgr.h | 3 ++- src/shared/revision_nr.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 8db24d0bb..57ac388e8 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -651,7 +651,8 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_ break; if( itr_team == m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end() ) return false; - GroupsQueueType::iterator itr_team2 = ++itr_team; + GroupsQueueType::iterator itr_team2 = itr_team; + ++itr_team2; //invite players to other selection pool for(; itr_team2 != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team2) { @@ -673,7 +674,9 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BGQueueIdBasedOnLevel queue_ //add team to other queue m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + otherTeam].push_front(*itr); //remove team from old queue - for(GroupsQueueType::iterator itr2 = itr_team; itr2 != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr2) + GroupsQueueType::iterator itr2 = itr_team; + ++itr2; + for(; itr2 != m_QueuedGroups[queue_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr2) { if( *itr2 == *itr ) { @@ -703,9 +706,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve //battleground with free slot for player should be always in the beggining of the queue // maybe it would be better to create bgfreeslotqueue for each queue_id_based_on_level - bool continueAdding = true; BGFreeSlotQueueType::iterator itr, next; - for (itr = sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].begin(); continueAdding && itr != sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].end(); itr = next) + for (itr = sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].end(); itr = next) { next = itr; ++next; @@ -731,8 +733,6 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve if( !bg->HasFreeSlots() ) { - if( next == sBattleGroundMgr.BGFreeSlotQueue[bgTypeId].end() ) - continueAdding = false; // remove BG from BGFreeSlotQueue bg->RemoveFromBGFreeSlotQueue(); } diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index df4903e89..dc2979267 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -24,7 +24,8 @@ typedef std::map BattleGroundSet; -typedef std::deque BGFreeSlotQueueType; +//this container can't be deque, because deque doesn't like removing the last element - if you remove it, it invalidates next iterator and crash appears +typedef std::list BGFreeSlotQueueType; typedef UNORDERED_MAP BattleMastersMap; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f13bf1ca3..bd0712af7 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 "7369" + #define REVISION_NR "7370" #endif // __REVISION_NR_H__