diff options
author | andrew <xdotftw@gmail.com> | 2014-05-11 19:30:54 +0200 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-05-11 19:30:54 +0200 |
commit | e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c (patch) | |
tree | 36e303c31006c346aaf895cdb631ff60dd9cdca6 /src/Entities/Player.cpp | |
parent | Statistic Manager (diff) | |
download | cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar.gz cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar.bz2 cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar.lz cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar.xz cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.tar.zst cuberite-e3c6c8f3ddffdc368ebbc1a7688de2ca1b97167c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Player.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a42fe89cf..1df473eb2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -133,15 +133,6 @@ cPlayer::~cPlayer(void) SaveToDisk(); -#if 0 - /* Save statistics. */ - cStatSerializer StatSerializer(m_World->GetName(), m_PlayerName, &m_Stats); - if (!StatSerializer.Save()) - { - LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); - } -#endif - m_World->RemovePlayer( this ); m_ClientHandle = NULL; @@ -1638,6 +1629,12 @@ bool cPlayer::LoadFromDisk() m_Inventory.LoadFromJson(root["inventory"]); m_LoadedWorldName = root.get("world", "world").asString(); + + /* Load the player stats. + * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. + */ + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats); + StatSerializer.Load(); LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"", m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str() @@ -1709,6 +1706,17 @@ bool cPlayer::SaveToDisk() LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str()); return false; } + + /* Save the player stats. + * We use the default world name (like bukkit) because stats are shared between dimensions/worlds. + */ + cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats); + if (!StatSerializer.Save()) + { + LOGERROR("Could not save stats for player %s", m_PlayerName.c_str()); + return false; + } + return true; } @@ -1723,7 +1731,10 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) { - if( itr->second ) Permissions.push_back( itr->first ); + if (itr->second) + { + Permissions.push_back( itr->first ); + } } return Permissions; |