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:
parent
8c2a79b5cf
commit
aed67025df
6 changed files with 50 additions and 56 deletions
|
@ -9,7 +9,9 @@ class SquareBoot : public QObject {
|
|||
public:
|
||||
SquareBoot(LauncherCore& window, SquareLauncher& launcher);
|
||||
|
||||
void bootCheck(LoginInformation& info);
|
||||
void checkGateStatus(const LoginInformation& info);
|
||||
|
||||
void bootCheck(const LoginInformation& info);
|
||||
|
||||
private:
|
||||
QProgressDialog* dialog;
|
||||
|
|
|
@ -7,19 +7,12 @@ class SquareLauncher : public QObject {
|
|||
public:
|
||||
SquareLauncher(LauncherCore& window);
|
||||
|
||||
void gateOpen();
|
||||
|
||||
void getStored(const LoginInformation& info);
|
||||
|
||||
void login(const LoginInformation& info, QUrl referer);
|
||||
|
||||
void registerSession(const LoginInformation& info);
|
||||
|
||||
bool isGateOpen = false;
|
||||
|
||||
signals:
|
||||
void gateStatusRecieved(bool gateOpen);
|
||||
|
||||
private:
|
||||
QString getBootHash(const LoginInformation& info);
|
||||
|
||||
|
|
|
@ -545,12 +545,6 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco
|
|||
#endif
|
||||
|
||||
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 {
|
||||
|
|
|
@ -279,9 +279,9 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
|
|||
#endif
|
||||
|
||||
if(currentProfile().isSapphire) {
|
||||
//this->core.sapphireLauncher->login(currentProfile().lobbyURL, info);
|
||||
this->core.sapphireLauncher->login(currentProfile().lobbyURL, info);
|
||||
} 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)");
|
||||
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)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QFile>
|
||||
#include <patch.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#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->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version.");
|
||||
dialog->show();
|
||||
|
@ -100,3 +102,43 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -218,35 +218,3 @@ QString SquareLauncher::getBootHash(const LoginInformation& info) {
|
|||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue