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)

Port From (https://github.com/TrinityCore/TrinityCore/commit/4c173e4b7b35161fcaaa4917da8fde2e4f3cbdd8)
This commit is contained in:
hondacrx
2020-07-24 18:14:35 -04:00
parent 97ee7c437d
commit b628eaec35
4 changed files with 37 additions and 47 deletions
+4 -4
View File
@@ -1170,9 +1170,9 @@ namespace Game
Global.ObjectMgr.AddCreatureToGrid(guid, data);
// Spawn if necessary (loaded grids only)
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
Map map = Global.MapMgr.FindMap(data.mapid, 0);
// We use spawn coords to spawn
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
if (map != null && !map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
Creature.CreateCreatureFromDB(guid, map);
}
}
@@ -1193,9 +1193,9 @@ namespace Game
Global.ObjectMgr.AddGameObjectToGrid(guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
Map map = Global.MapMgr.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 != null && !map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
{
GameObject pGameobject = GameObject.CreateGameObjectFromDB(guid, map, false);
// @todo find out when it is add to map