summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authorlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-13 17:26:27 +0200
committerlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-13 17:26:27 +0200
commitabf9e3f6dd9b610ef83a586e12abfbbd00dea640 (patch)
tree46c3fbcf113028c8bc92731b0deb76f215275a51 /source/cPlayer.cpp
parentSave last gamemode (diff)
downloadcuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar.gz
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar.bz2
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar.lz
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar.xz
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.tar.zst
cuberite-abf9e3f6dd9b610ef83a586e12abfbbd00dea640.zip
Diffstat (limited to '')
-rw-r--r--source/cPlayer.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 5ab06fa62..9e54b7c44 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -53,7 +53,7 @@ CLASS_DEFINITION( cPlayer, cPawn );
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
- : m_GameMode( eGameMode_Survival )
+ : m_GameMode(eGameMode_NotSet)
, m_IP("")
, m_LastBlockActionTime( 0 )
, m_LastBlockActionCnt( 0 )
@@ -915,7 +915,10 @@ bool cPlayer::LoadFromDisk()
m_Health = (short)root.get("health", 0 ).asInt();
m_FoodLevel = (short)root.get("food", 0 ).asInt();
- m_GameMode = (eGameMode) root.get("gamemode", cRoot::Get()->GetDefaultWorld()->GetGameMode()).asInt();
+
+ m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
+
+
m_Inventory->LoadFromJson(root["inventory"]);
m_CreativeInventory->LoadFromJson(root["creativeinventory"]);
@@ -961,7 +964,13 @@ bool cPlayer::SaveToDisk()
root["health"] = m_Health;
root["food"] = m_FoodLevel;
root["world"] = GetWorld()->GetName();
- root["gamemode"] = (int) m_GameMode;
+
+ if(m_GameMode == GetWorld()->GetGameMode())
+ {
+ root["gamemode"] = (int) eGameMode_NotSet;
+ }else{
+ root["gamemode"] = (int) m_GameMode;
+ }
Json::StyledWriter writer;
std::string JsonData = writer.write( root );