From 8a65726e9dbe990a898a49d4ce05d61ad5b06852 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 30 Jul 2022 17:38:02 -0300 Subject: fix: use more robust method of finding matches for major version This uses the proper version list to find all MC versions matching the major number (_don't say anything about SemVer_ :gun:). Signed-off-by: flow --- launcher/meta/VersionList.cpp | 7 +++++++ launcher/meta/VersionList.h | 1 + 2 files changed, 8 insertions(+) (limited to 'launcher/meta') diff --git a/launcher/meta/VersionList.cpp b/launcher/meta/VersionList.cpp index 6d23ce9a..f609e94c 100644 --- a/launcher/meta/VersionList.cpp +++ b/launcher/meta/VersionList.cpp @@ -140,6 +140,13 @@ VersionPtr VersionList::getVersion(const QString &version) return out; } +bool VersionList::hasVersion(QString version) const +{ + auto ver = std::find_if(m_versions.constBegin(), m_versions.constEnd(), + [&](Meta::VersionPtr const& a){ return a->version() == version; }); + return (ver != m_versions.constEnd()); +} + void VersionList::setName(const QString &name) { m_name = name; diff --git a/launcher/meta/VersionList.h b/launcher/meta/VersionList.h index 378255df..a6db2fd7 100644 --- a/launcher/meta/VersionList.h +++ b/launcher/meta/VersionList.h @@ -66,6 +66,7 @@ public: QString humanReadable() const; VersionPtr getVersion(const QString &version); + bool hasVersion(QString version) const; QVector versions() const { -- cgit