summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/onesix
diff options
context:
space:
mode:
Diffstat (limited to 'logic/minecraft/onesix')
-rw-r--r--logic/minecraft/onesix/OneSixInstance.cpp5
-rw-r--r--logic/minecraft/onesix/OneSixUpdate.cpp35
2 files changed, 14 insertions, 26 deletions
diff --git a/logic/minecraft/onesix/OneSixInstance.cpp b/logic/minecraft/onesix/OneSixInstance.cpp
index f8b274ff..328c3b38 100644
--- a/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/logic/minecraft/onesix/OneSixInstance.cpp
@@ -125,14 +125,15 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
QString absRootDir = QDir(minecraftRoot()).absolutePath();
token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath();
- token_mapping["game_assets"] = AssetsUtils::reconstructAssets(m_profile->getMinecraftAssets()).absolutePath();
+ auto assets = m_profile->getMinecraftAssets();
+ token_mapping["game_assets"] = AssetsUtils::reconstructAssets(assets->id).absolutePath();
token_mapping["user_properties"] = session->serializeUserProperties();
token_mapping["user_type"] = session->user_type;
// 1.7.3+ assets tokens
token_mapping["assets_root"] = absAssetsDir;
- token_mapping["assets_index_name"] = m_profile->getMinecraftAssets();
+ token_mapping["assets_index_name"] = assets->id;
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
for (int i = 0; i < parts.length(); i++)
diff --git a/logic/minecraft/onesix/OneSixUpdate.cpp b/logic/minecraft/onesix/OneSixUpdate.cpp
index fe1d3a6e..10d1e294 100644
--- a/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -88,9 +88,9 @@ void OneSixUpdate::assetIndexStart()
setStatus(tr("Updating assets index..."));
OneSixInstance *inst = (OneSixInstance *)m_inst;
auto profile = inst->getMinecraftProfile();
- QString assetName = profile->getMinecraftAssets();
- QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
- QString localPath = assetName + ".json";
+ auto assets = profile->getMinecraftAssets();
+ QUrl indexUrl = assets->url;
+ QString localPath = assets->id + ".json";
auto job = new NetJob(tr("Asset index for %1").arg(inst->name()));
auto metacache = ENV.metacache();
@@ -114,36 +114,23 @@ void OneSixUpdate::assetIndexFinished()
OneSixInstance *inst = (OneSixInstance *)m_inst;
auto profile = inst->getMinecraftProfile();
- QString assetName = profile->getMinecraftAssets();
+ auto assets = profile->getMinecraftAssets();
- QString asset_fname = "assets/indexes/" + assetName + ".json";
- if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index))
+ QString asset_fname = "assets/indexes/" + assets->id + ".json";
+ // FIXME: this looks like a job for a generic validator based on json schema?
+ if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, &index))
{
auto metacache = ENV.metacache();
- auto entry = metacache->resolveEntry("asset_indexes", assetName + ".json");
+ auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json");
metacache->evictEntry(entry);
emitFailed(tr("Failed to read the assets index!"));
}
- QList<Md5EtagDownloadPtr> dls;
- for (auto object : index.objects.values())
- {
- QString objectName = object.hash.left(2) + "/" + object.hash;
- QFileInfo objectFile("assets/objects/" + objectName);
- if ((!objectFile.isFile()) || (objectFile.size() != object.size))
- {
- auto objectDL = MD5EtagDownload::make(QUrl("http://" + URLConstants::RESOURCE_BASE + objectName), objectFile.filePath());
- objectDL->m_total_progress = object.size;
- dls.append(objectDL);
- }
- }
- if (dls.size())
+ auto job = index.getDownloadJob();
+ if(job)
{
setStatus(tr("Getting the assets files from Mojang..."));
- auto job = new NetJob(tr("Assets for %1").arg(inst->name()));
- for (auto dl : dls)
- job->addNetAction(dl);
- jarlibDownloadJob.reset(job);
+ jarlibDownloadJob = job;
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
connect(jarlibDownloadJob.get(), &NetJob::failed, this, &OneSixUpdate::assetsFailed);
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));