mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[9598] update battlegrounds per map + cleanup at delete
this will be useful, if we have multithreaded mapupdates one day since i couldn't reproduce any errors regarding to self deletions of battlegrounds i removed the m_deleteThis variable
This commit is contained in:
parent
24d45c6a08
commit
1b2eefd721
7 changed files with 19 additions and 40 deletions
|
|
@ -1139,16 +1139,8 @@ BattleGroundMgr::~BattleGroundMgr()
|
|||
void BattleGroundMgr::DeleteAllBattleGrounds()
|
||||
{
|
||||
for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
|
||||
{
|
||||
for(BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end();)
|
||||
{
|
||||
BattleGround * bg = itr->second;
|
||||
m_BattleGrounds[i].erase(itr++);
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
delete bg;
|
||||
}
|
||||
}
|
||||
delete itr->second;
|
||||
|
||||
// destroy template battlegrounds that listed only in queues (other already terminated)
|
||||
for(uint32 bgTypeId = 0; bgTypeId < MAX_BATTLEGROUND_TYPE_ID; ++bgTypeId)
|
||||
|
|
@ -1162,31 +1154,6 @@ void BattleGroundMgr::DeleteAllBattleGrounds()
|
|||
// used to update running battlegrounds, and delete finished ones
|
||||
void BattleGroundMgr::Update(uint32 diff)
|
||||
{
|
||||
BattleGroundSet::iterator itr, next;
|
||||
for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
|
||||
{
|
||||
itr = m_BattleGrounds[i].begin();
|
||||
// skip updating battleground template
|
||||
if (itr != m_BattleGrounds[i].end())
|
||||
++itr;
|
||||
for(; itr != m_BattleGrounds[i].end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
itr->second->Update(diff);
|
||||
// use the SetDeleteThis variable
|
||||
// direct deletion caused crashes
|
||||
if (itr->second->m_SetDeleteThis)
|
||||
{
|
||||
BattleGround * bg = itr->second;
|
||||
m_BattleGrounds[i].erase(itr);
|
||||
if (!m_ClientBattleGroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattleGroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
delete bg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update scheduled queues
|
||||
if (!m_QueueUpdateScheduler.empty())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue