From 41a91a0295818bb011686c6222e37cce79dec877 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 9 Nov 2024 14:45:51 -0500 Subject: [PATCH] Fix how game PID detection in Dalamud mode when using Wine The PID Dalamud gives us is the Windows PID, which would be internal to Wine. Instead, if we're using Wine we need to ignore that and find the ffxiv process ourselves. --- launcher/src/gamerunner.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/launcher/src/gamerunner.cpp b/launcher/src/gamerunner.cpp index e32cdfc..6c34617 100644 --- a/launcher/src/gamerunner.cpp +++ b/launcher/src/gamerunner.cpp @@ -14,6 +14,8 @@ #include "processwatcher.h" #include "utility.h" +#include + using namespace Qt::StringLiterals; GameRunner::GameRunner(LauncherCore &launcher, QObject *parent) @@ -103,9 +105,21 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr const auto match = pidRegex.match(log); if (match.hasCaptured(1)) { - const int PID = match.captured(1).toInt(); + qint64 PID = match.captured(1).toInt(); if (PID > 0) { qCInfo(ASTRA_LOG) << "Recieved PID from Dalamud:" << PID; +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) + // Dalamud gives us a Windows PID, but that's useless to us. We need to find the PID of the game now: + + const auto info = KProcessList::processInfoList(); + for (const auto &entry : info) { + if (entry.name().contains(QLatin1String("ffxiv"))) { + qCInfo(ASTRA_LOG) << "Using PID of" << entry.name() << "which is" << entry.pid(); + PID = entry.pid(); + } + } + +#endif auto watcher = new ProcessWatcher(PID); connect(watcher, &ProcessWatcher::finished, this, [this, &profile] { profile.setLoggedIn(false); @@ -377,4 +391,4 @@ void GameRunner::setWindowsVersion(const Profile &settings, const QString &versi process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); launchExecutable(settings, process, {QStringLiteral("winecfg"), QStringLiteral("/v"), version}, false, false); process->waitForFinished(); -} \ No newline at end of file +}