diff options
Diffstat (limited to 'api/logic/minecraft')
108 files changed, 3190 insertions, 2493 deletions
diff --git a/api/logic/minecraft/AssetsUtils.cpp b/api/logic/minecraft/AssetsUtils.cpp index c6db2a40..c01733b6 100644 --- a/api/logic/minecraft/AssetsUtils.cpp +++ b/api/logic/minecraft/AssetsUtils.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2018 MultiMC Contributors +/* Copyright 2013-2021 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,34 @@ #include "FileSystem.h" #include "net/Download.h" #include "net/ChecksumValidator.h" +#include "BuildConfig.h" + +namespace { +QSet<QString> collectPathsFromDir(QString dirPath) +{ + QFileInfo dirInfo(dirPath); + + if (!dirInfo.exists()) + { + return {}; + } + + QSet<QString> out; + + QDirIterator iter(dirPath, QDirIterator::Subdirectories); + while (iter.hasNext()) + { + QString value = iter.next(); + QFileInfo info(value); + if(info.isFile()) + { + out.insert(value); + qDebug() << value; + } + } + return out; +} +} namespace AssetsUtils @@ -36,7 +64,7 @@ namespace AssetsUtils * Returns true on success, with index populated * index is undefined otherwise */ -bool loadAssetsIndexJson(QString assetsId, QString path, AssetsIndex *index) +bool loadAssetsIndexJson(const QString &assetsId, const QString &path, AssetsIndex& index) { /* { @@ -60,7 +88,7 @@ bool loadAssetsIndexJson(QString assetsId, QString path, AssetsIndex *index) qCritical() << "Failed to read assets index file" << path; return false; } - index->id = assetsId; + index.id = assetsId; // Read the file and close it. QByteArray jsonData = file.readAll(); @@ -89,7 +117,13 @@ bool loadAssetsIndexJson(QString assetsId, QString path, AssetsIndex *index) QJsonValue isVirtual = root.value("virtual"); if (!isVirtual.isUndefined()) { - index->isVirtual = isVirtual.toBool(false); + index.isVirtual = isVirtual.toBool(false); + } + + QJsonValue mapToResources = root.value("map_to_resources"); + if (!mapToResources.isUndefined()) + { + index.mapToResources = mapToResources.toBool(false); } QJsonValue objects = root.value("objects"); @@ -121,13 +155,14 @@ bool loadAssetsIndexJson(QString assetsId, QString path, AssetsIndex *index) } } - index->objects.insert(iter.key(), object); + index.objects.insert(iter.key(), object); } |
