From 090d8305e4e3c3ee085a897b72f2b4708e183eb8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 Oct 2020 13:09:42 +0100 Subject: Warnings improvements * Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality * Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already * Reduced GetStackValue verbosity + Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness + Give SettingsRepositoryInterface a move constructor to simplify main.cpp code - Remove do {} while (false) construction in redstone handler --- src/Protocol/ProtocolRecognizer.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src/Protocol/ProtocolRecognizer.cpp') diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 94208cbf3..5d146c46a 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -253,9 +253,7 @@ std::unique_ptr cMultiVersionProtocol::TryRecognizeLengthedProtocol(c a_Client.GetIPString().c_str(), PacketType ); - throw TriedToJoinWithUnsupportedProtocolException( - Printf("Your client isn't supported.\nTry connecting with Minecraft " MCS_CLIENT_VERSIONS, ProtocolVersion) - ); + throw TriedToJoinWithUnsupportedProtocolException("Your client isn't supported.\nTry connecting with Minecraft " MCS_CLIENT_VERSIONS); } if ( @@ -270,21 +268,16 @@ std::unique_ptr cMultiVersionProtocol::TryRecognizeLengthedProtocol(c throw TriedToJoinWithUnsupportedProtocolException("Incorrect amount of data received - hacked client?"); } - cProtocol::State NextState = [&] + const auto NextState = [NextStateValue] + { + switch (NextStateValue) { - switch (NextStateValue) - { - case cProtocol::State::Status: return cProtocol::State::Status; - case cProtocol::State::Login: return cProtocol::State::Login; - case cProtocol::State::Game: return cProtocol::State::Game; - default: - { - throw TriedToJoinWithUnsupportedProtocolException( - fmt::format("Invalid next game state: {}", NextStateValue) - ); - } - } - }(); + case 1: return cProtocol::State::Status; + case 2: return cProtocol::State::Login; + case 3: return cProtocol::State::Game; + default: throw TriedToJoinWithUnsupportedProtocolException("Your client isn't supported.\nTry connecting with Minecraft " MCS_CLIENT_VERSIONS); + } + }(); // TODO: this should be a protocol property, not ClientHandle: a_Client.SetProtocolVersion(ProtocolVersion); -- cgit v1.2.3