diff --git a/launcher/Application.cpp b/launcher/Application.cpp index e87fe87b6..7eec56ed9 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -268,11 +268,11 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QSt std::tuple readLockFile(const QString& path) { - auto rsp = FS::read(path); - if (!rsp) { - unrecoverable("Failed to read lock file: " + rsp.error()); + auto res = FS::read(path); + if (!res) { + unrecoverable("Failed to read lock file: " + res.error()); } - auto contents = QString(rsp.value()); + auto contents = QString(res.value()); auto lines = contents.split('\n'); QDateTime timestamp; @@ -1114,11 +1114,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) auto msgBox = QMessageBox(QMessageBox::Warning, tr("Update In Progress"), infoMsg, QMessageBox::Ignore | QMessageBox::Abort); msgBox.setDefaultButton(QMessageBox::Abort); msgBox.setModal(true); - auto rsp = FS::read(updateLogPath); - if (!rsp) { - unrecoverable("Failed to read update log: " + rsp.error()); + auto maybeRes = FS::read(updateLogPath); + if (!maybeRes) { + unrecoverable("Failed to read update log: " + maybeRes.error()); } - msgBox.setDetailedText(rsp.value()); + msgBox.setDetailedText(maybeRes.value()); msgBox.setMinimumWidth(460); msgBox.adjustSize(); auto res = msgBox.exec(); @@ -1150,11 +1150,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) auto msgBox = QMessageBox(QMessageBox::Warning, tr("Update Failed"), infoMsg, QMessageBox::Ignore | QMessageBox::Abort); msgBox.setDefaultButton(QMessageBox::Abort); msgBox.setModal(true); - auto rsp = FS::read(updateLogPath); - if (!rsp) { - unrecoverable("Failed to read update log: " + rsp.error()); + auto maybeRes = FS::read(updateLogPath); + if (!maybeRes) { + unrecoverable("Failed to read update log: " + maybeRes.error()); } - msgBox.setDetailedText(rsp.value()); + msgBox.setDetailedText(maybeRes.value()); msgBox.setMinimumWidth(460); msgBox.adjustSize(); auto res = msgBox.exec(); @@ -1185,11 +1185,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) .arg(updateLogPath); auto* msgBox = new QMessageBox(QMessageBox::Information, tr("Update Succeeded"), infoMsg, QMessageBox::Ok); msgBox->setDefaultButton(QMessageBox::Ok); - auto rsp = FS::read(updateLogPath); - if (!rsp) { - unrecoverable("Failed to read update log: " + rsp.error()); + auto res = FS::read(updateLogPath); + if (!res) { + unrecoverable("Failed to read update log: " + res.error()); } - msgBox->setDetailedText(rsp.value()); + msgBox->setDetailedText(res.value()); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setMinimumWidth(460); msgBox->adjustSize(); @@ -1461,9 +1461,9 @@ Application::~Application() void Application::messageReceived(const QByteArray& message) { ApplicationMessage received; - auto rsp = received.parse(message); - if (!rsp) { - qWarning() << "Received invalid message:" << rsp.error(); + auto res = received.parse(message); + if (!res) { + qWarning() << "Received invalid message:" << res.error(); return; } diff --git a/launcher/FileIgnoreProxy.cpp b/launcher/FileIgnoreProxy.cpp index c7c3d8b55..913fe03fa 100644 --- a/launcher/FileIgnoreProxy.cpp +++ b/launcher/FileIgnoreProxy.cpp @@ -295,8 +295,8 @@ void FileIgnoreProxy::loadBlockedPathsFromFile(const QString& fileName) void FileIgnoreProxy::saveBlockedPathsToFile(const QString& fileName) { auto ignoreData = blockedPaths().toStringList().join('\n').toUtf8(); - auto rsp = FS::write(fileName, ignoreData); - if (!rsp) { - qWarning() << rsp.error(); + auto res = FS::write(fileName, ignoreData); + if (!res) { + qWarning() << res.error(); } } diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 0513545f8..a775679ee 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -189,9 +189,9 @@ namespace FS { Result<> write(const QString& filename, const QByteArray& data) { - auto rsp = ensureExists(QFileInfo(filename).dir()); - if (!rsp) { - return rsp; + auto res = ensureExists(QFileInfo(filename).dir()); + if (!res) { + return res; } PSaveFile file(filename); if (!file.open(PSaveFile::WriteOnly)) { @@ -208,9 +208,9 @@ Result<> write(const QString& filename, const QByteArray& data) Result<> appendSafe(const QString& filename, const QByteArray& data) { - auto rsp = ensureExists(QFileInfo(filename).dir()); - if (!rsp) { - return rsp; + auto res = ensureExists(QFileInfo(filename).dir()); + if (!res) { + return res; } QByteArray buffer; @@ -234,9 +234,9 @@ Result<> appendSafe(const QString& filename, const QByteArray& data) Result<> append(const QString& filename, const QByteArray& data) { - auto rsp = ensureExists(QFileInfo(filename).dir()); - if (!rsp) { - return rsp; + auto res = ensureExists(QFileInfo(filename).dir()); + if (!res) { + return res; } QFile file(filename); if (!file.open(QFile::Append)) { diff --git a/launcher/InstanceCopyTask.cpp b/launcher/InstanceCopyTask.cpp index 3ca3e63f3..1eb8d753b 100644 --- a/launcher/InstanceCopyTask.cpp +++ b/launcher/InstanceCopyTask.cpp @@ -162,11 +162,11 @@ void InstanceCopyTask::copyFinished() QByteArray allowedSymlinks; if (allowedSymlinksFile.exists()) { - auto rsp = FS::read(allowedSymlinksFile.filePath()); - if (!rsp) { - qCritical() << "Failed to read symlink" << rsp.error(); + auto res = FS::read(allowedSymlinksFile.filePath()); + if (!res) { + qCritical() << "Failed to read symlink" << res.error(); } else { - allowedSymlinks.append(rsp.value()); + allowedSymlinks.append(res.value()); if (allowedSymlinks.right(1) != "\n") { allowedSymlinks.append("\n"); // we want to be on a new line } @@ -180,9 +180,9 @@ void InstanceCopyTask::copyFinished() .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link. } - auto rsp = FS::write(allowedSymlinksFile.filePath(), allowedSymlinks); - if (!rsp) { - qCritical() << "Failed to write symlink :" << rsp.error(); + auto res = FS::write(allowedSymlinksFile.filePath(), allowedSymlinks); + if (!res) { + qCritical() << "Failed to write symlink :" << res.error(); } } diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 567ce8d40..b3bc2020f 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -791,9 +791,9 @@ void InstanceList::saveGroupList() toplevel.insert("ungrouped", ungrouped); } QJsonDocument doc(toplevel); - auto rsp = FS::write(groupFileName, doc.toJson()); - if (!rsp) { - qCritical() << "Failed to write instance group file :" << rsp.error(); + auto res = FS::write(groupFileName, doc.toJson()); + if (!res) { + qCritical() << "Failed to write instance group file :" << res.error(); } else { qDebug() << "Group list saved."; } @@ -822,12 +822,12 @@ void InstanceList::loadGroupList() migratingLegacyGroups = true; } - auto rsp = FS::read(groupFileName); - if (!rsp) { - qCritical() << "Failed to read instance group file :" << rsp.error(); + auto res = FS::read(groupFileName); + if (!res) { + qCritical() << "Failed to read instance group file :" << res.error(); return; } - const auto& jsonData = rsp.value(); + const auto& jsonData = res.value(); auto jsonDoc = Json::requireObject(jsonData); diff --git a/launcher/meta/BaseEntity.cpp b/launcher/meta/BaseEntity.cpp index 69b6387e3..858046f36 100644 --- a/launcher/meta/BaseEntity.cpp +++ b/launcher/meta/BaseEntity.cpp @@ -107,10 +107,10 @@ void BaseEntityLoadTask::executeTask() if (m_entity->m_load_status == BaseEntity::LoadStatus::NotLoaded || m_entity->m_file_sha256.isEmpty()) { setStatus(tr("Loading local file")); - auto rsp = FS::read(fname); - TRY(rsp) + auto res = FS::read(fname); + TRY(res) - fileData = rsp.value(); + fileData = res.value(); m_entity->m_file_sha256 = Hashing::hash(fileData, Hashing::Algorithm::Sha256); } @@ -129,9 +129,9 @@ void BaseEntityLoadTask::executeTask() } return {}; }; - auto rsp = parse(); - if (!rsp) { - qCritical() << QString("Unable to parse file %1: %2").arg(fname, rsp.error()); + auto res = parse(); + if (!res) { + qCritical() << QString("Unable to parse file %1: %2").arg(fname, res.error()); // just make sure it's gone and we never consider it again. FS::deletePath(fname); m_entity->m_load_status = BaseEntity::LoadStatus::NotLoaded; diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 9890a1ba7..cbf09b5d7 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1090,8 +1090,8 @@ QString MinecraftInstance::getStatusbarDescription() QString mcVersion = m_components->getComponentVersion("net.minecraft"); if (mcVersion.isEmpty()) { // Load component info if needed - if (auto rsp = m_components->reload(Net::Mode::Offline); !rsp) { - qWarning() << "Failed to reload components:" << rsp.error(); + if (auto res = m_components->reload(Net::Mode::Offline); !res) { + qWarning() << "Failed to reload components:" << res.error(); } mcVersion = m_components->getComponentVersion("net.minecraft"); } diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp index d2c028b85..0979a43a1 100644 --- a/launcher/minecraft/OneSixVersionFormat.cpp +++ b/launcher/minecraft/OneSixVersionFormat.cpp @@ -54,9 +54,9 @@ Result<> optionalString(const QJsonObject& root, const QString& key, QString& va Result OneSixVersionFormat::libraryFromJson(ProblemContainer& problems, const QJsonObject& libObj, const QString& filename) { - auto rsp = MojangVersionFormat::libraryFromJson(problems, libObj, filename); - TRY(rsp) - auto out = rsp.value(); + auto res = MojangVersionFormat::libraryFromJson(problems, libObj, filename); + TRY(res) + auto out = res.value(); TRY(optionalString(libObj, "MMC-hint", out->m_hint)) TRY(optionalString(libObj, "MMC-absulute_url", out->m_absoluteURL)) TRY(optionalString(libObj, "MMC-absoluteUrl", out->m_absoluteURL)) diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 53def62f4..1b1a87c1b 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -222,10 +222,10 @@ Result<> loadPackProfile(PackProfile* parent, const QString& filename, Component } return {}; }; - if (auto rsp = parse(); !rsp) { + if (auto res = parse(); !res) { auto message = QObject::tr("Couldn't parse %1 : bad file format").arg(componentsFile.fileName()); qCCritical(instanceProfileC) << message; - qCWarning(instanceProfileC) << "error:" << rsp.error(); + qCWarning(instanceProfileC) << "error:" << res.error(); container.clear(); return std::unexpected(message); } diff --git a/launcher/minecraft/ProfileUtils.cpp b/launcher/minecraft/ProfileUtils.cpp index 19eb231c8..115854ad8 100644 --- a/launcher/minecraft/ProfileUtils.cpp +++ b/launcher/minecraft/ProfileUtils.cpp @@ -58,11 +58,11 @@ VersionFilePtr createErrorVersionFile(QString fileId, QString filepath, const QS VersionFilePtr guardedParseJson(const QJsonDocument& doc, const QString& fileId, const QString& filepath, const bool& requireOrder) { - auto rsp = OneSixVersionFormat::versionFileFromJson(doc, filepath, requireOrder); - if (!rsp) { - return createErrorVersionFile(fileId, filepath, rsp.error()); + auto res = OneSixVersionFormat::versionFileFromJson(doc, filepath, requireOrder); + if (!res) { + return createErrorVersionFile(fileId, filepath, res.error()); } - return rsp.value(); + return res.value(); } } // namespace diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index f3dc1a3fb..22f248fc5 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -539,7 +539,7 @@ bool ModFolderModel::deleteResources(const QModelIndexList& indexes) } } }; - auto rsp = ResourceFolderModel::deleteResources(indexes); + auto res = ResourceFolderModel::deleteResources(indexes); for (auto* mod : allMods()) { auto id = mod->mod_id(); deleteInvalid(m_requiredBy[id]); @@ -551,5 +551,5 @@ bool ModFolderModel::deleteResources(const QModelIndexList& indexes) emit dataChanged(index(row, RequiresColumn), index(row, RequiredByColumn)); } } - return rsp; + return res; } diff --git a/launcher/minecraft/skins/SkinList.cpp b/launcher/minecraft/skins/SkinList.cpp index c4497c4de..ca3a4361c 100644 --- a/launcher/minecraft/skins/SkinList.cpp +++ b/launcher/minecraft/skins/SkinList.cpp @@ -361,9 +361,9 @@ void SkinList::save() arr << s.toJSON(); } doc["skins"] = arr; - auto rsp = Json::write(doc, m_dir.absoluteFilePath("index.json")); - if (!rsp) { - qCritical() << "Failed to write skin index file :" << rsp.error(); + auto res = Json::write(doc, m_dir.absoluteFilePath("index.json")); + if (!res) { + qCritical() << "Failed to write skin index file :" << res.error(); } } diff --git a/launcher/modplatform/EnsureMetadataTask.cpp b/launcher/modplatform/EnsureMetadataTask.cpp index d5f6cc6a8..73adf3f18 100644 --- a/launcher/modplatform/EnsureMetadataTask.cpp +++ b/launcher/modplatform/EnsureMetadataTask.cpp @@ -261,8 +261,8 @@ Task::Ptr EnsureMetadataTask::modrinthVersionsTask() m_tempVersions.insert(hash, version.value()); return {}; }; - if (auto rsp = parse(); !rsp) { - qDebug() << rsp.error(); + if (auto res = parse(); !res) { + qDebug() << res.error(); qDebug() << entries; emitFail(resource); @@ -334,8 +334,8 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask() updateMetadata(pack, m_tempVersions.find(hash).value(), resource); return {}; }; - if (auto rsp = parse(); !rsp) { - qWarning() << rsp.error(); + if (auto res = parse(); !res) { + qWarning() << res.error(); qWarning() << *doc; continue; } diff --git a/launcher/modplatform/ResourceAPI.cpp b/launcher/modplatform/ResourceAPI.cpp index 47cc48d52..0628b1445 100644 --- a/launcher/modplatform/ResourceAPI.cpp +++ b/launcher/modplatform/ResourceAPI.cpp @@ -173,8 +173,8 @@ Task::Ptr ResourceAPI::getProjectInfo(const ProjectInfoArgs& args, return loadExtraPackInfo(*pack, obj); }; - if (auto rsp = parse(); !rsp) { - qWarning() << "Error while reading" << debugName() << "resource info:" << rsp.error(); + if (auto res = parse(); !res) { + qWarning() << "Error while reading" << debugName() << "resource info:" << res.error(); return; } diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp index 0525ce231..d32541103 100644 --- a/launcher/modplatform/flame/FileResolvingTask.cpp +++ b/launcher/modplatform/flame/FileResolvingTask.cpp @@ -163,8 +163,8 @@ void Flame::FileResolvingTask::netJobFinished(QByteArray* response) qDebug() << "Found alternative on modrinth" << out.version.fileName; return {}; }; - if (auto rsp = parse(); !rsp) { - qDebug() << rsp.error(); + if (auto res = parse(); !res) { + qDebug() << res.error(); qDebug() << entries; continue; } @@ -204,9 +204,7 @@ void Flame::FileResolvingTask::getFlameProjects() auto stepProgress2 = std::make_shared(); connect(m_task.get(), &Task::succeeded, this, [this, response, stepProgress2] { - auto doc = Json::requireObject(*response).and_then([](const auto& v) { - return Json::requireArray(v, "data"); - }); + auto doc = Json::requireObject(*response).and_then([](const auto& v) { return Json::requireArray(v, "data"); }); if (!doc) { qWarning() << "Error while parsing CurseForge projects response:" << doc.error(); qWarning() << *response; diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp index 9c4fb5f33..cab2d8db7 100644 --- a/launcher/modplatform/flame/FlameAPI.cpp +++ b/launcher/modplatform/flame/FlameAPI.cpp @@ -213,9 +213,7 @@ QList FlameAPI::loadModCategories(const QByteArray& respo { QList categories; auto parse = [&response, &categories] -> Result<> { - auto doc = Json::requireObject(response).and_then([](const auto& v) { - return Json::requireArray(v, "data"); - }); + auto doc = Json::requireObject(response).and_then([](const auto& v) { return Json::requireArray(v, "data"); }); TRY(doc) for (auto val : doc.value()) { @@ -229,8 +227,8 @@ QList FlameAPI::loadModCategories(const QByteArray& respo } return {}; }; - if (auto rsp = parse(); !rsp) { - qCritical() << "Failed to parse response from categories:" << rsp.error(); + if (auto res = parse(); !res) { + qCritical() << "Failed to parse response from categories:" << res.error(); qDebug() << response; } return categories; diff --git a/launcher/modplatform/flame/FlameCheckUpdate.cpp b/launcher/modplatform/flame/FlameCheckUpdate.cpp index 267c716eb..eee09ffb3 100644 --- a/launcher/modplatform/flame/FlameCheckUpdate.cpp +++ b/launcher/modplatform/flame/FlameCheckUpdate.cpp @@ -75,8 +75,8 @@ void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* TRY(arr) return FlameMod::loadIndexedPackVersions(*pack.get(), arr.value()); }; - if (auto rsp = parse(); !rsp) { - qWarning() << "Error while parsing JSON response from latest mod version:" << rsp.error(); + if (auto res = parse(); !res) { + qWarning() << "Error while parsing JSON response from latest mod version:" << res.error(); qWarning() << *response; return; } @@ -175,15 +175,15 @@ void FlameCheckUpdate::collectBlockedMods() setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(resource->name())); ModPlatform::IndexedPack pack; - auto rsp = FlameMod::loadIndexedPack(pack, entryObj.value()); - TRY(rsp) + auto res = FlameMod::loadIndexedPack(pack, entryObj.value()); + TRY(res) auto recoverUrl = QString("%1/download/%2").arg(pack.websiteUrl, m_blocked[resource]); emit checkFailed(resource, tr("Resource has a new update available, but is not downloadable using CurseForge."), recoverUrl); return {}; }; - if (auto rsp = parse(); !rsp) { - qDebug() << rsp.error(); + if (auto res = parse(); !res) { + qDebug() << res.error(); qDebug() << *doc; continue; } diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index 927881ae8..b6b51537c 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -164,9 +164,9 @@ void FlameCreationTask::executeTask() if (oldIndexFile.exists()) { Flame::Manifest oldPack; - auto rsp = Flame::loadManifest(oldPack, oldIndexPath); - if (!rsp) { - qWarning() << "Error while parsing old manifest: " << rsp.error(); + auto res = Flame::loadManifest(oldPack, oldIndexPath); + if (!res) { + qWarning() << "Error while parsing old manifest: " << res.error(); } auto oldFiles = oldPack.files; @@ -247,8 +247,8 @@ void FlameCreationTask::executeTask() oldFiles.insert(id.value(), file); return {}; }; - if (auto rsp = parse(); !rsp) { - qCritical() << rsp.error(); + if (auto res = parse(); !res) { + qCritical() << res.error(); break; } } @@ -381,9 +381,9 @@ void FlameCreationTask::createInstance() const QString indexPath(FS::PathCombine(m_stagingPath, "manifest.json")); if (!m_pack.isLoaded) { - auto rsp = Flame::loadManifest(m_pack, indexPath); - if (!rsp) { - emitFailed(tr("Could not understand pack manifest:\n") + rsp.error()); + auto res = Flame::loadManifest(m_pack, indexPath); + if (!res) { + emitFailed(tr("Could not understand pack manifest:\n") + res.error()); return; } } diff --git a/launcher/modplatform/flame/FlamePackExportTask.cpp b/launcher/modplatform/flame/FlamePackExportTask.cpp index 736547a20..0dbe17161 100644 --- a/launcher/modplatform/flame/FlamePackExportTask.cpp +++ b/launcher/modplatform/flame/FlamePackExportTask.cpp @@ -222,8 +222,8 @@ void FlamePackExportTask::makeApiRequest() { .addonId = modid.value(), .version = id.value(), .enabled = mod->enabled, .isMod = mod->isMod }); return {}; }; - if (auto rsp = parse(); !rsp) { - qDebug() << rsp.error(); + if (auto res = parse(); !res) { + qDebug() << res.error(); qDebug() << *doc; break; } @@ -306,8 +306,8 @@ void FlamePackExportTask::getProjectsInfo() } return {}; }; - if (auto rsp = parse(); !rsp) { - qDebug() << rsp.error(); + if (auto res = parse(); !res) { + qDebug() << res.error(); qDebug() << *doc; continue; } diff --git a/launcher/modplatform/import_ftb/PackHelpers.cpp b/launcher/modplatform/import_ftb/PackHelpers.cpp index de56d4fdc..27d07583c 100644 --- a/launcher/modplatform/import_ftb/PackHelpers.cpp +++ b/launcher/modplatform/import_ftb/PackHelpers.cpp @@ -96,8 +96,8 @@ Result parseDirectory(const QString& path) } } if (!modpack.loaderType.has_value()) { - if (auto rsp = legacyInstanceParsing(path, &modpack.loaderType, &modpack.loaderVersion); !rsp) { - qDebug() << rsp.error(); + if (auto res = legacyInstanceParsing(path, &modpack.loaderType, &modpack.loaderVersion); !res) { + qDebug() << res.error(); } } diff --git a/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp b/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp index 09eade3ea..82faed93f 100644 --- a/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp +++ b/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp @@ -43,13 +43,13 @@ namespace LegacyFTB { void PrivatePackManager::load() { - auto rsp = FS::read(m_filename); - if (!rsp) { + auto res = FS::read(m_filename); + if (!res) { currentPacks = {}; qWarning() << "Failed to read third party FTB pack codes from" << m_filename; return; } - auto foo = QString::fromUtf8(rsp.value()).split('\n', Qt::SkipEmptyParts); + auto foo = QString::fromUtf8(res.value()).split('\n', Qt::SkipEmptyParts); currentPacks = QSet(foo.begin(), foo.end()); dirty = false; @@ -61,8 +61,8 @@ void PrivatePackManager::save() const return; } QStringList list = currentPacks.values(); - auto rsp = FS::write(m_filename, list.join('\n').toUtf8()); - if (!rsp) { + auto res = FS::write(m_filename, list.join('\n').toUtf8()); + if (!res) { qWarning() << "Failed to write third party FTB pack codes to" << m_filename; return; } diff --git a/launcher/modplatform/modrinth/ModrinthAPI.cpp b/launcher/modplatform/modrinth/ModrinthAPI.cpp index 9a28d3559..a718c5057 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.cpp +++ b/launcher/modplatform/modrinth/ModrinthAPI.cpp @@ -184,8 +184,8 @@ QList ModrinthAPI::loadCategories(const QByteArray& respo } return {}; }; - if (auto rsp = parse(); !rsp) { - qWarning() << "Error while parsing JSON response from categories:" << rsp.error(); + if (auto res = parse(); !res) { + qWarning() << "Error while parsing JSON response from categories:" << res.error(); qWarning() << response; } return categories; diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index ba45f2208..0bf445728 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -412,8 +412,8 @@ bool ModrinthCreationTask::parseManifest(const QString& indexPath, std::vector& languages) { auto parse = [&languages, &path] -> Result<> { - auto rsp = Json::requireObject(path); - TRY(rsp) + auto res = Json::requireObject(path); + TRY(res) - const auto& doc = rsp.value(); + const auto& doc = res.value(); auto fileType = Json::requireString(doc, "file_type"); TRY(fileType) if (fileType.value() != "MMC-TRANSLATION-INDEX") { @@ -258,8 +258,8 @@ void readIndex(const QString& path, QMap& languages) } return {}; }; - if (auto rsp = parse(); !rsp) { - qCritical() << "Translations Download Failed:" << rsp.error(); + if (auto res = parse(); !res) { + qCritical() << "Translations Download Failed:" << res.error(); } } } // namespace diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp index 376be1544..7e7b47c99 100644 --- a/launcher/ui/GuiUtil.cpp +++ b/launcher/ui/GuiUtil.cpp @@ -89,9 +89,9 @@ bool GuiUtil::isUploadCanceled(const Result& result) Result GuiUtil::uploadPaste(const QString& name, const QFileInfo& filePath, QWidget* parentWidget) { - auto rsp = FS::read(filePath.absoluteFilePath()); - TRY(rsp) - return uploadPaste(name, rsp.value(), parentWidget); + auto res = FS::read(filePath.absoluteFilePath()); + TRY(res) + return uploadPaste(name, res.value(), parentWidget); }; Result GuiUtil::uploadPaste(const QString& name, const QString& data, QWidget* parentWidget) diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp index adf7387de..6163c3f74 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.cpp +++ b/launcher/ui/dialogs/ExportToModListDialog.cpp @@ -169,9 +169,9 @@ void ExportToModListDialog::done(int result) return; } - auto rsp = FS::write(output, ui->finalText->toPlainText().toUtf8()); - if (!rsp) { - qCritical() << "Failed to save mod list file :" << rsp.error(); + auto res = FS::write(output, ui->finalText->toPlainText().toUtf8()); + if (!res) { + qCritical() << "Failed to save mod list file :" << res.error(); } } diff --git a/launcher/ui/pages/instance/McClient.cpp b/launcher/ui/pages/instance/McClient.cpp index ace4e5617..370e601fe 100644 --- a/launcher/ui/pages/instance/McClient.cpp +++ b/launcher/ui/pages/instance/McClient.cpp @@ -122,12 +122,12 @@ void McClient::readRawResponse() m_resp.append(m_socket.readAll()); if (m_responseReadState == ResponseReadState::Waiting && m_resp.size() >= 5) { - auto rsp = readVarInt(m_resp); - if (!rsp) { - emitFail(rsp.error()); + auto res = readVarInt(m_resp); + if (!res) { + emitFail(res.error()); return; } - m_wantedRespLength = *rsp; + m_wantedRespLength = *res; m_responseReadState = ResponseReadState::GotLength; } diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 414388ce8..e721e5a43 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -365,8 +365,8 @@ CoreModFolderPage::CoreModFolderPage(MinecraftInstance* inst, ModFolderModel* mo if ((version != nullptr) && version->getComponent("net.minecraftforge") && version->getComponent("net.minecraft")) { auto minecraftCmp = version->getComponent("net.minecraft"); if (!minecraftCmp->m_loaded) { - if (auto rsp = version->reload(Net::Mode::Offline); !rsp) { - qWarning() << "Failed to reload components:" << rsp.error(); + if (auto res = version->reload(Net::Mode::Offline); !res) { + qWarning() << "Failed to reload components:" << res.error(); } auto update = version->getCurrentTask(); if (update) { diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp index 48857620f..a4bd18dfc 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.cpp +++ b/launcher/ui/pages/instance/OtherLogsPage.cpp @@ -355,9 +355,9 @@ void OtherLogsPage::reload() void OtherLogsPage::on_btnPaste_clicked() { QString name = m_currentFile.isEmpty() ? displayName() : m_currentFile; - auto rsp = GuiUtil::uploadPaste(name, ui->text->toPlainText(), this); - if (!rsp && !GuiUtil::isUploadCanceled(rsp)) { - qWarning() << "Log upload failed:" << rsp.error(); + auto res = GuiUtil::uploadPaste(name, ui->text->toPlainText(), this); + if (!res && !GuiUtil::isUploadCanceled(res)) { + qWarning() << "Log upload failed:" << res.error(); } } diff --git a/launcher/ui/pages/instance/ServerPingTask.cpp b/launcher/ui/pages/instance/ServerPingTask.cpp index 408f30bc3..5e2e98761 100644 --- a/launcher/ui/pages/instance/ServerPingTask.cpp +++ b/launcher/ui/pages/instance/ServerPingTask.cpp @@ -9,12 +9,12 @@ namespace { unsigned getOnlinePlayers(const QJsonObject& data) { - auto rsp = Json::requireObject(data, "players").and_then([](const auto& v) { return Json::requireInteger(v, "online"); }); - if (!rsp) { - qWarning() << "server ping failed to parse response" << rsp.error(); + auto res = Json::requireObject(data, "players").and_then([](const auto& v) { return Json::requireInteger(v, "online"); }); + if (!res) { + qWarning() << "server ping failed to parse response" << res.error(); return 0; } - return rsp.value(); + return res.value(); } } // namespace diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp index 3739b9d46..0c9cd2a3d 100644 --- a/launcher/ui/pages/instance/ServersPage.cpp +++ b/launcher/ui/pages/instance/ServersPage.cpp @@ -118,11 +118,11 @@ struct Server { static std::unique_ptr parseServersDat(const QString& filename) { try { - auto rsp = FS::read(filename); - if (!rsp) { + auto res = FS::read(filename); + if (!res) { return nullptr; } - const auto& input = rsp.value(); + const auto& input = res.value(); std::istringstream foo(std::string(input.constData(), input.size())); auto pair = nbt::io::read_compound(foo); @@ -149,8 +149,8 @@ static bool serializeServerDat(const QString& filename, nbt::tag_compound* level std::ostringstream s; nbt::io::write_tag("", *levelInfo, s); QByteArray val(s.str().data(), (int)s.str().size()); - auto rsp = FS::write(filename, val); - return rsp.has_value(); + auto res = FS::write(filename, val); + return res.has_value(); } catch (...) { return false; } diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp index bd729253e..9bc8b43e4 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp +++ b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp @@ -238,8 +238,8 @@ void Technic::ListModel::searchRequestFinished(QByteArray* responsePtr) } return {}; }; - if (auto rsp = parse(); !rsp) { - qCritical() << "Couldn't parse technic search results:" << rsp.error(); + if (auto res = parse(); !res) { + qCritical() << "Couldn't parse technic search results:" << res.error(); return; } searchState = Finished; diff --git a/launcher/ui/themes/CustomTheme.cpp b/launcher/ui/themes/CustomTheme.cpp index 4daadf72d..a0408ade0 100644 --- a/launcher/ui/themes/CustomTheme.cpp +++ b/launcher/ui/themes/CustomTheme.cpp @@ -65,9 +65,9 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest m_palette = baseTheme->colorScheme(); bool hasCustomLogColors = false; - auto rsp = read(themeFilePath, hasCustomLogColors); - if (!rsp) { - themeWarningLog() << "Couldn't read theme json:" << rsp.error(); + auto res = read(themeFilePath, hasCustomLogColors); + if (!res) { + themeWarningLog() << "Couldn't read theme json:" << res.error(); m_logColors = defaultLogColors(m_palette); m_styleSheet = baseTheme->appStyleSheet(); } else { @@ -109,12 +109,12 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest m_palette = baseTheme->colorScheme(); // TODO: validate qss? - auto rsp = FS::read(path); - if (!rsp) { - themeWarningLog() << "Couldn't load qss:" << rsp.error() << "from" << path; + auto res = FS::read(path); + if (!res) { + themeWarningLog() << "Couldn't load qss:" << res.error() << "from" << path; m_styleSheet = baseTheme->appStyleSheet(); } else { - m_styleSheet = QString::fromUtf8(rsp.value()); + m_styleSheet = QString::fromUtf8(res.value()); } } } diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index bb60bdce7..48c3076e3 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -355,11 +355,11 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar auto markerFilePath = QDir(m_rootPath).absoluteFilePath(".prism_launcher_updater_unpack.marker"); auto markerFile = QFileInfo(markerFilePath); if (markerFile.exists()) { - auto rsp = FS::read(markerFilePath); - if (!rsp) { - unrecoverable("Could not read updater marker file: " + rsp.error()); + auto res = FS::read(markerFilePath); + if (!res) { + unrecoverable("Could not read updater marker file: " + res.error()); } - auto targetDir = QString(rsp.value()).trimmed(); + auto targetDir = QString(res.value()).trimmed(); if (targetDir.isEmpty()) { qWarning() << "Empty updater marker file contains no install target. making best guess of parent dir"; targetDir = QDir(m_rootPath).absoluteFilePath(".."); @@ -515,11 +515,11 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target) if (manifest.isFile()) { // load manifest from file logUpdate(tr("Reading manifest from %1").arg(manifest.absoluteFilePath())); - auto rsp = FS::read(manifest.absoluteFilePath()); - if (!rsp) { - logUpdate(tr("Could not read manifest: %1").arg(rsp.error())); + auto res = FS::read(manifest.absoluteFilePath()); + if (!res) { + logUpdate(tr("Could not read manifest: %1").arg(res.error())); } else { - auto contents = QString::fromUtf8(rsp.value()); + auto contents = QString::fromUtf8(res.value()); auto files = contents.split('\n'); for (const auto& file : files) { fileList.append(file.trimmed()); @@ -812,19 +812,19 @@ void PrismUpdaterApp::clearUpdateLog() void PrismUpdaterApp::logUpdate(const QString& msg) { qDebug() << qUtf8Printable(msg); - auto rsp = FS::append(m_updateLogPath, QStringLiteral("%1\n").arg(msg).toUtf8()); - if (!rsp) { - qWarning() << "Failed to write update log:" << rsp.error(); + auto res = FS::append(m_updateLogPath, QStringLiteral("%1\n").arg(msg).toUtf8()); + if (!res) { + qWarning() << "Failed to write update log:" << res.error(); } } std::tuple read_lock_File(const QString& path) { - auto rsp = FS::read(path); - if (!rsp) { - unrecoverable("Could not read lock file: " + rsp.error()); + auto res = FS::read(path); + if (!res) { + unrecoverable("Could not read lock file: " + res.error()); } - auto contents = QString(rsp.value()); + auto contents = QString(res.value()); auto lines = contents.split('\n'); QDateTime timestamp; @@ -853,15 +853,15 @@ std::tuple read_lock_File(const Q bool write_lock_file(const QString& path, QDateTime timestamp, QString from, QString to, QString target, QString data_path) { - auto rsp = FS::write(path, QStringLiteral("TIMESTAMP=%1\nFROM=%2\nTO=%3\nTARGET=%4\nDATA_PATH=%5\n") + auto res = FS::write(path, QStringLiteral("TIMESTAMP=%1\nFROM=%2\nTO=%3\nTARGET=%4\nDATA_PATH=%5\n") .arg(timestamp.toString(Qt::ISODate)) .arg(from) .arg(to) .arg(target) .arg(data_path) .toUtf8()); - if (!rsp) { - qWarning() << "Error writing lockfile:" << rsp.error(); + if (!res) { + qWarning() << "Error writing lockfile:" << res.error(); return false; } return true; @@ -912,8 +912,8 @@ void PrismUpdaterApp::performInstall(QFileInfo file) clearUpdateLog(); auto changelogPath = FS::PathCombine(m_dataPath, ".prism_launcher_update.changelog"); - if (auto rsp = FS::write(changelogPath, m_install_release.body.toUtf8()); !rsp) { - logUpdate(tr("Failed to write changelog: %1").arg(rsp.error())); + if (auto res = FS::write(changelogPath, m_install_release.body.toUtf8()); !res) { + logUpdate(tr("Failed to write changelog: %1").arg(res.error())); } logUpdate(tr("Updating from %1 to %2").arg(m_prismVersion).arg(m_install_release.tag_name)); @@ -943,8 +943,8 @@ void PrismUpdaterApp::unpackAndInstall(QFileInfo archive) if (auto loc = unpackArchive(archive)) { auto markerFilePath = loc.value().absoluteFilePath(".prism_launcher_updater_unpack.marker"); - if (auto rsp = FS::write(markerFilePath, m_rootPath.toUtf8()); !rsp) { - unrecoverable("Failed to write unpack marker: " + rsp.error()); + if (auto res = FS::write(markerFilePath, m_rootPath.toUtf8()); !res) { + unrecoverable("Failed to write unpack marker: " + res.error()); } QProcess proc = QProcess(); @@ -981,11 +981,11 @@ void PrismUpdaterApp::backupAppDir() // load manifest from file logUpdate(tr("Reading manifest from %1").arg(manifest.absoluteFilePath())); - auto rsp = FS::read(manifest.absoluteFilePath()); - if (!rsp) { - logUpdate(tr("Could not read manifest: %1").arg(rsp.error())); + auto res = FS::read(manifest.absoluteFilePath()); + if (!res) { + logUpdate(tr("Could not read manifest: %1").arg(res.error())); } else { - auto contents = QString::fromUtf8(rsp.value()); + auto contents = QString::fromUtf8(res.value()); auto files = contents.split('\n'); for (const auto& file : files) { file_list.append(file.trimmed()); @@ -1023,8 +1023,8 @@ void PrismUpdaterApp::backupAppDir() QStringLiteral("backup_") + QString(m_prismVersion).replace(s_replaceRegex, QString("_")) + "-" + m_prismGitCommit); FS::ensureFolderPathExists(backup_dir); auto backup_marker_path = FS::PathCombine(m_dataPath, ".prism_launcher_update_backup_path.txt"); - if (auto rsp = FS::write(backup_marker_path, backup_dir.toUtf8()); !rsp) { - unrecoverable("Failed to write backup marker: " + rsp.error()); + if (auto res = FS::write(backup_marker_path, backup_dir.toUtf8()); !res) { + unrecoverable("Failed to write backup marker: " + res.error()); } QProgressDialog progress(tr("Backing up install at %1").arg(m_rootPath), "", 0, file_list.length());