diff options
author | flow <flowlnlnln@gmail.com> | 2022-06-26 14:17:15 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-07-17 11:33:44 -0300 |
commit | c4316e81e64ad4ac63b0b50106b324a73abdc150 (patch) | |
tree | 9a9bb56eb95efa78e6f3a13fd618225ccda85908 /launcher/modplatform/modrinth | |
parent | fac63541a4831414b052de6400e7543bbc611db0 (diff) | |
download | PrismLauncher-c4316e81e64ad4ac63b0b50106b324a73abdc150.tar.gz PrismLauncher-c4316e81e64ad4ac63b0b50106b324a73abdc150.tar.bz2 PrismLauncher-c4316e81e64ad4ac63b0b50106b324a73abdc150.zip |
change: make Mod a QObject used as a pointer
Prevents problems when copying it around!
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/modplatform/modrinth')
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp | 34 | ||||
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthCheckUpdate.h | 2 |
2 files changed, 18 insertions, 18 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp index 5d936fec..79d8edf7 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp @@ -27,29 +27,29 @@ void ModrinthCheckUpdate::executeTask() setStatus(tr("Preparing mods for Modrinth...")); setProgress(0, 3); - QHash<QString, Mod> mappings; + QHash<QString, Mod*> mappings; // Create all hashes QStringList hashes; auto best_hash_type = ProviderCaps.hashType(ModPlatform::Provider::MODRINTH).first(); - for (auto mod : m_mods) { - if (!mod.enabled()) { + for (auto* mod : m_mods) { + if (!mod->enabled()) { emit checkFailed(mod, tr("Disabled mods won't be updated, to prevent mod duplication issues!")); continue; } - auto hash = mod.metadata()->hash; + auto hash = mod->metadata()->hash; // Sadly the API can only handle one hash type per call, se we // need to generate a new hash if the current one is innadequate // (though it will rarely happen, if at all) - if (mod.metadata()->hash_format != best_hash_type) { + if (mod->metadata()->hash_format != best_hash_type) { QByteArray jar_data; try { - jar_data = FS::read(mod.fileinfo().absoluteFilePath()); + jar_data = FS::read(mod->fileinfo().absoluteFilePath()); } catch (FS::FileSystemException& e) { - qCritical() << QString("Failed to open / read JAR file of %1").arg(mod.name()); + qCritical() << QString("Failed to open / read JAR file of %1").arg(mod->name()); qCritical() << QString("Reason: ") << e.cause(); failed(e.what()); @@ -90,7 +90,7 @@ void ModrinthCheckUpdate::executeTask() // If the returned project is empty, but we have Modrinth metadata, // it means this specific version is not available if (project_obj.isEmpty()) { - qDebug() << "Mod " << mappings.find(hash).value().name() << " got an empty response."; + qDebug() << "Mod " << mappings.find(hash).value()->name() << " got an empty response."; qDebug() << "Hash: " << hash; emit checkFailed( @@ -134,24 +134,24 @@ void ModrinthCheckUpdate::executeTask() auto mod = *mod_iter; auto key = project_ver.hash; - if ((key != hash && project_ver.is_preferred) || (mod.status() == ModStatus::NotInstalled)) { - if (mod.version() == project_ver.version_number) + if ((key != hash && project_ver.is_preferred) || (mod->status() == ModStatus::NotInstalled)) { + if (mod->version() == project_ver.version_number) continue; // Fake pack with the necessary info to pass to the download task :) ModPlatform::IndexedPack pack; - pack.name = mod.name(); - pack.slug = mod.metadata()->slug; - pack.addonId = mod.metadata()->project_id; - pack.websiteUrl = mod.homeurl(); - for (auto& author : mod.authors()) + pack.name = mod->name(); + pack.slug = mod->metadata()->slug; + pack.addonId = mod->metadata()->project_id; + pack.websiteUrl = mod->homeurl(); + for (auto& author : mod->authors()) pack.authors.append({ author }); - pack.description = mod.description(); + pack.description = mod->description(); pack.provider = ModPlatform::Provider::MODRINTH; auto download_task = new ModDownloadTask(pack, project_ver, m_mods_folder); - m_updatable.emplace_back(mod.name(), hash, mod.version(), project_ver.version_number, project_ver.changelog, + m_updatable.emplace_back(pack.name, hash, mod->version(), project_ver.version_number, project_ver.changelog, ModPlatform::Provider::MODRINTH, download_task); } } diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.h b/launcher/modplatform/modrinth/ModrinthCheckUpdate.h index 7e685a6d..d61667f5 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.h +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.h @@ -8,7 +8,7 @@ class ModrinthCheckUpdate : public CheckUpdateTask { Q_OBJECT public: - ModrinthCheckUpdate(std::list<Mod>& mods, std::list<Version>& mcVersions, ModAPI::ModLoaderTypes loaders, std::shared_ptr<ModFolderModel> mods_folder) + ModrinthCheckUpdate(std::list<Mod*>& mods, std::list<Version>& mcVersions, ModAPI::ModLoaderTypes loaders, std::shared_ptr<ModFolderModel> mods_folder) : CheckUpdateTask(mods, mcVersions, loaders, mods_folder) {} |