aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2020-07-18 00:57:16 +0200
committerShauren <shauren.trinity@gmail.com>2020-07-18 00:57:16 +0200
commit4c173e4b7b35161fcaaa4917da8fde2e4f3cbdd8 (patch)
tree361de2f13c3ebac3bd853789e9254f825f57a7e3 /src
parentc56d0a092fa5732d5131713e355ae850d672e090 (diff)
Core/Maps: Use FindMap instead of CreateBaseMap in places where the intent was to check for a existing map (and a loaded grid on that map)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp24
-rw-r--r--src/server/game/Events/GameEventMgr.cpp8
-rw-r--r--src/server/game/Pools/PoolMgr.cpp16
3 files changed, 16 insertions, 32 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index f6387959aae..4203af63d28 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -789,21 +789,13 @@ bool BfGraveyard::HasNpc(ObjectGuid guid)
Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos)
{
- //Get map object
- Map* map = sMapMgr->CreateBaseMap(m_MapId);
- if (!map)
- {
- TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u, map not found.", entry);
- return nullptr;
- }
-
if (!sObjectMgr->GetCreatureTemplate(entry))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
return nullptr;
}
- Creature* creature = Creature::CreateCreature(entry, map, pos);
+ Creature* creature = Creature::CreateCreature(entry, m_Map, pos);
if (!creature)
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
@@ -813,7 +805,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos)
creature->SetHomePosition(pos);
// Set creature in world
- map->AddToMap(creature);
+ m_Map->AddToMap(creature);
creature->setActive(true);
return creature;
@@ -822,14 +814,6 @@ Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos)
// Method for spawning gameobject on map
GameObject* Battlefield::SpawnGameObject(uint32 entry, Position const& pos, QuaternionData const& rot)
{
- // Get map object
- Map* map = sMapMgr->CreateBaseMap(m_MapId);
- if (!map)
- {
- TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Can't create GameObject (Entry: %u). Map not found.", entry);
- return nullptr;
- }
-
if (!sObjectMgr->GetGameObjectTemplate(entry))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template %u not found in database! Battlefield not created!", entry);
@@ -837,7 +821,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, Position const& pos, Quat
}
// Create gameobject
- GameObject* go = GameObject::CreateGameObject(entry, map, pos, rot, 255, GO_STATE_READY);
+ GameObject* go = GameObject::CreateGameObject(entry, m_Map, pos, rot, 255, GO_STATE_READY);
if (!go)
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template %u! Battlefield has not been created!", entry);
@@ -845,7 +829,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, Position const& pos, Quat
}
// Add to world
- map->AddToMap(go);
+ m_Map->AddToMap(go);
go->setActive(true);
return go;
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 2084cb43e2e..9516c566ce9 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -1215,9 +1215,9 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
sObjectMgr->AddCreatureToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
+ if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
Creature::CreateCreatureFromDB(*itr, map);
}
}
@@ -1237,9 +1237,9 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
sObjectMgr->AddGameobjectToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
// We use current coords to unspawn, not spawn coords since creature can have changed grid
- if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
+ if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
if (GameObject* go = GameObject::CreateGameObjectFromDB(*itr, map, false))
{
diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp
index f8172471154..81dad690975 100644
--- a/src/server/game/Pools/PoolMgr.cpp
+++ b/src/server/game/Pools/PoolMgr.cpp
@@ -228,8 +228,8 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid)
{
sObjectMgr->RemoveCreatureFromGrid(guid, data);
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
- if (!map->Instanceable())
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
+ if (map && !map->Instanceable())
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
@@ -250,8 +250,8 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid)
{
sObjectMgr->RemoveGameobjectFromGrid(guid, data);
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
- if (!map->Instanceable())
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
+ if (map && !map->Instanceable())
{
auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid);
for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second;)
@@ -385,9 +385,9 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddCreatureToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
+ if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
Creature::CreateCreatureFromDB(obj->guid, map);
}
}
@@ -401,9 +401,9 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddGameobjectToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = sMapMgr->CreateBaseMap(data->mapid);
+ Map* map = sMapMgr->FindMap(data->mapid, 0);
// We use current coords to unspawn, not spawn coords since creature can have changed grid
- if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
+ if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
if (GameObject* go = GameObject::CreateGameObjectFromDB(obj->guid, map, false))
{