mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/GameEventMgr: Spawn creatures and gameobjects in all active instances when event starts
This commit is contained in:
@@ -1235,11 +1235,13 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
sObjectMgr->AddCreatureToGrid(data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
Map* map = sMapMgr->CreateBaseMap(data->mapId);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, *itr);
|
||||
// We use spawn coords to spawn
|
||||
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
|
||||
Creature::CreateCreatureFromDB(*itr, map);
|
||||
sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr, data](Map* map)
|
||||
{
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, *itr);
|
||||
// We use spawn coords to spawn
|
||||
if (map->IsGridLoaded(data->spawnPoint))
|
||||
Creature::CreateCreatureFromDB(*itr, map);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1258,21 +1260,23 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
sObjectMgr->AddGameobjectToGrid(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->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, *itr);
|
||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
|
||||
sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr, data](Map* map)
|
||||
{
|
||||
if (GameObject* go = GameObject::CreateGameObjectFromDB(*itr, map, false))
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, *itr);
|
||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||
if (map->IsGridLoaded(data->spawnPoint))
|
||||
{
|
||||
/// @todo find out when it is add to map
|
||||
if (go->isSpawnedByDefault())
|
||||
if (GameObject* go = GameObject::CreateGameObjectFromDB(*itr, map, false))
|
||||
{
|
||||
if (!map->AddToMap(go))
|
||||
delete go;
|
||||
/// @todo find out when it is add to map
|
||||
if (go->isSpawnedByDefault())
|
||||
{
|
||||
if (!map->AddToMap(go))
|
||||
delete go;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user