1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-22 20:47:45 +00:00

Add boot update support

Now with the related changes in libxiv, Astra is now capable of updating
the boot folder on it's own! The actual user-visible flow however is a
WIP. This also includes changes to properly load version files from a
freshly installed game, and report expansion levels correctly.
This commit is contained in:
Joshua Goins 2022-03-17 01:03:08 -04:00
parent 2bb7b90bec
commit 06c9658e94
4 changed files with 47 additions and 10 deletions

View file

@ -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);

View file

@ -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;

View file

@ -4,6 +4,9 @@
#include <QNetworkReply>
#include <QMessageBox>
#include <QPushButton>
#include <QStandardPaths>
#include <QFile>
#include <patch.h>
#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();
});
}
}
});
}

View file

@ -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());