From c00f25029e03e4a26aa4e62a4981ca97e861a6c4 Mon Sep 17 00:00:00 2001 From: Toofy Date: Tue, 25 Apr 2023 10:31:38 -0400 Subject: [PATCH] Better error messages Spent way too long thinking I had an incorrect game directory version until I remembered a part in the wiki saying redhat systems needed to update the crypto policies. Thought I'd add that into the main program as a check as well as default the errors better. --- launcher/core/src/squarelauncher.cpp | 52 ++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/launcher/core/src/squarelauncher.cpp b/launcher/core/src/squarelauncher.cpp index e7c9a79..161d5c8 100644 --- a/launcher/core/src/squarelauncher.cpp +++ b/launcher/core/src/squarelauncher.cpp @@ -187,26 +187,48 @@ void SquareLauncher::registerSession(const LoginInformation& info) { auto reply = window.mgr->post(request, report.toUtf8()); connect(reply, &QNetworkReply::finished, [=, &info] { - if (reply->rawHeaderList().contains("X-Patch-Unique-Id")) { - QString body = reply->readAll(); + if (reply->error() == QNetworkReply::NoError) { + if (reply->rawHeaderList().contains("X-Patch-Unique-Id")) { + QString body = reply->readAll(); - patcher = new Patcher(info.settings->gamePath + "/game", info.settings->gameData); - connect(patcher, &Patcher::done, [=, &info] { - window.readGameVersion(); + patcher = new Patcher(info.settings->gamePath + "/game", info.settings->gameData); + connect(patcher, &Patcher::done, [=, &info] { + window.readGameVersion(); - auth.SID = reply->rawHeader("X-Patch-Unique-Id"); + auth.SID = reply->rawHeader("X-Patch-Unique-Id"); - window.launchGame(*info.settings, auth); - }); + window.launchGame(*info.settings, auth); + }); - patcher->processPatchList(*window.mgr, body); + patcher->processPatchList(*window.mgr, body); + } else { + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Fatal error, request was successful but X-Patch-Unique-Id was not received"); + messageBox->show(); + } } else { - auto messageBox = new QMessageBox( - QMessageBox::Icon::Critical, - "Failed to Login", - "Failed the anti-tamper check. Please restore your game to the original state or update the game."); - - messageBox->show(); + if (reply->error() == QNetworkReply::SslHandshakeFailedError) { + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "SSL handshake error detected. If you are using OpenSUSE Tumbleweed or Fedora, this launcher will " + "only work if you run the following command `update-crypto-policies --set LEGACY`"); + messageBox->show(); + } else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 405) { + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, + "Failed to Login", + "Failed the anti-tamper check. Please restore your game to the original state or update the " + "game."); + messageBox->show(); + } else { + int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + auto messageBox = new QMessageBox( + QMessageBox::Icon::Critical, "Failed to Login", &"Unknown error! Status code was "[statusCode]); + messageBox->show(); + } } }); }