Core/GameEventMgr: Spawn creatures and gameobjects in all active instances when event starts

Port From (https://github.com/TrinityCore/TrinityCore/commit/6ca0f99ccfc6549f3390a1bac151f85fdcb77561)
This commit is contained in:
hondacrx
2022-06-14 23:20:28 -04:00
parent c60fa1d1a3
commit 5ff87102ca
+15 -8
View File
@@ -1190,11 +1190,13 @@ namespace Game
Global.ObjectMgr.AddCreatureToGrid(data); Global.ObjectMgr.AddCreatureToGrid(data);
// Spawn if necessary (loaded grids only) // Spawn if necessary (loaded grids only)
Map map = Global.MapMgr.CreateBaseMap(data.MapId); Global.MapMgr.DoForAllMapsWithMapId(data.MapId, map =>
{
map.RemoveRespawnTime(SpawnObjectType.Creature, guid); map.RemoveRespawnTime(SpawnObjectType.Creature, guid);
// We use spawn coords to spawn // We use spawn coords to spawn
if (map != null && !map.Instanceable() && map.IsGridLoaded(data.SpawnPoint)) if (map.IsGridLoaded(data.SpawnPoint))
Creature.CreateCreatureFromDB(guid, map); Creature.CreateCreatureFromDB(guid, map);
});
} }
} }
@@ -1214,21 +1216,26 @@ namespace Game
Global.ObjectMgr.AddGameObjectToGrid(data); Global.ObjectMgr.AddGameObjectToGrid(data);
// Spawn if necessary (loaded grids only) // Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed // this base map checked as non-instanced and then only existed
Map map = Global.MapMgr.CreateBaseMap(data.MapId); Global.MapMgr.DoForAllMapsWithMapId(data.MapId, map =>
{
map.RemoveRespawnTime(SpawnObjectType.GameObject, guid); map.RemoveRespawnTime(SpawnObjectType.GameObject, guid);
// We use current coords to unspawn, not spawn coords since creature can have changed grid // We use current coords to unspawn, not spawn coords since creature can have changed grid
if (map != null && !map.Instanceable() && map.IsGridLoaded(data.SpawnPoint)) if (map.IsGridLoaded(data.SpawnPoint))
{ {
GameObject pGameobject = GameObject.CreateGameObjectFromDB(guid, map, false); GameObject go = GameObject.CreateGameObjectFromDB(guid, map, false);
// @todo find out when it is add to map // @todo find out when it is add to map
if (pGameobject) if (go)
{ {
// @todo find out when it is add to map // @todo find out when it is add to map
if (pGameobject.IsSpawnedByDefault()) if (go.IsSpawnedByDefault())
map.AddToMap(pGameobject); {
if (!map.AddToMap(go))
go.Dispose();
} }
} }
} }
});
}
} }
if (internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.Length) if (internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.Length)