aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2023-01-29 19:50:34 +0100
committerGitHub <noreply@github.com>2023-01-29 19:50:34 +0100
commit97d413c9b4be6af296490580f7acc1d66e606ca9 (patch)
tree05a2a8de6279e824ee47137f5243e603df0fe652 /src/server/game
parent03918978c166c9fb191117a0cae9ba1285bf0e37 (diff)
Core/Spawns: Allow spawn groups with MANUAL_SPAWN flag to automatically despawn if conditions are not met (#28778)
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp4
-rw-r--r--src/server/game/Maps/Map.cpp12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 9935969706b..4f80e811e03 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -2175,9 +2175,9 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
TC_LOG_ERROR("sql.sql", "{} SourceEntry in `condition` table, does not exist in `spawn_group_template`, ignoring.", cond->ToString());
return false;
}
- if (spawnGroup->flags & (SPAWNGROUP_FLAG_SYSTEM | SPAWNGROUP_FLAG_MANUAL_SPAWN))
+ if (spawnGroup->flags & (SPAWNGROUP_FLAG_SYSTEM))
{
- TC_LOG_ERROR("sql.sql", "{} in `spawn_group_template` table cannot have SPAWNGROUP_FLAG_SYSTEM or SPAWNGROUP_FLAG_MANUAL_SPAWN flags, ignoring.", cond->ToString());
+ TC_LOG_ERROR("sql.sql", "{} in `spawn_group_template` table cannot have SPAWNGROUP_FLAG_SYSTEM flags, ignoring.", cond->ToString());
return false;
}
break;
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 2836fc423d8..d215693c4cc 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -2459,11 +2459,19 @@ void Map::UpdateSpawnGroupConditions()
for (uint32 spawnGroupId : *spawnGroups)
{
SpawnGroupTemplateData const* spawnGroupTemplate = ASSERT_NOTNULL(GetSpawnGroupData(spawnGroupId));
- if (spawnGroupTemplate->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
- continue;
bool isActive = IsSpawnGroupActive(spawnGroupId);
bool shouldBeActive = sConditionMgr->IsMapMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPAWN_GROUP, spawnGroupId, this);
+
+ if (spawnGroupTemplate->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
+ {
+ // Only despawn the group if it isn't meeting conditions
+ if (isActive && !shouldBeActive && spawnGroupTemplate->flags & SPAWNGROUP_FLAG_DESPAWN_ON_CONDITION_FAILURE)
+ SpawnGroupDespawn(spawnGroupId, true);
+
+ continue;
+ }
+
if (isActive == shouldBeActive)
continue;