From e2ad7e71d5913c82a09bc73d9044167017637832 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 11 Oct 2023 13:03:23 -0400 Subject: [PATCH] Add update config step to work around some launch issues This will update the config file on boot to prevent stalls due to the opening cutscene movie, and also update the screenshot dir. --- launcher/include/account.h | 2 ++ launcher/src/account.cpp | 38 +++++++++++++++++++++++++++++++++++ launcher/src/launchercore.cpp | 2 ++ 3 files changed, 42 insertions(+) diff --git a/launcher/include/account.h b/launcher/include/account.h index 6cddc19..71a2dd8 100644 --- a/launcher/include/account.h +++ b/launcher/include/account.h @@ -78,6 +78,8 @@ public: [[nodiscard]] QDir getConfigDir() const; + void updateConfig(); + Q_SIGNALS: void nameChanged(); void languageChanged(); diff --git a/launcher/src/account.cpp b/launcher/src/account.cpp index 87d4eaa..bde5af7 100644 --- a/launcher/src/account.cpp +++ b/launcher/src/account.cpp @@ -10,6 +10,7 @@ #include #include +#include "astra_log.h" #include "launchercore.h" #include "utility.h" @@ -290,3 +291,40 @@ QCoro::Task Account::getKeychainValue(const QString &key) co_return job->textData(); } + +void Account::updateConfig() +{ + auto configDir = getConfigDir().absoluteFilePath("FFXIV.cfg"); + + if (!QFile::exists(configDir)) { + return; + } + + qInfo(ASTRA_LOG) << "Updating FFXIV.cfg..."; + + auto configDirStd = configDir.toStdString(); + + auto cfgFileBuffer = physis_read_file(configDirStd.c_str()); + 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.screenshotDir(); + + if (!QDir().exists(screenshotDir)) + QDir().mkpath(screenshotDir); + + auto screenshotDirWin = Utility::toWindowsPath(screenshotDir); + auto screenshotDirWinStd = screenshotDirWin.toStdString(); + + // Set the screenshot path + physis_cfg_set_value(cfgFile, "ScreenShotDir", screenshotDirWinStd.c_str()); + + auto buffer = physis_cfg_write(cfgFile); + + QFile file(configDir); + file.open(QIODevice::WriteOnly); + file.write(reinterpret_cast(buffer.data), buffer.size); + file.close(); +} diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 34ebec4..ef94c48 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -76,6 +76,8 @@ void LauncherCore::launchGame(Profile &profile, const LoginAuth &auth) QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) { + info.profile->account()->updateConfig(); + auto assetUpdater = new AssetUpdater(*info.profile, *this, this); if (co_await assetUpdater->update()) { if (info.profile->account()->isSapphire()) {