diff options
author | Lane Kolbly <lane@rscheme.org> | 2017-08-30 16:01:33 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2017-08-30 16:01:33 +0200 |
commit | 5d64451f74af1839177f9b93d76cd393b7a58ad1 (patch) | |
tree | a2467709cc553fa0bcaeecc5253042387577b73c /src | |
parent | Update mbedtls to 2.5.1 (#3964) (diff) | |
download | cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar.gz cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar.bz2 cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar.lz cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar.xz cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.tar.zst cuberite-5d64451f74af1839177f9b93d76cd393b7a58ad1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.h | 4 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 28 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 28 |
3 files changed, 36 insertions, 24 deletions
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index d143e3814..f39039183 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -306,6 +306,10 @@ public: /** Exported in ManualBindings */ const Vector3d & GetSpeed(void) const { return m_Speed; } + /** Returns the last position we sent to all the clients. Use this to + initialize clients with our position. */ + Vector3d GetLastSentPos(void) const { return m_LastSentPosition; } + /** Destroy the entity without scheduling memory freeing. This should only be used by cChunk or cClientHandle for internal memory management. */ void DestroyNoScheduling(bool a_ShouldBroadcast); diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 7f4b074ce..b6e5b5a38 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -1077,9 +1077,10 @@ void cProtocol_1_8_0::SendPlayerSpawn(const cPlayer & a_Player) cPacketizer Pkt(*this, 0x0c); // Spawn Player packet Pkt.WriteVarInt32(a_Player.GetUniqueID()); Pkt.WriteUUID(a_Player.GetUUID()); - Pkt.WriteFPInt(a_Player.GetPosX()); - Pkt.WriteFPInt(a_Player.GetPosY() + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. - Pkt.WriteFPInt(a_Player.GetPosZ()); + Vector3d LastSentPos = a_Player.GetLastSentPos(); + Pkt.WriteFPInt(LastSentPos.x); + Pkt.WriteFPInt(LastSentPos.y + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. + Pkt.WriteFPInt(LastSentPos.z); Pkt.WriteByteAngle(a_Player.GetYaw()); Pkt.WriteByteAngle(a_Player.GetPitch()); short ItemType = a_Player.GetEquippedItem().IsEmpty() ? 0 : a_Player.GetEquippedItem().m_ItemType; @@ -1314,9 +1315,10 @@ void cProtocol_1_8_0::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock cPacketizer Pkt(*this, 0x0e); // Spawn Object packet Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID()); Pkt.WriteBEUInt8(70); // Falling block - Pkt.WriteFPInt(a_FallingBlock.GetPosX()); - Pkt.WriteFPInt(a_FallingBlock.GetPosY()); - Pkt.WriteFPInt(a_FallingBlock.GetPosZ()); + Vector3d LastSentPos = a_FallingBlock.GetLastSentPos(); + Pkt.WriteFPInt(LastSentPos.x); + Pkt.WriteFPInt(LastSentPos.y); + Pkt.WriteFPInt(LastSentPos.z); Pkt.WriteByteAngle(a_FallingBlock.GetYaw()); Pkt.WriteByteAngle(a_FallingBlock.GetPitch()); Pkt.WriteBEInt32(static_cast<Int32>(a_FallingBlock.GetBlockType()) | (static_cast<Int32>(a_FallingBlock.GetBlockMeta()) << 12)); @@ -1336,9 +1338,10 @@ void cProtocol_1_8_0::SendSpawnMob(const cMonster & a_Mob) cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet Pkt.WriteVarInt32(a_Mob.GetUniqueID()); Pkt.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType())); - Pkt.WriteFPInt(a_Mob.GetPosX()); - Pkt.WriteFPInt(a_Mob.GetPosY()); - Pkt.WriteFPInt(a_Mob.GetPosZ()); + Vector3d LastSentPos = a_Mob.GetLastSentPos(); + Pkt.WriteFPInt(LastSentPos.x); + Pkt.WriteFPInt(LastSentPos.y); + Pkt.WriteFPInt(LastSentPos.z); Pkt.WriteByteAngle(a_Mob.GetPitch()); Pkt.WriteByteAngle(a_Mob.GetHeadYaw()); Pkt.WriteByteAngle(a_Mob.GetYaw()); @@ -1392,9 +1395,10 @@ void cProtocol_1_8_0::SendSpawnVehicle(const cEntity & a_Vehicle, char a_Vehicle cPacketizer Pkt(*this, 0xe); // Spawn Object packet Pkt.WriteVarInt32(a_Vehicle.GetUniqueID()); Pkt.WriteBEUInt8(static_cast<UInt8>(a_VehicleType)); - Pkt.WriteFPInt(a_Vehicle.GetPosX()); - Pkt.WriteFPInt(a_Vehicle.GetPosY()); - Pkt.WriteFPInt(a_Vehicle.GetPosZ()); + Vector3d LastSentPos = a_Vehicle.GetLastSentPos(); + Pkt.WriteFPInt(LastSentPos.x); + Pkt.WriteFPInt(LastSentPos.y); + Pkt.WriteFPInt(LastSentPos.z); Pkt.WriteByteAngle(a_Vehicle.GetPitch()); Pkt.WriteByteAngle(a_Vehicle.GetYaw()); Pkt.WriteBEInt32(a_VehicleSubType); diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index c440a94ca..475047417 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -1124,9 +1124,10 @@ void cProtocol_1_9_0::SendPlayerSpawn(const cPlayer & a_Player) cPacketizer Pkt(*this, 0x05); // Spawn Player packet Pkt.WriteVarInt32(a_Player.GetUniqueID()); Pkt.WriteUUID(a_Player.GetUUID()); - Pkt.WriteBEDouble(a_Player.GetPosX()); - Pkt.WriteBEDouble(a_Player.GetPosY() + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. - Pkt.WriteBEDouble(a_Player.GetPosZ()); + Vector3d LastSentPos = a_Player.GetLastSentPos(); + Pkt.WriteBEDouble(LastSentPos.x); + Pkt.WriteBEDouble(LastSentPos.y + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. + Pkt.WriteBEDouble(LastSentPos.z); Pkt.WriteByteAngle(a_Player.GetYaw()); Pkt.WriteByteAngle(a_Player.GetPitch()); WriteEntityMetadata(Pkt, a_Player); @@ -1359,9 +1360,10 @@ void cProtocol_1_9_0::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock Pkt.WriteBEUInt64(0); Pkt.WriteBEUInt64(a_FallingBlock.GetUniqueID()); Pkt.WriteBEUInt8(70); // Falling block - Pkt.WriteBEDouble(a_FallingBlock.GetPosX()); - Pkt.WriteBEDouble(a_FallingBlock.GetPosY()); - Pkt.WriteBEDouble(a_FallingBlock.GetPosZ()); + Vector3d LastSentPos = a_FallingBlock.GetLastSentPos(); + Pkt.WriteBEDouble(LastSentPos.x); + Pkt.WriteBEDouble(LastSentPos.y); + Pkt.WriteBEDouble(LastSentPos.z); Pkt.WriteByteAngle(a_FallingBlock.GetYaw()); Pkt.WriteByteAngle(a_FallingBlock.GetPitch()); Pkt.WriteBEInt32(static_cast<Int32>(a_FallingBlock.GetBlockType()) | (static_cast<Int32>(a_FallingBlock.GetBlockMeta()) << 12)); @@ -1384,9 +1386,10 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob) Pkt.WriteBEUInt64(0); Pkt.WriteBEUInt64(a_Mob.GetUniqueID()); Pkt.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType())); - Pkt.WriteBEDouble(a_Mob.GetPosX()); - Pkt.WriteBEDouble(a_Mob.GetPosY()); - Pkt.WriteBEDouble(a_Mob.GetPosZ()); + Vector3d LastSentPos = a_Mob.GetLastSentPos(); + Pkt.WriteBEDouble(LastSentPos.x); + Pkt.WriteBEDouble(LastSentPos.y); + Pkt.WriteBEDouble(LastSentPos.z); Pkt.WriteByteAngle(a_Mob.GetPitch()); Pkt.WriteByteAngle(a_Mob.GetHeadYaw()); Pkt.WriteByteAngle(a_Mob.GetYaw()); @@ -1443,9 +1446,10 @@ void cProtocol_1_9_0::SendSpawnVehicle(const cEntity & a_Vehicle, char a_Vehicle Pkt.WriteBEUInt64(0); Pkt.WriteBEUInt64(a_Vehicle.GetUniqueID()); Pkt.WriteBEUInt8(static_cast<UInt8>(a_VehicleType)); - Pkt.WriteBEDouble(a_Vehicle.GetPosX()); - Pkt.WriteBEDouble(a_Vehicle.GetPosY()); - Pkt.WriteBEDouble(a_Vehicle.GetPosZ()); + Vector3d LastSentPos = a_Vehicle.GetLastSentPos(); + Pkt.WriteBEDouble(LastSentPos.x); + Pkt.WriteBEDouble(LastSentPos.y); + Pkt.WriteBEDouble(LastSentPos.z); Pkt.WriteByteAngle(a_Vehicle.GetPitch()); Pkt.WriteByteAngle(a_Vehicle.GetYaw()); Pkt.WriteBEInt32(a_VehicleSubType); |