summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-09-10 12:41:32 +0200
committerPetr Mrázek <peterix@gmail.com>2017-09-10 12:41:32 +0200
commit9491396292b740072fa90e6e81e81dbd1b159166 (patch)
treec48431516081c88b8eb23e8b73de751c45129c99 /api
parent13628e7a8260b9407b0d44069f5bc1ecab585f35 (diff)
downloadMultiMC-9491396292b740072fa90e6e81e81dbd1b159166.tar
MultiMC-9491396292b740072fa90e6e81e81dbd1b159166.tar.gz
MultiMC-9491396292b740072fa90e6e81e81dbd1b159166.tar.lz
MultiMC-9491396292b740072fa90e6e81e81dbd1b159166.tar.xz
MultiMC-9491396292b740072fa90e6e81e81dbd1b159166.zip
NOISSUE put back missing OneSix upgrade logic
Diffstat (limited to 'api')
-rw-r--r--api/logic/minecraft/MinecraftProfile.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp
index c883e8e9..e6562230 100644
--- a/api/logic/minecraft/MinecraftProfile.cpp
+++ b/api/logic/minecraft/MinecraftProfile.cpp
@@ -669,6 +669,67 @@ int MinecraftProfile::getFreeOrderNumber()
return largest + 1;
}
+void MinecraftProfile::upgradeDeprecatedFiles_internal()
+{
+ auto versionJsonPath = FS::PathCombine(m_instance->instanceRoot(), "version.json");
+ auto customJsonPath = FS::PathCombine(m_instance->instanceRoot(), "custom.json");
+ auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json");
+
+ QString sourceFile;
+ QString renameFile;
+
+ // convert old crap.
+ if(QFile::exists(customJsonPath))
+ {
+ sourceFile = customJsonPath;
+ renameFile = versionJsonPath;
+ }
+ else if(QFile::exists(versionJsonPath))
+ {
+ sourceFile = versionJsonPath;
+ }
+ if(!sourceFile.isEmpty() && !QFile::exists(mcJson))
+ {
+ if(!FS::ensureFilePathExists(mcJson))
+ {
+ qWarning() << "Couldn't create patches folder for" << m_instance->name();
+ return;
+ }
+ if(!renameFile.isEmpty() && QFile::exists(renameFile))
+ {
+ if(!QFile::rename(renameFile, renameFile + ".old"))
+ {
+ qWarning() << "Couldn't rename" << renameFile << "to" << renameFile + ".old" << "in" << m_instance->name();
+ return;
+ }
+ }
+ auto file = ProfileUtils::parseJsonFile(QFileInfo(sourceFile), false);
+ ProfileUtils::removeLwjglFromPatch(file);
+ file->uid = "net.minecraft";
+ file->version = file->minecraftVersion;
+ file->name = "Minecraft";
+ auto data = OneSixVersionFormat::versionFileToJson(file, false).toJson();
+ QSaveFile newPatchFile(mcJson);
+ if(!newPatchFile.open(QIODevice::WriteOnly))
+ {
+ newPatchFile.cancelWriting();
+ qWarning() << "Couldn't open main patch for writing in" << m_instance->name();
+ return;
+ }
+ newPatchFile.write(data);
+ if(!newPatchFile.commit())
+ {
+ qWarning() << "Couldn't save main patch in" << m_instance->name();
+ return;
+ }
+ if(!QFile::rename(sourceFile, sourceFile + ".old"))
+ {
+ qWarning() << "Couldn't rename" << sourceFile << "to" << sourceFile + ".old" << "in" << m_instance->name();
+ return;
+ }
+ }
+}
+
void MinecraftProfile::loadDefaultBuiltinPatches_internal()
{
auto addBuiltinPatch = [&](const QString &uid, const QString intendedVersion, int order)
@@ -793,6 +854,7 @@ void MinecraftProfile::loadUserPatches_internal()
void MinecraftProfile::load_internal()
{
clearPatches();
+ upgradeDeprecatedFiles_internal();
loadDefaultBuiltinPatches_internal();
loadUserPatches_internal();
}