From 3e5d0a06012af20c67b83bd1f8a5f4acf21f5ea0 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:23:32 -0400 Subject: [PATCH] [Cleanup] Unconditional return in for loop in GetRaidByCharID() (#3179) # Notes - This is improper and should just check if we have no result, return `0`, otherwise return `row[0]` of the row we queried. --- common/database.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index ff78711ba..37cb7f9ba 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -2043,10 +2043,12 @@ uint32 Database::GetRaidIDByCharID(uint32 character_id) { character_id ); auto results = QueryDatabase(query); - for (auto row = results.begin(); row != results.end(); ++row) { - return Strings::ToUnsignedInt(row[0]); + if (!results.Success() || !results.RowCount()) { + return 0; } - return 0; + + auto row = results.begin(); + return Strings::ToUnsignedInt(row[0]); } int Database::CountInvSnapshots() {