LaunchController: fix offline launches always failing (#4436)
This commit is contained in:
@@ -148,8 +148,12 @@ bool LaunchController::askPlayDemo()
|
|||||||
return box.clickedButton() == demoButton;
|
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
|
// we ask the user for a player name
|
||||||
QString message = tr("Choose your offline mode player name.");
|
QString message = tr("Choose your offline mode player name.");
|
||||||
if (demo) {
|
if (demo) {
|
||||||
@@ -166,9 +170,12 @@ QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const QString name = dialog.getUsername(); !name.isEmpty()) {
|
const QString name = dialog.getUsername();
|
||||||
usedname = name;
|
usedname = name;
|
||||||
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
|
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
|
||||||
|
|
||||||
|
if (ok != nullptr) {
|
||||||
|
*ok = true;
|
||||||
}
|
}
|
||||||
return usedname;
|
return usedname;
|
||||||
}
|
}
|
||||||
@@ -185,7 +192,7 @@ void LaunchController::login()
|
|||||||
if (m_demo) {
|
if (m_demo) {
|
||||||
// we ask the user for a player name
|
// we ask the user for a player name
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
auto name = askOfflineName("Player", m_demo, ok);
|
auto name = askOfflineName("Player", m_demo, &ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
m_session = std::make_shared<AuthSession>();
|
m_session = std::make_shared<AuthSession>();
|
||||||
static const QRegularExpression s_removeChars("[{}-]");
|
static const QRegularExpression s_removeChars("[{}-]");
|
||||||
@@ -264,7 +271,7 @@ void LaunchController::login()
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString name;
|
QString name;
|
||||||
if (m_offlineName.isEmpty()) {
|
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) {
|
if (!ok) {
|
||||||
tryagain = false;
|
tryagain = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class LaunchController : public Task {
|
|||||||
void launchInstance();
|
void launchInstance();
|
||||||
void decideAccount();
|
void decideAccount();
|
||||||
bool askPlayDemo();
|
bool askPlayDemo();
|
||||||
QString askOfflineName(QString playerName, bool demo, bool& ok);
|
QString askOfflineName(QString playerName, bool demo, bool* ok = nullptr);
|
||||||
bool reauthenticateAccount(MinecraftAccountPtr account);
|
bool reauthenticateAccount(MinecraftAccountPtr account);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user