Added support to change the online account for the same player.
This commit is contained in:
parent
c551ea0c14
commit
f4688fa621
@ -114,7 +114,10 @@ namespace Online
|
|||||||
OnlinePlayerProfile::requestSignIn(const core::stringw &username,
|
OnlinePlayerProfile::requestSignIn(const core::stringw &username,
|
||||||
const core::stringw &password)
|
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);
|
SignInRequest * request = new SignInRequest(false);
|
||||||
// We can't use setUserDetail here, since there is no token yet
|
// We can't use setUserDetail here, since there is no token yet
|
||||||
request->setServerURL("client-user.php");
|
request->setServerURL("client-user.php");
|
||||||
|
@ -303,12 +303,20 @@ void BaseUserScreen::login()
|
|||||||
|
|
||||||
PlayerProfile *player = getSelectedPlayer();
|
PlayerProfile *player = getSelectedPlayer();
|
||||||
PlayerProfile *current = PlayerManager::getCurrentPlayer();
|
PlayerProfile *current = PlayerManager::getCurrentPlayer();
|
||||||
// If a different player is connecting, log out the current player.
|
core::stringw new_username = m_username_tb->getText();
|
||||||
if(player!=current && current && current->isLoggedIn())
|
// 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();
|
m_sign_out_name = current->getLastOnlineName();
|
||||||
current->requestSignOut();
|
current->requestSignOut();
|
||||||
m_state = (UserScreenState)(m_state | STATE_LOGOUT);
|
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);
|
PlayerManager::get()->setCurrentPlayer(player);
|
||||||
assert(player);
|
assert(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user