From f905ee70e458b89b99590b7e17faebddfb85f347 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Thu, 28 Mar 2024 09:48:17 -0400 Subject: [PATCH] [Bug Fix] Fix Auto Login Issue (#4213) * [Bug Fix] Fix Auto Login Issue # Notes - We were setting `live_name` value regardless of if we were zoning, causing us to automatically log in to the last character we'd logged in to before. * Remove & --- common/database.cpp | 2 +- common/database.h | 2 +- world/client.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index 247c602ab..ce6e1c312 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -986,7 +986,7 @@ bool Database::UpdateLiveChar(const std::string& name, uint32 account_id) return AccountRepository::UpdateOne(*this, e); } -const std::string& Database::GetLiveChar(uint32 account_id) +const std::string Database::GetLiveChar(uint32 account_id) { auto e = AccountRepository::FindOne(*this, account_id); diff --git a/common/database.h b/common/database.h index f57721c7e..1f022ab19 100644 --- a/common/database.h +++ b/common/database.h @@ -166,7 +166,7 @@ public: bool GetAdventureStats(uint32 character_id, AdventureStats_Struct* as); /* Account Related */ - const std::string& GetLiveChar(uint32 account_id); + const std::string GetLiveChar(uint32 account_id); bool SetAccountStatus(const std::string& account_name, int16 status); bool SetLocalPassword(uint32 account_id, const std::string& password); bool UpdateLiveChar(const std::string& name, uint32 account_id); diff --git a/world/client.cpp b/world/client.cpp index 08f96db3c..bbafcface 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -193,8 +193,9 @@ bool Client::CanTradeFVNoDropItem() void Client::SendEnterWorld(std::string name) { - const std::string live_name = database.GetLiveChar(GetAccountID()); + std::string live_name {}; if (is_player_zoning) { + live_name = database.GetLiveChar(GetAccountID()); if(database.GetAccountIDByChar(live_name) != GetAccountID()) { eqs->Close(); return;