From e7ab46cfdbb59b9e0bb4aa98502d94316073985e Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Thu, 27 Apr 2023 18:50:45 +0300 Subject: [PATCH] add logging for gd::string and fix version comparisons being inverted --- loader/include/Geode/loader/Log.hpp | 2 +- loader/include/Geode/utils/VersionInfo.hpp | 8 +++++--- loader/src/loader/Log.cpp | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/loader/include/Geode/loader/Log.hpp b/loader/include/Geode/loader/Log.hpp index 7eafaaf9..b3c255bd 100644 --- a/loader/include/Geode/loader/Log.hpp +++ b/loader/include/Geode/loader/Log.hpp @@ -33,7 +33,7 @@ namespace geode { GEODE_DLL std::string parse(cocos2d::CCRect const&); GEODE_DLL std::string parse(cocos2d::CCSize const&); GEODE_DLL std::string parse(Mod*); - + GEODE_DLL std::string parse(gd::string const&); template requires std::convertible_to diff --git a/loader/include/Geode/utils/VersionInfo.hpp b/loader/include/Geode/utils/VersionInfo.hpp index 3fce41e8..23dc785e 100644 --- a/loader/include/Geode/utils/VersionInfo.hpp +++ b/loader/include/Geode/utils/VersionInfo.hpp @@ -199,13 +199,15 @@ namespace geode { return false; } + // the comparison works invertedly as a version like "v1.2.0" + // should return true for "<=v1.3.0" switch (m_compare) { case VersionCompare::LessEq: - return m_version <= version; + return version <= m_version; case VersionCompare::MoreEq: - return m_version >= version; + return version >= m_version; default: - return m_version == version; + return version == m_version; } } diff --git a/loader/src/loader/Log.cpp b/loader/src/loader/Log.cpp index 102e7c73..42e735ae 100644 --- a/loader/src/loader/Log.cpp +++ b/loader/src/loader/Log.cpp @@ -85,6 +85,10 @@ std::string log::parse(cocos2d::ccColor4B const& col) { return fmt::format("rgba({}, {}, {}, {})", col.r, col.g, col.b, col.a); } +std::string log::parse(gd::string const& str) { + return fmt::format("{}", std::string(str)); +} + // Log Log::Log(Mod* mod, Severity sev) : m_sender(mod), m_time(log_clock::now()), m_severity(sev) {}