diff --git a/src/launchercore.cpp b/src/launchercore.cpp index b2ae293..8f74413 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -411,6 +411,7 @@ void LauncherCore::readGameVersion() { for(auto& profile : profileSettings) { profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver"); profile.gameVersion = readVersion(profile.gamePath + "/game/ffxivgame.ver"); + profile.installedMaxExpansion = 0; for(auto dir : QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs)) { if(dir.contains("ex") && dir.length() == 3 && dir[2].isDigit()) { @@ -418,10 +419,6 @@ void LauncherCore::readGameVersion() { profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expacVersion); } - - if(dir == "ffxiv") { - profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, 0); - } } readExpansionVersions(profile, profile.installedMaxExpansion); diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 0b099b7..d6a5a25 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -425,7 +425,7 @@ void SettingsWindow::reloadControls() { directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0); currentGameDirectory->setText(profile.gamePath); - if(profile.installedMaxExpansion == -1) { + if(profile.gameVersion.isEmpty()) { expansionVersionLabel->setText("No game installed."); } else { QString expacString; diff --git a/src/squareboot.cpp b/src/squareboot.cpp index 551d669..58c258e 100644 --- a/src/squareboot.cpp +++ b/src/squareboot.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include "squarelauncher.h" @@ -32,14 +35,51 @@ void SquareBoot::bootCheck(LoginInformation& info) { auto reply = window.mgr->get(request); connect(reply, &QNetworkReply::finished, [=] { - QString response = reply->readAll(); + const QString response = reply->readAll(); + if(response.isEmpty()) { launcher.getStored(info); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed to launch. The game may require an update, please use another launcher."); - window.addUpdateButtons(*info.settings, *messageBox); + // TODO: move this out into a dedicated function, we need to use this for regular game patches later on + // TODO: create a nice progress window like ffxivboot has + // TODO: improve flow when updating boot, maybe do at launch ala official launcher? + const QStringList parts = response.split(QRegExp("\n|\r\n|\r")); - messageBox->show(); + // patch list starts at line 5 + for(int i = 5; i < parts.size() - 2; i++) { + const QStringList patchParts = parts[i].split("\t"); + + const int length = patchParts[0].toInt(); + const int version = patchParts[4].toInt(); + const int hashType = patchParts[5].toInt(); + + QString name = patchParts[4]; + QString url = patchParts[5]; + + QNetworkRequest patchRequest(url); + auto patchReply = window.mgr->get(patchRequest); + connect(patchReply, &QNetworkReply::finished, [=] { + const QString dataDir = + QStandardPaths::writableLocation(QStandardPaths::TempLocation); + + QFile file(dataDir + "/" + name + ".patch"); + file.open(QIODevice::WriteOnly); + file.write(patchReply->readAll()); + file.close(); + + // TODO: we really a dedicated .ver writing/reading class + QFile verFile(info.settings->gamePath + "/boot/ffxivboot.ver"); + verFile.open(QIODevice::WriteOnly | QIODevice::Text); + verFile.write(name.toUtf8()); + verFile.close(); + + processPatch((dataDir + "/" + name + ".patch").toStdString(), (info.settings->gamePath + "/boot").toStdString()); + + auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Successfully updated", "ffxivboot is now updated to " + name); + + messageBox->show(); + }); + } } }); } \ No newline at end of file diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index f5a9e2d..bba3a06 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -171,7 +171,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { QString report = info.settings->bootVersion + "=" + getBootHash(info); - for(int i = 0; i < info.settings->expansionVersions.size(); i++) + for(int i = 0; i < info.settings->installedMaxExpansion; i++) report += QString("\nex%1\t%2").arg(QString::number(i + 1), info.settings->expansionVersions[i]); auto reply = window.mgr->post(request, report.toUtf8());