From 440d5670e7d34c5ee59024d18a4c9f99a4d16461 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 9 Aug 2022 22:44:10 -0400 Subject: [PATCH] Update patcher for new physis changes --- launcher/core/include/launchercore.h | 3 +++ launcher/core/include/patcher.h | 12 ++++++++--- launcher/core/src/launchercore.cpp | 10 ++++------ launcher/core/src/patcher.cpp | 30 ++++++++++++++++------------ launcher/core/src/squareboot.cpp | 2 +- launcher/core/src/squarelauncher.cpp | 2 +- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 869a5d9..5fb309c 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -50,6 +50,9 @@ public: QVector gameVersions; bool enableWatchdog = false; + BootData* bootData; + GameData* gameData; + bool isGameInstalled() const { return !gameVersions.isEmpty(); } diff --git a/launcher/core/include/patcher.h b/launcher/core/include/patcher.h index 180e20b..049664c 100644 --- a/launcher/core/include/patcher.h +++ b/launcher/core/include/patcher.h @@ -3,14 +3,15 @@ #include #include #include +#include // General-purpose patcher routine. It opens a nice dialog box, handles downloading // and processing patches. class Patcher : public QObject { Q_OBJECT public: - // isBoot is used for telling the patcher that you're reading boot patches, which for some reason has a different patchlist format. - Patcher(bool isBoot, QString baseDirectory); + Patcher(QString baseDirectory, GameData* game_data); + Patcher(QString baseDirectory, BootData* game_data); void processPatchList(QNetworkAccessManager& mgr, QString patchList); @@ -20,6 +21,10 @@ signals: private: void checkIfDone(); + bool isBoot() const { + return boot_data != nullptr; + } + struct QueuedPatch { QString name, repository, version, path; }; @@ -28,8 +33,9 @@ private: QVector patchQueue; - bool isBoot = false; QString baseDirectory; + BootData* boot_data = nullptr; + GameData* game_data = nullptr; QProgressDialog* dialog = nullptr; diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index 14f9bd3..f8303e4 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -704,12 +704,12 @@ void LauncherCore::addRegistryKey(const ProfileSettings& settings, } void LauncherCore::readGameData(ProfileSettings& profile) { - auto path = profile.gamePath.toStdString() + "/game"; - GameData* game_data = physis_gamedata_initialize(path.c_str()); + profile.gameData = physis_gamedata_initialize((profile.gamePath + "/game").toStdString().c_str()); + profile.bootData = physis_bootdata_initialize((profile.gamePath + "/boot").toStdString().c_str()); - EXH* exh = physis_gamedata_read_excel_sheet_header(game_data, "ExVersion"); + EXH* exh = physis_gamedata_read_excel_sheet_header(profile.gameData, "ExVersion"); if(exh != nullptr) { - physis_EXD exd = physis_gamedata_read_excel_sheet(game_data, "ExVersion", exh, Language::English, 0); + physis_EXD exd = physis_gamedata_read_excel_sheet(profile.gameData, "ExVersion", exh, Language::English, 0); for(int i = 0; i < exd.row_count; i++) { expansionNames.push_back(exd.row_data[i].column_data[0].string._0); @@ -718,6 +718,4 @@ void LauncherCore::readGameData(ProfileSettings& profile) { physis_gamedata_free_sheet(exd); physis_gamedata_free_sheet_header(exh); } - - physis_gamedata_free(game_data); } diff --git a/launcher/core/src/patcher.cpp b/launcher/core/src/patcher.cpp index 245532c..dca2728 100644 --- a/launcher/core/src/patcher.cpp +++ b/launcher/core/src/patcher.cpp @@ -6,14 +6,16 @@ #include #include -Patcher::Patcher(bool isBoot, QString baseDirectory) : isBoot(isBoot), baseDirectory(baseDirectory) { +Patcher::Patcher(QString baseDirectory, BootData* boot_data) : boot_data(boot_data), baseDirectory(baseDirectory) { dialog = new QProgressDialog(); + dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version."); - if(isBoot) { - dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version."); - } else { - dialog->setLabelText("Checking the FINAL FANTASY XIV Game version."); - } + dialog->show(); +} + +Patcher::Patcher(QString baseDirectory, GameData* game_data) : game_data(game_data), baseDirectory(baseDirectory) { + dialog = new QProgressDialog(); + dialog->setLabelText("Checking the FINAL FANTASY XIV Game version."); dialog->show(); } @@ -24,7 +26,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { emit done(); } else { - if(isBoot) { + if(isBoot()) { dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version."); } else { dialog->setLabelText("Updating the FINAL FANTASY XIV Game version."); @@ -41,7 +43,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { QString name, url, version, repository; - if (isBoot) { + if (isBoot()) { name = patchParts[4]; url = patchParts[5]; version = name; @@ -54,7 +56,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) { auto url_parts = url.split('/'); repository = url_parts[url_parts.size() - 3]; - if(isBoot) { + if(isBoot()) { dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + version); } else { dialog->setLabelText("Updating the FINAL FANTASY XIV Game version.\nDownloading " + repository + " - " + version); @@ -114,12 +116,14 @@ void Patcher::checkIfDone() { } void Patcher::processPatch(QueuedPatch patch) { - auto data_path = baseDirectory.toStdString(); - - physis_patch_process(data_path.c_str(), patch.path.toStdString().c_str()); + if(isBoot()) { + physis_bootdata_apply_patch(boot_data, patch.path.toStdString().c_str()); + } else { + physis_gamedata_apply_patch(game_data, patch.path.toStdString().c_str()); + } QString verFilePath; - if(isBoot) { + if(isBoot()) { verFilePath = baseDirectory + "/ffxivboot.ver"; } else { if(patch.repository == "game") { diff --git a/launcher/core/src/squareboot.cpp b/launcher/core/src/squareboot.cpp index 663d04d..008a6d8 100644 --- a/launcher/core/src/squareboot.cpp +++ b/launcher/core/src/squareboot.cpp @@ -17,7 +17,7 @@ SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window( } void SquareBoot::bootCheck(const LoginInformation& info) { - patcher = new Patcher(true, info.settings->gamePath + "/boot"); + patcher = new Patcher(info.settings->gamePath + "/boot", info.settings->bootData); connect(patcher, &Patcher::done, [=, &info] { window.readGameVersion(); diff --git a/launcher/core/src/squarelauncher.cpp b/launcher/core/src/squarelauncher.cpp index 045fc2b..0b2532c 100644 --- a/launcher/core/src/squarelauncher.cpp +++ b/launcher/core/src/squarelauncher.cpp @@ -185,7 +185,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { QString body = reply->readAll(); - patcher = new Patcher(false, info.settings->gamePath + "/game"); + patcher = new Patcher(info.settings->gamePath + "/game", info.settings->gameData); connect(patcher, &Patcher::done, [=, &info] { window.readGameVersion();