summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorPablo Beltrán <spekdrum@gmail.com>2017-06-04 06:35:02 +0200
committerLukas Pioch <lukas@zgow.de>2017-06-04 06:35:02 +0200
commit2b699dc749b1827e47943f148f57dfe2e03f3a75 (patch)
treee743e2abe76e6c22a221f13648b26f4dda986dd4 /src/Entities/Entity.cpp
parentAdd command line argument for disabling the logfile (diff)
downloadcuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar.gz
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar.bz2
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar.lz
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar.xz
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.tar.zst
cuberite-2b699dc749b1827e47943f148f57dfe2e03f3a75.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index f776f881a..db70044b4 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1010,6 +1010,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
NextPos.y += 0.5;
}
+ m_bHasSentNoSpeed = false; // this unlocks movement sending to client in BroadcastMovementUpdate function
m_bOnGround = true;
/*
@@ -1915,35 +1916,39 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
m_bHasSentNoSpeed = false;
}
- // TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
- int DiffX = FloorC(GetPosX() * 32.0) - FloorC(m_LastSentPosition.x * 32.0);
- int DiffY = FloorC(GetPosY() * 32.0) - FloorC(m_LastSentPosition.y * 32.0);
- int DiffZ = FloorC(GetPosZ() * 32.0) - FloorC(m_LastSentPosition.z * 32.0);
-
- if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved?
+ // Only send movement if speed is not 0 and 'no speed' was sent to client
+ if (!m_bHasSentNoSpeed)
{
- if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte
+ // TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
+ int DiffX = FloorC(GetPosX() * 32.0) - FloorC(m_LastSentPosition.x * 32.0);
+ int DiffY = FloorC(GetPosY() * 32.0) - FloorC(m_LastSentPosition.y * 32.0);
+ int DiffZ = FloorC(GetPosZ() * 32.0) - FloorC(m_LastSentPosition.z * 32.0);
+
+ if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved?
{
- // Difference within Byte limitations, use a relative move packet
- if (m_bDirtyOrientation)
+ if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte
{
- m_World->BroadcastEntityRelMoveLook(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
- m_bDirtyOrientation = false;
+ // Difference within Byte limitations, use a relative move packet
+ if (m_bDirtyOrientation)
+ {
+ m_World->BroadcastEntityRelMoveLook(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
+ m_bDirtyOrientation = false;
+ }
+ else
+ {
+ m_World->BroadcastEntityRelMove(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
+ }
+ // Clients seem to store two positions, one for the velocity packet and one for the teleport / relmove packet
+ // The latter is only changed with a relmove / teleport, and m_LastSentPosition stores this position
+ m_LastSentPosition = GetPosition();
}
else
{
- m_World->BroadcastEntityRelMove(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
+ // Too big a movement, do a teleport
+ m_World->BroadcastTeleportEntity(*this, a_Exclude);
+ m_LastSentPosition = GetPosition(); // See above
+ m_bDirtyOrientation = false;
}
- // Clients seem to store two positions, one for the velocity packet and one for the teleport / relmove packet
- // The latter is only changed with a relmove / teleport, and m_LastSentPosition stores this position
- m_LastSentPosition = GetPosition();
- }
- else
- {
- // Too big a movement, do a teleport
- m_World->BroadcastTeleportEntity(*this, a_Exclude);
- m_LastSentPosition = GetPosition(); // See above
- m_bDirtyOrientation = false;
}
}