Core/Spawn: Move spawn group state management from sObjectMgr to the Map object, which makes it actually function as intended with instances. Woops.

This commit is contained in:
Treeston
2017-08-26 13:14:25 +02:00
parent 80a8867332
commit f279207d48
11 changed files with 182 additions and 156 deletions

View File

@@ -133,13 +133,18 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T>
ASSERT(cdata, "Tried to load creature with spawnId %u, but no such creature exists.", guid);
SpawnGroupTemplateData const* const group = cdata->spawnGroupData;
// If creature in manual spawn group, don't spawn here, unless group is already active.
if ((group->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN) && !group->isActive)
continue;
if (!(group->flags & SPAWNGROUP_FLAG_SYSTEM))
if (!map->IsSpawnGroupActive(group->groupId))
{
delete obj;
continue;
}
// If script is blocking spawn, don't spawn but queue for a re-check in a little bit
if (!(group->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE) && !sScriptMgr->CanSpawn(guid, cdata->id, cdata, map))
{
map->SaveRespawnTime(SPAWN_TYPE_CREATURE, guid, cdata->id, time(NULL) + urand(4,7), map->GetZoneId(cdata->spawnPoint), Trinity::ComputeGridCoord(cdata->spawnPoint.GetPositionX(), cdata->spawnPoint.GetPositionY()).GetId(), false);
delete obj;
continue;
}
}
@@ -148,8 +153,12 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T>
// If gameobject in manual spawn group, don't spawn here, unless group is already active.
GameObjectData const* godata = sObjectMgr->GetGameObjectData(guid);
ASSERT(godata, "Tried to load gameobject with spawnId %u, but no such object exists.", guid);
if ((godata->spawnGroupData->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN) && !godata->spawnGroupData->isActive)
continue;
if (!(godata->spawnGroupData->flags & SPAWNGROUP_FLAG_SYSTEM))
if (!map->IsSpawnGroupActive(godata->spawnGroupData->groupId))
{
delete obj;
continue;
}
}
if (!obj->LoadFromDB(guid, map, false, false))