aboutsummaryrefslogtreecommitdiff
path: root/api/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-07-15 14:51:05 +0200
committerPetr Mrázek <peterix@gmail.com>2018-07-15 14:51:05 +0200
commitbbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9 (patch)
treee6497e304b7b9368367565fbc7c06efab1124b1c /api/logic/minecraft
parent03280cc62e75f8073f8d3d9e9e3952acf21fa77d (diff)
downloadPrismLauncher-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.gz
PrismLauncher-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.bz2
PrismLauncher-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.zip
NOISSUE tabs -> spaces
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r--api/logic/minecraft/AssetsUtils.cpp340
-rw-r--r--api/logic/minecraft/AssetsUtils.h20
-rw-r--r--api/logic/minecraft/Component.cpp604
-rw-r--r--api/logic/minecraft/Component.h138
-rw-r--r--api/logic/minecraft/ComponentList.cpp1896
-rw-r--r--api/logic/minecraft/ComponentList.h138
-rw-r--r--api/logic/minecraft/ComponentList_p.h44
-rw-r--r--api/logic/minecraft/ComponentUpdateTask.cpp1120
-rw-r--r--api/logic/minecraft/ComponentUpdateTask.h30
-rw-r--r--api/logic/minecraft/ComponentUpdateTask_p.h32
-rw-r--r--api/logic/minecraft/GradleSpecifier.h266
-rw-r--r--api/logic/minecraft/GradleSpecifier_test.cpp126
-rw-r--r--api/logic/minecraft/LaunchProfile.cpp324
-rw-r--r--api/logic/minecraft/LaunchProfile.h140
-rw-r--r--api/logic/minecraft/Library.cpp538
-rw-r--r--api/logic/minecraft/Library.h330
-rw-r--r--api/logic/minecraft/Library_test.cpp498
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp1410
-rw-r--r--api/logic/minecraft/MinecraftInstance.h174
-rw-r--r--api/logic/minecraft/MinecraftLoadAndCheck.cpp50
-rw-r--r--api/logic/minecraft/MinecraftLoadAndCheck.h20
-rw-r--r--api/logic/minecraft/MinecraftUpdate.cpp234
-rw-r--r--api/logic/minecraft/MinecraftUpdate.h32
-rw-r--r--api/logic/minecraft/Mod.cpp572
-rw-r--r--api/logic/minecraft/Mod.h228
-rw-r--r--api/logic/minecraft/ModsModel.cpp548
-rw-r--r--api/logic/minecraft/ModsModel.h152
-rw-r--r--api/logic/minecraft/MojangDownloadInfo.h110
-rw-r--r--api/logic/minecraft/MojangVersionFormat.cpp578
-rw-r--r--api/logic/minecraft/MojangVersionFormat.h20
-rw-r--r--api/logic/minecraft/MojangVersionFormat_test.cpp76
-rw-r--r--api/logic/minecraft/OneSixVersionFormat.cpp650
-rw-r--r--api/logic/minecraft/OneSixVersionFormat.h28
-rw-r--r--api/logic/minecraft/OpSys.cpp36
-rw-r--r--api/logic/minecraft/OpSys.h8
-rw-r--r--api/logic/minecraft/ParseUtils.cpp36
-rw-r--r--api/logic/minecraft/ParseUtils_test.cpp56
-rw-r--r--api/logic/minecraft/ProfileUtils.cpp264
-rw-r--r--api/logic/minecraft/Rule.cpp106
-rw-r--r--api/logic/minecraft/Rule.h94
-rw-r--r--api/logic/minecraft/SimpleModList.cpp552
-rw-r--r--api/logic/minecraft/SimpleModList.h152
-rw-r--r--api/logic/minecraft/SimpleModList_test.cpp70
-rw-r--r--api/logic/minecraft/SkinUpload.cpp80
-rw-r--r--api/logic/minecraft/SkinUpload.h32
-rw-r--r--api/logic/minecraft/VersionFile.cpp68
-rw-r--r--api/logic/minecraft/VersionFile.h118
-rw-r--r--api/logic/minecraft/VersionFilterData.cpp104
-rw-r--r--api/logic/minecraft/VersionFilterData.h24
-rw-r--r--api/logic/minecraft/World.cpp560
-rw-r--r--api/logic/minecraft/World.h102
-rw-r--r--api/logic/minecraft/WorldList.cpp510
-rw-r--r--api/logic/minecraft/WorldList.h174
-rw-r--r--api/logic/minecraft/auth/AuthSession.cpp32
-rw-r--r--api/logic/minecraft/auth/AuthSession.h70
-rw-r--r--api/logic/minecraft/auth/MojangAccount.cpp442
-rw-r--r--api/logic/minecraft/auth/MojangAccount.h170
-rw-r--r--api/logic/minecraft/auth/MojangAccountList.cpp682
-rw-r--r--api/logic/minecraft/auth/MojangAccountList.h304
-rw-r--r--api/logic/minecraft/auth/YggdrasilTask.cpp356
-rw-r--r--api/logic/minecraft/auth/YggdrasilTask.h212
-rw-r--r--api/logic/minecraft/auth/flows/AuthenticateTask.cpp312
-rw-r--r--api/logic/minecraft/auth/flows/AuthenticateTask.h14
-rw-r--r--api/logic/minecraft/auth/flows/RefreshTask.cpp188
-rw-r--r--api/logic/minecraft/auth/flows/RefreshTask.h12
-rw-r--r--api/logic/minecraft/auth/flows/ValidateTask.cpp32
-rw-r--r--api/logic/minecraft/auth/flows/ValidateTask.h12
-rw-r--r--api/logic/minecraft/forge/ForgeXzDownload.cpp640
-rw-r--r--api/logic/minecraft/forge/ForgeXzDownload.h46
-rw-r--r--api/logic/minecraft/launch/ClaimAccount.cpp20
-rw-r--r--api/logic/minecraft/launch/ClaimAccount.h22
-rw-r--r--api/logic/minecraft/launch/CreateServerResourcePacksFolder.cpp14
-rw-r--r--api/logic/minecraft/launch/CreateServerResourcePacksFolder.h16
-rw-r--r--api/logic/minecraft/launch/DirectJavaLaunch.cpp196
-rw-r--r--api/logic/minecraft/launch/DirectJavaLaunch.h38
-rw-r--r--api/logic/minecraft/launch/ExtractNatives.cpp120
-rw-r--r--api/logic/minecraft/launch/ExtractNatives.h18
-rw-r--r--api/logic/minecraft/launch/LauncherPartLaunch.cpp292
-rw-r--r--api/logic/minecraft/launch/LauncherPartLaunch.h42
-rw-r--r--api/logic/minecraft/launch/ModMinecraftJar.cpp90
-rw-r--r--api/logic/minecraft/launch/ModMinecraftJar.h20
-rw-r--r--api/logic/minecraft/launch/PrintInstanceInfo.h18
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.cpp226
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.h216
-rw-r--r--api/logic/minecraft/legacy/LegacyModList.cpp262
-rw-r--r--api/logic/minecraft/legacy/LegacyModList.h28
-rw-r--r--api/logic/minecraft/legacy/LegacyUpgradeTask.cpp200
-rw-r--r--api/logic/minecraft/legacy/LegacyUpgradeTask.h18
-rw-r--r--api/logic/minecraft/testdata/lib-native-arch.json88
-rw-r--r--api/logic/minecraft/testdata/lib-native.json100
-rw-r--r--api/logic/minecraft/testdata/lib-simple.json18
-rw-r--r--api/logic/minecraft/update/AssetUpdateTask.cpp124
-rw-r--r--api/logic/minecraft/update/AssetUpdateTask.h22
-rw-r--r--api/logic/minecraft/update/FMLLibrariesTask.cpp190
-rw-r--r--api/logic/minecraft/update/FMLLibrariesTask.h22
-rw-r--r--api/logic/minecraft/update/FoldersTask.cpp20
-rw-r--r--api/logic/minecraft/update/FoldersTask.h10
-rw-r--r--api/logic/minecraft/update/LibrariesTask.cpp124
-rw-r--r--api/logic/minecraft/update/LibrariesTask.h18
99 files changed, 10364 insertions, 10364 deletions
diff --git a/api/logic/minecraft/AssetsUtils.cpp b/api/logic/minecraft/AssetsUtils.cpp
index 5b25bede..a2274492 100644
--- a/api/logic/minecraft/AssetsUtils.cpp
+++ b/api/logic/minecraft/AssetsUtils.cpp
@@ -38,200 +38,200 @@ namespace AssetsUtils
*/
bool loadAssetsIndexJson(QString assetsId, QString path, AssetsIndex *index)
{
- /*
- {
- "objects": {
- "icons/icon_16x16.png": {
- "hash": "bdf48ef6b5d0d23bbb02e17d04865216179f510a",
- "size": 3665
- },
- ...
- }
- }
- }
- */
-
- QFile file(path);
-
- // Try to open the file and fail if we can't.
- // TODO: We should probably report this error to the user.
- if (!file.open(QIODevice::ReadOnly))
- {
- qCritical() << "Failed to read assets index file" << path;
- return false;
- }
- index->id = assetsId;
-
- // Read the file and close it.
- QByteArray jsonData = file.readAll();
- file.close();
-
- QJsonParseError parseError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parseError);
-
- // Fail if the JSON is invalid.
- if (parseError.error != QJsonParseError::NoError)
- {
- qCritical() << "Failed to parse assets index file:" << parseError.errorString()
- << "at offset " << QString::number(parseError.offset);
- return false;
- }
-
- // Make sure the root is an object.
- if (!jsonDoc.isObject())
- {
- qCritical() << "Invalid assets index JSON: Root should be an array.";
- return false;
- }
-
- QJsonObject root = jsonDoc.object();
-
- QJsonValue isVirtual = root.value("virtual");
- if (!isVirtual.isUndefined())
- {
- index->isVirtual = isVirtual.toBool(false);
- }
-
- QJsonValue objects = root.value("objects");
- QVariantMap map = objects.toVariant().toMap();
-
- for (QVariantMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
- {
- // qDebug() << iter.key();
-
- QVariant variant = iter.value();
- QVariantMap nested_objects = variant.toMap();
-
- AssetObject object;
-
- for (QVariantMap::const_iterator nested_iter = nested_objects.begin();
- nested_iter != nested_objects.end(); ++nested_iter)
- {
- // qDebug() << nested_iter.key() << nested_iter.value().toString();
- QString key = nested_iter.key();
- QVariant value = nested_iter.value();
-
- if (key == "hash")
- {
- object.hash = value.toString();
- }
- else if (key == "size")
- {
- object.size = value.toDouble();
- }
- }
-
- index->objects.insert(iter.key(), object);
- }
-
- return true;
+ /*
+ {
+ "objects": {
+ "icons/icon_16x16.png": {
+ "hash": "bdf48ef6b5d0d23bbb02e17d04865216179f510a",
+ "size": 3665
+ },
+ ...
+ }
+ }
+ }
+ */
+
+ QFile file(path);
+
+ // Try to open the file and fail if we can't.
+ // TODO: We should probably report this error to the user.
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ qCritical() << "Failed to read assets index file" << path;
+ return false;
+ }
+ index->id = assetsId;
+
+ // Read the file and close it.
+ QByteArray jsonData = file.readAll();
+ file.close();
+
+ QJsonParseError parseError;
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parseError);
+
+ // Fail if the JSON is invalid.
+ if (parseError.error != QJsonParseError::NoError)
+ {
+ qCritical() << "Failed to parse assets index file:" << parseError.errorString()
+ << "at offset " << QString::number(parseError.offset);
+ return false;
+ }
+
+ // Make sure the root is an object.
+ if (!jsonDoc.isObject())
+ {
+ qCritical() << "Invalid assets index JSON: Root should be an array.";
+ return false;
+ }
+
+ QJsonObject root = jsonDoc.object();
+
+ QJsonValue isVirtual = root.value("virtual");
+ if (!isVirtual.isUndefined())
+ {
+ index->isVirtual = isVirtual.toBool(false);
+ }
+
+ QJsonValue objects = root.value("objects");
+ QVariantMap map = objects.toVariant().toMap();
+
+ for (QVariantMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
+ {
+ // qDebug() << iter.key();
+
+ QVariant variant = iter.value();
+ QVariantMap nested_objects = variant.toMap();
+
+ AssetObject object;
+
+ for (QVariantMap::const_iterator nested_iter = nested_objects.begin();
+ nested_iter != nested_objects.end(); ++nested_iter)
+ {
+ // qDebug() << nested_iter.key() << nested_iter.value().toString();
+ QString key = nested_iter.key();
+ QVariant value = nested_iter.value();
+
+ if (key == "hash")
+ {
+ object.hash = value.toString();
+ }
+ else if (key == "size")
+ {
+ object.size = value.toDouble();
+ }
+ }
+
+ index->objects.insert(iter.key(), object);
+ }
+
+ return true;
}
QDir reconstructAssets(QString assetsId)
{
- QDir assetsDir = QDir("assets/");
- QDir indexDir = QDir(FS::PathCombine(assetsDir.path(), "indexes"));
- QDir objectDir = QDir(FS::PathCombine(assetsDir.path(), "objects"));
- QDir virtualDir = QDir(FS::PathCombine(assetsDir.path(), "virtual"));
-
- QString indexPath = FS::PathCombine(indexDir.path(), assetsId + ".json");
- QFile indexFile(indexPath);
- QDir virtualRoot(FS::PathCombine(virtualDir.path(), assetsId));
-
- if (!indexFile.exists())
- {
- qCritical() << "No assets index file" << indexPath << "; can't reconstruct assets";
- return virtualRoot;
- }
-
- qDebug() << "reconstructAssets" << assetsDir.path() << indexDir.path()
- << objectDir.path() << virtualDir.path() << virtualRoot.path();
-
- AssetsIndex index;
- bool loadAssetsIndex = AssetsUtils::loadAssetsIndexJson(assetsId, indexPath, &index);
-
- if (loadAssetsIndex && index.isVirtual)
- {
- qDebug() << "Reconstructing virtual assets folder at" << virtualRoot.path();
-
- for (QString map : index.objects.keys())
- {
- AssetObject asset_object = index.objects.value(map);
- QString target_path = FS::PathCombine(virtualRoot.path(), map);
- QFile target(target_path);
-
- QString tlk = asset_object.hash.left(2);
-
- QString original_path = FS::PathCombine(objectDir.path(), tlk, asset_object.hash);
- QFile original(original_path);
- if (!original.exists())
- continue;
- if (!target.exists())
- {
- QFileInfo info(target_path);
- QDir target_dir = info.dir();
- // qDebug() << target_dir;
- if (!target_dir.exists())
- QDir("").mkpath(target_dir.path());
-
- bool couldCopy = original.copy(target_path);
- qDebug() << " Copying" << original_path << "to" << target_path
- << QString::number(couldCopy); // << original.errorString();
- }
- }
-
- // TODO: Write last used time to virtualRoot/.lastused
- }
-
- return virtualRoot;
+ QDir assetsDir = QDir("assets/");
+ QDir indexDir = QDir(FS::PathCombine(assetsDir.path(), "indexes"));
+ QDir objectDir = QDir(FS::PathCombine(assetsDir.path(), "objects"));
+ QDir virtualDir = QDir(FS::PathCombine(assetsDir.path(), "virtual"));
+
+ QString indexPath = FS::PathCombine(indexDir.path(), assetsId + ".json");
+ QFile indexFile(indexPath);
+ QDir virtualRoot(FS::PathCombine(virtualDir.path(), assetsId));
+
+ if (!indexFile.exists())
+ {