Remove more prototype not good code

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-04-06 19:24:19 +01:00
parent 073aaf9b3b
commit d7a137ad13
2 changed files with 15 additions and 9 deletions

View File

@ -37,7 +37,13 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
InstancePtr instance, InstancePtr instance,
const QString& output, const QString& output,
MMCZip::FilterFunction filter) MMCZip::FilterFunction filter)
: name(name), version(version), summary(summary), instance(instance), output(output), filter(filter) : name(name)
, version(version)
, summary(summary)
, instance(instance)
, mcInstance(dynamic_cast<const MinecraftInstance*>(instance.get()))
, output(output)
, filter(filter)
{} {}
void ModrinthPackExportTask::executeTask() void ModrinthPackExportTask::executeTask()
@ -73,17 +79,15 @@ void ModrinthPackExportTask::collectFiles()
pendingHashes.clear(); pendingHashes.clear();
resolvedFiles.clear(); resolvedFiles.clear();
const MinecraftInstance* mcInstance = dynamic_cast<const MinecraftInstance*>(instance.get()); if (mcInstance) {
auto mods = mcInstance->loaderModList(); mcInstance->loaderModList()->update();
mods->update(); connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
connect(mods.get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes); } else
collectHashes();
} }
void ModrinthPackExportTask::collectHashes() void ModrinthPackExportTask::collectHashes()
{ {
const MinecraftInstance* mcInstance = dynamic_cast<const MinecraftInstance*>(instance.get());
auto mods = mcInstance->loaderModList();
QDir mc(instance->gameRoot()); QDir mc(instance->gameRoot());
for (QFileInfo file : files) { for (QFileInfo file : files) {
QString relative = mc.relativeFilePath(file.absoluteFilePath()); QString relative = mc.relativeFilePath(file.absoluteFilePath());
@ -110,7 +114,7 @@ void ModrinthPackExportTask::collectHashes()
} }
hash.addData(data); hash.addData(data);
auto allMods = mods->allMods(); auto allMods = mcInstance->loaderModList()->allMods();
if (auto modIter = std::find_if(allMods.begin(), allMods.end(), [&file](Mod* mod) { return mod->fileinfo() == file; }); if (auto modIter = std::find_if(allMods.begin(), allMods.end(), [&file](Mod* mod) { return mod->fileinfo() == file; });
modIter != allMods.end()) { modIter != allMods.end()) {
Mod* mod = *modIter; Mod* mod = *modIter;

View File

@ -20,6 +20,7 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "MMCZip.h" #include "MMCZip.h"
#include "minecraft/MinecraftInstance.h"
#include "modplatform/modrinth/ModrinthAPI.h" #include "modplatform/modrinth/ModrinthAPI.h"
#include "tasks/Task.h" #include "tasks/Task.h"
@ -48,6 +49,7 @@ class ModrinthPackExportTask : public Task {
// inputs // inputs
const QString name, version, summary; const QString name, version, summary;
const InstancePtr instance; const InstancePtr instance;
const MinecraftInstance* mcInstance;
const QString output; const QString output;
const MMCZip::FilterFunction filter; const MMCZip::FilterFunction filter;