1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 12:57:45 +00:00

Check gate status when actually trying to login instead of at startup

This fixes a couple of issues, such as Sapphire login breaking. This
also makes it possible to wait out the login gate, instead of having
to restart the launcher. The gate status check is also moved to the
squareboot class for now.
This commit is contained in:
Joshua Goins 2022-05-09 15:53:17 -04:00
parent 8c2a79b5cf
commit aed67025df
6 changed files with 50 additions and 56 deletions

View file

@ -9,7 +9,9 @@ class SquareBoot : public QObject {
public: public:
SquareBoot(LauncherCore& window, SquareLauncher& launcher); SquareBoot(LauncherCore& window, SquareLauncher& launcher);
void bootCheck(LoginInformation& info); void checkGateStatus(const LoginInformation& info);
void bootCheck(const LoginInformation& info);
private: private:
QProgressDialog* dialog; QProgressDialog* dialog;

View file

@ -7,19 +7,12 @@ class SquareLauncher : public QObject {
public: public:
SquareLauncher(LauncherCore& window); SquareLauncher(LauncherCore& window);
void gateOpen();
void getStored(const LoginInformation& info); void getStored(const LoginInformation& info);
void login(const LoginInformation& info, QUrl referer); void login(const LoginInformation& info, QUrl referer);
void registerSession(const LoginInformation& info); void registerSession(const LoginInformation& info);
bool isGateOpen = false;
signals:
void gateStatusRecieved(bool gateOpen);
private: private:
QString getBootHash(const LoginInformation& info); QString getBootHash(const LoginInformation& info);

View file

@ -545,12 +545,6 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco
#endif #endif
readInitialInformation(); readInitialInformation();
// check gate status before login
squareLauncher->gateOpen();
// TODO: we really should call this "heavy" signal
connect(squareLauncher, &SquareLauncher::gateStatusRecieved, this, &LauncherCore::settingsChanged);
} }
LauncherCore::~LauncherCore() noexcept { LauncherCore::~LauncherCore() noexcept {

View file

@ -279,9 +279,9 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
#endif #endif
if(currentProfile().isSapphire) { if(currentProfile().isSapphire) {
//this->core.sapphireLauncher->login(currentProfile().lobbyURL, info); this->core.sapphireLauncher->login(currentProfile().lobbyURL, info);
} else { } else {
this->core.squareBoot->bootCheck(info); this->core.squareBoot->checkGateStatus(info);
} }
}); });
@ -375,11 +375,6 @@ void LauncherWindow::reloadControls() {
loginButton->setText("Login (Lobby URL is invalid)"); loginButton->setText("Login (Lobby URL is invalid)");
canLogin = false; canLogin = false;
} }
} else {
if(!core.squareLauncher->isGateOpen) {
loginButton->setText("Login (Maintenance is in progress)");
canLogin = false;
}
} }
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) #if defined(Q_OS_LINUX) || defined(Q_OS_MAC)

View file

@ -7,6 +7,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QFile> #include <QFile>
#include <patch.h> #include <patch.h>
#include <QJsonDocument>
#include <QJsonObject>
#include "squarelauncher.h" #include "squarelauncher.h"
@ -14,7 +16,7 @@ SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window(
} }
void SquareBoot::bootCheck(LoginInformation& info) { void SquareBoot::bootCheck(const LoginInformation& info) {
dialog = new QProgressDialog(); dialog = new QProgressDialog();
dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version."); dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version.");
dialog->show(); dialog->show();
@ -99,4 +101,44 @@ void SquareBoot::bootCheck(LoginInformation& info) {
} }
} }
}); });
} }
void SquareBoot::checkGateStatus(const LoginInformation& info) {
QUrlQuery query;
query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch()));
QUrl url;
url.setUrl("https://frontier.ffxiv.com/worldStatus/gate_status.json");
url.setQuery(query);
QNetworkRequest request;
request.setUrl(url);
// TODO: really?
window.buildRequest(*info.settings, request);
auto reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [=] {
// I happen to run into this issue often, if I start the launcher really quickly after bootup
// it's possible to actually check this quicker than the network is actually available,
// causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic.
// TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in
// some way.
if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError)
checkGateStatus(info);
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0;
if(isGateOpen) {
bootCheck(info);
} else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical,
"Failed to Login",
"The login gate is closed, the game may be under maintenance.");
messageBox->show();
}
});
}

View file

@ -217,36 +217,4 @@ QString SquareLauncher::getBootHash(const LoginInformation& info) {
} }
return result; return result;
} }
void SquareLauncher::gateOpen() {
QUrlQuery query;
query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch()));
QUrl url;
url.setUrl("https://frontier.ffxiv.com/worldStatus/gate_status.json");
url.setQuery(query);
QNetworkRequest request;
request.setUrl(url);
// TODO: really?
window.buildRequest(window.getProfile(window.defaultProfileIndex), request);
auto reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [this, reply] {
// I happen to run into this issue often, if I start the launcher really quickly after bootup
// it's possible to actually check this quicker than the network is actually available,
// causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic.
// TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in
// some way.
if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError)
gateOpen();
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0;
gateStatusRecieved(isGateOpen);
});
}