mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 11:47:46 +00:00
Communicate to nativelauncher through IPC
This makes Dalamud launching under Wine scenarios (such as on Linux or macOS) much more stable, as it's no longer sifting through stdout output. This requires nativelauncher >=v1.1.0, and the update functionality will come in a later commit.
This commit is contained in:
parent
d39aa8d5aa
commit
dbbcb67134
1 changed files with 53 additions and 49 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <QTcpServer>
|
||||||
|
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
#include "sapphirelauncher.h"
|
#include "sapphirelauncher.h"
|
||||||
|
@ -63,6 +64,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
|
||||||
|
|
||||||
if(profile.dalamud.enabled) {
|
if(profile.dalamud.enabled) {
|
||||||
arguments.push_back(dataDir + "/NativeLauncher.exe");
|
arguments.push_back(dataDir + "/NativeLauncher.exe");
|
||||||
|
arguments.push_back("5248"); // TODO: make port configurable/random
|
||||||
}
|
}
|
||||||
|
|
||||||
// now for the actual game...
|
// now for the actual game...
|
||||||
|
@ -112,20 +114,33 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
|
||||||
|
|
||||||
gameProcess->setProcessEnvironment(env);
|
gameProcess->setProcessEnvironment(env);
|
||||||
|
|
||||||
gameProcess->setProcessChannelMode(QProcess::MergedChannels);
|
gameProcess->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
|
||||||
|
const QString argFormat = profile.encryptArguments ? " /%1 =%2" : " %1=%2";
|
||||||
|
|
||||||
|
QString argJoined;
|
||||||
|
for(const auto& arg : gameArgs) {
|
||||||
|
argJoined += argFormat.arg(arg.key, arg.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(profile.encryptArguments) {
|
||||||
|
arguments.append(encryptGameArg(argJoined));
|
||||||
|
} else {
|
||||||
|
arguments.append(argJoined);
|
||||||
|
}
|
||||||
|
|
||||||
if(profile.dalamud.enabled) {
|
if(profile.dalamud.enabled) {
|
||||||
connect(gameProcess, &QProcess::readyReadStandardOutput, [this, gameProcess, profile] {
|
auto socket = new QTcpServer();
|
||||||
QString output = gameProcess->readAllStandardOutput();
|
|
||||||
|
connect(socket, &QTcpServer::newConnection, [this, profile, socket] {
|
||||||
|
auto connection = socket->nextPendingConnection();
|
||||||
|
|
||||||
|
connect(connection, &QTcpSocket::readyRead, [this, connection, profile, socket] {
|
||||||
|
QString output = connection->readAll();
|
||||||
bool success;
|
bool success;
|
||||||
int dec = output.toInt(&success, 10);
|
int exitCode = output.toInt(&success, 10);
|
||||||
if(!success)
|
|
||||||
return;
|
|
||||||
|
|
||||||
qDebug() << "got output: " << output;
|
|
||||||
|
|
||||||
qDebug() << "Now launching dalamud...";
|
|
||||||
|
|
||||||
|
if(exitCode != -1 && success) {
|
||||||
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
dataDir = "Z:" + dataDir.replace('/', '\\');
|
dataDir = "Z:" + dataDir.replace('/', '\\');
|
||||||
|
|
||||||
|
@ -155,28 +170,17 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
|
||||||
|
|
||||||
auto list = dalamudProcess->processEnvironment().toStringList();
|
auto list = dalamudProcess->processEnvironment().toStringList();
|
||||||
|
|
||||||
launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", output, argsEncoded});
|
launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded});
|
||||||
|
|
||||||
|
connection->close();
|
||||||
|
socket->close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const QString argFormat = profile.encryptArguments ? " /%1 =%2" : " %1=%2";
|
|
||||||
|
|
||||||
QString argJoined;
|
|
||||||
for(const auto& arg : gameArgs) {
|
|
||||||
argJoined += argFormat.arg(arg.key, arg.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(profile.encryptArguments) {
|
|
||||||
arguments.append(encryptGameArg(argJoined));
|
|
||||||
} else {
|
|
||||||
arguments.append(argJoined);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(gameProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
|
||||||
[=](int exitCode, QProcess::ExitStatus exitStatus){
|
|
||||||
gameClosed();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket->listen(QHostAddress::Any, 5248);
|
||||||
|
}
|
||||||
|
|
||||||
launchGameExecutable(profile, gameProcess, arguments);
|
launchGameExecutable(profile, gameProcess, arguments);
|
||||||
|
|
||||||
successfulLaunch();
|
successfulLaunch();
|
||||||
|
|
Loading…
Add table
Reference in a new issue