mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[8405] Fixed possible crash in BGQueueRemoveEvent::Execute() when two paralell BattleGroundQueue Updates are called, optimalized code.
Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
4826a192a0
commit
178c308c5b
3 changed files with 38 additions and 2 deletions
|
|
@ -1077,7 +1077,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
|||
sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId].RemovePlayer(m_PlayerGuid, true);
|
||||
//update queues if battleground isn't ended
|
||||
if (bg)
|
||||
sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId].Update(m_BgTypeId, bg->GetQueueId());
|
||||
sBattleGroundMgr.ScheduleQueueUpdate(m_BgQueueTypeId, m_BgTypeId, bg->GetQueueId());
|
||||
|
||||
WorldPacket data;
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
|
||||
|
|
@ -1161,6 +1161,22 @@ void BattleGroundMgr::Update(uint32 diff)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update scheduled queues
|
||||
if (!m_QueueUpdateScheduler.empty())
|
||||
{
|
||||
//copy vector and clear the other
|
||||
std::vector<uint32> scheduled(m_QueueUpdateScheduler);
|
||||
m_QueueUpdateScheduler.clear();
|
||||
for (uint8 i = 0; i < scheduled.size(); i++)
|
||||
{
|
||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundQueueTypeId(scheduled[i] / 65536);
|
||||
BattleGroundTypeId bgTypeId = BattleGroundTypeId((scheduled[i] % 65536) / 256);
|
||||
BGQueueIdBasedOnLevel queue_id = BGQueueIdBasedOnLevel(scheduled[i] % 256);
|
||||
m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, queue_id);
|
||||
}
|
||||
}
|
||||
|
||||
// if rating difference counts, maybe force-update queues
|
||||
if (sWorld.getConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE) && sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER))
|
||||
{
|
||||
|
|
@ -1987,6 +2003,24 @@ void BattleGroundMgr::ToggleArenaTesting()
|
|||
sWorld.SendWorldText(LANG_DEBUG_ARENA_OFF);
|
||||
}
|
||||
|
||||
void BattleGroundMgr::ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
|
||||
{
|
||||
//This method must be atomic!
|
||||
//we will use only 1 number created of bgTypeId and queue_id
|
||||
uint32 schedule_id = (bgQueueTypeId * 65536) + (bgTypeId * 256) + queue_id;
|
||||
bool found = false;
|
||||
for (uint8 i = 0; i < m_QueueUpdateScheduler.size(); i++)
|
||||
{
|
||||
if (m_QueueUpdateScheduler[i] == schedule_id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
m_QueueUpdateScheduler.push_back(schedule_id);
|
||||
}
|
||||
|
||||
uint32 BattleGroundMgr::GetMaxRatingDifference() const
|
||||
{
|
||||
// this is for stupid people who can't use brain and set max rating difference to 0
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ class BattleGroundMgr
|
|||
|
||||
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
|
||||
|
||||
void ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id);
|
||||
uint32 GetMaxRatingDifference() const;
|
||||
uint32 GetRatingDiscardTimer() const;
|
||||
uint32 GetPrematureFinishTime() const;
|
||||
|
|
@ -248,6 +249,7 @@ class BattleGroundMgr
|
|||
|
||||
/* Battlegrounds */
|
||||
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
||||
std::vector<uint32>m_QueueUpdateScheduler;
|
||||
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_QUEUES]; //the instanceids just visible for the client
|
||||
uint32 m_NextRatingDiscardUpdate;
|
||||
time_t m_NextAutoDistributionTime;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8404"
|
||||
#define REVISION_NR "8405"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue