mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
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;
|
||||
|
||||
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
|
||||
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!
|
||||
ASSERT(type < m_BgObjects.size());
|
||||
|
||||
Map* map = GetBgMap();
|
||||
Map* map = FindBgMap();
|
||||
if (!map)
|
||||
return false;
|
||||
// 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)
|
||||
{
|
||||
if (Map* map = GetBgMap())
|
||||
if (Map* map = FindBgMap())
|
||||
if (GameObject* obj = map->GetGameObject(m_BgObjects[type]))
|
||||
{
|
||||
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!
|
||||
ASSERT(type < m_BgCreatures.size());
|
||||
|
||||
Map* map = GetBgMap();
|
||||
Map* map = FindBgMap();
|
||||
if (!map)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -431,11 +431,8 @@ class Battleground
|
||||
|
||||
// Map pointers
|
||||
void SetBgMap(BattlegroundMap* map) { m_Map = map; }
|
||||
BattlegroundMap* GetBgMap()
|
||||
{
|
||||
ASSERT(m_Map);
|
||||
return m_Map;
|
||||
}
|
||||
BattlegroundMap* GetBgMap() const { ASSERT(m_Map); return m_Map; }
|
||||
BattlegroundMap* FindBgMap() const { return m_Map; }
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user