From 41aef57758d7b858d5fa7cb22ab1ffe603ff365f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Thu, 9 Feb 2023 09:45:06 -0600 Subject: [PATCH] make >= default prevent issues --- loader/include/Geode/utils/VersionInfo.hpp | 11 +++++++---- loader/src/utils/VersionInfo.cpp | 9 +++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/loader/include/Geode/utils/VersionInfo.hpp b/loader/include/Geode/utils/VersionInfo.hpp index 2744300b..f94472ca 100644 --- a/loader/include/Geode/utils/VersionInfo.hpp +++ b/loader/include/Geode/utils/VersionInfo.hpp @@ -121,12 +121,15 @@ namespace geode { if (m_version.getMajor() != version.getMajor()) { return false; } + switch (m_compare) { - case VersionCompare::Exact: return m_version == version; break; - case VersionCompare::LessEq: return m_version <= version; break; - case VersionCompare::MoreEq: return m_version >= version; break; + case VersionCompare::LessEq: + return m_version <= version; + case VersionCompare::MoreEq: + return m_version >= version; + default: + return m_version == version; } - return false; } std::string toString() const; diff --git a/loader/src/utils/VersionInfo.cpp b/loader/src/utils/VersionInfo.cpp index f0abafc3..13f8aad7 100644 --- a/loader/src/utils/VersionInfo.cpp +++ b/loader/src/utils/VersionInfo.cpp @@ -115,15 +115,16 @@ Result ComparableVersionInfo::parse(std::string const& ra if (string.starts_with("<=")) { compare = VersionCompare::LessEq; string.erase(0, 2); - } - else if (string.starts_with(">=")) { + } else if (string.starts_with(">=")) { compare = VersionCompare::MoreEq; string.erase(0, 2); - } - else if (string.starts_with("=")) { + } else if (string.starts_with("=")) { compare = VersionCompare::Exact; string.erase(0, 1); + } else { + compare = VersionCompare::MoreEq; } + GEODE_UNWRAP_INTO(auto version, VersionInfo::parse(string)); return Ok(ComparableVersionInfo(version, compare)); }