From a20d333f9de1e0acba009324c6bf564193a0d34c Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Sat, 11 Nov 2023 21:00:50 -0600 Subject: [PATCH] [Spawn2] Fix edge case with instances not copying disabled spawn state (#3688) * [Spawn2] Fix edge case with instances not copying disabled spawn state * Update spawn2.cpp --- zone/spawn2.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 27307c464..efb435c1d 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -485,12 +485,15 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa spawn2_ids.push_back(s.id); } + // we load spawn2_disabled entries for this zone + // if there are more specific entries for an instance of this zone, we load those instead + // if there are no entries for this zone, we load the default entries std::vector disabled_spawns = {}; if (!spawn2_ids.empty()) { disabled_spawns = Spawn2DisabledRepository::GetWhere( database, fmt::format( - "spawn2_id IN ({}) and instance_id = {}", + "spawn2_id IN ({}) and (instance_id = {} OR instance_id = 0) ORDER BY instance_id", Strings::Join(spawn2_ids, ","), zone->GetInstanceID() ) @@ -505,11 +508,11 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa // load from spawn2_disabled bool spawn_enabled = true; + // check if spawn is disabled for (auto &ds: disabled_spawns) { if (ds.spawn2_id == s.id) { - spawn_enabled = false; - break; + spawn_enabled = !ds.disabled; } }