summaryrefslogtreecommitdiffstats
path: root/source/packets
diff options
context:
space:
mode:
Diffstat (limited to 'source/packets')
-rw-r--r--source/packets/cPacket_BlockAction.cpp12
-rw-r--r--source/packets/cPacket_BlockAction.h27
-rw-r--r--source/packets/cPacket_EntityLook.h7
-rw-r--r--source/packets/cPacket_KeepAlive.h6
-rw-r--r--source/packets/cPacket_Player.cpp33
-rw-r--r--source/packets/cPacket_Player.h4
-rw-r--r--source/packets/cPacket_Respawn.h27
-rw-r--r--source/packets/cPacket_TeleportEntity.cpp14
-rw-r--r--source/packets/cPacket_TeleportEntity.h9
-rw-r--r--source/packets/cPacket_UpdateSign.cpp12
-rw-r--r--source/packets/cPacket_UpdateSign.h25
-rw-r--r--source/packets/cPacket_UseEntity.cpp6
-rw-r--r--source/packets/cPacket_UseEntity.h24
13 files changed, 117 insertions, 89 deletions
diff --git a/source/packets/cPacket_BlockAction.cpp b/source/packets/cPacket_BlockAction.cpp
index 43a279f37..a4eb01ad8 100644
--- a/source/packets/cPacket_BlockAction.cpp
+++ b/source/packets/cPacket_BlockAction.cpp
@@ -10,9 +10,9 @@
cPacket_BlockAction::cPacket_BlockAction( const cPacket_BlockAction & a_Copy )
{
m_PacketID = E_BLOCK_ACTION;
- m_PosX = a_Copy.m_PosX;
- m_PosY = a_Copy.m_PosY;
- m_PosZ = a_Copy.m_PosZ;
+ m_BlockX = a_Copy.m_BlockX;
+ m_BlockY = a_Copy.m_BlockY;
+ m_BlockZ = a_Copy.m_BlockZ;
m_Byte1 = a_Copy.m_Byte1;
m_Byte2 = a_Copy.m_Byte2;
}
@@ -24,9 +24,9 @@ cPacket_BlockAction::cPacket_BlockAction( const cPacket_BlockAction & a_Copy )
void cPacket_BlockAction::Serialize(AString & a_Data) const
{
AppendByte (a_Data, m_PacketID);
- AppendInteger(a_Data, m_PosX);
- AppendShort (a_Data, m_PosY);
- AppendInteger(a_Data, m_PosZ);
+ AppendInteger(a_Data, m_BlockX);
+ AppendShort (a_Data, m_BlockY);
+ AppendInteger(a_Data, m_BlockZ);
AppendByte (a_Data, m_Byte1);
AppendByte (a_Data, m_Byte2);
}
diff --git a/source/packets/cPacket_BlockAction.h b/source/packets/cPacket_BlockAction.h
index c74068401..df473801f 100644
--- a/source/packets/cPacket_BlockAction.h
+++ b/source/packets/cPacket_BlockAction.h
@@ -4,28 +4,33 @@
#include "cPacket.h"
-class cPacket_BlockAction : public cPacket
+
+
+
+class cPacket_BlockAction :
+ public cPacket
{
public:
cPacket_BlockAction()
- : m_PosX( 0 )
- , m_PosY( 0 )
- , m_PosZ( 0 )
+ : m_BlockX( 0 )
+ , m_BlockY( 0 )
+ , m_BlockZ( 0 )
, m_Byte1( 0 )
, m_Byte2( 0 )
- { m_PacketID = E_BLOCK_ACTION; }
+ {
+ m_PacketID = E_BLOCK_ACTION;
+ }
+
cPacket_BlockAction( const cPacket_BlockAction & a_Copy );
- virtual cPacket* Clone() const { return new cPacket_BlockAction(*this); }
+ virtual cPacket * Clone() const { return new cPacket_BlockAction(*this); }
virtual void Serialize(AString & a_Data) const override;
- int m_PosX; // Block X Coordinate
- short m_PosY; // Block Y Coordinate
- int m_PosZ; // Block Z Coordinate
+ int m_BlockX;
+ short m_BlockY;
+ int m_BlockZ;
char m_Byte1; // Varies
char m_Byte2; // Varies
-
- static const unsigned int c_Size = 1 + 4 + 2 + 4 + 1 + 1;
};
diff --git a/source/packets/cPacket_EntityLook.h b/source/packets/cPacket_EntityLook.h
index 7f2864d46..463faccda 100644
--- a/source/packets/cPacket_EntityLook.h
+++ b/source/packets/cPacket_EntityLook.h
@@ -43,14 +43,17 @@ public:
cPacket_EntityHeadLook(void)
: m_UniqueID( 0 )
, m_HeadYaw( 0 )
- { m_PacketID = E_ENT_LOOK; }
+ {
+ m_PacketID = E_ENT_LOOK;
+ }
+
cPacket_EntityHeadLook(const cEntity & a_Entity);
virtual cPacket * Clone(void) const { return new cPacket_EntityHeadLook(*this); }
virtual void Serialize(AString & a_Data) const override;
- int m_UniqueID;
+ int m_UniqueID;
char m_HeadYaw;
};
diff --git a/source/packets/cPacket_KeepAlive.h b/source/packets/cPacket_KeepAlive.h
index 0eeb5e095..c3b9d0587 100644
--- a/source/packets/cPacket_KeepAlive.h
+++ b/source/packets/cPacket_KeepAlive.h
@@ -12,14 +12,12 @@ class cPacket_KeepAlive : public cPacket
public:
cPacket_KeepAlive() { m_PacketID = E_KEEP_ALIVE; }
cPacket_KeepAlive(int a_PingID) { m_KeepAliveID = a_PingID; }
- virtual cPacket* Clone() const { return new cPacket_KeepAlive(*this); }
+ virtual cPacket * Clone() const { return new cPacket_KeepAlive(*this); }
- virtual int Parse(cByteBuffer & a_Buffer) override;
+ virtual int Parse(cByteBuffer & a_Buffer) override;
virtual void Serialize(AString & a_Data) const override;
int m_KeepAliveID;
-
- static const unsigned int c_Size = 1 + 4;
};
diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp
index c24905e15..2136d63e6 100644
--- a/source/packets/cPacket_Player.cpp
+++ b/source/packets/cPacket_Player.cpp
@@ -143,16 +143,16 @@ void cPacket_PlayerLook::Serialize(AString & a_Data) const
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cPacket_PlayerMoveLook:
-cPacket_PlayerMoveLook::cPacket_PlayerMoveLook( cPlayer* a_Player )
+cPacket_PlayerMoveLook::cPacket_PlayerMoveLook(const cPlayer & a_Player)
{
m_PacketID = E_PLAYERMOVELOOK;
- m_PosX = a_Player->GetPosX();
- m_PosY = a_Player->GetPosY() + 1.65;
- m_PosZ = a_Player->GetPosZ();
- m_Stance = a_Player->GetStance();
- m_Rotation = a_Player->GetRotation();
- m_Pitch = a_Player->GetPitch();
- m_IsOnGround = a_Player->IsOnGround();
+ m_PosX = a_Player.GetPosX();
+ m_PosY = a_Player.GetPosY() + 0.03; // Add a small amount so that the player doesn't start inside a block
+ m_PosZ = a_Player.GetPosZ();
+ m_Stance = a_Player.GetStance() + 0.03; // Add a small amount so that the player doesn't start inside a block
+ m_Rotation = a_Player.GetRotation();
+ m_Pitch = a_Player.GetPitch();
+ m_IsOnGround = a_Player.IsOnGround();
}
@@ -161,6 +161,8 @@ cPacket_PlayerMoveLook::cPacket_PlayerMoveLook( cPlayer* a_Player )
int cPacket_PlayerMoveLook::Parse(cByteBuffer & a_Buffer)
{
+ // NOTE that Stance and Y are swapped when sent C->S vs S->C
+ // This is the C->S case:
int TotalBytes = 0;
HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes);
HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes);
@@ -169,6 +171,7 @@ int cPacket_PlayerMoveLook::Parse(cByteBuffer & a_Buffer)
HANDLE_PACKET_READ(ReadBEFloat, m_Rotation, TotalBytes);
HANDLE_PACKET_READ(ReadBEFloat, m_Pitch, TotalBytes);
HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes);
+ // LOGD("Recv PML: {%0.2f, %0.2f, %0.2f}, Stance %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0);
return TotalBytes;
}
@@ -178,10 +181,14 @@ int cPacket_PlayerMoveLook::Parse(cByteBuffer & a_Buffer)
void cPacket_PlayerMoveLook::Serialize(AString & a_Data) const
{
+ // NOTE that Stance and Y are swapped when sent C->S vs S->C
+ // This is the S->C case:
+ // LOGD("Send PML: {%0.2f, %0.2f, %0.2f}, Stance: %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0);
+
AppendByte (a_Data, m_PacketID);
AppendDouble(a_Data, m_PosX);
- AppendDouble(a_Data, m_PosY);
AppendDouble(a_Data, m_Stance);
+ AppendDouble(a_Data, m_PosY);
AppendDouble(a_Data, m_PosZ);
AppendFloat (a_Data, m_Rotation);
AppendFloat (a_Data, m_Pitch);
@@ -200,7 +207,7 @@ cPacket_PlayerPosition::cPacket_PlayerPosition(cPlayer * a_Player)
m_PacketID = E_PLAYERPOS;
m_PosX = a_Player->GetPosX();
- m_PosY = a_Player->GetPosY() + 1.65;
+ m_PosY = a_Player->GetPosY();
m_PosZ = a_Player->GetPosZ();
m_Stance = a_Player->GetStance();
m_IsOnGround = a_Player->IsOnGround();
@@ -218,6 +225,7 @@ int cPacket_PlayerPosition::Parse(cByteBuffer & a_Buffer)
HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes);
HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes);
HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes);
+ // LOGD("Recv PlayerPos: {%0.2f %0.2f %0.2f}, Stance %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0);
return TotalBytes;
}
@@ -227,12 +235,17 @@ int cPacket_PlayerPosition::Parse(cByteBuffer & a_Buffer)
void cPacket_PlayerPosition::Serialize(AString & a_Data) const
{
+ LOGD("Ignore send PlayerPos");
+ /*
+ LOGD("Send PlayerPos: {%0.2f %0.2f %0.2f}, Stance %0.2f, Gnd: %d", m_PosX, m_PosY, m_PosZ, m_Stance, m_IsOnGround ? 1 : 0);
+ // _X: This should not get sent to the client at all - http://wiki.vg/wiki/index.php?title=Protocol&oldid=2513#Player_Position_.280x0B.29
AppendByte (a_Data, m_PacketID);
AppendDouble (a_Data, m_PosX);
AppendDouble (a_Data, m_PosY);
AppendDouble (a_Data, m_Stance);
AppendDouble (a_Data, m_PosZ);
AppendBool (a_Data, m_IsOnGround);
+ */
}
diff --git a/source/packets/cPacket_Player.h b/source/packets/cPacket_Player.h
index d9f7c0057..af2dbcc34 100644
--- a/source/packets/cPacket_Player.h
+++ b/source/packets/cPacket_Player.h
@@ -109,8 +109,8 @@ public:
m_PacketID = E_PLAYERMOVELOOK;
}
- cPacket_PlayerMoveLook( cPlayer* a_Player );
- virtual cPacket* Clone() const { return new cPacket_PlayerMoveLook(*this); }
+ cPacket_PlayerMoveLook(const cPlayer & a_Player);
+ virtual cPacket * Clone() const { return new cPacket_PlayerMoveLook(*this); }
virtual int Parse(cByteBuffer & a_Buffer) override;
virtual void Serialize(AString & a_Data) const override;
diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h
index d51869cda..b05f84614 100644
--- a/source/packets/cPacket_Respawn.h
+++ b/source/packets/cPacket_Respawn.h
@@ -9,26 +9,29 @@
-class cPacket_Respawn : public cPacket
+class cPacket_Respawn :
+ public cPacket
{
public:
cPacket_Respawn()
- : m_Dimension( 0 )
- , m_Difficulty( 0 )
- , m_CreativeMode( 0 )
- , m_WorldHeight( 0 )
+ : m_Dimension(0)
+ , m_Difficulty(0)
+ , m_CreativeMode(0)
+ , m_WorldHeight(256)
, m_LevelType( cPacket_Login::LEVEL_TYPE_DEFAULT )
- { m_PacketID = E_RESPAWN; }
+ {
+ m_PacketID = E_RESPAWN;
+ }
- virtual cPacket* Clone() const { return new cPacket_Respawn( *this ); }
+ virtual cPacket * Clone() const { return new cPacket_Respawn( *this ); }
- virtual int Parse(cByteBuffer & a_Buffer) override;
+ virtual int Parse(cByteBuffer & a_Buffer) override;
virtual void Serialize(AString & a_Data) const override;
- int m_Dimension;
- char m_Difficulty;
- char m_CreativeMode;
- short m_WorldHeight;
+ int m_Dimension;
+ char m_Difficulty;
+ char m_CreativeMode;
+ short m_WorldHeight;
AString m_LevelType;
};
diff --git a/source/packets/cPacket_TeleportEntity.cpp b/source/packets/cPacket_TeleportEntity.cpp
index 396095037..14905701a 100644
--- a/source/packets/cPacket_TeleportEntity.cpp
+++ b/source/packets/cPacket_TeleportEntity.cpp
@@ -9,16 +9,16 @@
-cPacket_TeleportEntity::cPacket_TeleportEntity(cEntity* a_Client)
+cPacket_TeleportEntity::cPacket_TeleportEntity(const cEntity & a_Entity)
{
m_PacketID = E_ENT_TELEPORT;
- m_UniqueID = a_Client->GetUniqueID();
- m_PosX = (int)(a_Client->GetPosX() * 32);
- m_PosY = (int)(a_Client->GetPosY() * 32);
- m_PosZ = (int)(a_Client->GetPosZ() * 32);
- m_Rotation = (char)((a_Client->GetRotation() / 360.f) * 256);
- m_Pitch = (char)((a_Client->GetPitch() / 360.f) * 256);
+ m_UniqueID = a_Entity.GetUniqueID();
+ m_PosX = (int)(a_Entity.GetPosX() * 32);
+ m_PosY = (int)(a_Entity.GetPosY() * 32);
+ m_PosZ = (int)(a_Entity.GetPosZ() * 32);
+ m_Rotation = (char)((a_Entity.GetRotation() / 360.f) * 256);
+ m_Pitch = (char)((a_Entity.GetPitch() / 360.f) * 256);
}
diff --git a/source/packets/cPacket_TeleportEntity.h b/source/packets/cPacket_TeleportEntity.h
index d0504f901..5203badb6 100644
--- a/source/packets/cPacket_TeleportEntity.h
+++ b/source/packets/cPacket_TeleportEntity.h
@@ -18,9 +18,12 @@ public:
, m_PosZ( 0 )
, m_Rotation( 0 )
, m_Pitch( 0 )
- { m_PacketID = E_ENT_TELEPORT; }
- virtual cPacket* Clone() const { return new cPacket_TeleportEntity(*this); }
- cPacket_TeleportEntity(cEntity* a_Client);
+ {
+ m_PacketID = E_ENT_TELEPORT;
+ }
+
+ virtual cPacket * Clone() const { return new cPacket_TeleportEntity(*this); }
+ cPacket_TeleportEntity(const cEntity & a_Entity);
virtual void Serialize(AString & a_Data) const override;
diff --git a/source/packets/cPacket_UpdateSign.cpp b/source/packets/cPacket_UpdateSign.cpp
index 3ef587f13..564debf01 100644
--- a/source/packets/cPacket_UpdateSign.cpp
+++ b/source/packets/cPacket_UpdateSign.cpp
@@ -10,9 +10,9 @@
int cPacket_UpdateSign::Parse(cByteBuffer & a_Buffer)
{
int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes);
- HANDLE_PACKET_READ(ReadBEShort, m_PosY, TotalBytes);
- HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEInt, m_BlockX, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEShort, m_BlockY, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEInt, m_BlockZ, TotalBytes);
HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line1, TotalBytes);
HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line2, TotalBytes);
HANDLE_PACKET_READ(ReadBEUTF16String16, m_Line3, TotalBytes);
@@ -27,9 +27,9 @@ int cPacket_UpdateSign::Parse(cByteBuffer & a_Buffer)
void cPacket_UpdateSign::Serialize(AString & a_Data) const
{
AppendByte (a_Data, m_PacketID);
- AppendInteger (a_Data, m_PosX);
- AppendShort (a_Data, m_PosY);
- AppendInteger (a_Data, m_PosZ);
+ AppendInteger (a_Data, m_BlockX);
+ AppendShort (a_Data, m_BlockY);
+ AppendInteger (a_Data, m_BlockZ);
AppendString16(a_Data, m_Line1);
AppendString16(a_Data, m_Line2);
AppendString16(a_Data, m_Line3);
diff --git a/source/packets/cPacket_UpdateSign.h b/source/packets/cPacket_UpdateSign.h
index 9c3790c77..110ae8253 100644
--- a/source/packets/cPacket_UpdateSign.h
+++ b/source/packets/cPacket_UpdateSign.h
@@ -11,24 +11,25 @@ class cPacket_UpdateSign : public cPacket
{
public:
cPacket_UpdateSign()
- : m_PosX( 0 )
- , m_PosY( 0 )
- , m_PosZ( 0 )
- { m_PacketID = E_UPDATE_SIGN; }
- virtual cPacket* Clone() const { return new cPacket_UpdateSign( *this ); }
-
- virtual int Parse(cByteBuffer & a_Buffer) override;
+ : m_BlockX( 0 )
+ , m_BlockY( 0 )
+ , m_BlockZ( 0 )
+ {
+ m_PacketID = E_UPDATE_SIGN;
+ }
+
+ virtual cPacket * Clone() const { return new cPacket_UpdateSign( *this ); }
+
+ virtual int Parse(cByteBuffer & a_Buffer) override;
virtual void Serialize(AString & a_Data) const override;
- int m_PosX;
- short m_PosY;
- int m_PosZ;
+ int m_BlockX;
+ short m_BlockY;
+ int m_BlockZ;
AString m_Line1;
AString m_Line2;
AString m_Line3;
AString m_Line4;
-
- static const unsigned int c_Size = 1 + 4 + 2 + 4 + 2 + 2 + 2 + 2; // minimum size
};
diff --git a/source/packets/cPacket_UseEntity.cpp b/source/packets/cPacket_UseEntity.cpp
index 73b4f7f82..9ecb3bffc 100644
--- a/source/packets/cPacket_UseEntity.cpp
+++ b/source/packets/cPacket_UseEntity.cpp
@@ -10,9 +10,9 @@
int cPacket_UseEntity::Parse(cByteBuffer & a_Buffer)
{
int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadBEInt, m_UniqueID, TotalBytes);
- HANDLE_PACKET_READ(ReadBEInt, m_TargetID, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_bLeftClick, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEInt, m_SourceEntityID, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEInt, m_TargetEntityID, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_IsLeftClick, TotalBytes);
return TotalBytes;
}
diff --git a/source/packets/cPacket_UseEntity.h b/source/packets/cPacket_UseEntity.h
index 799122bf9..ff33ccd93 100644
--- a/source/packets/cPacket_UseEntity.h
+++ b/source/packets/cPacket_UseEntity.h
@@ -7,23 +7,25 @@
-class cPacket_UseEntity : public cPacket
+class cPacket_UseEntity :
+ public cPacket
{
public:
cPacket_UseEntity()
- : m_UniqueID( 0 )
- , m_TargetID( 0 )
- , m_bLeftClick( false )
- { m_PacketID = E_USE_ENTITY; }
- virtual cPacket* Clone() const { return new cPacket_UseEntity(*this); }
+ : m_SourceEntityID(0)
+ , m_TargetEntityID(0)
+ , m_IsLeftClick(false)
+ {
+ m_PacketID = E_USE_ENTITY;
+ }
+
+ virtual cPacket * Clone() const { return new cPacket_UseEntity(*this); }
virtual int Parse(cByteBuffer & a_Buffer) override;
- int m_UniqueID;
- int m_TargetID;
- bool m_bLeftClick;
-
- static const unsigned int c_Size = 1 + 4 + 4 + 1;
+ int m_SourceEntityID;
+ int m_TargetEntityID;
+ bool m_IsLeftClick;
};