Added support to change the online account for the same player.

This commit is contained in:
hiker 2014-05-22 08:12:55 +10:00
parent c551ea0c14
commit f4688fa621
2 changed files with 14 additions and 3 deletions

View File

@ -114,7 +114,10 @@ namespace Online
OnlinePlayerProfile::requestSignIn(const core::stringw &username,
const core::stringw &password)
{
assert(m_online_state == OS_SIGNED_OUT);
// If the player changes the online account, there can be a
// logout stil happening.
assert(m_online_state == OS_SIGNED_OUT ||
m_online_state == OS_SIGNING_OUT );
SignInRequest * request = new SignInRequest(false);
// We can't use setUserDetail here, since there is no token yet
request->setServerURL("client-user.php");

View File

@ -303,12 +303,20 @@ void BaseUserScreen::login()
PlayerProfile *player = getSelectedPlayer();
PlayerProfile *current = PlayerManager::getCurrentPlayer();
// If a different player is connecting, log out the current player.
if(player!=current && current && current->isLoggedIn())
core::stringw new_username = m_username_tb->getText();
// If a different player is connecting, or the same local player with
// a different online account, log out the current player.
if(current && current->isLoggedIn() &&
(player!=current || current->getLastOnlineName()!=new_username) )
{
m_sign_out_name = current->getLastOnlineName();
current->requestSignOut();
m_state = (UserScreenState)(m_state | STATE_LOGOUT);
// If the online user name was changed, reset the save data
// for this user (otherwise later the saved session will be
// resumed, not logging the user with the new account).
if(current->getLastOnlineName()!=new_username)
current->clearSession();
}
PlayerManager::get()->setCurrentPlayer(player);
assert(player);