aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-05-29 16:48:26 +0200
committer0neGal <mail@0negal.com>2022-05-29 16:48:26 +0200
commit83361f13bbc656faca99ba21f6394d7072c2fa63 (patch)
treec3f7c21f0175a209632aee5590cd0bed5e395fdc
parent91a6f7161865b4b405e7c5517113d8e519c15aaf (diff)
downloadViper-83361f13bbc656faca99ba21f6394d7072c2fa63.tar.gz
Viper-83361f13bbc656faca99ba21f6394d7072c2fa63.zip
added checks to make sure the version is correct
We now check all the Northstar mods and make sure they've the same version number, and if not it's counted as an unknown version, as we can't reliable guess which version is the correct one. If Northstar Auto-Updates is enabled it'll then re-install.
-rw-r--r--src/utils.js48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/utils.js b/src/utils.js
index c4318d0..7139706 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -220,21 +220,49 @@ function saveSettings(obj = {}) {
// Returns the current Northstar version
// If not installed it'll return "unknown"
function getNSVersion() {
- var versionFile = path.join(settings.gamepath, "R2Northstar/mods/Northstar.Client/mod.json");
+ var versionFiles = [
+ "Northstar.Client",
+ "Northstar.Custom",
+ "Northstar.CustomServers"
+ ]
+
+ var versions = [];
+
+
+ let add = (version) => {
+ versions.push(version)
+ }
+
+ for (let i = 0; i < versionFiles.length; i++) {
+ var versionFile = path.join(settings.gamepath, "R2Northstar/mods/", versionFiles[i],"/mod.json");
+ if (fs.existsSync(versionFile)) {
+ if (! fs.statSync(versionFile).isFile()) {
+ add("unknown");
+ }
- if (fs.existsSync(versionFile)) {
- if (! fs.statSync(versionFile).isFile()) {
- return "unknown"
+ try {
+ add("v" + JSON.parse(fs.readFileSync(versionFile, "utf8")).Version);
+ }catch(err) {
+ add("unknown");
+ }
+ } else {
+ add("unknown");
}
+ }
+
+ if (versions.includes("unknown")) {return "unknown"}
- try {
- return "v" + JSON.parse(fs.readFileSync(versionFile, "utf8")).Version;
- }catch(err) {
- return "unknown";
+ let mismatch = false;
+ let baseVersion = versions[0];
+ for (let i = 0; i < versions.length; i++) {
+ if (versions[i] != baseVersion) {
+ mismatch = true;
+ break
}
- } else {
- return "unknown";
}
+
+ if (mismatch) {return "unknown"}
+ return baseVersion;
}