Difference between revisions of "JCM:MTR Version Check"
From The District of Joban
Views
Actions
Namespaces
Variants
Tools
Line 6: | Line 6: | ||
The code is later rewritten, and is displayed below (Presented in javascript): | The code is later rewritten, and is displayed below (Presented in javascript): | ||
<nowiki> | <nowiki> | ||
let minVer = "3.1.0- | let minVer = "3.1.0-unofficial-5" | ||
let curVer = "3.1.0" | let curVer = "3.1.0-prerelease-1" | ||
console.log(lowerThanMin(minVer, curVer)) | console.log(lowerThanMin(minVer, curVer)) | ||
Line 38: | Line 38: | ||
for (let i = 0; i < splittedA.length; i++) { | for (let i = 0; i < splittedA.length; i++) { | ||
let min = splittedA[i]; | let min = parseInt(splittedA[i]); | ||
let cur = splittedB[i]; | let cur = parseInt(splittedB[i]); | ||
if (min > cur) { | if (min > cur) { | ||
return true; | return true; | ||
Line 46: | Line 46: | ||
return false; | return false; | ||
} else { | } else { | ||
if (minVersion.includes("-unofficial-") && | if (minVersion.includes("-unofficial-") && curVersion.includes("-unofficial-")) { | ||
let minUnofficialVer = parseInt(minVersion.split("-unofficial-")[1].split("-hotfix-")[0]) | let minUnofficialVer = parseInt(minVersion.split("-unofficial-")[1].split("-hotfix-")[0]) | ||
let curUnofficialVer = parseInt(curVersion.split("-unofficial-")[1].split("-hotfix-")[0]) | let curUnofficialVer = parseInt(curVersion.split("-unofficial-")[1].split("-hotfix-")[0]) | ||
Line 55: | Line 55: | ||
} | } | ||
if (minVersion.includes("-prerelease-") && | if (minVersion.includes("-prerelease-") && curVersion.includes("-prerelease-")) { | ||
let minUnofficialVer = parseInt(minVersion.split("-prerelease-")[1].split("-hotfix-")[0]); | let minUnofficialVer = parseInt(minVersion.split("-prerelease-")[1].split("-hotfix-")[0]); | ||
let curUnofficialVer = parseInt(curVersion.split("-prerelease-")[1].split("-hotfix-")[0]); | let curUnofficialVer = parseInt(curVersion.split("-prerelease-")[1].split("-hotfix-")[0]); |
Revision as of 20:36, 31 August 2022
For a more friendly experience, Joban Client Mod grabs the MTR Mod version from the corresponding Mod Loader (Fabric or Forge), then compare it to the minimum MTR version. (Which is manually bumped by the developers whenever there's an incompatibilties)
Issues
On JCM v1.1.5, the code for comparing versions is flawed. After MTR releases 3.1.0-prerelease-1, all JCM users using that version gets a pop up saying their version is incompatible every time the game launches. (When in fact, it is compatible)
The code is later rewritten, and is displayed below (Presented in javascript):
let minVer = "3.1.0-unofficial-5" let curVer = "3.1.0-prerelease-1" console.log(lowerThanMin(minVer, curVer)) function lowerThanMin(ogMinVersion, ogCurVersion) { let minVersion = ogMinVersion.split("-hotfix-")[0] let curVersion = ogCurVersion.split("-hotfix-")[0] if (curVersion == null) { return false; } if (curVersion.includes("beta")) { return true; } if (minVersion == curVersion) { return false; } let minimumMainVersion = minVersion.split("-")[0]; let currentMainVersion = curVersion.split("-")[0]; if (minimumMainVersion != currentMainVersion) { let splittedA = minimumMainVersion.split("."); let splittedB = currentMainVersion.split("."); if (splittedA.length != splittedB.length) { return false; } for (let i = 0; i < splittedA.length; i++) { let min = parseInt(splittedA[i]); let cur = parseInt(splittedB[i]); if (min > cur) { return true; } } return false; } else { if (minVersion.includes("-unofficial-") && curVersion.includes("-unofficial-")) { let minUnofficialVer = parseInt(minVersion.split("-unofficial-")[1].split("-hotfix-")[0]) let curUnofficialVer = parseInt(curVersion.split("-unofficial-")[1].split("-hotfix-")[0]) if (minUnofficialVer > curUnofficialVer) { return true; } } if (minVersion.includes("-prerelease-") && curVersion.includes("-prerelease-")) { let minUnofficialVer = parseInt(minVersion.split("-prerelease-")[1].split("-hotfix-")[0]); let curUnofficialVer = parseInt(curVersion.split("-prerelease-")[1].split("-hotfix-")[0]); if (minUnofficialVer > curUnofficialVer) { return true; } } if (minVersion.includes("-unofficial-") && curVersion.includes("-prerelease-")) { return false; } if (minVersion.includes("-prerelease-") && curVersion.includes("-unofficial-")) { return true; } let minVerIsOfficial = !minVersion.includes("-unofficial-") && !minVersion.includes("-prerelease-"); let curVerIsOfficial = !curVersion.includes("-unofficial-") && !curVersion.includes("-prerelease-"); if (minVerIsOfficial && !curVerIsOfficial) { return true; } if (curVerIsOfficial && !minVerIsOfficial) { return false; } return false; } }