diff --git a/include/Common.h b/include/Common.h index f6721c11..9944fc75 100644 --- a/include/Common.h +++ b/include/Common.h @@ -74,7 +74,7 @@ class Application final { static TConsole& Console() { return mConsole; } static std::string ServerVersionString(); static const Version& ServerVersion() { return mVersion; } - static uint8_t ClientMajorVersion() { return 2; } + static Version ClientMinimumVersion() { return Version { 2, 2, 0 }; } static std::string PPS() { return mPPS; } static void SetPPS(const std::string& NewPPS) { mPPS = NewPPS; } @@ -162,13 +162,13 @@ void RegisterThread(const std::string& str); #else #define _function_name std::string(__func__) #endif - + #ifndef NDEBUG #define DEBUG #endif - + #if defined(DEBUG) - + // if this is defined, we will show the full function signature infront of // each info/debug/warn... call instead of the 'filename:line' format. #if defined(BMP_FULL_FUNCTION_NAMES) @@ -178,7 +178,7 @@ void RegisterThread(const std::string& str); #endif #endif // defined(DEBUG) - + #define beammp_warn(x) Application::Console().Write(_this_location + std::string("[WARN] ") + (x)) #define beammp_info(x) Application::Console().Write(_this_location + std::string("[INFO] ") + (x)) #define beammp_error(x) \ @@ -221,7 +221,7 @@ void RegisterThread(const std::string& str); #else #define beammp_trace(x) #endif // defined(DEBUG) - + #define beammp_errorf(...) beammp_error(fmt::format(__VA_ARGS__)) #define beammp_infof(...) beammp_info(fmt::format(__VA_ARGS__)) #define beammp_debugf(...) beammp_debug(fmt::format(__VA_ARGS__)) diff --git a/src/THeartbeatThread.cpp b/src/THeartbeatThread.cpp index 849b3212..303cc9b1 100644 --- a/src/THeartbeatThread.cpp +++ b/src/THeartbeatThread.cpp @@ -20,6 +20,7 @@ #include "ChronoWrapper.h" #include "Client.h" +#include "Common.h" #include "Http.h" // #include "SocketIO.h" #include @@ -146,7 +147,7 @@ std::string THeartbeatThread::GenerateCall() { << "&map=" << Application::Settings.getAsString(Settings::Key::General_Map) << "&private=" << (Application::Settings.getAsBool(Settings::Key::General_Private) ? "true" : "false") << "&version=" << Application::ServerVersionString() - << "&clientversion=" << std::to_string(Application::ClientMajorVersion()) + ".0" // FIXME: Wtf. + << "&clientversion=" << Application::ClientMinimumVersion().AsString() << "&name=" << Application::Settings.getAsString(Settings::Key::General_Name) << "&tags=" << Application::Settings.getAsString(Settings::Key::General_Tags) << "&guests=" << (Application::Settings.getAsBool(Settings::Key::General_AllowGuests) ? "true" : "false") diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 78784dea..f89035a4 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -293,10 +293,11 @@ std::shared_ptr TNetwork::Authentication(TConnection&& RawConnection) { if (Data.size() > 3 && std::equal(Data.begin(), Data.begin() + VC.size(), VC.begin(), VC.end())) { std::string ClientVersionStr(reinterpret_cast(Data.data() + 2), Data.size() - 2); Version ClientVersion = Application::VersionStrToInts(ClientVersionStr + ".0"); - if (ClientVersion.major != Application::ClientMajorVersion()) { - beammp_errorf("Client tried to connect with version '{}', but only versions '{}.x.x' is allowed", - ClientVersion.AsString(), Application::ClientMajorVersion()); - ClientKick(*Client, "Outdated Version!"); + Version MinClientVersion = Application::ClientMinimumVersion(); + if (Application::IsOutdated(ClientVersion, MinClientVersion)) { + beammp_errorf("Client tried to connect with version '{}', but only versions >= {} are allowed", + ClientVersion.AsString(), MinClientVersion.AsString()); + ClientKick(*Client, fmt::format("Outdated version, launcher version >={} required to join!", MinClientVersion.AsString())); return nullptr; } } else {