summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-19 21:53:47 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-19 21:53:47 +0100
commit03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce (patch)
tree82dd75c70052b9b32781a589b7d2cee13faa237f /src
parentFixed 1.7 arm swing animation (diff)
downloadcuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar.gz
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar.bz2
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar.lz
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar.xz
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.tar.zst
cuberite-03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce.zip
Diffstat (limited to 'src')
-rw-r--r--src/ClientHandle.cpp6
-rw-r--r--src/Entities/Player.cpp18
-rw-r--r--src/Protocol/Protocol17x.cpp13
3 files changed, 24 insertions, 13 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index de0a57a0a..1e63e2ba1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -264,9 +264,6 @@ void cClientHandle::Authenticate(void)
// Send experience
m_Player->SendExperience();
- // Send gamemode (1.6.1 movementSpeed):
- SendGameMode(m_Player->GetGameMode());
-
m_Player->Initialize(World);
m_State = csAuthenticated;
@@ -489,6 +486,9 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel
void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
{
+ UNUSED(FlyingSpeed); // Ignore the client values for these
+ UNUSED(WalkingSpeed);
+
m_Player->SetCanFly(a_CanFly);
m_Player->SetFlying(a_IsFlying);
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 7e7d77433..bb19bcce9 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1500,6 +1500,24 @@ bool cPlayer::LoadFromDisk()
//SetExperience(root.get("experience", 0).asInt());
m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
+
+ if (m_GameMode == eGameMode_Creative)
+ {
+ m_CanFly = true;
+ }
+ else if (m_GameMode == eGameMode_NotSet)
+ {
+ cWorld * World = cRoot::Get()->GetWorld(GetLoadedWorldName());
+ if (World == NULL)
+ {
+ World = cRoot::Get()->GetDefaultWorld();
+ }
+
+ if (World->GetGameMode() == eGameMode_Creative)
+ {
+ m_CanFly = true;
+ }
+ }
m_Inventory.LoadFromJson(root["inventory"]);
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index fff5311f6..161e81936 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -490,6 +490,7 @@ void cProtocol172::SendPlayerAbilities(void)
if (m_Client->GetPlayer()->IsGameModeCreative())
{
Flags |= 0x01;
+ Flags |= 0x08; // Godmode, used for creative
}
if (m_Client->GetPlayer()->IsFlying())
{
@@ -499,7 +500,6 @@ void cProtocol172::SendPlayerAbilities(void)
{
Flags |= 0x04;
}
- // TODO: Other flags (god mode)
Pkt.WriteByte(Flags);
// TODO: Pkt.WriteFloat(m_Client->GetPlayer()->GetMaxFlyingSpeed());
Pkt.WriteFloat(0.05f);
@@ -1291,23 +1291,16 @@ void cProtocol172::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, FlyingSpeed);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, WalkingSpeed);
- bool IsFlying, CanFly;
+ bool IsFlying = false, CanFly = false;
if ((Flags & 2) != 0)
{
IsFlying = true;
}
- else
- {
- IsFlying = false;
- }
if ((Flags & 4) != 0)
{
CanFly = true;
}
- else
- {
- CanFly = false;
- }
+
m_Client->HandlePlayerAbilities(CanFly, IsFlying, FlyingSpeed, WalkingSpeed);
}