mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +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
|
|
@ -225,7 +225,6 @@ BattleGround::BattleGround()
|
|||
m_LevelMin = 0;
|
||||
m_LevelMax = 0;
|
||||
m_InBGFreeSlotQueue = false;
|
||||
m_SetDeleteThis = false;
|
||||
|
||||
m_MaxPlayersPerTeam = 0;
|
||||
m_MaxPlayers = 0;
|
||||
|
|
@ -296,6 +295,7 @@ BattleGround::~BattleGround()
|
|||
}
|
||||
|
||||
sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID());
|
||||
sBattleGroundMgr.DeleteClientVisibleInstanceId(GetTypeID(), GetBracketId(), GetClientInstanceID());
|
||||
|
||||
// unload map
|
||||
// map can be null at bg destruction
|
||||
|
|
@ -324,7 +324,8 @@ void BattleGround::Update(uint32 diff)
|
|||
// ]]
|
||||
// BattleGround Template instance cannot be updated, because it would be deleted
|
||||
if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
|
||||
m_SetDeleteThis = true;
|
||||
delete this;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -516,8 +516,6 @@ class BattleGround
|
|||
uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; }
|
||||
bool IsPlayerInBattleGround(uint64 guid);
|
||||
|
||||
void SetDeleteThis() {m_SetDeleteThis = true;}
|
||||
|
||||
/* virtual score-array - get's used in bg-subclasses */
|
||||
int32 m_TeamScores[BG_TEAMS_COUNT];
|
||||
|
||||
|
|
@ -572,7 +570,6 @@ class BattleGround
|
|||
BattleGroundBracketId m_BracketId;
|
||||
uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5
|
||||
bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattleGroundMgr.BGFreeSlotQueue[bgTypeId] deque
|
||||
bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave
|
||||
bool m_IsArena;
|
||||
uint8 m_Winner; // 0=alliance, 1=horde, 2=none
|
||||
int32 m_StartDelayTime;
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -211,6 +211,11 @@ class BattleGroundMgr
|
|||
void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
|
||||
void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
|
||||
uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
|
||||
void DeleteClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, uint32 clientInstanceID)
|
||||
{
|
||||
if (!m_ClientBattleGroundIds[bgTypeId][bracket_id].empty())
|
||||
m_ClientBattleGroundIds[bgTypeId][bracket_id].erase(clientInstanceID);
|
||||
}
|
||||
|
||||
void CreateInitialBattleGrounds();
|
||||
void DeleteAllBattleGrounds();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "MapInstanced.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "BattleGroundMgr.h"
|
||||
|
||||
GridState* si_GridStates[MAX_GRID_STATE];
|
||||
|
||||
|
|
@ -2527,6 +2528,13 @@ void InstanceMap::Update(const uint32& t_diff)
|
|||
i_data->Update(t_diff);
|
||||
}
|
||||
|
||||
void BattleGroundMap::Update(const uint32& diff)
|
||||
{
|
||||
Map::Update(diff);
|
||||
|
||||
GetBG()->Update(diff);
|
||||
}
|
||||
|
||||
void InstanceMap::Remove(Player *player, bool remove)
|
||||
{
|
||||
sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
|
||||
|
|
|
|||
|
|
@ -576,6 +576,7 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map
|
|||
BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode);
|
||||
~BattleGroundMap();
|
||||
|
||||
void Update(const uint32&);
|
||||
bool Add(Player *);
|
||||
void Remove(Player *, bool);
|
||||
bool CanEnter(Player* player);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9597"
|
||||
#define REVISION_NR "9598"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue