From 0c41026df020d3065bcb96d01a64f564fab78da0 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:00:30 -0700 Subject: [PATCH] Fixed friendless crash --- dGame/dComponents/PropertyEntranceComponent.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index 504f2dc3..fbbdb896 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -117,8 +117,14 @@ std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMe friendsList = friendsList + std::to_string(playerIDToConvert) + ","; } // Replace trailing comma with the closing parenthesis. - friendsList.replace(friendsList.size() - 1, 2, ") "); - orderBy = friendsList + "ORDER BY ci.name ASC "; + if (friendsList.at(friendsList.size() - 1) == ',') friendsList.erase(friendsList.size() - 1, 1); + friendsList += ") "; + if (friendsList.find("()") == std::string::npos) { + orderBy = friendsList; + } else { + friendsList = " AND p.owner_id IN (-1) "; + } + orderBy += friendsList + "ORDER BY ci.name ASC "; delete friendsListQueryResult; friendsListQueryResult = nullptr;