summaryrefslogtreecommitdiffstats
path: root/logic/forge
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-06-25 00:54:00 +0200
committerPetr Mrázek <peterix@gmail.com>2014-06-25 00:54:00 +0200
commitaffb2fdd6c7c7d82fb812b88c61ccadeea8104f3 (patch)
treea84cb3a7e22451558c5479be9244d82a2155e9c1 /logic/forge
parent1194ec9a8e78df9e8e19d54d63a2379408dc7a66 (diff)
parentc081cd80213c5598729222fc274d8ae77efeff1b (diff)
downloadMultiMC-affb2fdd6c7c7d82fb812b88c61ccadeea8104f3.tar
MultiMC-affb2fdd6c7c7d82fb812b88c61ccadeea8104f3.tar.gz
MultiMC-affb2fdd6c7c7d82fb812b88c61ccadeea8104f3.tar.lz
MultiMC-affb2fdd6c7c7d82fb812b88c61ccadeea8104f3.tar.xz
MultiMC-affb2fdd6c7c7d82fb812b88c61ccadeea8104f3.zip
Merge branch 'feature/forge_pre4_fix' into develop
Conflicts: logic/forge/ForgeVersionList.cpp logic/forge/ForgeVersionList.h
Diffstat (limited to 'logic/forge')
-rw-r--r--logic/forge/ForgeVersion.h2
-rw-r--r--logic/forge/ForgeVersionList.cpp59
2 files changed, 40 insertions, 21 deletions
diff --git a/logic/forge/ForgeVersion.h b/logic/forge/ForgeVersion.h
index 74e45c5a..466f46bd 100644
--- a/logic/forge/ForgeVersion.h
+++ b/logic/forge/ForgeVersion.h
@@ -20,11 +20,13 @@ struct ForgeVersion : public BaseVersion
bool usesInstaller();
int m_buildnr = 0;
+ QString branch;
QString universal_url;
QString changelog_url;
QString installer_url;
QString jobbuildver;
QString mcver;
+ QString mcver_sane;
QString universal_filename;
QString installer_filename;
bool is_recommended = false;
diff --git a/logic/forge/ForgeVersionList.cpp b/logic/forge/ForgeVersionList.cpp
index 545fff42..efb30ba6 100644
--- a/logic/forge/ForgeVersionList.cpp
+++ b/logic/forge/ForgeVersionList.cpp
@@ -72,7 +72,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();
@@ -282,7 +282,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;
fVersion->installer_filename = installer_filename;
fVersion->universal_filename = universal_filename;
fVersion->m_buildnr = build_nr;
@@ -336,9 +336,17 @@ 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();
fVersion->universal_filename = "";
- QString filename, installer_filename;
+ fVersion->installer_filename = "";
+ // 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");
+
+ QString universal_filename, installer_filename;
QJsonArray files = number.value("files").toArray();
for (auto fIt = files.begin(); fIt != files.end(); ++fIt)
{
@@ -348,38 +356,47 @@ 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())
{
- 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());
+ longVersion = longVersion + "-" + fVersion->branch;
}
- else if (file.at(1).toString() == "universal")
+ QString filename = artifact + "-" + longVersion + "-" + part + "." + extension;
+
+ QString url = QString("%1/%2/%3")
+ .arg(webpath)
+ .arg(longVersion)
+ .arg(filename);
+
+ if (part == "installer")
{
- 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->installer_url = url;
+ installer_filename = filename;
}
- else if (file.at(1).toString() == "changelog")
+ else if (part == "universal")
{
- fVersion->changelog_url = QString("%1/%2-%3/%4-%2-%3-changelog.%5").arg(
- webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
- file.at(0).toString());
+ fVersion->universal_url = url;
+ universal_filename = filename;
+ }
+ else if (part == "changelog")
+ {
+ fVersion->changelog_url = url;
}
}
if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty())
{
continue;
}
- fVersion->universal_filename = filename;
+ fVersion->universal_filename = universal_filename;
fVersion->installer_filename = installer_filename;
out.append(fVersion);
}
-
return true;
}