From a5581b479e4c76a917716e915c4666d2be678f00 Mon Sep 17 00:00:00 2001
From: Petr Mrázek <peterix@gmail.com>
Date: Mon, 6 Dec 2021 20:17:31 +0100
Subject: NOISSUE fix launching offline while online

---
 launcher/LaunchController.cpp | 47 +++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp
index a0458168..be12eb79 100644
--- a/launcher/LaunchController.cpp
+++ b/launcher/LaunchController.cpp
@@ -117,31 +117,34 @@ void LaunchController::login() {
 
         switch(m_accountToUse->accountState()) {
             case AccountState::Offline: {
-                // we ask the user for a player name
-                bool ok = false;
-                QString usedname = m_session->player_name;
-                QString name = QInputDialog::getText(
-                    m_parentWidget,
-                    tr("Player name"),
-                    tr("Choose your offline mode player name."),
-                    QLineEdit::Normal,
-                    m_session->player_name,
-                    &ok
-                );
-                if (!ok)
-                {
-                    tryagain = false;
-                    break;
-                }
-                if (name.length())
-                {
-                    usedname = name;
-                }
-                m_session->MakeOffline(usedname);
-                // offline flavored game from here :3
+                m_session->wants_online = false;
                 // NOTE: fallthrough is intentional
             }
             case AccountState::Online: {
+                if(!m_session->wants_online) {
+                    // we ask the user for a player name
+                    bool ok = false;
+                    QString usedname = m_session->player_name;
+                    QString name = QInputDialog::getText(
+                        m_parentWidget,
+                        tr("Player name"),
+                        tr("Choose your offline mode player name."),
+                        QLineEdit::Normal,
+                        m_session->player_name,
+                        &ok
+                    );
+                    if (!ok)
+                    {
+                        tryagain = false;
+                        break;
+                    }
+                    if (name.length())
+                    {
+                        usedname = name;
+                    }
+                    m_session->MakeOffline(usedname);
+                    // offline flavored game from here :3
+                }
                 if(m_accountToUse->ownsMinecraft() && !m_accountToUse->hasProfile()) {
                     auto entitlement = m_accountToUse->accountData()->minecraftEntitlement;
                     QString errorString;
-- 
cgit