diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 393a86c..6562d13 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -225,7 +225,6 @@ public: QString dalamudVersion; int dalamudAssetVersion = -1; QString runtimeVersion; - QString nativeLauncherVersion; int defaultProfileIndex = 0; @@ -237,7 +236,27 @@ signals: void gameClosed(); private: + /* + * Begins the game executable, but calls to Dalamud if needed. + */ void beginGameExecutable(const ProfileSettings& settings, const LoginAuth& auth); + + /* + * Starts a vanilla game session with no Dalamud injection. + */ + void beginVanillaGame(const QString& gameExecutablePath, const ProfileSettings& profile, const LoginAuth& auth); + + /* + * Starts a game session with Dalamud injected. + */ + void beginDalamudGame(const QString& gameExecutablePath, const ProfileSettings& profile, const LoginAuth& 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 ProfileSettings& profile, const LoginAuth& auth); + bool checkIfInPath(QString program); void readGameData(ProfileSettings& profile); diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index 191f854..71124cb 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -73,22 +73,70 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth& a } void LauncherCore::beginGameExecutable(const ProfileSettings& profile, const LoginAuth& auth) { - QList arguments; + QString gameExectuable; + if(profile.useDX9) { + gameExectuable = profile.gamePath + "/game/ffxiv.exe"; + } else { + gameExectuable = profile.gamePath + "/game/ffxiv_dx11.exe"; + } + + if(profile.dalamud.enabled) { + beginDalamudGame(gameExectuable, profile, auth); + } else { + beginVanillaGame(gameExectuable, profile, auth); + } + + successfulLaunch(); +} + +void LauncherCore::beginVanillaGame(const QString& gameExecutablePath, const ProfileSettings& profile, const LoginAuth& auth) { + auto gameProcess = new QProcess(); + gameProcess->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); + + auto args = getGameArgs(profile, auth); + + launchExecutable( + profile, + gameProcess, + {gameExecutablePath, args}, + true, + true); +} + +void LauncherCore::beginDalamudGame(const QString& gameExecutablePath, const ProfileSettings& profile, const LoginAuth& auth) { + QString gamePath = gameExecutablePath; + gamePath = "Z:" + gamePath.replace('/', '\\'); QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + dataDir = "Z:" + dataDir.replace('/', '\\'); - if (profile.dalamud.enabled) { - arguments.push_back(dataDir + "/NativeLauncher.exe"); - arguments.push_back("5248"); // TODO: make port configurable/random - } + auto dalamudProcess = new QProcess(); - // now for the actual game... - if (profile.useDX9) { - arguments.push_back(profile.gamePath + "\\game\\ffxiv.exe"); - } else { - arguments.push_back(profile.gamePath + "\\game\\ffxiv_dx11.exe"); - } + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("DALAMUD_RUNTIME", dataDir + "\\DalamudRuntime"); +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) + env.insert("XL_WINEONLINUX", "true"); +#endif + dalamudProcess->setProcessEnvironment(env); + + auto args = getGameArgs(profile, auth); + + launchExecutable( + profile, + dalamudProcess, + {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", "launch", "-m", "inject", + "--game=" + gamePath, + "--dalamud-configuration-path=" + dataDir + "\\dalamudConfig.json", + "--dalamud-plugin-directory=" + dataDir + "\\installedPlugins", + "--dalamud-asset-directory=" + dataDir + "\\DalamudAssets", + "--dalamud-client-language=" + QString::number(profile.language), + "--", args}, + true, + true); +} + +QString LauncherCore::getGameArgs(const ProfileSettings& profile, const LoginAuth& auth) { struct Argument { QString key, value; }; @@ -111,25 +159,10 @@ void LauncherCore::beginGameExecutable(const ProfileSettings& profile, const Log } } - auto gameProcess = new QProcess(this); - - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - if (profile.license == GameLicense::WindowsSteam) { gameArgs.push_back({"IsSteam", "1"}); - env.insert("IS_FFXIV_LAUNCH_FROM_STEAM", QString::number(1)); } - if (profile.dalamud.enabled) { - // TODO: this depends on the default wine Z: path existing, which may not - // always the case. - env.insert("DALAMUD_RUNTIME", "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime"); - } - - gameProcess->setProcessEnvironment(env); - - gameProcess->setProcessChannelMode(QProcess::ForwardedChannels); - const QString argFormat = profile.encryptArguments ? " /%1 =%2" : " %1=%2"; QString argJoined; @@ -137,80 +170,7 @@ void LauncherCore::beginGameExecutable(const ProfileSettings& profile, const Log argJoined += argFormat.arg(arg.key, arg.value); } - if (profile.encryptArguments) { - arguments.append(encryptGameArg(argJoined)); - } else { - arguments.append(argJoined); - } - - if (profile.dalamud.enabled) { - auto socket = new QTcpServer(); - - 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; - int exitCode = output.toInt(&success, 10); - - if (exitCode != -1 && success) { - QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - dataDir = "Z:" + dataDir.replace('/', '\\'); - - QJsonObject startInfo; - startInfo["WorkingDirectory"] = dataDir; - startInfo["ConfigurationPath"] = dataDir + "\\dalamudConfig.json"; - startInfo["PluginDirectory"] = dataDir + "\\installedPlugins"; - startInfo["AssetDirectory"] = dataDir + "\\DalamudAssets"; - startInfo["DefaultPluginDirectory"] = dataDir + "\\devPlugins"; - startInfo["DelayInitializeMs"] = 0; - startInfo["GameVersion"] = profile.repositories.repositories[0].version; - startInfo["Language"] = profile.language; - startInfo["OptOutMbCollection"] = profile.dalamud.optOutOfMbCollection; - - QString argsEncoded = QJsonDocument(startInfo).toJson().toBase64(); - - auto dalamudProcess = new QProcess(); - dalamudProcess->setProcessChannelMode(QProcess::ForwardedChannels); - - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - env.insert("DALAMUD_RUNTIME", dataDir + "\\DalamudRuntime"); - -#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) - env.insert("XL_WINEONLINUX", "true"); -#endif - dalamudProcess->setProcessEnvironment(env); - - auto list = dalamudProcess->processEnvironment().toStringList(); - - launchExecutable( - profile, - dalamudProcess, - {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, - false, - true); - - connection->close(); - socket->close(); - } - }); - }); - - socket->listen(QHostAddress::Any, 5248); - } - - connect( - gameProcess, - qOverload(&QProcess::finished), - this, - [this](int code, QProcess::ExitStatus status) { - gameClosed(); - }); - - launchGameExecutable(profile, gameProcess, arguments); - - successfulLaunch(); + return profile.encryptArguments ? encryptGameArg(argJoined) : argJoined; } void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) { @@ -378,13 +338,6 @@ void LauncherCore::readInitialInformation() { } } - if (QFile::exists(dataDir + "/nativelauncher.ver")) { - QFile nativeVer(dataDir + "/nativelauncher.ver"); - nativeVer.open(QFile::ReadOnly | QFile::Text); - - nativeLauncherVersion = QString(nativeVer.readAll()); - } - auto profiles = settings.childGroups(); // create the Default profile if it doesnt exist diff --git a/launcher/desktop/include/assetupdater.h b/launcher/desktop/include/assetupdater.h index b3ec538..e4a523f 100644 --- a/launcher/desktop/include/assetupdater.h +++ b/launcher/desktop/include/assetupdater.h @@ -35,17 +35,14 @@ private: QString remoteDalamudVersion; QString remoteRuntimeVersion; - QString remoteNativeLauncherVersion; QTemporaryDir tempDir; bool doneDownloadingDalamud = false; - bool doneDownloadingNativelauncher = false; bool doneDownloadingRuntimeCore = false; bool doneDownloadingRuntimeDesktop = false; bool needsRuntimeInstall = false; bool needsDalamudInstall = false; - bool needsNativeInstall = false; int remoteDalamudAssetVersion = -1; QList dalamudAssetNeededFilenames; diff --git a/launcher/desktop/include/settingswindow.h b/launcher/desktop/include/settingswindow.h index 5aa34e7..511837c 100644 --- a/launcher/desktop/include/settingswindow.h +++ b/launcher/desktop/include/settingswindow.h @@ -72,7 +72,6 @@ private: QCheckBox* enableDalamudBox = nullptr; QLabel* dalamudVersionLabel = nullptr; QLabel* dalamudAssetVersionLabel = nullptr; - QLabel* nativeLauncherVersionLabel = nullptr; QCheckBox* dalamudOptOutBox = nullptr; QComboBox* dalamudChannel = nullptr; diff --git a/launcher/desktop/src/assetupdater.cpp b/launcher/desktop/src/assetupdater.cpp index 09e4055..97385a3 100644 --- a/launcher/desktop/src/assetupdater.cpp +++ b/launcher/desktop/src/assetupdater.cpp @@ -20,10 +20,6 @@ const QString dalamudVersionManifestURL = baseDalamudDistribution + "%1version"; const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets"; const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json"; -const QString baseNativeLauncherDistribution = "https://xiv.zone/astra-distrib/nativelauncher"; -const QString nativeLauncherLatestPackageURL = baseNativeLauncherDistribution + "/NativeLauncher.exe"; -const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version"; - const QString dotnetRuntimePackageURL = "https://dotnetcli.azureedge.net/dotnet/Runtime/%1/dotnet-runtime-%1-win-x64.zip"; const QString dotnetDesktopPackageURL = @@ -86,25 +82,7 @@ void AssetUpdater::update(const ProfileSettings& profile) { }); } - // native launcher - { - QNetworkRequest request(nativeLauncherVersionManifestURL); - - remoteNativeLauncherVersion.clear(); - - auto reply = launcher.mgr->get(request); - connect(reply, &QNetworkReply::finished, [this, &profile, reply] { - dialog->setLabelText("Checking for native launcher updates..."); - - remoteNativeLauncherVersion = reply->readAll().trimmed(); - - qInfo() << "Latest native launcher version reported: " << remoteNativeLauncherVersion; - - checkIfCheckingIsDone(); - }); - } - - // dalamud injector / net runtime / nativelauncher + // dalamud injector / net runtime // they're all updated in unison, so there's no reason to have multiple checks { QNetworkRequest request(dalamudVersionManifestURL.arg(channelToDistribPrefix[profile.dalamud.channel])); @@ -153,26 +131,6 @@ void AssetUpdater::beginInstall() { } } - if (needsNativeInstall) { - qInfo() << "Installing native launcher..."; - - if (QFile::exists(dataDir + "/NativeLauncher.exe")) - QFile::remove(dataDir + "/NativeLauncher.exe"); - - bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe", dataDir + "/NativeLauncher.exe"); - - if (!success) { - qInfo() << "Failed to install native launcher!"; - } else { - QFile file(dataDir + "/nativelauncher.ver"); - file.open(QIODevice::WriteOnly | QIODevice::Text); - file.write(remoteNativeLauncherVersion.toUtf8()); - file.close(); - - needsNativeInstall = false; - } - } - if (needsRuntimeInstall) { bool success = !JlCompress::extractDir(tempDir.path() + "/dotnet-core.zip", dataDir + "/DalamudRuntime").empty(); @@ -216,9 +174,9 @@ void AssetUpdater::checkIfFinished() { if (dialog->wasCanceled()) return; - if (doneDownloadingDalamud && doneDownloadingNativelauncher && doneDownloadingRuntimeCore && + if (doneDownloadingDalamud && doneDownloadingRuntimeCore && doneDownloadingRuntimeDesktop && dalamudAssetNeededFilenames.empty()) { - if (needsRuntimeInstall || needsNativeInstall || needsDalamudInstall) { + if (needsRuntimeInstall || needsDalamudInstall) { beginInstall(); } else { dialog->setLabelText("Finished!"); @@ -233,8 +191,7 @@ void AssetUpdater::checkIfCheckingIsDone() { if (dialog->wasCanceled()) return; - if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || - remoteNativeLauncherVersion.isEmpty()) { + if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) { return; } @@ -376,34 +333,4 @@ void AssetUpdater::checkIfCheckingIsDone() { checkIfFinished(); } - - if (remoteNativeLauncherVersion != launcher.nativeLauncherVersion) { - qInfo() << "Native launcher out of date."; - - dialog->setLabelText("Updating native launcher..."); - - needsNativeInstall = true; - - QNetworkRequest request(nativeLauncherLatestPackageURL); - - auto reply = launcher.mgr->get(request); - connect(reply, &QNetworkReply::finished, [this, reply] { - qInfo() << "NativeLauncher finished downloading!"; - - QFile file(tempDir.path() + "/NativeLauncher.exe"); - file.open(QIODevice::WriteOnly); - file.write(reply->readAll()); - file.close(); - - doneDownloadingNativelauncher = true; - - checkIfFinished(); - }); - } else { - qInfo() << "Native launcher up to date."; - - doneDownloadingNativelauncher = true; - - checkIfFinished(); - } } diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index d02f589..a030eb4 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -295,12 +295,6 @@ void SettingsWindow::reloadControls() { dalamudAssetVersionLabel->setText(QString::number(core.dalamudAssetVersion)); } - if (core.nativeLauncherVersion.isEmpty()) { - nativeLauncherVersionLabel->setText("Native launcher is not installed."); - } else { - nativeLauncherVersionLabel->setText(core.nativeLauncherVersion); - } - dalamudOptOutBox->setChecked(profile.dalamud.optOutOfMbCollection); dalamudChannel->setCurrentIndex((int)profile.dalamud.channel); @@ -651,10 +645,6 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) { dalamudAssetVersionLabel = new QLabel(); dalamudAssetVersionLabel->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); layout.addRow("Dalamud Asset Version", dalamudAssetVersionLabel); - - nativeLauncherVersionLabel = new QLabel(); - nativeLauncherVersionLabel->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); - layout.addRow("Native Launcher Version", nativeLauncherVersionLabel); } void SettingsWindow::setupAccountsTab(QFormLayout& layout) {}