diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-07-07 19:46:56 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-07-07 19:46:56 +0200 |
commit | e5b4b5d2954d72f0323ced8e7d14f5ce9606e4cb (patch) | |
tree | 5baef66192a4d73fbee3ff9652e55b121882ec76 /api/logic/minecraft/legacy/LegacyInstance.cpp | |
parent | fbeceaa98cc252c671ef6a9d26837973cc9bffa3 (diff) | |
download | PrismLauncher-e5b4b5d2954d72f0323ced8e7d14f5ce9606e4cb.tar.gz PrismLauncher-e5b4b5d2954d72f0323ced8e7d14f5ce9606e4cb.tar.bz2 PrismLauncher-e5b4b5d2954d72f0323ced8e7d14f5ce9606e4cb.zip |
GH-1927 Add more specific task status logging
* Tasks are now described by class name and object name (or memory address).
* Tasks starts are logged.
* Aborted tasks are now treated just as the other cases.
Diffstat (limited to 'api/logic/minecraft/legacy/LegacyInstance.cpp')
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.cpp | 124 |
1 files changed, 64 insertions, 60 deletions
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp index 0987d56f..9382ec21 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.cpp +++ b/api/logic/minecraft/legacy/LegacyInstance.cpp @@ -95,85 +95,87 @@ shared_qobject_ptr<Task> LegacyInstance::createUpdateTask() return shared_qobject_ptr<Task>(new LegacyUpdate(this, this)); } -std::shared_ptr<Task> LegacyInstance::createJarModdingTask() +class LegacyJarModTask : public Task { - class JarModTask : public Task + Q_OBJECT +public: + explicit LegacyJarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst) + { + } + virtual void executeTask() { - public: - explicit JarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst) + if (!m_inst->shouldRebuild()) { + emitSucceeded(); + return; } - virtual void executeTask() - { - if (!m_inst->shouldRebuild()) - { - emitSucceeded(); - return; - } - // Get the mod list - auto modList = m_inst->getJarMods(); + // Get the mod list + auto modList = m_inst->getJarMods(); - QFileInfo runnableJar(m_inst->runnableJar()); - QFileInfo baseJar(m_inst->baseJar()); - bool base_is_custom = m_inst->shouldUseCustomBaseJar(); + QFileInfo runnableJar(m_inst->runnableJar()); + QFileInfo baseJar(m_inst->baseJar()); + bool base_is_custom = m_inst->shouldUseCustomBaseJar(); - // Nothing to do if there are no jar mods to install, no backup and just the mc jar - if (base_is_custom) - { - // yes, this can happen if the instance only has the runnable jar and not the base jar - // it *could* be assumed that such an instance is vanilla, but that wouldn't be safe - // because that's not something mmc4 guarantees - if (runnableJar.isFile() && !baseJar.exists() && modList.empty()) - { - m_inst->setShouldRebuild(false); - emitSucceeded(); - return; - } - - setStatus(tr("Installing mods: Backing up minecraft.jar ...")); - if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath())) - { - emitFailed("It seems both the active and base jar are gone. A fresh base jar will " - "be used on next run."); - m_inst->setShouldRebuild(true); - m_inst->setShouldUpdate(true); - m_inst->setShouldUseCustomBaseJar(false); - return; - } - } - - if (!baseJar.exists()) + // Nothing to do if there are no jar mods to install, no backup and just the mc jar + if (base_is_custom) + { + // yes, this can happen if the instance only has the runnable jar and not the base jar + // it *could* be assumed that such an instance is vanilla, but that wouldn't be safe + // because that's not something mmc4 guarantees + if (runnableJar.isFile() && !baseJar.exists() && modList.empty()) { - emitFailed("The base jar " + baseJar.filePath() + " does not exist"); + m_inst->setShouldRebuild(false); + emitSucceeded(); return; } - if (runnableJar.exists() && !QFile::remove(runnableJar.filePath())) + setStatus(tr("Installing mods: Backing up minecraft.jar ...")); + if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath())) { - emitFailed("Failed to delete old minecraft.jar"); + emitFailed("It seems both the active and base jar are gone. A fresh base jar will " + "be used on next run."); + m_inst->setShouldRebuild(true); + m_inst->setShouldUpdate(true); + m_inst->setShouldUseCustomBaseJar(false); return; } + } - setStatus(tr("Installing mods: Opening minecraft.jar ...")); - - QString outputJarPath = runnableJar.filePath(); - QString inputJarPath = baseJar.filePath(); + if (!baseJar.exists()) + { + emitFailed("The base jar " + baseJar.filePath() + " does not exist"); + return; + } - if(!MMCZip::createModdedJar(inputJarPath, outputJarPath, modList)) - { - emitFailed(tr("Failed to create the custom Minecraft jar file.")); - return; - } - m_inst->setShouldRebuild(false); - // inst->UpdateVersion(true); - emitSucceeded(); + if (runnableJar.exists() && !QFile::remove(runnableJar.filePath())) + { + emitFailed("Failed to delete old minecraft.jar"); return; + } + + setStatus(tr("Installing mods: Opening minecraft.jar ...")); + + QString outputJarPath = runnableJar.filePath(); + QString inputJarPath = baseJar.filePath(); + if(!MMCZip::createModdedJar(inputJarPath, outputJarPath, modList)) + { + emitFailed(tr("Failed to create the custom Minecraft jar file.")); + return; } - std::shared_ptr<LegacyInstance> m_inst; - }; - return std::make_shared<JarModTask>(std::dynamic_pointer_cast<LegacyInstance>(shared_from_this())); + m_inst->setShouldRebuild(false); + // inst->UpdateVersion(true); + emitSucceeded(); + return; + + } + std::shared_ptr<LegacyInstance> m_inst; +}; + +std::shared_ptr<Task> LegacyInstance::createJarModdingTask() +{ + return std::make_shared<LegacyJarModTask>(std::dynamic_pointer_cast<LegacyInstance>(shared_from_this())); } QString LegacyInstance::createLaunchScript(AuthSessionPtr session) @@ -515,3 +517,5 @@ QStringList LegacyInstance::processMinecraftArgs(AuthSessionPtr account) const out.append(account->session); return out; } + +#include "LegacyInstance.moc" |