From 435b6142b84d453a2c4ef548b831732c40a9096e Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 12 Feb 2024 20:00:45 -0500 Subject: [PATCH] [Bug Fix] Fix Issue with ClearSpawnTimers() (#4070) # Notes - We were using the improper ID for this and not checking if the vector was empty before using. --- zone/zone.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index c05f0643c..1bb71727b 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2649,22 +2649,24 @@ void Zone::ClearSpawnTimers() iterator.Reset(); - std::vector respawn_ids; + std::vector respawn_ids; while (iterator.MoreElements()) { - respawn_ids.emplace_back(std::to_string(iterator.GetData()->GetID())); + respawn_ids.emplace_back(iterator.GetData()->spawn2_id); iterator.Advance(); } - RespawnTimesRepository::DeleteWhere( - database, - fmt::format( - "`instance_id` = {} AND `id` IN ({})", - GetInstanceID(), - Strings::Implode(", ", respawn_ids) - ) - ); + if (!respawn_ids.empty()) { + RespawnTimesRepository::DeleteWhere( + database, + fmt::format( + "`instance_id` = {} AND `id` IN ({})", + GetInstanceID(), + Strings::Join(respawn_ids, ", ") + ) + ); + } } uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) {