The gamemode is now only saved if it is different from the current gamemode.

Default gamemode now depends on the joined world, not on the default world

git-svn-id: http://mc-server.googlecode.com/svn/trunk@661 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
lapayo94@gmail.com 2012-07-13 15:26:27 +00:00
parent 6c5a42737f
commit abf9e3f6dd
3 changed files with 15 additions and 4 deletions

View File

@ -273,6 +273,7 @@ namespace ItemCategory
//tolua_begin //tolua_begin
enum eGameMode enum eGameMode
{ {
eGameMode_NotSet = -1,
eGameMode_Survival = 0, eGameMode_Survival = 0,
eGameMode_Creative = 1, eGameMode_Creative = 1,
}; };

View File

@ -307,7 +307,8 @@ void cClientHandle::Authenticate(void)
World = cRoot::Get()->GetDefaultWorld(); World = cRoot::Get()->GetDefaultWorld();
} }
// We don´t need this, do we? m_Player->LoginSetGameMode (World->GetGameMode()); //set player's gamemode to server's gamemode at login. TODO: set to last player's gamemode at logout if(m_Player->GetGameMode() == eGameMode_NotSet)
m_Player->LoginSetGameMode(World->GetGameMode());
m_Player->SetIP (m_Socket.GetIPString()); m_Player->SetIP (m_Socket.GetIPString());

View File

@ -53,7 +53,7 @@ CLASS_DEFINITION( cPlayer, cPawn );
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
: m_GameMode( eGameMode_Survival ) : m_GameMode(eGameMode_NotSet)
, m_IP("") , m_IP("")
, m_LastBlockActionTime( 0 ) , m_LastBlockActionTime( 0 )
, m_LastBlockActionCnt( 0 ) , m_LastBlockActionCnt( 0 )
@ -915,7 +915,10 @@ bool cPlayer::LoadFromDisk()
m_Health = (short)root.get("health", 0 ).asInt(); m_Health = (short)root.get("health", 0 ).asInt();
m_FoodLevel = (short)root.get("food", 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_Inventory->LoadFromJson(root["inventory"]);
m_CreativeInventory->LoadFromJson(root["creativeinventory"]); m_CreativeInventory->LoadFromJson(root["creativeinventory"]);
@ -961,7 +964,13 @@ bool cPlayer::SaveToDisk()
root["health"] = m_Health; root["health"] = m_Health;
root["food"] = m_FoodLevel; root["food"] = m_FoodLevel;
root["world"] = GetWorld()->GetName(); 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; Json::StyledWriter writer;
std::string JsonData = writer.write( root ); std::string JsonData = writer.write( root );