From 935d5d6593a854a82dca76c91c237b7ba42647f8 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 9 Aug 2022 23:18:18 -0400 Subject: [PATCH] Use physis for reading game/boot versions --- launcher/core/include/launchercore.h | 9 +++--- launcher/core/src/launchercore.cpp | 42 +++++-------------------- launcher/core/src/squarelauncher.cpp | 8 ++--- launcher/desktop/src/settingswindow.cpp | 4 +-- 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 5fb309c..77d80a2 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -45,16 +45,17 @@ public: // game int language = 1; // 1 is english, thats all i know QString gamePath, winePath, winePrefixPath; - QString bootVersion, wineVersion; - int installedMaxExpansion = -1; - QVector gameVersions; + QString wineVersion; bool enableWatchdog = false; BootData* bootData; GameData* gameData; + physis_Repositories repositories; + const char* bootVersion; + bool isGameInstalled() const { - return !gameVersions.isEmpty(); + return repositories.repositories_count > 0; } bool isWineInstalled() const { diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index f8303e4..e63c927 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -85,7 +85,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au gameArgs.push_back({"DEV.TestSID", auth.SID}); gameArgs.push_back({"SYS.Region", QString::number(auth.region)}); gameArgs.push_back({"language", QString::number(profile.language)}); - gameArgs.push_back({"ver", profile.gameVersions[0]}); + gameArgs.push_back({"ver", profile.repositories.repositories[0].version}); if(!auth.lobbyhost.isEmpty()) { gameArgs.push_back({"DEV.GMServerHost", auth.frontierHost}); @@ -150,7 +150,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au startInfo["AssetDirectory"] = dataDir + "\\DalamudAssets"; startInfo["DefaultPluginDirectory"] = dataDir + "\\devPlugins"; startInfo["DelayInitializeMs"] = 0; - startInfo["GameVersion"] = profile.gameVersions[0]; + startInfo["GameVersion"] = profile.repositories.repositories[0].version; startInfo["Language"] = profile.language; startInfo["OptOutMbCollection"] = profile.dalamud.optOutOfMbCollection; @@ -494,38 +494,13 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { void LauncherCore::readGameVersion() { for(auto& profile : profileSettings) { - profile->bootVersion = readVersion(profile->gamePath + "/boot/ffxivboot.ver"); + profile->gameData = physis_gamedata_initialize((profile->gamePath + "/game").toStdString().c_str()); + profile->bootData = physis_bootdata_initialize((profile->gamePath + "/boot").toStdString().c_str()); - if(QFile::exists(profile->gamePath + QString("/game/ffxivgame.ver"))) { - profile->gameVersions.push_back(readVersion(profile->gamePath + QString("/game/ffxivgame.ver"))); - profile->installedMaxExpansion = 0; - } + profile->repositories = physis_gamedata_get_repositories(profile->gameData); + profile->bootVersion = physis_bootdata_get_version(profile->bootData); - auto sqpackDirectories = QDir(profile->gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot); - - if(QDir().exists(profile->gamePath + "/game/sqpack/")) - profile->gameVersions.resize(sqpackDirectories.size()); - - for(auto dir : sqpackDirectories) { - if(dir.contains("ex")) { - int expansion = -1; - - QString originalName = dir.remove("ex"); - bool ok = false; - int convertedInt = originalName.toInt(&ok); - if(ok) - expansion = convertedInt; - - profile->gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile->gamePath, QString::number(expansion))); - - if(expansion != -1) { - profile->installedMaxExpansion = std::max(profile->installedMaxExpansion, expansion); - } - } - } - - if(profile->installedMaxExpansion >= 0 && !sqpackDirectories.empty()) - readGameData(*profile); + readGameData(*profile); } } @@ -704,9 +679,6 @@ void LauncherCore::addRegistryKey(const ProfileSettings& settings, } void LauncherCore::readGameData(ProfileSettings& profile) { - 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(profile.gameData, "ExVersion"); if(exh != nullptr) { physis_EXD exd = physis_gamedata_read_excel_sheet(profile.gameData, "ExVersion", exh, Language::English, 0); diff --git a/launcher/core/src/squarelauncher.cpp b/launcher/core/src/squarelauncher.cpp index 0b2532c..563194a 100644 --- a/launcher/core/src/squarelauncher.cpp +++ b/launcher/core/src/squarelauncher.cpp @@ -161,7 +161,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { QUrl url; url.setScheme("https"); url.setHost("patch-gamever.ffxiv.com"); - url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->gameVersions[0], SID)); + url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->repositories.repositories[0].version, SID)); auto request = QNetworkRequest(url); window.setSSL(request); @@ -169,12 +169,12 @@ void SquareLauncher::registerSession(const LoginInformation& info) { request.setRawHeader("User-Agent", "FFXIV PATCH CLIENT"); request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); - QString report = info.settings->bootVersion + "=" + getBootHash(info); + QString report = QString("%1=%2").arg(info.settings->bootVersion, getBootHash(info)); for(int i = 1; i < auth.maxExpansion + 1; i++) { - if(i <= info.settings->installedMaxExpansion) { + if(i <= info.settings->repositories.repositories_count) { report += QString("\nex%1\t%2") - .arg(QString::number(i), info.settings->gameVersions[i]); + .arg(QString::number(i), info.settings->repositories.repositories[i].version); } else { report += QString("\nex%1\t2012.01.01.0000.0000").arg(QString::number(i)); } diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index 3fef144..32fccee 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -204,14 +204,14 @@ void SettingsWindow::reloadControls() { expacString += "Boot"; expacString += QString(" (%1)\n").arg(profile.bootVersion); - for(int i = 0; i < profile.gameVersions.size(); i++) { + for(int i = 0; i < profile.repositories.repositories_count; i++) { QString expansionName = "Unknown Expansion"; if(i < core.expansionNames.size()) { expansionName = core.expansionNames[i]; } expacString += expansionName; - expacString += QString(" (%1)\n").arg(profile.gameVersions[i]); + expacString += QString(" (%1)\n").arg(profile.repositories.repositories[i].version); } expansionVersionLabel->setText(expacString);