Merge pull request #3395 from megamage/master
Fix a crash caused by SetupBattleground when m_Map is not created.
This commit is contained in:
@@ -437,6 +437,13 @@ inline void Battleground::_ProcessJoin(uint32 diff)
|
|||||||
{
|
{
|
||||||
m_Events |= BG_STARTING_EVENT_1;
|
m_Events |= BG_STARTING_EVENT_1;
|
||||||
|
|
||||||
|
if(!FindBgMap())
|
||||||
|
{
|
||||||
|
sLog->outError("Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", m_MapId, m_InstanceID);
|
||||||
|
EndNow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup here, only when at least one player has ported to the map
|
// Setup here, only when at least one player has ported to the map
|
||||||
if (!SetupBattleground())
|
if (!SetupBattleground())
|
||||||
{
|
{
|
||||||
@@ -1407,7 +1414,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
|
|||||||
// If the assert is called, means that m_BgObjects must be resized!
|
// If the assert is called, means that m_BgObjects must be resized!
|
||||||
ASSERT(type < m_BgObjects.size());
|
ASSERT(type < m_BgObjects.size());
|
||||||
|
|
||||||
Map* map = GetBgMap();
|
Map* map = FindBgMap();
|
||||||
if (!map)
|
if (!map)
|
||||||
return false;
|
return false;
|
||||||
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
||||||
@@ -1504,7 +1511,7 @@ Creature* Battleground::GetBGCreature(uint32 type)
|
|||||||
|
|
||||||
void Battleground::SpawnBGObject(uint32 type, uint32 respawntime)
|
void Battleground::SpawnBGObject(uint32 type, uint32 respawntime)
|
||||||
{
|
{
|
||||||
if (Map* map = GetBgMap())
|
if (Map* map = FindBgMap())
|
||||||
if (GameObject* obj = map->GetGameObject(m_BgObjects[type]))
|
if (GameObject* obj = map->GetGameObject(m_BgObjects[type]))
|
||||||
{
|
{
|
||||||
if (respawntime)
|
if (respawntime)
|
||||||
@@ -1523,7 +1530,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
|
|||||||
// If the assert is called, means that m_BgCreatures must be resized!
|
// If the assert is called, means that m_BgCreatures must be resized!
|
||||||
ASSERT(type < m_BgCreatures.size());
|
ASSERT(type < m_BgCreatures.size());
|
||||||
|
|
||||||
Map* map = GetBgMap();
|
Map* map = FindBgMap();
|
||||||
if (!map)
|
if (!map)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -431,11 +431,8 @@ class Battleground
|
|||||||
|
|
||||||
// Map pointers
|
// Map pointers
|
||||||
void SetBgMap(BattlegroundMap* map) { m_Map = map; }
|
void SetBgMap(BattlegroundMap* map) { m_Map = map; }
|
||||||
BattlegroundMap* GetBgMap()
|
BattlegroundMap* GetBgMap() const { ASSERT(m_Map); return m_Map; }
|
||||||
{
|
BattlegroundMap* FindBgMap() const { return m_Map; }
|
||||||
ASSERT(m_Map);
|
|
||||||
return m_Map;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
|
void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
|
||||||
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
|
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
|
||||||
|
|||||||
Reference in New Issue
Block a user