Core/Maps: Properly set initial spawn group state for groups that have conditions (#29509)

This commit is contained in:
Jeremy
2023-12-29 14:02:37 +01:00
committed by GitHub
parent a2be97414b
commit fb64d7fe8e
3 changed files with 15 additions and 0 deletions

View File

@@ -2452,6 +2452,16 @@ bool Map::IsSpawnGroupActive(uint32 groupId) const
return (_toggledSpawnGroupIds.find(groupId) != _toggledSpawnGroupIds.end()) != !(data->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN);
}
void Map::InitSpawnGroupState()
{
std::vector<uint32> const* spawnGroups = sObjectMgr->GetSpawnGroupsForMap(GetId());
if (!spawnGroups)
return;
for (uint32 spawnGroupId : *spawnGroups)
SetSpawnGroupActive(spawnGroupId, sConditionMgr->IsMapMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPAWN_GROUP, spawnGroupId, this));
}
void Map::UpdateSpawnGroupConditions()
{
std::vector<uint32> const* spawnGroups = sObjectMgr->GetSpawnGroupsForMap(GetId());

View File

@@ -713,6 +713,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
typedef std::function<void(Map*)> FarSpellCallback;
void AddFarSpellCallback(FarSpellCallback&& callback);
void InitSpawnGroupState();
void UpdateSpawnGroupConditions();
private:

View File

@@ -74,6 +74,7 @@ Map* MapManager::CreateWorldMap(uint32 mapId, uint32 instanceId)
Map* map = new Map(mapId, i_gridCleanUpDelay, instanceId, DIFFICULTY_NONE);
map->LoadRespawnTimes();
map->LoadCorpseData();
map->InitSpawnGroupState();
if (sWorld->getBoolConfig(CONFIG_BASEMAP_LOAD_GRIDS))
map->LoadAllCells();
@@ -107,6 +108,7 @@ InstanceMap* MapManager::CreateInstance(uint32 mapId, uint32 instanceId, Instanc
map->CreateInstanceData();
map->SetInstanceScenario(sScenarioMgr->CreateInstanceScenario(map, team));
map->InitSpawnGroupState();
if (sWorld->getBoolConfig(CONFIG_INSTANCEMAP_LOAD_GRIDS))
map->LoadAllCells();
@@ -122,6 +124,7 @@ BattlegroundMap* MapManager::CreateBattleground(uint32 mapId, uint32 instanceId,
ASSERT(map->IsBattlegroundOrArena());
map->SetBG(bg);
bg->SetBgMap(map);
map->InitSpawnGroupState();
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUNDMAP_LOAD_GRIDS))
map->LoadAllCells();
@@ -133,6 +136,7 @@ GarrisonMap* MapManager::CreateGarrison(uint32 mapId, uint32 instanceId, Player*
{
GarrisonMap* map = new GarrisonMap(mapId, i_gridCleanUpDelay, instanceId, owner->GetGUID());
ASSERT(map->IsGarrison());
map->InitSpawnGroupState();
return map;
}