summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-24 14:28:53 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-24 14:28:53 +0100
commit57834374363965198f8870c9f11111d7c8a12d7f (patch)
tree1b45896954eba5c15ad7d4b8bb790322a1c21fc1
parentProtocol version bumped up to 29 (MC 1.2.4), seems to work. (diff)
downloadcuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar.gz
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar.bz2
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar.lz
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar.xz
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.tar.zst
cuberite-57834374363965198f8870c9f11111d7c8a12d7f.zip
-rw-r--r--VC2008/MCServer.vcproj28
-rw-r--r--VC2010/MCServer.vcxproj10
-rw-r--r--VC2010/MCServer.vcxproj.filters42
-rw-r--r--source/PacketID.h1
-rw-r--r--source/cClientHandle.cpp10
-rw-r--r--source/cClientHandle.h5
-rw-r--r--source/cPlayer.cpp2
-rw-r--r--source/packets/cPacket_Player.cpp243
-rw-r--r--source/packets/cPacket_Player.h150
-rw-r--r--source/packets/cPacket_PlayerListItem.cpp56
-rw-r--r--source/packets/cPacket_PlayerListItem.h30
-rw-r--r--source/packets/cPacket_PlayerLook.cpp46
-rw-r--r--source/packets/cPacket_PlayerLook.h39
-rw-r--r--source/packets/cPacket_PlayerMoveLook.cpp58
-rw-r--r--source/packets/cPacket_PlayerMoveLook.h43
-rw-r--r--source/packets/cPacket_PlayerPosition.cpp53
-rw-r--r--source/packets/cPacket_PlayerPosition.h44
17 files changed, 408 insertions, 452 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 0fbad631f..4b8bcdbfb 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -902,35 +902,11 @@
>
</File>
<File
- RelativePath="..\source\packets\cPacket_PlayerListItem.cpp"
+ RelativePath="..\source\packets\cPacket_Player.cpp"
>
</File>
<File
- RelativePath="..\source\packets\cPacket_PlayerListItem.h"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerLook.cpp"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerLook.h"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerMoveLook.cpp"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerMoveLook.h"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerPosition.cpp"
- >
- </File>
- <File
- RelativePath="..\source\packets\cPacket_PlayerPosition.h"
+ RelativePath="..\source\packets\cPacket_Player.h"
>
</File>
<File
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj
index e711a66ba..d6ddb3b1c 100644
--- a/VC2010/MCServer.vcxproj
+++ b/VC2010/MCServer.vcxproj
@@ -439,7 +439,7 @@
<ClCompile Include="..\source\packets\cPacket_Explosion.cpp" />
<ClCompile Include="..\source\packets\cPacket_ItemData.cpp" />
<ClCompile Include="..\source\packets\cPacket_NewInvalidState.cpp" />
- <ClCompile Include="..\source\packets\cPacket_PlayerListItem.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_Player.cpp" />
<ClCompile Include="..\source\packets\cPacket_SoundEffect.cpp" />
<ClCompile Include="..\source\packets\cPacket_Thunderbolt.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityLook.cpp" />
@@ -456,9 +456,6 @@
<ClCompile Include="..\source\packets\cPacket_MultiBlock.cpp" />
<ClCompile Include="..\source\packets\cPacket_NamedEntitySpawn.cpp" />
<ClCompile Include="..\source\packets\cPacket_PickupSpawn.cpp" />
- <ClCompile Include="..\source\packets\cPacket_PlayerLook.cpp" />
- <ClCompile Include="..\source\packets\cPacket_PlayerMoveLook.cpp" />
- <ClCompile Include="..\source\packets\cPacket_PlayerPosition.cpp" />
<ClCompile Include="..\source\packets\cPacket_PreChunk.cpp" />
<ClCompile Include="..\source\packets\cPacket_RelativeEntityMove.cpp" />
<ClCompile Include="..\source\packets\cPacket_RelativeEntityMoveLook.cpp" />
@@ -625,7 +622,7 @@
<ClInclude Include="..\source\packets\cPacket_Explosion.h" />
<ClInclude Include="..\source\packets\cPacket_ItemData.h" />
<ClInclude Include="..\source\packets\cPacket_NewInvalidState.h" />
- <ClInclude Include="..\source\packets\cPacket_PlayerListItem.h" />
+ <ClInclude Include="..\source\packets\cPacket_Player.h" />
<ClInclude Include="..\source\packets\cPacket_SoundEffect.h" />
<ClInclude Include="..\source\packets\cPacket_Thunderbolt.h" />
<ClInclude Include="..\source\packets\cPacket_EntityLook.h" />
@@ -643,9 +640,6 @@
<ClInclude Include="..\source\packets\cPacket_NamedEntitySpawn.h" />
<ClInclude Include="..\source\packets\cPacket_PickupSpawn.h" />
<ClInclude Include="..\source\packets\cPacket_Ping.h" />
- <ClInclude Include="..\source\packets\cPacket_PlayerLook.h" />
- <ClInclude Include="..\source\packets\cPacket_PlayerMoveLook.h" />
- <ClInclude Include="..\source\packets\cPacket_PlayerPosition.h" />
<ClInclude Include="..\source\packets\cPacket_PreChunk.h" />
<ClInclude Include="..\source\packets\cPacket_RelativeEntityMove.h" />
<ClInclude Include="..\source\packets\cPacket_RelativeEntityMoveLook.h" />
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters
index 8fe9c35f0..02421c803 100644
--- a/VC2010/MCServer.vcxproj.filters
+++ b/VC2010/MCServer.vcxproj.filters
@@ -148,9 +148,6 @@
<Filter Include="Packets\cPacket_Respawn">
<UniqueIdentifier>{b2903385-bb48-4240-8c5b-bd8896f2c5ab}</UniqueIdentifier>
</Filter>
- <Filter Include="Packets\cPacket_PlayerPosition">
- <UniqueIdentifier>{c05411e1-a0f1-4528-a8c5-17f5bed4b0da}</UniqueIdentifier>
- </Filter>
<Filter Include="Packets\cPacket_DestroyEntity">
<UniqueIdentifier>{c06db7ec-cdd8-4ad3-8f9b-9848bf706c30}</UniqueIdentifier>
</Filter>
@@ -226,9 +223,6 @@
<Filter Include="cMakeDir">
<UniqueIdentifier>{102fff22-0eb3-4977-9de3-307534954fbc}</UniqueIdentifier>
</Filter>
- <Filter Include="Packets\cPacket_PlayerMoveLook">
- <UniqueIdentifier>{91d451ac-766b-44a9-918d-e0876cf99dbb}</UniqueIdentifier>
- </Filter>
<Filter Include="Packets\cPacket_TimeUpdate">
<UniqueIdentifier>{3328f163-6be9-4115-aa18-a67419a40b61}</UniqueIdentifier>
</Filter>
@@ -244,9 +238,6 @@
<Filter Include="Packets\cPacket_Handshake">
<UniqueIdentifier>{dad042ce-6d1a-4a77-8bdd-a2d364e8fcf2}</UniqueIdentifier>
</Filter>
- <Filter Include="Packets\cPacket_PlayerLook">
- <UniqueIdentifier>{c8aaae5b-7a57-48a0-ae2f-416211f6e73d}</UniqueIdentifier>
- </Filter>
<Filter Include="Packets\cPacket_ArmAnim">
<UniqueIdentifier>{8d8b006e-6529-4519-a479-84fb9ecfe6f6}</UniqueIdentifier>
</Filter>
@@ -403,9 +394,6 @@
<Filter Include="cEntity\cPawn\cMonster\Personalities\PassiveAggressive">
<UniqueIdentifier>{71574b1c-a518-4a17-92c1-e3ea340f73bc}</UniqueIdentifier>
</Filter>
- <Filter Include="Packets\cPacket_PlayerListItem">
- <UniqueIdentifier>{b690d7b6-3697-4d91-bab3-21fd652986be}</UniqueIdentifier>
- </Filter>
<Filter Include="cWorldGenerator">
<UniqueIdentifier>{72727ea7-779f-439e-8f30-53bd6985c9e7}</UniqueIdentifier>
</Filter>
@@ -604,9 +592,6 @@
<ClCompile Include="..\source\packets\cPacket_Respawn.cpp">
<Filter>Packets\cPacket_Respawn</Filter>
</ClCompile>
- <ClCompile Include="..\source\packets\cPacket_PlayerPosition.cpp">
- <Filter>Packets\cPacket_PlayerPosition</Filter>
- </ClCompile>
<ClCompile Include="..\source\packets\cPacket_DestroyEntity.cpp">
<Filter>Packets\cPacket_DestroyEntity</Filter>
</ClCompile>
@@ -682,9 +667,6 @@
<ClCompile Include="..\source\cMakeDir.cpp">
<Filter>cMakeDir</Filter>
</ClCompile>
- <ClCompile Include="..\source\packets\cPacket_PlayerMoveLook.cpp">
- <Filter>Packets\cPacket_PlayerMoveLook</Filter>
- </ClCompile>
<ClCompile Include="..\source\packets\cPacket_TimeUpdate.cpp">
<Filter>Packets\cPacket_TimeUpdate</Filter>
</ClCompile>
@@ -700,9 +682,6 @@
<ClCompile Include="..\source\packets\cPacket_Handshake.cpp">
<Filter>Packets\cPacket_Handshake</Filter>
</ClCompile>
- <ClCompile Include="..\source\packets\cPacket_PlayerLook.cpp">
- <Filter>Packets\cPacket_PlayerLook</Filter>
- </ClCompile>
<ClCompile Include="..\source\packets\cPacket_ArmAnim.cpp">
<Filter>Packets\cPacket_ArmAnim</Filter>
</ClCompile>
@@ -868,9 +847,6 @@
<ClCompile Include="..\source\cPassiveMonster.cpp">
<Filter>cEntity\cPawn\cMonster\Personalities\Passive</Filter>
</ClCompile>
- <ClCompile Include="..\source\packets\cPacket_PlayerListItem.cpp">
- <Filter>Packets\cPacket_PlayerListItem</Filter>
- </ClCompile>
<ClCompile Include="..\source\cWorldGenerator.cpp">
<Filter>cWorldGenerator</Filter>
</ClCompile>
@@ -922,6 +898,9 @@
<ClCompile Include="..\source\WSSAnvil.cpp" />
<ClCompile Include="..\source\NBT.cpp" />
<ClCompile Include="..\source\WGFlat.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_Player.cpp">
+ <Filter>Packets</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\cServer.h">
@@ -1101,9 +1080,6 @@
<ClInclude Include="..\source\packets\cPacket_Respawn.h">
<Filter>Packets\cPacket_Respawn</Filter>
</ClInclude>
- <ClInclude Include="..\source\packets\cPacket_PlayerPosition.h">
- <Filter>Packets\cPacket_PlayerPosition</Filter>
- </ClInclude>
<ClInclude Include="..\source\packets\cPacket_DestroyEntity.h">
<Filter>Packets\cPacket_DestroyEntity</Filter>
</ClInclude>
@@ -1179,9 +1155,6 @@
<ClInclude Include="..\source\cMakeDir.h">
<Filter>cMakeDir</Filter>
</ClInclude>
- <ClInclude Include="..\source\packets\cPacket_PlayerMoveLook.h">
- <Filter>Packets\cPacket_PlayerMoveLook</Filter>
- </ClInclude>
<ClInclude Include="..\source\packets\cPacket_TimeUpdate.h">
<Filter>Packets\cPacket_TimeUpdate</Filter>
</ClInclude>
@@ -1197,9 +1170,6 @@
<ClInclude Include="..\source\packets\cPacket_Handshake.h">
<Filter>Packets\cPacket_Handshake</Filter>
</ClInclude>
- <ClInclude Include="..\source\packets\cPacket_PlayerLook.h">
- <Filter>Packets\cPacket_PlayerLook</Filter>
- </ClInclude>
<ClInclude Include="..\source\packets\cPacket_ArmAnim.h">
<Filter>Packets\cPacket_ArmAnim</Filter>
</ClInclude>
@@ -1368,9 +1338,6 @@
<ClInclude Include="..\source\cPassiveMonster.h">
<Filter>cEntity\cPawn\cMonster\Personalities\Passive</Filter>
</ClInclude>
- <ClInclude Include="..\source\packets\cPacket_PlayerListItem.h">
- <Filter>Packets\cPacket_PlayerListItem</Filter>
- </ClInclude>
<ClInclude Include="..\source\cWorldGenerator.h">
<Filter>cWorldGenerator</Filter>
</ClInclude>
@@ -1426,6 +1393,9 @@
<ClInclude Include="..\source\NBT.h" />
<ClInclude Include="..\source\WGFlat.h" />
<ClInclude Include="..\source\ChunkDef.h" />
+ <ClInclude Include="..\source\packets\cPacket_Player.h">
+ <Filter>Packets</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\source\AllToLua.pkg">
diff --git a/source/PacketID.h b/source/PacketID.h
index b10bc54be..d557a284f 100644
--- a/source/PacketID.h
+++ b/source/PacketID.h
@@ -54,6 +54,7 @@ enum ENUM_PACKET_ID
E_CREATIVE_INVENTORY_ACTION = 0x6B,
E_UPDATE_SIGN = 0x82,
E_PLAYER_LIST_ITEM = 0xC9,
+ E_PLAYER_ABILITIES = 0xca, // since 1.2.4, protocol version 29
E_PING = 0xfe,
E_DISCONNECT = 0xff,
};
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 268e6a510..e8f874489 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -38,18 +38,15 @@
#include "MersenneTwister.h"
#include "packets/cPacket_KeepAlive.h"
-#include "packets/cPacket_PlayerPosition.h"
#include "packets/cPacket_Respawn.h"
#include "packets/cPacket_UpdateHealth.h"
#include "packets/cPacket_RelativeEntityMoveLook.h"
#include "packets/cPacket_Chat.h"
#include "packets/cPacket_Login.h"
#include "packets/cPacket_WindowClick.h"
-#include "packets/cPacket_PlayerMoveLook.h"
#include "packets/cPacket_TimeUpdate.h"
#include "packets/cPacket_BlockDig.h"
#include "packets/cPacket_Handshake.h"
-#include "packets/cPacket_PlayerLook.h"
#include "packets/cPacket_ArmAnim.h"
#include "packets/cPacket_BlockPlace.h"
#include "packets/cPacket_Flying.h"
@@ -64,7 +61,6 @@
#include "packets/cPacket_13.h"
#include "packets/cPacket_UpdateSign.h"
#include "packets/cPacket_Ping.h"
-#include "packets/cPacket_PlayerListItem.h"
#include "packets/cPacket_NamedEntitySpawn.h"
#include "packets/cPacket_MapChunk.h"
#include "packets/cPacket_PreChunk.h"
@@ -125,6 +121,7 @@ cClientHandle::cClientHandle(const cSocket & a_Socket, int a_ViewDistance)
m_PacketMap[E_PLAYERPOS] = new cPacket_PlayerPosition;
m_PacketMap[E_PLAYERLOOK] = new cPacket_PlayerLook;
m_PacketMap[E_PLAYERMOVELOOK] = new cPacket_PlayerMoveLook;
+ m_PacketMap[E_PLAYER_ABILITIES] = new cPacket_PlayerAbilities;
m_PacketMap[E_CHAT] = new cPacket_Chat;
m_PacketMap[E_ANIMATION] = new cPacket_ArmAnim;
m_PacketMap[E_FLYING] = new cPacket_Flying;
@@ -352,8 +349,7 @@ void cClientHandle::StreamChunks(void)
m_LastStreamedChunkX = ChunkPosX;
m_LastStreamedChunkZ = ChunkPosZ;
- // DEBUG:
- LOGINFO("Streaming chunks centered on [%d, %d], view distance %d", ChunkPosX, ChunkPosZ, m_ViewDistance);
+ LOGD("Streaming chunks centered on [%d, %d], view distance %d", ChunkPosX, ChunkPosZ, m_ViewDistance);
cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL);
@@ -1871,7 +1867,7 @@ void cClientHandle::DataReceived(const char * a_Data, int a_Size)
LOGERROR("Unknown packet type 0x%02x from client \"%s\"", (unsigned char)m_ReceivedData[0], m_Username.c_str());
AString Reason;
- Printf(Reason, "[C->S] Unknown PacketID: 0x%02x", m_ReceivedData[0]);
+ Printf(Reason, "[C->S] Unknown PacketID: 0x%02x", (unsigned char)m_ReceivedData[0]);
cPacket_Disconnect DC(Reason);
m_Socket.Send(&DC);
cSleep::MilliSleep(1000); // Give packet some time to be received
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
index c41d08de7..d0ac81db8 100644
--- a/source/cClientHandle.h
+++ b/source/cClientHandle.h
@@ -17,17 +17,15 @@
#include "ChunkDef.h"
#include "packets/cPacket_KeepAlive.h"
-#include "packets/cPacket_PlayerPosition.h"
+#include "packets/cPacket_Player.h"
#include "packets/cPacket_Respawn.h"
#include "packets/cPacket_RelativeEntityMoveLook.h"
#include "packets/cPacket_Chat.h"
#include "packets/cPacket_Login.h"
#include "packets/cPacket_WindowClick.h"
-#include "packets/cPacket_PlayerMoveLook.h"
#include "packets/cPacket_TimeUpdate.h"
#include "packets/cPacket_BlockDig.h"
#include "packets/cPacket_Handshake.h"
-#include "packets/cPacket_PlayerLook.h"
#include "packets/cPacket_ArmAnim.h"
#include "packets/cPacket_BlockPlace.h"
#include "packets/cPacket_Flying.h"
@@ -41,7 +39,6 @@
#include "packets/cPacket_WindowClose.h"
#include "packets/cPacket_UpdateSign.h"
#include "packets/cPacket_Ping.h"
-#include "packets/cPacket_PlayerListItem.h"
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 4e5f47c72..961145d6e 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -28,12 +28,10 @@
#include "packets/cPacket_RelativeEntityMoveLook.h"
#include "packets/cPacket_UpdateHealth.h"
#include "packets/cPacket_Respawn.h"
-#include "packets/cPacket_PlayerPosition.h"
#include "packets/cPacket_DestroyEntity.h"
#include "packets/cPacket_Metadata.h"
#include "packets/cPacket_Chat.h"
#include "packets/cPacket_NewInvalidState.h"
-#include "packets/cPacket_PlayerListItem.h"
#include "packets/cPacket_BlockAction.h"
#include "Vector3d.h"
diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp
new file mode 100644
index 000000000..86214d725
--- /dev/null
+++ b/source/packets/cPacket_Player.cpp
@@ -0,0 +1,243 @@
+
+// cPacket_Player.cpp
+
+/* Implements the player-related packets:
+ - PlayerAbilities (0xca)
+ - PlayerListItem (0xc9)
+ - PlayerLook (0x0c)
+ - PlayerMoveLook (0x0d)
+ - PlayerPosition (0x0b)
+*/
+
+#include "Globals.h"
+
+#include "cPacket_Player.h"
+#include "../cPlayer.h"
+#include "../cChatColor.h"
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cPacket_PlayerAbilities:
+
+int cPacket_PlayerAbilities::Parse(const char * a_Data, int a_Size)
+{
+ if (a_Size < 4)
+ {
+ return PACKET_INCOMPLETE;
+ }
+ m_Invulnerable = (a_Data[0] != 0);
+ m_IsFlying = (a_Data[1] != 0);
+ m_CanFly = (a_Data[2] != 0);
+ m_InstaMine = (a_Data[3] != 0);
+ return 4;
+}
+
+
+
+
+
+void cPacket_PlayerAbilities::Serialize(AString & a_Data) const
+{
+ char Data[5];
+ Data[0] = m_PacketID;
+ Data[1] = (char)m_Invulnerable;
+ Data[2] = (char)m_IsFlying;
+ Data[3] = (char)m_CanFly;
+ Data[4] = (char)m_InstaMine;
+ a_Data.append(Data, 5);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cPacket_PlayerListItem:
+
+cPacket_PlayerListItem::cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping)
+{
+ m_PacketID = E_PLAYER_LIST_ITEM;
+ m_PlayerName = a_PlayerName;
+ m_Online = a_Online;
+ m_Ping = a_Ping;
+}
+
+
+
+
+
+int cPacket_PlayerListItem::Parse(const char * a_Data, int a_Size)
+{
+ int TotalBytes = 0;
+ HANDLE_PACKET_READ(ReadString16, m_PlayerName, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_Online, TotalBytes);
+ HANDLE_PACKET_READ(ReadShort, m_Ping, TotalBytes);
+ return TotalBytes;
+}
+
+
+
+
+
+void cPacket_PlayerListItem::Serialize(AString & a_Data) const
+{
+ AString PlayerName(m_PlayerName);
+ if (PlayerName.length() > 16)
+ {
+ PlayerName.erase(16);
+ }
+ else if (PlayerName.length() <= 14)
+ {
+ PlayerName += cChatColor::White;
+ }
+
+ AppendByte (a_Data, m_PacketID);
+ AppendString16(a_Data, PlayerName);
+ AppendBool (a_Data, m_Online);
+ AppendShort (a_Data, m_Ping);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cPacket_PlayerLook:
+
+cPacket_PlayerLook::cPacket_PlayerLook( cPlayer* a_Player )
+{
+ m_PacketID = E_PLAYERLOOK;
+ m_Rotation = a_Player->GetRotation();
+ m_Pitch = a_Player->GetPitch();
+ m_bFlying = a_Player->GetFlying();
+}
+
+
+
+
+
+int cPacket_PlayerLook::Parse(const char * a_Data, int a_Size)
+{
+ int TotalBytes = 0;
+ HANDLE_PACKET_READ(ReadFloat, m_Rotation, TotalBytes);
+ HANDLE_PACKET_READ(ReadFloat, m_Pitch, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
+ return TotalBytes;
+}
+
+
+
+
+
+void cPacket_PlayerLook::Serialize(AString & a_Data) const
+{
+ AppendByte (a_Data, m_PacketID);
+ AppendFloat (a_Data, m_Rotation);
+ AppendFloat (a_Data, m_Pitch);
+ AppendBool (a_Data, m_bFlying);
+}
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cPacket_PlayerMoveLook:
+
+cPacket_PlayerMoveLook::cPacket_PlayerMoveLook( 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_bFlying = a_Player->GetFlying();
+}
+
+
+
+
+
+int cPacket_PlayerMoveLook::Parse(const char * a_Data, int a_Size)
+{
+ int TotalBytes = 0;
+ HANDLE_PACKET_READ(ReadDouble, m_PosX, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_PosY, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_Stance, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_PosZ, TotalBytes);
+ HANDLE_PACKET_READ(ReadFloat, m_Rotation, TotalBytes);
+ HANDLE_PACKET_READ(ReadFloat, m_Pitch, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
+ return TotalBytes;
+}
+
+
+
+
+
+void cPacket_PlayerMoveLook::Serialize(AString & a_Data) const
+{
+ 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);
+ AppendFloat (a_Data, m_Rotation);
+ AppendFloat (a_Data, m_Pitch);
+ AppendBool (a_Data, m_bFlying);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cPacket_PlayerPosition:
+
+cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player )
+{
+ m_PacketID = E_PLAYERPOS;
+
+ m_PosX = a_Player->GetPosX();
+ m_PosY = a_Player->GetPosY() + 1.65;
+ m_PosZ = a_Player->GetPosZ();
+ m_Stance = a_Player->GetStance();
+ m_bFlying = a_Player->GetFlying();
+}
+
+
+
+
+
+int cPacket_PlayerPosition::Parse(const char * a_Data, int a_Size)
+{
+ int TotalBytes = 0;
+ HANDLE_PACKET_READ(ReadDouble, m_PosX, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_PosY, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_Stance, TotalBytes);
+ HANDLE_PACKET_READ(ReadDouble, m_PosZ, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
+ return TotalBytes;
+}
+
+
+
+
+
+void cPacket_PlayerPosition::Serialize(AString & a_Data) const
+{
+ 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_bFlying);
+}
+
+
+
+
diff --git a/source/packets/cPacket_Player.h b/source/packets/cPacket_Player.h
new file mode 100644
index 000000000..ce88cc451
--- /dev/null
+++ b/source/packets/cPacket_Player.h
@@ -0,0 +1,150 @@
+
+// cPacket_Player.h
+
+/* Interfaces to the player-related packets:
+ - PlayerAbilities (0xca)
+ - PlayerListItem (0xc9)
+ - PlayerLook (0x0c)
+ - PlayerMoveLook (0x0d)
+ - PlayerPosition (0x0b)
+*/
+
+#pragma once
+
+
+
+
+
+#include "cPacket.h"
+
+
+
+
+
+// fwd:
+class cPlayer;
+
+
+
+
+
+class cPacket_PlayerAbilities : public cPacket
+{
+public:
+ cPacket_PlayerAbilities(void) { m_PacketID = E_PLAYER_LIST_ITEM; }
+
+ virtual int Parse(const char * a_Data, int a_Size) override;
+ virtual void Serialize(AString & a_Data) const override;
+
+ virtual cPacket * Clone() const { return new cPacket_PlayerAbilities(*this); }
+
+ bool m_Invulnerable; // Speculation
+ bool m_IsFlying;
+ bool m_CanFly;
+ bool m_InstaMine; // Speculation
+} ;
+
+
+
+
+
+class cPacket_PlayerListItem : public cPacket
+{
+public:
+ cPacket_PlayerListItem() { m_PacketID = E_PLAYER_LIST_ITEM; }
+ cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping);
+
+ virtual int Parse(const char * a_Data, int a_Size) override;
+ virtual void Serialize(AString & a_Data) const override;
+
+ virtual cPacket* Clone() const { return new cPacket_PlayerListItem(*this); }
+
+ AString m_PlayerName; // Supports chat coloring, limited to 16 characters.
+ bool m_Online;
+ short m_Ping;
+} ;
+
+
+
+
+
+class cPacket_PlayerLook : public cPacket
+{
+public:
+ cPacket_PlayerLook()
+ : m_Rotation( 0 )
+ , m_Pitch( 0 )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERLOOK; }
+ cPacket_PlayerLook( cPlayer* a_Player );
+ virtual cPacket* Clone() const { return new cPacket_PlayerLook(*this); }
+
+ virtual int Parse(const char * a_Data, int a_Size) override;
+ virtual void Serialize(AString & a_Data) const override;
+
+ float m_Rotation;
+ float m_Pitch;
+ bool m_bFlying; // Yeah.. wtf
+} ;
+
+
+
+
+
+class cPacket_PlayerMoveLook : public cPacket
+{
+public:
+ cPacket_PlayerMoveLook()
+ : m_PosX( 0.0 )
+ , m_PosY( 0.0 )
+ , m_Stance( 0.0 )
+ , m_PosZ( 0.0 )
+ , m_Rotation( 0.f )
+ , m_Pitch( 0.f )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERMOVELOOK; }
+ cPacket_PlayerMoveLook( cPlayer* a_Player );
+ virtual cPacket* Clone() const { return new cPacket_PlayerMoveLook(*this); }
+
+ virtual int Parse(const char * a_Data, int a_Size) override;
+ virtual void Serialize(AString & a_Data) const override;
+
+ double m_PosX;
+ double m_PosY;
+ double m_Stance;
+ double m_PosZ;
+ float m_Rotation;
+ float m_Pitch;
+ bool m_bFlying; // Yeah.. wtf
+} ;
+
+
+
+
+
+class cPacket_PlayerPosition : public cPacket
+{
+public:
+ cPacket_PlayerPosition( cPlayer* a_Player );
+ cPacket_PlayerPosition()
+ : m_PosX( 0.0 )
+ , m_PosY( 0.0 )
+ , m_Stance( 0.0 )
+ , m_PosZ( 0.0 )
+ , m_bFlying( false )
+ { m_PacketID = E_PLAYERPOS; }
+ virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); }
+
+ virtual int Parse(const char * a_Data, int a_Size) override;
+ virtual void Serialize(AString & a_Data) const override;
+
+ double m_PosX;
+ double m_PosY;
+ double m_Stance;
+ double m_PosZ;
+ bool m_bFlying; // Yeah.. wtf
+} ;
+
+
+
+
diff --git a/source/packets/cPacket_PlayerListItem.cpp b/source/packets/cPacket_PlayerListItem.cpp
deleted file mode 100644
index 3f8be2bde..000000000
--- a/source/packets/cPacket_PlayerListItem.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "cPacket_PlayerListItem.h"
-#include "../cChatColor.h"
-
-
-
-
-
-cPacket_PlayerListItem::cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping)
-{
- m_PacketID = E_PLAYER_LIST_ITEM;
- m_PlayerName = a_PlayerName;
- m_Online = a_Online;
- m_Ping = a_Ping;
-}
-
-
-
-
-
-int cPacket_PlayerListItem::Parse(const char * a_Data, int a_Size)
-{
- int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadString16, m_PlayerName, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_Online, TotalBytes);
- HANDLE_PACKET_READ(ReadShort, m_Ping, TotalBytes);
- return TotalBytes;
-}
-
-
-
-
-
-void cPacket_PlayerListItem::Serialize(AString & a_Data) const
-{
- AString PlayerName(m_PlayerName);
- if (PlayerName.length() > 16)
- {
- PlayerName.erase(16);
- }
- else if (PlayerName.length() <= 14)
- {
- PlayerName += cChatColor::White;
- }
-
- AppendByte (a_Data, m_PacketID);
- AppendString16(a_Data, PlayerName);
- AppendBool (a_Data, m_Online);
- AppendShort (a_Data, m_Ping);
-}
-
-
-
-
diff --git a/source/packets/cPacket_PlayerListItem.h b/source/packets/cPacket_PlayerListItem.h
deleted file mode 100644
index 45395c556..000000000
--- a/source/packets/cPacket_PlayerListItem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-
-#pragma once
-
-#include "cPacket.h"
-
-
-
-
-
-class cPacket_PlayerListItem : public cPacket
-{
-public:
- cPacket_PlayerListItem() { m_PacketID = E_PLAYER_LIST_ITEM; }
- cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping);
-
- virtual int Parse(const char * a_Data, int a_Size) override;
- virtual void Serialize(AString & a_Data) const override;
-
- virtual cPacket* Clone() const { return new cPacket_PlayerListItem(*this); }
-
- AString m_PlayerName; // Supports chat coloring, limited to 16 characters.
- bool m_Online;
- short m_Ping;
-
- static const unsigned int c_Size = 6; // Minimal size ( 6 + string )
-};
-
-
-
-
diff --git a/source/packets/cPacket_PlayerLook.cpp b/source/packets/cPacket_PlayerLook.cpp
deleted file mode 100644
index 75adcf38c..000000000
--- a/source/packets/cPacket_PlayerLook.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "cPacket_PlayerLook.h"
-#include "../cPlayer.h"
-
-
-
-
-
-cPacket_PlayerLook::cPacket_PlayerLook( cPlayer* a_Player )
-{
- m_PacketID = E_PLAYERLOOK;
- m_Rotation = a_Player->GetRotation();
- m_Pitch = a_Player->GetPitch();
- m_bFlying = a_Player->GetFlying();
-}
-
-
-
-
-
-int cPacket_PlayerLook::Parse(const char * a_Data, int a_Size)
-{
- int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadFloat, m_Rotation, TotalBytes);
- HANDLE_PACKET_READ(ReadFloat, m_Pitch, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
- return TotalBytes;
-}
-
-
-
-
-
-void cPacket_PlayerLook::Serialize(AString & a_Data) const
-{
- AppendByte (a_Data, m_PacketID);
- AppendFloat (a_Data, m_Rotation);
- AppendFloat (a_Data, m_Pitch);
- AppendBool (a_Data, m_bFlying);
-}
-
-
-
-
diff --git a/source/packets/cPacket_PlayerLook.h b/source/packets/cPacket_PlayerLook.h
deleted file mode 100644
index aed8a954d..000000000
--- a/source/packets/cPacket_PlayerLook.h
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#pragma once
-
-#include "cPacket.h"
-
-
-
-
-
-class cPlayer;
-
-
-
-
-
-class cPacket_PlayerLook : public cPacket
-{
-public:
- cPacket_PlayerLook()
- : m_Rotation( 0 )
- , m_Pitch( 0 )
- , m_bFlying( false )
- { m_PacketID = E_PLAYERLOOK; }
- cPacket_PlayerLook( cPlayer* a_Player );
- virtual cPacket* Clone() const { return new cPacket_PlayerLook(*this); }
-
- virtual int Parse(const char * a_Data, int a_Size) override;
- virtual void Serialize(AString & a_Data) const override;
-
- float m_Rotation;
- float m_Pitch;
- bool m_bFlying; // Yeah.. wtf
-
- static const unsigned int c_Size = 10;
-};
-
-
-
-
diff --git a/source/packets/cPacket_PlayerMoveLook.cpp b/source/packets/cPacket_PlayerMoveLook.cpp
deleted file mode 100644
index 4b0af62e1..000000000
--- a/source/packets/cPacket_PlayerMoveLook.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "cPacket_PlayerMoveLook.h"
-#include "../cPlayer.h"
-
-
-
-
-
-cPacket_PlayerMoveLook::cPacket_PlayerMoveLook( 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_bFlying = a_Player->GetFlying();
-}
-
-
-
-
-
-int cPacket_PlayerMoveLook::Parse(const char * a_Data, int a_Size)
-{
- int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadDouble, m_PosX, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_PosY, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_Stance, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_PosZ, TotalBytes);
- HANDLE_PACKET_READ(ReadFloat, m_Rotation, TotalBytes);
- HANDLE_PACKET_READ(ReadFloat, m_Pitch, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
- return TotalBytes;
-}
-
-
-
-
-
-void cPacket_PlayerMoveLook::Serialize(AString & a_Data) const
-{
- 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);
- AppendFloat (a_Data, m_Rotation);
- AppendFloat (a_Data, m_Pitch);
- AppendBool (a_Data, m_bFlying);
-}
-
-
-
-
diff --git a/source/packets/cPacket_PlayerMoveLook.h b/source/packets/cPacket_PlayerMoveLook.h
deleted file mode 100644
index c36698839..000000000
--- a/source/packets/cPacket_PlayerMoveLook.h
+++ /dev/null
@@ -1,43 +0,0 @@
-
-#pragma once
-
-#include "cPacket.h"
-
-
-
-
-
-class cPlayer;
-
-
-
-
-
-class cPacket_PlayerMoveLook : public cPacket
-{
-public:
- cPacket_PlayerMoveLook()
- : m_PosX( 0.0 )
- , m_PosY( 0.0 )
- , m_Stance( 0.0 )
- , m_PosZ( 0.0 )
- , m_Rotation( 0.f )
- , m_Pitch( 0.f )
- , m_bFlying( false )
- { m_PacketID = E_PLAYERMOVELOOK; }
- cPacket_PlayerMoveLook( cPlayer* a_Player );
- virtual cPacket* Clone() const { return new cPacket_PlayerMoveLook(*this); }
-
- virtual int Parse(const char * a_Data, int a_Size) override;
- virtual void Serialize(AString & a_Data) const override;
-
- double m_PosX;
- double m_PosY;
- double m_Stance;
- double m_PosZ;
- float m_Rotation;
- float m_Pitch;
- bool m_bFlying; // Yeah.. wtf
-
- static const unsigned int c_Size = 42;
-};
diff --git a/source/packets/cPacket_PlayerPosition.cpp b/source/packets/cPacket_PlayerPosition.cpp
deleted file mode 100644
index 3dae343dd..000000000
--- a/source/packets/cPacket_PlayerPosition.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "cPacket_PlayerPosition.h"
-#include "../cPlayer.h"
-
-
-
-
-
-cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player )
-{
- m_PacketID = E_PLAYERPOS;
-
- m_PosX = a_Player->GetPosX();
- m_PosY = a_Player->GetPosY() + 1.65;
- m_PosZ = a_Player->GetPosZ();
- m_Stance = a_Player->GetStance();
- m_bFlying = a_Player->GetFlying();
-}
-
-
-
-
-
-int cPacket_PlayerPosition::Parse(const char * a_Data, int a_Size)
-{
- int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadDouble, m_PosX, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_PosY, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_Stance, TotalBytes);
- HANDLE_PACKET_READ(ReadDouble, m_PosZ, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
- return TotalBytes;
-}
-
-
-
-
-
-void cPacket_PlayerPosition::Serialize(AString & a_Data) const
-{
- 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_bFlying);
-}
-
-
-
-
diff --git a/source/packets/cPacket_PlayerPosition.h b/source/packets/cPacket_PlayerPosition.h
deleted file mode 100644
index f883b6a4d..000000000
--- a/source/packets/cPacket_PlayerPosition.h
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#pragma once
-
-#include "cPacket.h"
-
-
-
-
-
-
-class cPlayer;
-
-
-
-
-
-class cPacket_PlayerPosition : public cPacket
-{
-public:
- cPacket_PlayerPosition( cPlayer* a_Player );
- cPacket_PlayerPosition()
- : m_PosX( 0.0 )
- , m_PosY( 0.0 )
- , m_Stance( 0.0 )
- , m_PosZ( 0.0 )
- , m_bFlying( false )
- { m_PacketID = E_PLAYERPOS; }
- virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); }
-
- virtual int Parse(const char * a_Data, int a_Size) override;
- virtual void Serialize(AString & a_Data) const override;
-
- double m_PosX;
- double m_PosY;
- double m_Stance;
- double m_PosZ;
- bool m_bFlying; // Yeah.. wtf
-
- static const unsigned int c_Size = 34;
-};
-
-
-
-