summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorkeyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-07 08:53:17 +0200
committerkeyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-07 08:53:17 +0200
commit92e782068f1b115ef767170bedad6a225ef2188e (patch)
treef51d998cd4c05e04f2e99bcb1863884783a147f1 /source
parentMineshafts: randomized start position, tweaked default generator parameters; removed debugging glass pillars. (diff)
downloadcuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar.gz
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar.bz2
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar.lz
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar.xz
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.tar.zst
cuberite-92e782068f1b115ef767170bedad6a225ef2188e.zip
Diffstat (limited to 'source')
-rw-r--r--source/Entity.cpp26
-rw-r--r--source/Protocol/Protocol125.cpp4
2 files changed, 16 insertions, 14 deletions
diff --git a/source/Entity.cpp b/source/Entity.cpp
index 0cb97e1ef..c6df88020 100644
--- a/source/Entity.cpp
+++ b/source/Entity.cpp
@@ -276,14 +276,21 @@ void cEntity::Tick(float a_Dt, MTRand & a_TickRandom)
void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
{
- int DiffX = (int)((GetPosX() - m_LastPosX) * 32.0);
- int DiffY = (int)((GetPosY() - m_LastPosY) * 32.0);
- int DiffZ = (int)((GetPosZ() - m_LastPosZ) * 32.0);
- Int64 DiffTeleportPacket = m_World->GetWorldAge() - m_TimeLastTeleportPacket;
-
- //Have to process this every two ticks
+ //We need to keep updating the clients when there is movement or if there was a change in speed and after 2 ticks
+ if( (m_Speed.SqrLength() > 0.0004f || m_bDirtySpeed) && (m_World->GetWorldAge() - m_TimeLastSpeedPacket >= 2))
+ {
+ m_World->BroadcastEntVelocity(*this,a_Exclude);
+ m_bDirtySpeed = false;
+ m_TimeLastSpeedPacket = m_World->GetWorldAge();
+ }
+
+ //Have to process position related packets this every two ticks
if (m_World->GetWorldAge() % 2 == 0)
{
+ int DiffX = (int) (floor(GetPosX() * 32.0) - floor(m_LastPosX * 32.0));
+ int DiffY = (int) (floor(GetPosY() * 32.0) - floor(m_LastPosY * 32.0));
+ int DiffZ = (int) (floor(GetPosZ() * 32.0) - floor(m_LastPosZ * 32.0));
+ Int64 DiffTeleportPacket = m_World->GetWorldAge() - m_TimeLastTeleportPacket;
// 4 blocks is max Relative So if the Diff is greater than 127 or. Send an absolute position every 20 seconds
if (DiffTeleportPacket >= 400 ||
((DiffX > 127) || (DiffX < -128) ||
@@ -336,13 +343,6 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
m_bDirtyHead = false;
}
}
- //We need to keep updating the clients when there is movement or if there was a change in speed and after 2 ticks
- if( (m_Speed.SqrLength() > 0.0004f || m_bDirtySpeed) && (m_World->GetWorldAge() - m_TimeLastSpeedPacket >= 2))
- {
- m_World->BroadcastEntVelocity(*this,a_Exclude);
- m_bDirtySpeed = false;
- m_TimeLastSpeedPacket = m_World->GetWorldAge();
- }
}
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 8d212a4a2..c3cfdfd81 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -725,7 +725,9 @@ void cProtocol125::SendTeleportEntity(const cEntity & a_Entity)
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_ENT_TELEPORT);
WriteInt (a_Entity.GetUniqueID());
- WriteVectorI((Vector3i)(a_Entity.GetPosition() * 32));
+ WriteInt ((int)(floor(a_Entity.GetPosX() * 32)));
+ WriteInt ((int)(floor(a_Entity.GetPosY() * 32)));
+ WriteInt ((int)(floor(a_Entity.GetPosZ() * 32)));
WriteByte ((char)((a_Entity.GetRotation() / 360.f) * 256));
WriteByte ((char)((a_Entity.GetPitch() / 360.f) * 256));
Flush();