Skip to content

Commit

Permalink
Error out when the boot patching server returns 404
Browse files Browse the repository at this point in the history
Found this while testing out Kawari, apparently we didn't check this
until now.
  • Loading branch information
redstrate committed Jun 29, 2024
1 parent 3618c50 commit d51ba16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion launcher/include/squareenixlogin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SquareEnixLogin : public QObject
QCoro::Task<bool> checkLoginStatus();

/// Check for updates to the boot components. Even though we don't use these, it's checked by later login steps.
QCoro::Task<> checkBootUpdates();
QCoro::Task<bool> checkBootUpdates();

using StoredInfo = std::pair<QString, QUrl>;

Expand Down
32 changes: 20 additions & 12 deletions launcher/src/squareenixlogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ QCoro::Task<std::optional<LoginAuth>> SquareEnixLogin::login(LoginInformation *i
// There seems to be a limitation in their boot patching system.
// Their server can only give one patch a time, so the boot process must keep trying to patch until
// there is no patches left.
co_await checkBootUpdates();
if (!co_await checkBootUpdates()) {
co_return std::nullopt;
}
}

// Then check if we can even login.
Expand Down Expand Up @@ -141,7 +143,7 @@ QCoro::Task<bool> SquareEnixLogin::checkLoginStatus()
}
}

QCoro::Task<> SquareEnixLogin::checkBootUpdates()
QCoro::Task<bool> SquareEnixLogin::checkBootUpdates()
{
m_lastRunHasPatched = false;

Expand Down Expand Up @@ -172,19 +174,25 @@ QCoro::Task<> SquareEnixLogin::checkBootUpdates()
const auto reply = m_launcher.mgr()->get(request);
co_await reply;

const QString patchList = QString::fromUtf8(reply->readAll());
if (!patchList.isEmpty()) {
m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/boot"), *m_info->profile->bootData(), this);
const bool hasPatched = co_await m_patcher->patch(PatchList(patchList));
if (hasPatched) {
// update game version information
m_info->profile->readGameVersion();
if (reply->error() == QNetworkReply::NoError) {
const QString patchList = QString::fromUtf8(reply->readAll());
if (!patchList.isEmpty()) {
m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/boot"), *m_info->profile->bootData(), this);
const bool hasPatched = co_await m_patcher->patch(PatchList(patchList));
if (hasPatched) {
// update game version information
m_info->profile->readGameVersion();
}
m_patcher->deleteLater();
m_lastRunHasPatched = true;
}
m_patcher->deleteLater();
m_lastRunHasPatched = true;
} else {
qWarning(ASTRA_LOG) << "Unknown error when verifying boot files:" << reply->errorString();
Q_EMIT m_launcher.loginError(i18n("Unknown error when verifying boot files.\n\n%1", reply->errorString()));
co_return false;
}

co_return;
co_return true;
}

QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStoredValue()
Expand Down

0 comments on commit d51ba16

Please sign in to comment.