summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/onesix
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-03-13 00:23:45 +0100
committerPetr Mrázek <peterix@gmail.com>2016-03-26 17:05:27 +0100
commit02c1df2c3c260fe625b9c3314e9eed2885a97456 (patch)
tree1ca64f44fc609ba47a6a1fde4b9e93fe15b1e618 /logic/minecraft/onesix
parent1854e05e1bb14d8f2bbc4676f44024a83e972f6f (diff)
downloadMultiMC-02c1df2c3c260fe625b9c3314e9eed2885a97456.tar
MultiMC-02c1df2c3c260fe625b9c3314e9eed2885a97456.tar.gz
MultiMC-02c1df2c3c260fe625b9c3314e9eed2885a97456.tar.lz
MultiMC-02c1df2c3c260fe625b9c3314e9eed2885a97456.tar.xz
MultiMC-02c1df2c3c260fe625b9c3314e9eed2885a97456.zip
NOISSUE continue version file format refactors
Diffstat (limited to 'logic/minecraft/onesix')
-rw-r--r--logic/minecraft/onesix/OneSixInstance.cpp44
-rw-r--r--logic/minecraft/onesix/OneSixProfileStrategy.cpp8
-rw-r--r--logic/minecraft/onesix/OneSixUpdate.cpp11
-rw-r--r--logic/minecraft/onesix/OneSixVersionFormat.cpp97
4 files changed, 80 insertions, 80 deletions
diff --git a/logic/minecraft/onesix/OneSixInstance.cpp b/logic/minecraft/onesix/OneSixInstance.cpp
index 2846640c..93034925 100644
--- a/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/logic/minecraft/onesix/OneSixInstance.cpp
@@ -61,7 +61,7 @@ QSet<QString> OneSixInstance::traits()
return {"version-incomplete"};
}
else
- return version->traits;
+ return version->getTraits();
}
std::shared_ptr<Task> OneSixInstance::createUpdateTask()
@@ -95,8 +95,8 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
{
- QString args_pattern = m_version->minecraftArguments;
- for (auto tweaker : m_version->tweakers)
+ QString args_pattern = m_version->getMinecraftArguments();
+ for (auto tweaker : m_version->getTweakers())
{
args_pattern += " --tweakClass " + tweaker;
}
@@ -113,7 +113,7 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
token_mapping["profile_name"] = token_mapping["version_name"] = "MultiMC5";
if(m_version->isVanilla())
{
- token_mapping["version_type"] = m_version->type;
+ token_mapping["version_type"] = m_version->getMinecraftVersionType();
}
else
{
@@ -123,24 +123,14 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
QString absRootDir = QDir(minecraftRoot()).absolutePath();
token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath();
- token_mapping["game_assets"] = AssetsUtils::reconstructAssets(m_version->assets).absolutePath();
+ token_mapping["game_assets"] = AssetsUtils::reconstructAssets(m_version->getMinecraftAssets()).absolutePath();
token_mapping["user_properties"] = session->serializeUserProperties();
token_mapping["user_type"] = session->user_type;
// 1.7.3+ assets tokens
token_mapping["assets_root"] = absAssetsDir;
- token_mapping["assets_index_name"] = m_version->assets;
-
- // 1.9+ version type token
- if(m_version->isVanilla())
- {
- token_mapping["version_type"] = m_version->type;
- }
- else
- {
- token_mapping["version_type"] = "custom";
- }
+ token_mapping["assets_index_name"] = m_version->getMinecraftAssets();
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
for (int i = 0; i < parts.length(); i++)
@@ -182,7 +172,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
launchScript += "coremod " + coremod.filename().completeBaseName() + "\n";;
}
- for(auto & jarmod: m_version->jarMods)
+ for(auto & jarmod: m_version->getJarMods())
{
launchScript += "jarmod " + jarmod->originalName + " (" + jarmod->name + ")\n";
}
@@ -201,17 +191,19 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
}
else
{
- QString relpath = m_version->id + "/" + m_version->id + ".jar";
+ QString relpath = m_version->getMinecraftVersion() + "/" + m_version->getMinecraftVersion() + ".jar";
launchScript += "cp " + versionsPath().absoluteFilePath(relpath) + "\n";
}
}
- if (!m_version->mainClass.isEmpty())
+ auto mainClass = m_version->getMainClass();
+ if (!mainClass.isEmpty())
{
- launchScript += "mainClass " + m_version->mainClass + "\n";
+ launchScript += "mainClass " + mainClass + "\n";
}
- if (!m_version->appletClass.isEmpty())
+ auto appletClass = m_version->getAppletClass();
+ if (!appletClass.isEmpty())
{
- launchScript += "appletClass " + m_version->appletClass + "\n";
+ launchScript += "appletClass " + appletClass + "\n";
}
// generic minecraft params
@@ -251,7 +243,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
}
// traits. including legacyLaunch and others ;)
- for (auto trait : m_version->traits)
+ for (auto trait : m_version->getTraits())
{
launchScript += "traits " + trait + "\n";
}
@@ -323,7 +315,7 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
{
std::shared_ptr<MinecraftProfile> version = m_inst->getMinecraftProfile();
// nuke obsolete stripped jar(s) if needed
- QString version_id = version->id;
+ QString version_id = version->getMinecraftVersion();
QString strippedPath = version_id + "/" + version_id + "-stripped.jar";
QFile strippedJar(strippedPath);
if(strippedJar.exists())
@@ -351,7 +343,7 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
auto jarMods = m_inst->getJarMods();
if(jarMods.size())
{
- auto sourceJarPath = m_inst->versionsPath().absoluteFilePath(version->id + "/" + version->id + ".jar");
+ auto sourceJarPath = m_inst->versionsPath().absoluteFilePath(version_id + "/" + version_id + ".jar");
QString localPath = version_id + "/" + version_id + ".jar";
auto metacache = ENV.metacache();
auto entry = metacache->resolveEntry("versions", localPath);
@@ -439,7 +431,7 @@ bool OneSixInstance::setIntendedVersionId(QString version)
QList< Mod > OneSixInstance::getJarMods() const
{
QList<Mod> mods;
- for (auto jarmod : m_version->jarMods)
+ for (auto jarmod : m_version->getJarMods())
{
QString filePath = jarmodsPath().absoluteFilePath(jarmod->name);
mods.push_back(Mod(QFileInfo(filePath)));
diff --git a/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/logic/minecraft/onesix/OneSixProfileStrategy.cpp
index fe4e0d26..baec635e 100644
--- a/logic/minecraft/onesix/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/onesix/OneSixProfileStrategy.cpp
@@ -228,8 +228,6 @@ void OneSixProfileStrategy::load()
upgradeDeprecatedFiles();
loadDefaultBuiltinPatches();
loadUserPatches();
-
- profile->finalize();
}
bool OneSixProfileStrategy::saveOrder(ProfileUtils::PatchOrder order)
@@ -246,7 +244,7 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
{
bool ok = true;
// first, remove the patch file. this ensures it's not used anymore
- auto fileName = patch->getPatchFilename();
+ auto fileName = patch->getFilename();
if(fileName.size())
{
QFile patchFile(fileName);
@@ -289,7 +287,7 @@ bool OneSixProfileStrategy::customizePatch(ProfilePatchPtr patch)
return false;
}
- auto filename = FS::PathCombine(m_instance->instanceRoot(), "patches" , patch->getPatchID() + ".json");
+ auto filename = FS::PathCombine(m_instance->instanceRoot(), "patches" , patch->getID() + ".json");
if(!FS::ensureFilePathExists(filename))
{
return false;
@@ -327,7 +325,7 @@ bool OneSixProfileStrategy::revertPatch(ProfilePatchPtr patch)
// already not custom
return true;
}
- auto filename = patch->getPatchFilename();
+ auto filename = patch->getFilename();
if(!QFile::exists(filename))
{
// already gone / not custom
diff --git a/logic/minecraft/onesix/OneSixUpdate.cpp b/logic/minecraft/onesix/OneSixUpdate.cpp
index da3bd504..c12674d4 100644
--- a/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -51,8 +51,7 @@ void OneSixUpdate::executeTask()
}
// Get a pointer to the version object that corresponds to the instance's version.
- targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(
- ENV.getVersion("net.minecraft", m_inst->intendedVersionId()));
+ targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(ENV.getVersion("net.minecraft", m_inst->intendedVersionId()));
if (targetVersion == nullptr)
{
// don't do anything if it was invalid
@@ -89,7 +88,7 @@ void OneSixUpdate::assetIndexStart()
setStatus(tr("Updating assets index..."));
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
- QString assetName = version->assets;
+ QString assetName = version->getMinecraftAssets();
QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
QString localPath = assetName + ".json";
auto job = new NetJob(tr("Asset index for %1").arg(inst->name()));
@@ -115,7 +114,7 @@ void OneSixUpdate::assetIndexFinished()
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
- QString assetName = version->assets;
+ QString assetName = version->getMinecraftAssets();
QString asset_fname = "assets/indexes/" + assetName + ".json";
if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index))
@@ -194,7 +193,7 @@ void OneSixUpdate::jarlibStart()
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
// minecraft.jar for this version
{
- QString version_id = version->id;
+ QString version_id = version->getMinecraftVersion();
QString localPath = version_id + "/" + version_id + ".jar";
QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath;
@@ -292,7 +291,7 @@ void OneSixUpdate::jarlibFinished()
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
- if (version->traits.contains("legacyFML"))
+ if (version->hasTrait("legacyFML"))
{
fmllibsStart();
}
diff --git a/logic/minecraft/onesix/OneSixVersionFormat.cpp b/logic/minecraft/onesix/OneSixVersionFormat.cpp
index 4ccf6e78..ff26ab92 100644
--- a/logic/minecraft/onesix/OneSixVersionFormat.cpp
+++ b/logic/minecraft/onesix/OneSixVersionFormat.cpp
@@ -81,9 +81,30 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
readString(root, "mainClass", out->mainClass);
readString(root, "appletClass", out->appletClass);
- readString(root, "processArguments", out->processArguments);
- readString(root, "minecraftArguments", out->overwriteMinecraftArguments);
- readString(root, "+minecraftArguments", out->addMinecraftArguments);
+ readString(root, "minecraftArguments", out->minecraftArguments);
+ if(out->minecraftArguments.isEmpty())
+ {
+ QString processArguments;
+ readString(root, "processArguments", processArguments);
+ QString toCompare = processArguments.toLower();
+ if (toCompare == "legacy")
+ {
+ out->minecraftArguments = " ${auth_player_name} ${auth_session}";
+ }
+ else if (toCompare == "username_session")
+ {
+ out->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}";
+ }
+ else if (toCompare == "username_session_version")
+ {
+ out->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}";
+ }
+ else if (!toCompare.isEmpty())
+ {
+ out->addProblem(PROBLEM_ERROR, QObject::tr("processArguments is set to unknown value '%1'").arg(processArguments));
+ }
+ }
+
readString(root, "type", out->type);
out->m_releaseTime = timeFromS3Time(readStringRet(root, "releaseTime"));
@@ -91,15 +112,6 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
readString(root, "assets", out->assets);
- if (root.contains("tweakers"))
- {
- out->shouldOverwriteTweakers = true;
- for (auto tweakerVal : requireArray(root.value("tweakers")))
- {
- out->overwriteTweakers.append(requireString(tweakerVal));
- }
- }
-
if (root.contains("+tweakers"))
{
for (auto tweakerVal : requireArray(root.value("+tweakers")))
@@ -108,7 +120,6 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
}
-
if (root.contains("+traits"))
{
for (auto tweakerVal : requireArray(root.value("+traits")))
@@ -117,18 +128,6 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
}
- if (root.contains("libraries"))
- {
- out->shouldOverwriteLibs = true;
- for (auto libVal : requireArray(root.value("libraries")))
- {
- auto libObj = requireObject(libVal);
-
- auto lib = libraryFromJson(libObj, filename);
- out->overwriteLibs.append(lib);
- }
- }
-
if (root.contains("+jarMods"))
{
for (auto libVal : requireArray(root.value("+jarMods")))
@@ -147,18 +146,38 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
}
- if (root.contains("+libraries"))
+ auto readLibs = [&](const char * which)
{
- for (auto libVal : requireArray(root.value("+libraries")))
+ for (auto libVal : requireArray(root.value(which)))
{
QJsonObject libObj = requireObject(libVal);
// parse the library
auto lib = libraryFromJson(libObj, filename);
out->addLibs.append(lib);
}
+ };
+ bool hasPlusLibs = root.contains("+libraries");
+ bool hasLibs = root.contains("libraries");
+ if (hasPlusLibs && hasLibs)
+ {
+ out->addProblem(PROBLEM_WARNING, QObject::tr("Version file has both '+libraries' and 'libraries'. This is no longer supported."));
+ readLibs("libraries");
+ readLibs("+libraries");
+ }
+ else if (hasLibs)
+ {
+ readLibs("libraries");
+ }
+ else if(hasPlusLibs)
+ {
+ readLibs("+libraries");
}
/* removed features that shouldn't be used */
+ if (root.contains("tweakers"))
+ {
+ out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element 'tweakers'"));
+ }
if (root.contains("-libraries"))
{
out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-libraries'"));
@@ -171,6 +190,10 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
{
out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-minecraftArguments'"));
}
+ if (root.contains("+minecraftArguments"))
+ {
+ out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '+minecraftArguments'"));
+ }
return out;
}
@@ -197,9 +220,7 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
writeString(root, "id", patch->id);
writeString(root, "mainClass", patch->mainClass);
writeString(root, "appletClass", patch->appletClass);
- writeString(root, "processArguments", patch->processArguments);
- writeString(root, "minecraftArguments", patch->overwriteMinecraftArguments);
- writeString(root, "+minecraftArguments", patch->addMinecraftArguments);
+ writeString(root, "minecraftArguments", patch->minecraftArguments);
writeString(root, "type", patch->type);
writeString(root, "assets", patch->assets);
if (patch->isMinecraftVersion())
@@ -207,18 +228,8 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
writeString(root, "releaseTime", timeToS3Time(patch->m_releaseTime));
writeString(root, "time", timeToS3Time(patch->m_updateTime));
}
- writeStringList(root, "tweakers", patch->overwriteTweakers);
writeStringList(root, "+tweakers", patch->addTweakers);
writeStringList(root, "+traits", patch->traits.toList());
- if (!patch->overwriteLibs.isEmpty())
- {
- QJsonArray array;
- for (auto value: patch->overwriteLibs)
- {
- array.append(OneSixVersionFormat::libraryToJson(value.get()));
- }
- root.insert("libraries", array);
- }
if (!patch->addLibs.isEmpty())
{
QJsonArray array;
@@ -226,7 +237,7 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
{
array.append(OneSixVersionFormat::libraryToJson(value.get()));
}
- root.insert("+libraries", array);
+ root.insert("libraries", array);
}
if (!patch->jarMods.isEmpty())
{
@@ -247,7 +258,7 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
static QJsonDocument minecraftVersionToJson(MinecraftVersionPtr patch, bool saveOrder)
{
- if(patch->m_versionSource == Local && patch->getVersionFile())
+ if(patch->getVersionSource() == Local && patch->getVersionFile())
{
return OneSixVersionFormat::profilePatchToJson(patch->getVersionFile(), saveOrder);
}
@@ -269,7 +280,7 @@ QJsonDocument OneSixVersionFormat::profilePatchToJson(const ProfilePatchPtr &pat
{
return minecraftVersionToJson(mversion, saveOrder);
}
- throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getPatchName()));
+ throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getName()));
}
std::shared_ptr<MinecraftProfile> OneSixVersionFormat::profileFromSingleJson(const QJsonObject &obj)