LaunchController: fix offline launches always failing (#4436)

This commit is contained in:
TheKodeToad
2025-12-06 21:32:14 +00:00
committed by GitHub
2 changed files with 14 additions and 7 deletions

View File

@@ -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 != nullptr) {
*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()) {
const QString name = dialog.getUsername();
usedname = name;
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
if (ok != nullptr) {
*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<AuthSession>();
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;

View File

@@ -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: