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,
const QString& output,
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()
@ -73,17 +79,15 @@ void ModrinthPackExportTask::collectFiles()
pendingHashes.clear();
resolvedFiles.clear();
const MinecraftInstance* mcInstance = dynamic_cast<const MinecraftInstance*>(instance.get());
auto mods = mcInstance->loaderModList();
mods->update();
connect(mods.get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
if (mcInstance) {
mcInstance->loaderModList()->update();
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
} else
collectHashes();
}
void ModrinthPackExportTask::collectHashes()
{
const MinecraftInstance* mcInstance = dynamic_cast<const MinecraftInstance*>(instance.get());
auto mods = mcInstance->loaderModList();
QDir mc(instance->gameRoot());
for (QFileInfo file : files) {
QString relative = mc.relativeFilePath(file.absoluteFilePath());
@ -110,7 +114,7 @@ void ModrinthPackExportTask::collectHashes()
}
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; });
modIter != allMods.end()) {
Mod* mod = *modIter;

View File

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