Avoid writing the players.xml file multiple time at the exit time.

This commit is contained in:
hiker
2014-10-08 22:53:34 +11:00
parent bc7d8f6103
commit 029c33c276
3 changed files with 9 additions and 4 deletions

View File

@@ -170,7 +170,11 @@ PlayerManager::~PlayerManager()
for_var_in(PlayerProfile*, player, m_all_players)
{
if(!player->rememberPassword())
player->clearSession();
{
// Don't let the player trigger a save, since it
// will be done below anyway.
player->clearSession(/*save*/false);
}
}
save();

View File

@@ -235,12 +235,13 @@ void PlayerProfile::saveSession(int user_id, const std::string &token)
// ------------------------------------------------------------------------
/** Unsets any saved session data. */
void PlayerProfile::clearSession()
void PlayerProfile::clearSession(bool save)
{
m_saved_session = false;
m_saved_user_id = 0;
m_saved_token = "";
PlayerManager::get()->save();
if(save)
PlayerManager::get()->save();
} // clearSession
//------------------------------------------------------------------------------

View File

@@ -121,7 +121,7 @@ public:
bool operator<(const PlayerProfile &other);
void raceFinished();
void saveSession(int user_id, const std::string &token);
void clearSession();
void clearSession(bool save=true);
void addIcon();
/** Abstract virtual classes, to be implemented by the OnlinePlayer. */