diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-25 00:36:42 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-25 00:36:42 +0200 |
commit | c081cd80213c5598729222fc274d8ae77efeff1b (patch) | |
tree | de259d9ac097cedbff60651cbcf511bb1edbef34 | |
parent | 3a0cdf2d3dde6192694ca34429ab277608357c2a (diff) | |
download | MultiMC-c081cd80213c5598729222fc274d8ae77efeff1b.tar MultiMC-c081cd80213c5598729222fc274d8ae77efeff1b.tar.gz MultiMC-c081cd80213c5598729222fc274d8ae77efeff1b.tar.lz MultiMC-c081cd80213c5598729222fc274d8ae77efeff1b.tar.xz MultiMC-c081cd80213c5598729222fc274d8ae77efeff1b.zip |
Fix forge prerelease mess.
This adds a HACK that assumes Mojang will be consistent with their versioning. What could possibly go wrong?
-rw-r--r-- | logic/lists/ForgeVersionList.cpp | 58 | ||||
-rw-r--r-- | logic/lists/ForgeVersionList.h | 2 |
2 files changed, 39 insertions, 21 deletions
diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp index 4902dc64..50899d24 100644 --- a/logic/lists/ForgeVersionList.cpp +++ b/logic/lists/ForgeVersionList.cpp @@ -71,7 +71,7 @@ QVariant ForgeVersionList::data(const QModelIndex &index, int role) const return version->name(); case 1: - return version->mcver; + return version->mcver_sane; case 2: return version->typeString(); @@ -281,7 +281,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out) fVersion->changelog_url = changelog_url; fVersion->installer_url = installer_url; fVersion->jobbuildver = jobbuildver; - fVersion->mcver = mcver; + fVersion->mcver = fVersion->mcver_sane = mcver; if (installer_filename.isEmpty()) { fVersion->filename = filename; @@ -341,9 +341,16 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out) std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion()); fVersion->m_buildnr = number.value("build").toDouble(); fVersion->jobbuildver = number.value("version").toString(); + fVersion->branch = number.value("branch").toString(""); fVersion->mcver = number.value("mcversion").toString(); + // HACK: here, we fix the minecraft version used by forge. + // HACK: this will inevitably break (later) + // FIXME: replace with a dictionary + fVersion->mcver_sane = fVersion->mcver; + fVersion->mcver_sane.replace("_pre", "-pre"); fVersion->filename = ""; - QString filename, installer_filename; + + QString universal_filename, installer_filename; QJsonArray files = number.value("files").toArray(); for (auto fIt = files.begin(); fIt != files.end(); ++fIt) { @@ -353,37 +360,46 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out) { continue; } - if (file.at(1).toString() == "installer") + + QString extension = file.at(0).toString(); + QString part = file.at(1).toString(); + QString checksum = file.at(2).toString(); + + // insane form of mcver is used here + QString longVersion = fVersion->mcver + "-" + fVersion->jobbuildver; + if (!fVersion->branch.isEmpty()) + { + longVersion = longVersion + "-" + fVersion->branch; + } + QString filename = artifact + "-" + longVersion + "-" + part + "." + extension; + + QString url = QString("%1/%2/%3") + .arg(webpath) + .arg(longVersion) + .arg(filename); + + if (part == "installer") { - fVersion->installer_url = QString("%1/%2-%3/%4-%2-%3-installer.%5").arg( - webpath, fVersion->mcver, fVersion->jobbuildver, artifact, - file.at(0).toString()); - installer_filename = QString("%1-%2-%3-installer.%4").arg( - artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString()); + fVersion->installer_url = url; + installer_filename = filename; } - else if (file.at(1).toString() == "universal") + else if (part == "universal") { - fVersion->universal_url = QString("%1/%2-%3/%4-%2-%3-universal.%5").arg( - webpath, fVersion->mcver, fVersion->jobbuildver, artifact, - file.at(0).toString()); - filename = QString("%1-%2-%3-universal.%4").arg( - artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString()); + fVersion->universal_url = url; + universal_filename = filename; } - else if (file.at(1).toString() == "changelog") + else if (part == "changelog") { - fVersion->changelog_url = QString("%1/%2-%3/%4-%2-%3-changelog.%5").arg( - webpath, fVersion->mcver, fVersion->jobbuildver, artifact, - file.at(0).toString()); + fVersion->changelog_url = url; } } if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty()) { continue; } - fVersion->filename = fVersion->installer_url.isEmpty() ? filename : installer_filename; + fVersion->filename = fVersion->installer_url.isEmpty() ? universal_filename : installer_filename; out.append(fVersion); } - return true; } diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h index b19d3f56..091072e4 100644 --- a/logic/lists/ForgeVersionList.h +++ b/logic/lists/ForgeVersionList.h @@ -68,6 +68,8 @@ struct ForgeVersion : public BaseVersion QString jobbuildver; QString mcver; QString filename; + QString branch; + QString mcver_sane; }; class ForgeVersionList : public BaseVersionList |