MCPcopy Create free account
hub / github.com/MultiMC/Launcher / migratePreComponentConfig

Method migratePreComponentConfig

launcher/minecraft/PackProfile.cpp:435–603  ·  view source on GitHub ↗

* Migrate old layout to the component based one... * - Part of the version information is taken from `instance.cfg` (fed to this class from outside). * - Part is taken from the old order.json file. * - Part is loaded from loose json files in the instance's `patches` directory. */

Source from the content-addressed store, hash-verified

433 * - Part is loaded from loose json files in the instance's `patches` directory.
434 */
435bool PackProfile::migratePreComponentConfig()
436{
437 // upgrade the very old files from the beginnings of MultiMC 5
438 upgradeDeprecatedFiles(d->m_instance->instanceRoot(), d->m_instance->name());
439
440 QList<ComponentPtr> components;
441 QSet<QString> loaded;
442
443 auto addBuiltinPatch = [&](const QString &uid, bool asDependency, const QString & emptyVersion, const Meta::Require & req, const Meta::Require & conflict)
444 {
445 auto jsonFilePath = FS::PathCombine(d->m_instance->instanceRoot(), "patches" , uid + ".json");
446 auto intendedVersion = d->getOldConfigVersion(uid);
447 // load up the base minecraft patch
448 ComponentPtr component;
449 if(QFile::exists(jsonFilePath))
450 {
451 if(intendedVersion.isEmpty())
452 {
453 intendedVersion = emptyVersion;
454 }
455 auto file = ProfileUtils::parseJsonFile(QFileInfo(jsonFilePath), false);
456 // fix uid
457 file->uid = uid;
458 // if version is missing, add it from the outside.
459 if(file->version.isEmpty())
460 {
461 file->version = intendedVersion;
462 }
463 // if this is a dependency (LWJGL), mark it also as volatile
464 if(asDependency)
465 {
466 file->m_volatile = true;
467 }
468 // insert requirements if needed
469 if(!req.uid.isEmpty())
470 {
471 file->requires.insert(req);
472 }
473 // insert conflicts if needed
474 if(!conflict.uid.isEmpty())
475 {
476 file->conflicts.insert(conflict);
477 }
478 // FIXME: @QUALITY do not ignore return value
479 ProfileUtils::saveJsonFile(OneSixVersionFormat::versionFileToJson(file), jsonFilePath);
480 component = new Component(this, uid, file);
481 component->m_version = intendedVersion;
482 }
483 else if(!intendedVersion.isEmpty())
484 {
485 auto metaVersion = APPLICATION->metadataIndex()->get(uid, intendedVersion);
486 component = new Component(this, metaVersion);
487 }
488 else
489 {
490 return;
491 }
492 component->m_dependencyOnly = asDependency;

Callers

nothing calls this directly

Calls 15

upgradeDeprecatedFilesFunction · 0.85
PathCombineFunction · 0.85
parseJsonFileFunction · 0.85
saveJsonFileFunction · 0.85
QStringClass · 0.85
readOverrideOrdersFunction · 0.85
savePackProfileFunction · 0.85
instanceRootMethod · 0.80
getOldConfigVersionMethod · 0.80
isEmptyMethod · 0.80
insertMethod · 0.80
metadataIndexMethod · 0.80

Tested by

no test coverage detected