From ad294867caced75b2975c95bb70c24202ddee0c7 Mon Sep 17 00:00:00 2001 From: redstrate Date: Tue, 2 Nov 2021 08:36:30 -0400 Subject: [PATCH] Add option to launch official client --- src/sapphirelauncher.cpp | 4 ++-- src/squarelauncher.cpp | 2 +- src/xivlauncher.cpp | 49 ++++++++++++++++++++++++++-------------- src/xivlauncher.h | 3 ++- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/sapphirelauncher.cpp b/src/sapphirelauncher.cpp index 523e7af..d30dc2a 100644 --- a/src/sapphirelauncher.cpp +++ b/src/sapphirelauncher.cpp @@ -33,7 +33,7 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { auth.frontierHost = document["frontierHost"].toString(); auth.region = 3; - window.launch(auth); + window.launchGame(auth); } else { auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password."); messageBox->show(); @@ -64,6 +64,6 @@ void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& auth.frontierHost = document["frontierHost"].toString(); auth.region = 3; - window.launch(auth); + window.launchGame(auth); }); } \ No newline at end of file diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index 56a4967..4a2b3a7 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -121,7 +121,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { auth.SID = reply->rawHeader("X-Patch-Unique-Id"); - window.launch(auth); + window.launchGame(auth); } else { auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game."); messageBox->show(); diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index 5c154e4..9648d1f 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -39,7 +39,30 @@ void LauncherWindow::buildRequest(QNetworkRequest& request) { request.setRawHeader("Accept-Language", "en-us"); } -void LauncherWindow::launch(const LoginAuth auth) { +void LauncherWindow::launchGame(const LoginAuth auth) { + QList arguments; + + // now for the actual game... + arguments.push_back(gamePath + "\\game\\ffxiv_dx11.exe"); + arguments.push_back("DEV.DataPathType=1"); + arguments.push_back("DEV.UseSqPack=1"); + + arguments.push_back(QString("DEV.MaxEntitledExpansionID=%1").arg(auth.maxExpansion)); + arguments.push_back(QString("DEV.TestSID=%1").arg(auth.SID)); + arguments.push_back(QString("SYS.Region=%1").arg(auth.region)); + arguments.push_back(QString("language=%1").arg(language)); + arguments.push_back(QString("ver=%1").arg(gameVersion)); + + if(!auth.lobbyhost.isEmpty()) { + arguments.push_back(QString("DEV.GMServerHost=%1").arg(auth.frontierHost)); + for(int i = 1; i < 9; i++) + arguments.push_back(QString("DEV.LobbyHost0%1=%2 DEV.LobbyPort0%1=54994").arg(QString::number(i), auth.lobbyhost)); + } + + launchExecutable(arguments); +} + +void LauncherWindow::launchExecutable(const QStringList args) { auto process = new QProcess(this); process->setProcessChannelMode(QProcess::ForwardedChannels); process->setWorkingDirectory(gamePath + "/game/"); @@ -73,22 +96,7 @@ void LauncherWindow::launch(const LoginAuth auth) { process->setEnvironment(env); #endif - // now for the actual game... - arguments.push_back(gamePath + "\\game\\ffxiv_dx11.exe"); - arguments.push_back("DEV.DataPathType=1"); - arguments.push_back("DEV.UseSqPack=1"); - - arguments.push_back(QString("DEV.MaxEntitledExpansionID=%1").arg(auth.maxExpansion)); - arguments.push_back(QString("DEV.TestSID=%1").arg(auth.SID)); - arguments.push_back(QString("SYS.Region=%1").arg(auth.region)); - arguments.push_back(QString("language=%1").arg(language)); - arguments.push_back(QString("ver=%1").arg(gameVersion)); - - if(!auth.lobbyhost.isEmpty()) { - arguments.push_back(QString("DEV.GMServerHost=%1").arg(auth.frontierHost)); - for(int i = 1; i < 9; i++) - arguments.push_back(QString("DEV.LobbyHost0%1=%2 DEV.LobbyPort0%1=54994").arg(QString::number(i), auth.lobbyhost)); - } + arguments.append(args); auto executable = arguments[0]; arguments.removeFirst(); @@ -142,6 +150,13 @@ LauncherWindow::LauncherWindow(QWidget* parent) : window->show(); }); + QMenu* toolsMenu = menuBar()->addMenu("Tools"); + + QAction* launchOfficial = toolsMenu->addAction("Launch Official Client..."); + connect(launchOfficial, &QAction::triggered, [=] { + launchExecutable({gamePath + "/boot/ffxivboot64.exe"}); + }); + const auto savedServerType = settings.value("serverType", 0).toInt(); const auto savedLobbyURL = settings.value("lobbyURL", "127.0.0.1").toString(); const auto shouldRememberUsername = settings.value("rememberUsername", false).toBool(); diff --git a/src/xivlauncher.h b/src/xivlauncher.h index 8a3add2..f20def4 100755 --- a/src/xivlauncher.h +++ b/src/xivlauncher.h @@ -37,7 +37,8 @@ public: bool useEsync, useGamescope, useGamemode; - void launch(const LoginAuth auth); + void launchGame(const LoginAuth auth); + void launchExecutable(const QStringList args); void buildRequest(QNetworkRequest& request); void setSSL(QNetworkRequest& request); QString readVersion(QString path);