diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-28 23:34:54 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-30 00:36:15 +0200 |
commit | 8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace (patch) | |
tree | 53f66b6f7ae85b56612aa0f1980a8adb5f29d008 /src/ClientHandle.cpp | |
parent | cIsThread cleanup (diff) | |
download | cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar.gz cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar.bz2 cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar.lz cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar.xz cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.tar.zst cuberite-8a30a4a7b8a7ebbdbccb6995fd2f5c0f8011bace.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 5762de897..61370ca4f 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -140,15 +140,6 @@ void cClientHandle::Destroy(void) -void cClientHandle::GenerateOfflineUUID(void) -{ - m_UUID = GenerateOfflineUUID(m_Username); -} - - - - - AString cClientHandle::FormatChatPrefix( bool ShouldAppendChatPrefixes, const AString & a_ChatPrefixS, const AString & m_Color1, const AString & m_Color2 @@ -318,7 +309,19 @@ void cClientHandle::Authenticate(const AString & a_Name, const cUUID & a_UUID, c void cClientHandle::FinishAuthenticate(const AString & a_Name, const cUUID & a_UUID, const Json::Value & a_Properties) { // Serverside spawned player (so data are loaded). - auto Player = std::make_unique<cPlayer>(shared_from_this()); + std::unique_ptr<cPlayer> Player; + + try + { + Player = std::make_unique<cPlayer>(shared_from_this()); + } + catch (const std::exception & Oops) + { + LOGWARNING("Error reading player \"%s\": %s", GetUsername().c_str(), Oops.what()); + Kick("Contact an operator.\n\nYour player's save files could not be parsed.\nTo avoid data loss you are prevented from joining."); + return; + } + m_Player = Player.get(); /* @@ -1461,9 +1464,7 @@ void cClientHandle::HandleChat(const AString & a_Message) { if ((a_Message.size()) > MAX_CHAT_MSG_LENGTH) { - this->Kick(std::string("Please don't exceed the maximum message length of ") - + std::to_string(MAX_CHAT_MSG_LENGTH) - ); + Kick("Please don't exceed the maximum message length of " + std::to_string(MAX_CHAT_MSG_LENGTH)); return; } // We no longer need to postpone message processing, because the messages already arrive in the Tick thread |