From d51ba16e5c5419ded1dd7029f71e6cba4f5d2ce9 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 29 Jun 2024 15:15:20 -0400 Subject: [PATCH] Error out when the boot patching server returns 404 Found this while testing out Kawari, apparently we didn't check this until now. --- launcher/include/squareenixlogin.h | 2 +- launcher/src/squareenixlogin.cpp | 32 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/launcher/include/squareenixlogin.h b/launcher/include/squareenixlogin.h index 5131e63..8260b2b 100644 --- a/launcher/include/squareenixlogin.h +++ b/launcher/include/squareenixlogin.h @@ -30,7 +30,7 @@ private: QCoro::Task 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 checkBootUpdates(); using StoredInfo = std::pair; diff --git a/launcher/src/squareenixlogin.cpp b/launcher/src/squareenixlogin.cpp index 15fd544..4192055 100644 --- a/launcher/src/squareenixlogin.cpp +++ b/launcher/src/squareenixlogin.cpp @@ -37,7 +37,9 @@ QCoro::Task> 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. @@ -141,7 +143,7 @@ QCoro::Task SquareEnixLogin::checkLoginStatus() } } -QCoro::Task<> SquareEnixLogin::checkBootUpdates() +QCoro::Task SquareEnixLogin::checkBootUpdates() { m_lastRunHasPatched = false; @@ -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> SquareEnixLogin::getStoredValue()