NOISSUE refactor builtin patch loading slightly

This commit is contained in:
Petr Mrázek 2017-03-28 09:45:51 +02:00
parent af3384c649
commit 53188386b8

View File

@ -85,58 +85,37 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
void OneSixProfileStrategy::loadDefaultBuiltinPatches() void OneSixProfileStrategy::loadDefaultBuiltinPatches()
{ {
auto addBuiltinPatch = [&](const QString &uid, const QString intendedVersion, int order)
{ {
auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); auto jsonFilePath = FS::PathCombine(m_instance->instanceRoot(), "patches" , uid + ".json");
// load up the base minecraft patch // load up the base minecraft patch
ProfilePatchPtr minecraftPatch; ProfilePatchPtr profilePatch;
if(QFile::exists(mcJson)) if(QFile::exists(jsonFilePath))
{ {
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); auto file = ProfileUtils::parseJsonFile(QFileInfo(jsonFilePath), false);
if(file->version.isEmpty()) if(file->version.isEmpty())
{ {
file->version = m_instance->intendedVersionId(); file->version = intendedVersion;
} }
minecraftPatch = std::make_shared<ProfilePatch>(file, mcJson); profilePatch = std::make_shared<ProfilePatch>(file, jsonFilePath);
minecraftPatch->setVanilla(false); profilePatch->setVanilla(false);
minecraftPatch->setRevertible(true); profilePatch->setRevertible(true);
} }
else else
{ {
auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId()); auto metaVersion = ENV.metadataIndex()->get(uid, intendedVersion);
minecraftPatch = std::make_shared<ProfilePatch>(mcversion); profilePatch = std::make_shared<ProfilePatch>(metaVersion);
minecraftPatch->setVanilla(true); profilePatch->setVanilla(true);
} }
if (!minecraftPatch) if (!profilePatch)
{ {
throw VersionIncomplete("net.minecraft"); throw VersionIncomplete(uid);
}
minecraftPatch->setOrder(-2);
profile->appendPatch(minecraftPatch);
}
{
auto lwjglJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "org.lwjgl.json");
ProfilePatchPtr lwjglPatch;
if(QFile::exists(lwjglJson))
{
auto file = ProfileUtils::parseJsonFile(QFileInfo(lwjglJson), false);
lwjglPatch = std::make_shared<ProfilePatch>(file, lwjglJson);
lwjglPatch->setVanilla(false);
lwjglPatch->setRevertible(true);
}
else
{
auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1");
lwjglPatch = std::make_shared<ProfilePatch>(lwjglversion);
lwjglPatch->setVanilla(true);
}
if (!lwjglPatch)
{
throw VersionIncomplete("org.lwjgl");
}
lwjglPatch->setOrder(-1);
profile->appendPatch(lwjglPatch);
} }
profilePatch->setOrder(order);
profile->appendPatch(profilePatch);
};
addBuiltinPatch("net.minecraft", m_instance->intendedVersionId(), -2);
addBuiltinPatch("org.lwjgl", "2.9.1", -1);
} }
void OneSixProfileStrategy::loadUserPatches() void OneSixProfileStrategy::loadUserPatches()