From 04a405067d80d716600c3bd51a25b6d7ad3161f8 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sat, 6 Dec 2025 14:37:39 +0500 Subject: [PATCH 1/2] fix(LaunchController): correctly communicate if asking for offline name was successful Signed-off-by: Octol1ttle --- launcher/LaunchController.cpp | 19 +++++++++++++------ launcher/LaunchController.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 2273318ee..ea9694056 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -148,8 +148,12 @@ bool LaunchController::askPlayDemo() return box.clickedButton() == demoButton; } -QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok) +QString LaunchController::askOfflineName(QString playerName, bool demo, bool* ok) { + if (ok) { + *ok = false; + } + // we ask the user for a player name QString message = tr("Choose your offline mode player name."); if (demo) { @@ -166,9 +170,12 @@ QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok return {}; } - if (const QString name = dialog.getUsername(); !name.isEmpty()) { - usedname = name; - APPLICATION->settings()->set("LastOfflinePlayerName", usedname); + const QString name = dialog.getUsername(); + usedname = name; + APPLICATION->settings()->set("LastOfflinePlayerName", usedname); + + if (ok) { + *ok = true; } return usedname; } @@ -185,7 +192,7 @@ void LaunchController::login() if (m_demo) { // we ask the user for a player name bool ok = false; - auto name = askOfflineName("Player", m_demo, ok); + auto name = askOfflineName("Player", m_demo, &ok); if (ok) { m_session = std::make_shared(); static const QRegularExpression s_removeChars("[{}-]"); @@ -264,7 +271,7 @@ void LaunchController::login() bool ok = false; QString name; if (m_offlineName.isEmpty()) { - name = askOfflineName(m_session->player_name, m_session->demo, ok); + name = askOfflineName(m_session->player_name, m_session->demo, &ok); if (!ok) { tryagain = false; break; diff --git a/launcher/LaunchController.h b/launcher/LaunchController.h index af57994f5..50b72eb18 100644 --- a/launcher/LaunchController.h +++ b/launcher/LaunchController.h @@ -77,7 +77,7 @@ class LaunchController : public Task { void launchInstance(); void decideAccount(); bool askPlayDemo(); - QString askOfflineName(QString playerName, bool demo, bool& ok); + QString askOfflineName(QString playerName, bool demo, bool* ok = nullptr); bool reauthenticateAccount(MinecraftAccountPtr account); private slots: From 86fd58e6cbe6683e0482646041c7695eb651d9fb Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sat, 6 Dec 2025 16:34:59 +0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: TheKodeToad Signed-off-by: Octol1ttle --- launcher/LaunchController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index ea9694056..cbea045fc 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -150,7 +150,7 @@ bool LaunchController::askPlayDemo() QString LaunchController::askOfflineName(QString playerName, bool demo, bool* ok) { - if (ok) { + if (ok != nullptr) { *ok = false; } @@ -174,7 +174,7 @@ QString LaunchController::askOfflineName(QString playerName, bool demo, bool* ok usedname = name; APPLICATION->settings()->set("LastOfflinePlayerName", usedname); - if (ok) { + if (ok != nullptr) { *ok = true; } return usedname;