1
0

Added the new 1.2.4's PlayerAbilities packet; restructures packet files for less files, more dense.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@431 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-03-24 13:28:53 +00:00
parent 3c3d1c60a3
commit 5783437436
17 changed files with 408 additions and 452 deletions

View File

@ -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

View File

@ -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" />

View File

@ -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">

View File

@ -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,
};

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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);
}

View File

@ -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
} ;

View File

@ -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);
}

View File

@ -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 )
};

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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;
};