瀏覽代碼

Do not inform of mod update if remote version is older than local

Ivan Savenko 10 月之前
父節點
當前提交
a80f65439b
共有 3 個文件被更改,包括 16 次插入1 次删除
  1. 1 1
      launcher/modManager/modstate.cpp
  2. 14 0
      lib/modding/ModDescription.cpp
  3. 1 0
      lib/modding/ModDescription.h

+ 1 - 1
launcher/modManager/modstate.cpp

@@ -217,7 +217,7 @@ bool ModState::isInstalled() const
 
 bool ModState::isUpdateAvailable() const
 {
-	return getInstalledVersion() != getRepositoryVersion() && !getRepositoryVersion().isEmpty() && !getInstalledVersion().isEmpty();
+	return impl.isUpdateAvailable();
 }
 
 bool ModState::isCompatible() const

+ 14 - 0
lib/modding/ModDescription.cpp

@@ -216,4 +216,18 @@ bool ModDescription::affectsGameplay() const
 	return false;
 }
 
+bool ModDescription::isUpdateAvailable() const
+{
+	if (getRepositoryValue("version").isNull())
+		return false;
+
+	if (getLocalValue("version").isNull())
+		return false;
+
+	auto localVersion = CModVersion::fromString(getLocalValue("version").String());
+	auto repositoryVersion = CModVersion::fromString(getRepositoryValue("version").String());
+
+	return localVersion < repositoryVersion;
+}
+
 VCMI_LIB_NAMESPACE_END

+ 1 - 0
lib/modding/ModDescription.h

@@ -58,6 +58,7 @@ public:
 	ModVerificationInfo getVerificationInfo() const;
 
 	bool isCompatible() const;
+	bool isUpdateAvailable() const;
 
 	bool affectsGameplay() const;
 	bool isCompatibility() const;