NOISSUE in offline mode, do not contact the auth server if there is a valid account already

This commit is contained in:
Petr Mrázek 2017-12-03 14:05:35 +01:00
parent 30fad998a6
commit 0a56b56286
2 changed files with 24 additions and 15 deletions

View File

@ -170,8 +170,7 @@ AccountStatus MojangAccount::accountStatus() const
return Verified;
}
std::shared_ptr<YggdrasilTask> MojangAccount::login(AuthSessionPtr session,
QString password)
std::shared_ptr<YggdrasilTask> MojangAccount::login(AuthSessionPtr session, QString password)
{
Q_ASSERT(m_currentTask.get() == nullptr);
@ -186,18 +185,28 @@ std::shared_ptr<YggdrasilTask> MojangAccount::login(AuthSessionPtr session,
return nullptr;
}
if (password.isEmpty())
if(accountStatus() == Verified && !session->wants_online)
{
m_currentTask.reset(new RefreshTask(this));
session->status = AuthSession::PlayableOffline;
session->auth_server_online = false;
fillSession(session);
return nullptr;
}
else
{
m_currentTask.reset(new AuthenticateTask(this, password));
}
m_currentTask->assignSession(session);
if (password.isEmpty())
{
m_currentTask.reset(new RefreshTask(this));
}
else
{
m_currentTask.reset(new AuthenticateTask(this, password));
}
m_currentTask->assignSession(session);
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
}
return m_currentTask;
}

View File

@ -22,12 +22,6 @@ LaunchController::LaunchController(QObject *parent) : Task(parent)
}
void LaunchController::executeTask()
{
login();
}
// FIXME: minecraft specific
void LaunchController::login()
{
if (!m_instance)
{
@ -35,6 +29,12 @@ void LaunchController::login()
return;
}
login();
}
// FIXME: minecraft specific
void LaunchController::login()
{
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
// Find an account to use.