diff --git a/launcher/include/account.h b/launcher/include/account.h index 4d3009f..1ce7b91 100644 --- a/launcher/include/account.h +++ b/launcher/include/account.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "accountconfig.h" @@ -104,13 +104,13 @@ private: void fetchAvatar(); QCoro::Task<> fetchPassword(); - /* - * Sets a value in the keychain. This function is asynchronous. + /** + * @brief Sets a value in the keychain. This function is asynchronous. */ void setKeychainValue(const QString &key, const QString &value); - /* - * Retrieves a value from the keychain. This function is synchronous. + /** + * @brief Retrieves a value from the keychain. This function is synchronous. */ QCoro::Task getKeychainValue(const QString &key); diff --git a/launcher/include/accountmanager.h b/launcher/include/accountmanager.h index 17d9f4a..1b2c25b 100644 --- a/launcher/include/accountmanager.h +++ b/launcher/include/accountmanager.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include "account.h" @@ -36,7 +35,7 @@ public: [[nodiscard]] Account *getByUuid(const QString &uuid) const; - Q_INVOKABLE bool canDelete(Account *account) const; + Q_INVOKABLE bool canDelete(const Account *account) const; Q_INVOKABLE void deleteAccount(Account *account); Q_INVOKABLE [[nodiscard]] bool hasAnyAccounts() const; diff --git a/launcher/include/assetupdater.h b/launcher/include/assetupdater.h index 0bd59e1..3cd6b98 100644 --- a/launcher/include/assetupdater.h +++ b/launcher/include/assetupdater.h @@ -3,9 +3,6 @@ #pragma once -#include -#include -#include #include #include "launchercore.h" diff --git a/launcher/include/compatibilitytoolinstaller.h b/launcher/include/compatibilitytoolinstaller.h index b2d2dcb..a65db97 100644 --- a/launcher/include/compatibilitytoolinstaller.h +++ b/launcher/include/compatibilitytoolinstaller.h @@ -3,9 +3,7 @@ #pragma once -#include -#include -#include +#include class LauncherCore; diff --git a/launcher/include/existinginstallmodel.h b/launcher/include/existinginstallmodel.h index b135d5f..9b21f54 100644 --- a/launcher/include/existinginstallmodel.h +++ b/launcher/include/existinginstallmodel.h @@ -4,6 +4,7 @@ #pragma once #include + #include class ExistingInstallModel : public QAbstractListModel diff --git a/launcher/include/gameinstaller.h b/launcher/include/gameinstaller.h index c240e3d..cc8b5c1 100644 --- a/launcher/include/gameinstaller.h +++ b/launcher/include/gameinstaller.h @@ -3,9 +3,7 @@ #pragma once -#include -#include -#include +#include class LauncherCore; class Profile; diff --git a/launcher/include/gamerunner.h b/launcher/include/gamerunner.h index a680067..6157810 100644 --- a/launcher/include/gamerunner.h +++ b/launcher/include/gamerunner.h @@ -16,7 +16,7 @@ public: explicit GameRunner(LauncherCore &launcher, QObject *parent = nullptr); /// Begins the game executable, but calls to Dalamud if needed. - void beginGameExecutable(Profile &settings, const std::optional &auth); + void beginGameExecutable(Profile &profile, const std::optional &auth); private: /// Starts a vanilla game session with no Dalamud injection. @@ -26,10 +26,10 @@ private: void beginDalamudGame(const QString &gameExecutablePath, Profile &profile, const std::optional &auth); /// Returns the game arguments needed to properly launch the game. This encrypts it too if needed, and it's already joined! - QString getGameArgs(const Profile &profile, const std::optional &auth); + QString getGameArgs(const Profile &profile, const std::optional &auth) const; /// This wraps it in wine if needed. - void launchExecutable(const Profile &settings, QProcess *process, const QStringList &args, bool isGame, bool needsRegistrySetup); + void launchExecutable(const Profile &profile, QProcess *process, const QStringList &args, bool isGame, bool needsRegistrySetup); /// Set a Wine registry key /// \param settings The profile that's being launched diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 9b60876..be2a257 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -3,9 +3,7 @@ #pragma once -#include #include -#include #include #include @@ -102,11 +100,11 @@ public: Q_INVOKABLE void refreshLogoImage(); [[nodiscard]] Profile *currentProfile() const; - void setCurrentProfile(Profile *profile); + void setCurrentProfile(const Profile *profile); [[nodiscard]] QString autoLoginProfileName() const; [[nodiscard]] Profile *autoLoginProfile() const; - void setAutoLoginProfile(Profile *value); + void setAutoLoginProfile(const Profile *value); // Networking misc. void buildRequest(const Profile &settings, QNetworkRequest &request); diff --git a/launcher/include/launchersettings.h b/launcher/include/launchersettings.h index f1adbf2..946975b 100644 --- a/launcher/include/launchersettings.h +++ b/launcher/include/launchersettings.h @@ -3,8 +3,7 @@ #pragma once -#include -#include +#include #include "config.h" #include "profile.h" diff --git a/launcher/include/patcher.h b/launcher/include/patcher.h index 1bdbf3c..e24a8b0 100644 --- a/launcher/include/patcher.h +++ b/launcher/include/patcher.h @@ -3,14 +3,16 @@ #pragma once -#include "patchlist.h" #include #include #include #include -#include #include +#include + +#include "patchlist.h" + class LauncherCore; // General-purpose patcher routine. It opens a nice dialog box, handles downloading diff --git a/launcher/include/profile.h b/launcher/include/profile.h index 2a19610..4acd358 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -3,9 +3,8 @@ #pragma once -#include -#include -#include +#include + #include class Account; @@ -150,13 +149,13 @@ public: void setDalamudApplicable(bool applicable); /// @return If Dalamud is enabled, and it's also applicable for the current game version. - bool dalamudShouldLaunch() const; + [[nodiscard]] bool dalamudShouldLaunch() const; [[nodiscard]] QString compatibilityToolVersion() const; void setCompatibilityToolVersion(const QString &version); - BootData *bootData(); - GameData *gameData(); + BootData *bootData() const; + GameData *gameData() const; [[nodiscard]] bool loggedIn() const; void setLoggedIn(bool value); diff --git a/launcher/include/profilemanager.h b/launcher/include/profilemanager.h index 324d87d..058eaea 100644 --- a/launcher/include/profilemanager.h +++ b/launcher/include/profilemanager.h @@ -3,8 +3,7 @@ #pragma once -#include -#include +#include #include "profile.h" @@ -41,7 +40,7 @@ public: [[nodiscard]] QList profiles() const; [[nodiscard]] int numProfiles() const; - Q_INVOKABLE bool canDelete(Profile *account) const; + Q_INVOKABLE bool canDelete(const Profile *account) const; [[nodiscard]] Q_INVOKABLE bool hasAnyExistingInstallations() const; diff --git a/launcher/include/sapphirelogin.h b/launcher/include/sapphirelogin.h index f842e9b..4e785a2 100644 --- a/launcher/include/sapphirelogin.h +++ b/launcher/include/sapphirelogin.h @@ -3,8 +3,6 @@ #pragma once -#include - #include "launchercore.h" class SapphireLogin : QObject @@ -13,6 +11,7 @@ public: explicit SapphireLogin(LauncherCore &window, QObject *parent = nullptr); /// Begins the login process for Sapphire servers + /// \param lobbyUrl The URL to the Sapphire lobby server /// \param info The required login information QCoro::Task> login(const QString &lobbyUrl, const LoginInformation &info); diff --git a/launcher/src/account.cpp b/launcher/src/account.cpp index df71038..d5aee2a 100644 --- a/launcher/src/account.cpp +++ b/launcher/src/account.cpp @@ -3,7 +3,6 @@ #include "account.h" -#include #include #include #include @@ -84,7 +83,7 @@ bool Account::isSapphire() const return m_config.isSapphire(); } -void Account::setIsSapphire(bool value) +void Account::setIsSapphire(const bool value) { if (m_config.isSapphire() != value) { m_config.setIsSapphire(value); @@ -98,10 +97,10 @@ QString Account::lobbyUrl() const return m_config.lobbyUrl(); } -void Account::setLobbyUrl(const QString &value) +void Account::setLobbyUrl(const QString &url) { - if (m_config.lobbyUrl() != value) { - m_config.setLobbyUrl(value); + if (m_config.lobbyUrl() != url) { + m_config.setLobbyUrl(url); m_config.save(); Q_EMIT lobbyUrlChanged(); } @@ -194,7 +193,7 @@ void Account::setPassword(const QString &password) QString Account::getOTP() { - auto otpSecret = QCoro::waitFor(getKeychainValue(QStringLiteral("otp-secret"))); + const auto otpSecret = QCoro::waitFor(getKeychainValue(QStringLiteral("otp-secret"))); if (otpSecret.isEmpty()) { return {}; } @@ -246,12 +245,12 @@ void Account::fetchAvatar() url.setHost(QStringLiteral("na.%1").arg(m_launcher.settings()->mainServer())); // TODO: NA isnt the only thing in the world... url.setPath(QStringLiteral("/lodestone/character/%1").arg(lodestoneId())); - QNetworkRequest request(url); + const QNetworkRequest request(url); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = m_launcher.mgr()->get(request); connect(reply, &QNetworkReply::finished, [this, filename, reply] { - QString document = QString::fromUtf8(reply->readAll()); + const QString document = QString::fromUtf8(reply->readAll()); if (!document.isEmpty()) { const static QRegularExpression re( QStringLiteral(R"lit(]*class=["|']frame__chara__face["|'][^>]*>\s*]*src=["|']([^"']*))lit")); @@ -260,7 +259,7 @@ void Account::fetchAvatar() if (match.hasCaptured(1)) { const QString newAvatarUrl = match.captured(1); - const QNetworkRequest avatarRequest = QNetworkRequest(QUrl(newAvatarUrl)); + const auto avatarRequest = QNetworkRequest(QUrl(newAvatarUrl)); Utility::printRequest(QStringLiteral("GET"), avatarRequest); auto avatarReply = m_launcher.mgr()->get(avatarRequest); @@ -331,9 +330,11 @@ QCoro::Task Account::getKeychainValue(const QString &key) } } +// ReSharper disable once CppMemberFunctionMayBeConst +// ^ Could be const, but this function shouldn't be considered as such void Account::updateConfig() { - auto configDir = getConfigDir().absoluteFilePath(QStringLiteral("FFXIV.cfg")); + const auto configDir = getConfigDir().absoluteFilePath(QStringLiteral("FFXIV.cfg")); if (!QFile::exists(configDir)) { return; @@ -341,24 +342,24 @@ void Account::updateConfig() qInfo(ASTRA_LOG) << "Updating FFXIV.cfg..."; - auto configDirStd = configDir.toStdString(); + const auto configDirStd = configDir.toStdString(); - auto cfgFileBuffer = physis_read_file(configDirStd.c_str()); - auto cfgFile = physis_cfg_parse(cfgFileBuffer); + const auto cfgFileBuffer = physis_read_file(configDirStd.c_str()); + const auto cfgFile = physis_cfg_parse(cfgFileBuffer); // Ensure that the opening cutscene movie never plays, since it's broken in most versions of Wine physis_cfg_set_value(cfgFile, "CutsceneMovieOpening", "1"); - auto screenshotDir = m_launcher.settings()->screenshotDir(); + const auto screenshotDir = m_launcher.settings()->screenshotDir(); Utility::createPathIfNeeded(screenshotDir); - auto screenshotDirWin = Utility::toWindowsPath(screenshotDir); - auto screenshotDirWinStd = screenshotDirWin.toStdString(); + const auto screenshotDirWin = Utility::toWindowsPath(screenshotDir); + const auto screenshotDirWinStd = screenshotDirWin.toStdString(); // Set the screenshot path physis_cfg_set_value(cfgFile, "ScreenShotDir", screenshotDirWinStd.c_str()); - auto buffer = physis_cfg_write(cfgFile); + const auto buffer = physis_cfg_write(cfgFile); QFile file(configDir); file.open(QIODevice::WriteOnly); diff --git a/launcher/src/accountmanager.cpp b/launcher/src/accountmanager.cpp index 756fa1f..ec174cd 100644 --- a/launcher/src/accountmanager.cpp +++ b/launcher/src/accountmanager.cpp @@ -22,7 +22,7 @@ void AccountManager::load() const QString uuid = QString(id).remove("account-"_L1); qInfo(ASTRA_LOG) << "Loading account" << uuid; - auto account = new Account(m_launcher, uuid, this); + const auto account = new Account(m_launcher, uuid, this); m_accounts.append(account); Q_EMIT accountsChanged(); } @@ -35,7 +35,7 @@ int AccountManager::rowCount(const QModelIndex &index) const return static_cast(m_accounts.size()); } -QVariant AccountManager::data(const QModelIndex &index, int role) const +QVariant AccountManager::data(const QModelIndex &index, const int role) const { if (!checkIndex(index)) { return {}; @@ -54,9 +54,9 @@ QHash AccountManager::roleNames() const return {{AccountRole, QByteArrayLiteral("account")}}; } -Account *AccountManager::createSquareEnixAccount(const QString &username, int licenseType, bool isFreeTrial) +Account *AccountManager::createSquareEnixAccount(const QString &username, const int licenseType, const bool isFreeTrial) { - auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); + const auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); account->setIsSapphire(false); account->setLicense(static_cast(licenseType)); account->setIsFreeTrial(isFreeTrial); @@ -69,7 +69,7 @@ Account *AccountManager::createSquareEnixAccount(const QString &username, int li Account *AccountManager::createSapphireAccount(const QString &lobbyUrl, const QString &username) { - auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); + const auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); account->setIsSapphire(true); account->setName(username); account->setLobbyUrl(lobbyUrl); @@ -90,7 +90,7 @@ Account *AccountManager::getByUuid(const QString &uuid) const return nullptr; } -bool AccountManager::canDelete(Account *account) const +bool AccountManager::canDelete(const Account *account) const { Q_UNUSED(account) return m_accounts.size() != 1; diff --git a/launcher/src/assetupdater.cpp b/launcher/src/assetupdater.cpp index 91827f5..3c6e239 100644 --- a/launcher/src/assetupdater.cpp +++ b/launcher/src/assetupdater.cpp @@ -207,7 +207,7 @@ QCoro::Task AssetUpdater::installCompatibilityTool() { Q_EMIT launcher.stageChanged(i18n("Updating compatibility tool...")); - const QNetworkRequest request = QNetworkRequest(QUrl(m_remoteCompatibilityToolUrl)); + const auto request = QNetworkRequest(QUrl(m_remoteCompatibilityToolUrl)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -233,8 +233,8 @@ QCoro::Task AssetUpdater::installCompatibilityTool() } // the first directory is the same as the version we download - const KArchiveDirectory *root = dynamic_cast(archive.directory()->entry(m_remoteCompatibilityToolVersion)); - root->copyTo(m_wineDir.absolutePath(), true); + const auto *root = dynamic_cast(archive.directory()->entry(m_remoteCompatibilityToolVersion)); + Q_UNUSED(root->copyTo(m_wineDir.absolutePath(), true)) archive.close(); @@ -249,7 +249,7 @@ QCoro::Task AssetUpdater::installDxvkTool() { Q_EMIT launcher.stageChanged(i18n("Updating DXVK...")); - const QNetworkRequest request = QNetworkRequest(QUrl(m_remoteDxvkToolUrl)); + const auto request = QNetworkRequest(QUrl(m_remoteDxvkToolUrl)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -275,8 +275,8 @@ QCoro::Task AssetUpdater::installDxvkTool() } // the first directory is the same as the version we download - const KArchiveDirectory *root = dynamic_cast(archive.directory()->entry(m_remoteDxvkToolVersion)); - root->copyTo(m_dxvkDir.absolutePath(), true); + const auto *root = dynamic_cast(archive.directory()->entry(m_remoteDxvkToolVersion)); + Q_UNUSED(root->copyTo(m_dxvkDir.absolutePath(), true)) archive.close(); @@ -289,7 +289,7 @@ QCoro::Task AssetUpdater::installDalamudAssets() { Q_EMIT launcher.stageChanged(i18n("Updating Dalamud assets...")); - const QNetworkRequest request = QNetworkRequest(QUrl(m_remoteDalamudAssetPackageUrl)); + const auto request = QNetworkRequest(QUrl(m_remoteDalamudAssetPackageUrl)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -321,7 +321,7 @@ QCoro::Task AssetUpdater::installDalamud() { Q_EMIT launcher.stageChanged(i18n("Updating Dalamud...")); - const QNetworkRequest request = QNetworkRequest(QUrl(m_remoteDalamudDownloadUrl)); + const auto request = QNetworkRequest(QUrl(m_remoteDalamudDownloadUrl)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); diff --git a/launcher/src/benchmarkinstaller.cpp b/launcher/src/benchmarkinstaller.cpp index 438e9cc..ebdf109 100644 --- a/launcher/src/benchmarkinstaller.cpp +++ b/launcher/src/benchmarkinstaller.cpp @@ -6,9 +6,6 @@ #include #include #include -#include -#include -#include #include "astra_log.h" #include "launchercore.h" @@ -16,7 +13,7 @@ #include "utility.h" // TODO: this should be dynamically grabbed from the webpage to avoid hardcoding it -const QString installerUrl = QStringLiteral("https://download.finalfantasyxiv.com/s9qmq6SJfMMqYM4o/ffxiv-dawntrail-bench.zip"); +const auto installerUrl = QStringLiteral("https://download.finalfantasyxiv.com/s9qmq6SJfMMqYM4o/ffxiv-dawntrail-bench.zip"); BenchmarkInstaller::BenchmarkInstaller(LauncherCore &launcher, Profile &profile, QObject *parent) : QObject(parent) @@ -34,7 +31,7 @@ BenchmarkInstaller::BenchmarkInstaller(LauncherCore &launcher, Profile &profile, void BenchmarkInstaller::start() { if (m_localInstallerPath.isEmpty()) { - const QNetworkRequest request = QNetworkRequest(QUrl(installerUrl)); + const auto request = QNetworkRequest(QUrl(installerUrl)); Utility::printRequest(QStringLiteral("GET"), request); // TODO: benchmarks are usually quite large, and need download progress reporting @@ -76,7 +73,7 @@ void BenchmarkInstaller::installGame() // the first directory is the same as the version we download const KArchiveDirectory *root = archive.directory(); - root->copyTo(installDirectory.absolutePath(), true); + Q_UNUSED(root->copyTo(installDirectory.absolutePath(), true)) archive.close(); diff --git a/launcher/src/compatibilitytoolinstaller.cpp b/launcher/src/compatibilitytoolinstaller.cpp index 2215d3d..1599fcd 100644 --- a/launcher/src/compatibilitytoolinstaller.cpp +++ b/launcher/src/compatibilitytoolinstaller.cpp @@ -29,10 +29,10 @@ void CompatibilityToolInstaller::installCompatibilityTool() if (astraToolDir.exists()) { Q_EMIT error(i18n("The compatibility tool is already installed.")); return; - } else { - QDir().mkpath(astraToolDir.absolutePath()); } + Q_UNUSED(QDir().mkpath(astraToolDir.absolutePath())) + QString command; if (KSandbox::isFlatpak()) { QFile::copy(QStringLiteral("/app/bin/steamwrap"), astraToolDir.absoluteFilePath(QStringLiteral("steamwrap"))); @@ -62,7 +62,7 @@ void CompatibilityToolInstaller::installCompatibilityTool() toolManifestFile.write(toolManifestContents.toUtf8()); toolManifestFile.close(); - const QString compatibilityToolContents = QStringLiteral( + const auto compatibilityToolContents = QStringLiteral( "\"compatibilitytools\"\n" "{\n" " \"compat_tools\"\n" diff --git a/launcher/src/encryptedarg.cpp b/launcher/src/encryptedarg.cpp index a089dd6..3bfe5e8 100644 --- a/launcher/src/encryptedarg.cpp +++ b/launcher/src/encryptedarg.cpp @@ -53,7 +53,7 @@ static char ChecksumTable[] = {'f', 'X', '1', 'p', 'G', 't', 'd', 'S', '5', 'C', inline char GetChecksum(const unsigned int key) { - auto value = key & 0x000F0000; + const auto value = key & 0x000F0000; return ChecksumTable[value >> 16]; } diff --git a/launcher/src/existinginstallmodel.cpp b/launcher/src/existinginstallmodel.cpp index 557acca..53fe663 100644 --- a/launcher/src/existinginstallmodel.cpp +++ b/launcher/src/existinginstallmodel.cpp @@ -11,7 +11,7 @@ ExistingInstallModel::ExistingInstallModel(QObject *parent) fill(); } -QVariant ExistingInstallModel::data(const QModelIndex &index, int role) const +QVariant ExistingInstallModel::data(const QModelIndex &index, const int role) const { Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)); @@ -54,8 +54,8 @@ QHash ExistingInstallModel::roleNames() const void ExistingInstallModel::fill() { - auto dirs = physis_find_existing_game_dirs(); - for (int i = 0; i < dirs.count; i++) { + const auto dirs = physis_find_existing_game_dirs(); + for (uint32_t i = 0; i < dirs.count; i++) { // We shouldn't be able to import our own game installs, that's handled elsewhere in the UI if (dirs.entries[i].install_type != ExistingInstallType::Astra) { beginInsertRows({}, m_existingInstalls.size(), m_existingInstalls.size()); diff --git a/launcher/src/gameinstaller.cpp b/launcher/src/gameinstaller.cpp index 75334e7..85b0dce 100644 --- a/launcher/src/gameinstaller.cpp +++ b/launcher/src/gameinstaller.cpp @@ -14,7 +14,7 @@ #include "profile.h" #include "utility.h" -const QString installerUrl = QStringLiteral("https://download.finalfantasyxiv.com/inst/ffxivsetup.exe"); +const auto installerUrl = QStringLiteral("https://download.finalfantasyxiv.com/inst/ffxivsetup.exe"); const QByteArray installerSha256 = QByteArray::fromHex("cf70bfaaf4f429794358ef84acbcbdc4193bee109fa1b6aea81bd4de038e500e"); GameInstaller::GameInstaller(LauncherCore &launcher, Profile &profile, QObject *parent) @@ -33,7 +33,7 @@ GameInstaller::GameInstaller(LauncherCore &launcher, Profile &profile, const QSt void GameInstaller::start() { if (m_localInstallerPath.isEmpty()) { - const QNetworkRequest request = QNetworkRequest(QUrl(installerUrl)); + const auto request = QNetworkRequest(QUrl(installerUrl)); Utility::printRequest(QStringLiteral("GET"), request); auto reply = m_launcher.mgr()->get(request); diff --git a/launcher/src/gamerunner.cpp b/launcher/src/gamerunner.cpp index fe72e01..98e45d6 100644 --- a/launcher/src/gamerunner.cpp +++ b/launcher/src/gamerunner.cpp @@ -42,9 +42,9 @@ void GameRunner::beginVanillaGame(const QString &gameExecutablePath, Profile &pr { profile.setLoggedIn(true); - auto gameProcess = new QProcess(this); + const auto gameProcess = new QProcess(this); gameProcess->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - connect(gameProcess, &QProcess::finished, this, [this, &profile](int exitCode) { + connect(gameProcess, &QProcess::finished, this, [this, &profile](const int exitCode) { profile.setLoggedIn(false); Q_UNUSED(exitCode) Q_EMIT m_launcher.gameClosed(); @@ -85,8 +85,8 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr const QDir dalamudInstallDir = dalamudDir.absoluteFilePath(profile.dalamudChannelName()); const QString dalamudInjector = dalamudInstallDir.absoluteFilePath(QStringLiteral("Dalamud.Injector.exe")); - auto dalamudProcess = new QProcess(this); - connect(dalamudProcess, &QProcess::finished, this, [this, &profile](int exitCode) { + const auto dalamudProcess = new QProcess(this); + connect(dalamudProcess, &QProcess::finished, this, [this, &profile](const int exitCode) { profile.setLoggedIn(false); Q_UNUSED(exitCode) Q_EMIT m_launcher.gameClosed(); @@ -123,7 +123,7 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr true); } -QString GameRunner::getGameArgs(const Profile &profile, const std::optional &auth) +QString GameRunner::getGameArgs(const Profile &profile, const std::optional &auth) const { QList> gameArgs; @@ -333,7 +333,7 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con void GameRunner::addRegistryKey(const Profile &settings, const QString &key, const QString &value, const QString &data) { - auto process = new QProcess(this); + const auto process = new QProcess(this); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); launchExecutable(settings, process, @@ -345,7 +345,7 @@ void GameRunner::addRegistryKey(const Profile &settings, const QString &key, con void GameRunner::setWindowsVersion(const Profile &settings, const QString &version) { - auto process = new QProcess(this); + const auto process = new QProcess(this); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); launchExecutable(settings, process, {QStringLiteral("winecfg"), QStringLiteral("/v"), version}, false, false); process->waitForFinished(); diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 74b2a28..645c1bd 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -39,14 +39,14 @@ LauncherCore::LauncherCore() m_accountManager->load(); // restore profile -> account connections - for (auto profile : m_profileManager->profiles()) { - if (auto account = m_accountManager->getByUuid(profile->accountUuid())) { + for (const auto profile : m_profileManager->profiles()) { + if (const auto account = m_accountManager->getByUuid(profile->accountUuid())) { profile->setAccount(account); } } // set default profile, if found - if (auto profile = m_profileManager->getProfileByUUID(m_settings->currentProfile())) { + if (const auto profile = m_profileManager->getProfileByUUID(m_settings->currentProfile())) { setCurrentProfile(profile); } @@ -64,7 +64,7 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin { Q_ASSERT(profile != nullptr); - auto loginInformation = new LoginInformation(this); + const auto loginInformation = new LoginInformation(this); loginInformation->profile = profile; // Benchmark never has to login, of course @@ -162,7 +162,7 @@ void LauncherCore::refreshLogoImage() const QDir logoDir = cacheDir.absoluteFilePath(QStringLiteral("logos")); if (!logoDir.exists()) { - QDir().mkpath(logoDir.absolutePath()); + Q_UNUSED(QDir().mkpath(logoDir.absolutePath())) } const auto saveTexture = [](GameData *data, const QString &path, const QString &name) { @@ -170,18 +170,18 @@ void LauncherCore::refreshLogoImage() return; } - auto file = physis_gamedata_extract_file(data, path.toStdString().c_str()); + const auto file = physis_gamedata_extract_file(data, path.toStdString().c_str()); if (file.data != nullptr) { - auto tex = physis_texture_parse(file); + const auto tex = physis_texture_parse(file); - QImage image(tex.rgba, tex.width, tex.height, QImage::Format_RGBA8888); - image.save(name); + const QImage image(tex.rgba, tex.width, tex.height, QImage::Format_RGBA8888); + Q_UNUSED(image.save(name)) } }; // TODO: this finds the first profile that has a valid image, but this could probably be cached per-profile for (int i = 0; i < m_profileManager->numProfiles(); i++) { - auto profile = m_profileManager->getProfile(i); + const auto profile = m_profileManager->getProfile(i); if (profile->isGameInstalled() && profile->gameData()) { // A Realm Reborn saveTexture(profile->gameData(), QStringLiteral("ui/uld/Title_Logo.tex"), logoDir.absoluteFilePath(QStringLiteral("ffxiv.png"))); @@ -220,7 +220,7 @@ Profile *LauncherCore::currentProfile() const return m_profileManager->getProfile(m_currentProfileIndex); } -void LauncherCore::setCurrentProfile(Profile *profile) +void LauncherCore::setCurrentProfile(const Profile *profile) { Q_ASSERT(profile != nullptr); @@ -246,7 +246,7 @@ void LauncherCore::setCurrentProfile(Profile *profile) return m_profileManager->getProfileByUUID(m_settings->config()->autoLoginProfile()); } -void LauncherCore::setAutoLoginProfile(Profile *profile) +void LauncherCore::setAutoLoginProfile(const Profile *profile) { if (profile != nullptr) { auto uuid = profile->uuid(); @@ -370,7 +370,7 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) } } - auto assetUpdater = new AssetUpdater(*info.profile, *this, this); + const auto assetUpdater = new AssetUpdater(*info.profile, *this, this); if (co_await assetUpdater->update()) { // If we expect an auth ticket, don't continue if missing if (!info.profile->isBenchmark() && auth == std::nullopt) { @@ -435,10 +435,10 @@ QCoro::Task<> LauncherCore::fetchNews() auto bannerReply = mgr()->get(bannerRequest); co_await bannerReply; - auto document = QJsonDocument::fromJson(headlineReply->readAll()); - auto bannerDocument = QJsonDocument::fromJson(bannerReply->readAll()); + const auto document = QJsonDocument::fromJson(headlineReply->readAll()); + const auto bannerDocument = QJsonDocument::fromJson(bannerReply->readAll()); - auto headline = new Headline(this); + const auto headline = new Headline(this); if (document.isEmpty() || bannerDocument.isEmpty()) { headline->failedToLoad = true; } else { diff --git a/launcher/src/logger.cpp b/launcher/src/logger.cpp index df8afc0..d796056 100644 --- a/launcher/src/logger.cpp +++ b/launcher/src/logger.cpp @@ -88,7 +88,7 @@ private: Q_GLOBAL_STATIC(Logger, logger) -void handler(QtMsgType type, const QMessageLogContext &context, const QString &message) +void handler(const QtMsgType type, const QMessageLogContext &context, const QString &message) { switch (type) { case QtDebugMsg: diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index e7af45b..cb56495 100755 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -4,9 +4,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -16,12 +13,9 @@ #endif #include "astra-version.h" -#include "compatibilitytoolinstaller.h" -#include "gameinstaller.h" #include "launchercore.h" #include "logger.h" #include "physis_logger.h" -#include "sapphirelogin.h" #ifdef Q_OS_WIN #include @@ -45,9 +39,9 @@ int main(int argc, char *argv[]) qputenv("QT_QUICK_CONTROLS_MOBILE", "1"); } - QGuiApplication app(argc, argv); + const QGuiApplication app(argc, argv); - KDSingleApplication singleApplication; + const KDSingleApplication singleApplication; if (!singleApplication.isPrimaryInstance()) { return 0; } @@ -153,7 +147,7 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; - auto core = engine.singletonInstance(QStringLiteral("zone.xiv.astra"), QStringLiteral("LauncherCore")); + const auto core = engine.singletonInstance(QStringLiteral("zone.xiv.astra"), QStringLiteral("LauncherCore")); if (parser.isSet(steamOption)) { core->initializeSteam(); } diff --git a/launcher/src/patcher.cpp b/launcher/src/patcher.cpp index bc861d4..6f0a811 100644 --- a/launcher/src/patcher.cpp +++ b/launcher/src/patcher.cpp @@ -6,9 +6,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -110,7 +108,7 @@ QCoro::Task Patcher::patch(const PatchList &patchList) auto patchReply = m_launcher.mgr()->get(patchRequest); - connect(patchReply, &QNetworkReply::downloadProgress, this, [this, ourIndex](int received, int total) { + connect(patchReply, &QNetworkReply::downloadProgress, this, [this, ourIndex](const int received, const int total) { Q_UNUSED(total) updateDownloadProgress(ourIndex, received); }); @@ -256,7 +254,7 @@ QString Patcher::getBaseString() const } } -void Patcher::updateDownloadProgress(const int index, int received) +void Patcher::updateDownloadProgress(const int index, const int received) { QMutexLocker locker(&m_finishedPatchesMutex); @@ -275,7 +273,7 @@ void Patcher::updateMessage() repositoryName = QStringLiteral("ffxiv"); } - const float progress = ((float)patch.bytesDownloaded / (float)patch.length) * 100.0f; + const float progress = (static_cast(patch.bytesDownloaded) / static_cast(patch.length)) * 100.0f; const QString progressStr = QStringLiteral("%1").arg(progress, 1, 'f', 1, QLatin1Char('0')); Q_EMIT m_launcher.stageChanged(i18n("Downloading %1 - %2 [%3/%4]", repositoryName, patch.version, m_finishedPatches, m_remainingPatches), diff --git a/launcher/src/processlogger.cpp b/launcher/src/processlogger.cpp index 7f50229..073360c 100644 --- a/launcher/src/processlogger.cpp +++ b/launcher/src/processlogger.cpp @@ -4,6 +4,7 @@ #include "processlogger.h" #include "astra_log.h" #include "utility.h" + #include ProcessLogger::ProcessLogger(QProcess *process) diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index 6dc1a86..1a0d73a 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -52,7 +52,7 @@ void Profile::readDalamudInfo() if (QFile::exists(dalamudDepsJson)) { QFile depsJson(dalamudDepsJson); depsJson.open(QFile::ReadOnly); - QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll()); + const QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll()); QString versionString; for (const auto &target : doc["targets"_L1].toObject().keys()) { @@ -85,10 +85,10 @@ void Profile::readGameData() return; } - auto header = physis_gamedata_extract_file(m_gameData, "exd/exversion.exh"); + const auto header = physis_gamedata_extract_file(m_gameData, "exd/exversion.exh"); physis_EXH *exh = physis_parse_excel_sheet_header(header); if (exh != nullptr) { - physis_EXD exd = physis_gamedata_read_excel_sheet(m_gameData, "ExVersion", exh, Language::English, 0); + const physis_EXD exd = physis_gamedata_read_excel_sheet(m_gameData, "ExVersion", exh, Language::English, 0); for (unsigned int i = 0; i < exd.row_count; i++) { m_expansionNames.push_back(QString::fromLatin1(exd.row_data[i].column_data[0].string._0)); @@ -334,10 +334,10 @@ Profile::DalamudChannel Profile::dalamudChannel() const return static_cast(m_config->dalamudChannel()); } -void Profile::setDalamudChannel(const DalamudChannel value) +void Profile::setDalamudChannel(const DalamudChannel channel) { - if (static_cast(m_config->dalamudChannel()) != value) { - m_config->setDalamudChannel(static_cast(value)); + if (static_cast(m_config->dalamudChannel()) != channel) { + m_config->setDalamudChannel(static_cast(channel)); m_config->save(); Q_EMIT dalamudChannelChanged(); } @@ -376,7 +376,7 @@ bool Profile::isBenchmark() const return m_config->isBenchmark(); } -void Profile::setIsBenchmark(bool value) +void Profile::setIsBenchmark(const bool value) { if (m_config->isBenchmark() != value) { m_config->setIsBenchmark(value); @@ -421,7 +421,7 @@ void Profile::readGameVersion() } // Extract frontier url if possible - const QString launcherPath = QString(gamePath() + QStringLiteral("/boot/ffxivlauncher64.exe")); + const auto launcherPath = QString(gamePath() + QStringLiteral("/boot/ffxivlauncher64.exe")); m_frontierUrl = QString::fromUtf8(physis_extract_frontier_url(launcherPath.toStdString().c_str())); Q_EMIT gameInstallChanged(); @@ -552,7 +552,7 @@ int Profile::dalamudAssetVersion() const return m_dalamudAssetVersion; } -void Profile::setDalamudAssetVersion(int version) +void Profile::setDalamudAssetVersion(const int version) { m_dalamudAssetVersion = version; } @@ -572,7 +572,7 @@ void Profile::setDalamudVersion(const QString &version) m_dalamudVersion = version; } -void Profile::setDalamudApplicable(bool applicable) +void Profile::setDalamudApplicable(const bool applicable) { m_dalamudApplicable = applicable; } @@ -593,12 +593,12 @@ void Profile::setCompatibilityToolVersion(const QString &version) m_compatibilityToolVersion = version; } -BootData *Profile::bootData() +BootData *Profile::bootData() const { return m_bootData; } -GameData *Profile::gameData() +GameData *Profile::gameData() const { return m_gameData; } diff --git a/launcher/src/profilemanager.cpp b/launcher/src/profilemanager.cpp index 2db1acb..656e603 100644 --- a/launcher/src/profilemanager.cpp +++ b/launcher/src/profilemanager.cpp @@ -33,7 +33,7 @@ int ProfileManager::getProfileIndex(const QString &name) Profile *ProfileManager::getProfileByUUID(const QString &uuid) { - for (auto &m_profile : m_profiles) { + for (const auto &m_profile : m_profiles) { if (m_profile->uuid() == uuid) return m_profile; } @@ -43,7 +43,7 @@ Profile *ProfileManager::getProfileByUUID(const QString &uuid) Profile *ProfileManager::addProfile() { - auto newProfile = new Profile(m_launcher, QUuid::createUuid().toString(), this); + const auto newProfile = new Profile(m_launcher, QUuid::createUuid().toString(), this); newProfile->setName(QStringLiteral("New Profile")); insertProfile(newProfile); @@ -85,7 +85,7 @@ void ProfileManager::load() if (id.contains("profile-"_L1)) { const QString uuid = QString(id).remove("profile-"_L1); qInfo(ASTRA_LOG) << "Loading profile" << uuid; - auto profile = new Profile(m_launcher, uuid, this); + const auto profile = new Profile(m_launcher, uuid, this); insertProfile(profile); } } @@ -102,7 +102,7 @@ int ProfileManager::rowCount(const QModelIndex &index) const return static_cast(m_profiles.size()); } -QVariant ProfileManager::data(const QModelIndex &index, int role) const +QVariant ProfileManager::data(const QModelIndex &index, const int role) const { if (!checkIndex(index)) { return {}; @@ -134,7 +134,7 @@ QList ProfileManager::profiles() const return m_profiles; } -bool ProfileManager::canDelete(Profile *account) const +bool ProfileManager::canDelete(const Profile *account) const { Q_UNUSED(account) return m_profiles.size() != 1; diff --git a/launcher/src/utility.cpp b/launcher/src/utility.cpp index 1daaa71..cae56d0 100644 --- a/launcher/src/utility.cpp +++ b/launcher/src/utility.cpp @@ -5,7 +5,6 @@ #include "astra_http_log.h" #include -#include using namespace Qt::StringLiterals; @@ -22,7 +21,7 @@ void Utility::printRequest(const QString &type, const QNetworkRequest &request) void Utility::createPathIfNeeded(const QDir &dir) { if (!QDir().exists(dir.absolutePath())) { - QDir().mkpath(dir.absolutePath()); + Q_UNUSED(QDir().mkpath(dir.absolutePath())) } }