diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-28 23:59:49 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-28 23:59:49 +0200 |
commit | 1651fcd9807f1033a5fc76e60cb17922e687a7b1 (patch) | |
tree | c9b82453023b52b05a61bcfd4c882ab5f6b60e23 /source/packets | |
parent | Fixed a few warnings (diff) | |
download | cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar.gz cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar.bz2 cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar.lz cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar.xz cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.tar.zst cuberite-1651fcd9807f1033a5fc76e60cb17922e687a7b1.zip |
Diffstat (limited to '')
79 files changed, 25 insertions, 2103 deletions
diff --git a/source/packets/cPacket.h b/source/packets/cPacket.h index bc0f052e8..580cd6771 100644 --- a/source/packets/cPacket.h +++ b/source/packets/cPacket.h @@ -52,15 +52,6 @@ public: return PACKET_ERROR; } - /// Called to serialize the packet into a string. Append all packet data to a_Data, including the packet type! - virtual void Serialize(AString & a_Data) const - { - // There are packets that are sent C->S only, those don't have a serializing function - UNUSED(a_Data); - LOGERROR("Packet type 0x%02x has no serializer defined!", m_PacketID); - ASSERT(!"Unserialized packet"); - } - virtual cPacket * Clone() const = 0; unsigned char m_PacketID; diff --git a/source/packets/cPacket_AddToInventory.cpp b/source/packets/cPacket_AddToInventory.cpp deleted file mode 100644 index b9231112c..000000000 --- a/source/packets/cPacket_AddToInventory.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_AddToInventory.h" -#include "cPacket_WholeInventory.h" -#include "cPacket_ItemData.h" - - - - - -void cPacket_AddToInventory::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - cPacket_ItemData::AppendItem(a_Data, m_ItemType, m_Count, m_Life); -} - - - - diff --git a/source/packets/cPacket_AddToInventory.h b/source/packets/cPacket_AddToInventory.h deleted file mode 100644 index f7e1a084b..000000000 --- a/source/packets/cPacket_AddToInventory.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "cPacket.h" - -#include "../BlockID.h" - -class cPacket_AddToInventory : public cPacket -{ -public: - cPacket_AddToInventory() - : m_ItemType( E_ITEM_EMPTY ) - , m_Count( 0 ) - , m_Life( 0 ) - { m_PacketID = E_ADD_TO_INV; } - virtual cPacket* Clone() const { return new cPacket_AddToInventory(*this); } - - // _X: This was unimplemented, do we need it?: - // bool Parse( cSocket & a_Socket ); - - virtual void Serialize(AString & a_Data) const override; - - ENUM_ITEM_ID m_ItemType; - char m_Count; - short m_Life; - static const unsigned int c_Size = 1; -}; diff --git a/source/packets/cPacket_ArmAnim.cpp b/source/packets/cPacket_ArmAnim.cpp index 6f7a261d4..8d46da39f 100644 --- a/source/packets/cPacket_ArmAnim.cpp +++ b/source/packets/cPacket_ArmAnim.cpp @@ -18,14 +18,3 @@ int cPacket_ArmAnim::Parse(cByteBuffer & a_Buffer) - -void cPacket_ArmAnim::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_EntityID); - AppendByte (a_Data, m_Animation); -} - - - - diff --git a/source/packets/cPacket_ArmAnim.h b/source/packets/cPacket_ArmAnim.h index 2fa613b83..c4f4694ce 100644 --- a/source/packets/cPacket_ArmAnim.h +++ b/source/packets/cPacket_ArmAnim.h @@ -1,21 +1,30 @@ + #pragma once #include "cPacket.h" -class cPacket_ArmAnim : public cPacket + + + +class cPacket_ArmAnim : + public cPacket { public: cPacket_ArmAnim() : m_EntityID( 0 ) , m_Animation( 0 ) - { m_PacketID = E_ANIMATION; } + { + m_PacketID = E_ANIMATION; + } virtual cPacket* Clone() const { return new cPacket_ArmAnim(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; int m_EntityID; char m_Animation; - static const unsigned int c_Size = 1 + 4 + 1; -};
\ No newline at end of file +}; + + + + diff --git a/source/packets/cPacket_BlockAction.cpp b/source/packets/cPacket_BlockAction.cpp deleted file mode 100644 index a4eb01ad8..000000000 --- a/source/packets/cPacket_BlockAction.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_BlockAction.h" - - - - - -cPacket_BlockAction::cPacket_BlockAction( const cPacket_BlockAction & a_Copy ) -{ - m_PacketID = E_BLOCK_ACTION; - 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; -} - - - - - -void cPacket_BlockAction::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - 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 deleted file mode 100644 index df473801f..000000000 --- a/source/packets/cPacket_BlockAction.h +++ /dev/null @@ -1,38 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_BlockAction : - public cPacket -{ -public: - cPacket_BlockAction() - : m_BlockX( 0 ) - , m_BlockY( 0 ) - , m_BlockZ( 0 ) - , m_Byte1( 0 ) - , m_Byte2( 0 ) - { - m_PacketID = E_BLOCK_ACTION; - } - - cPacket_BlockAction( const cPacket_BlockAction & a_Copy ); - virtual cPacket * Clone() const { return new cPacket_BlockAction(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_BlockX; - short m_BlockY; - int m_BlockZ; - char m_Byte1; // Varies - char m_Byte2; // Varies -}; - - - - diff --git a/source/packets/cPacket_BlockChange.cpp b/source/packets/cPacket_BlockChange.cpp deleted file mode 100644 index e0ef5c001..000000000 --- a/source/packets/cPacket_BlockChange.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_BlockChange.h" - - - - - -void cPacket_BlockChange::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_PosX); - AppendByte (a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendByte (a_Data, m_BlockType); - AppendByte (a_Data, m_BlockMeta); -} - - - - diff --git a/source/packets/cPacket_BlockChange.h b/source/packets/cPacket_BlockChange.h deleted file mode 100644 index 039043cf0..000000000 --- a/source/packets/cPacket_BlockChange.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "cPacket.h" - - -class cPacket_BlockChange : public cPacket -{ -public: - cPacket_BlockChange() - : m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_BlockType( 0 ) - , m_BlockMeta( 0 ) - { m_PacketID = E_BLOCK_CHANGE; } - virtual cPacket* Clone() const { return new cPacket_BlockChange(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_PosX; - unsigned char m_PosY; - int m_PosZ; - char m_BlockType; - char m_BlockMeta; - - static const unsigned int c_Size = 1 + 4 + 1 + 4 + 1 + 1; -};
\ No newline at end of file diff --git a/source/packets/cPacket_BlockDig.cpp b/source/packets/cPacket_BlockDig.cpp index 0c90436dd..8c7cc5955 100644 --- a/source/packets/cPacket_BlockDig.cpp +++ b/source/packets/cPacket_BlockDig.cpp @@ -7,19 +7,6 @@ -void cPacket_BlockDig::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_PosX); - AppendByte (a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendByte (a_Data, m_Direction); -} - - - - - int cPacket_BlockDig::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; diff --git a/source/packets/cPacket_BlockDig.h b/source/packets/cPacket_BlockDig.h index 01eb54377..1678dcaf3 100644 --- a/source/packets/cPacket_BlockDig.h +++ b/source/packets/cPacket_BlockDig.h @@ -24,7 +24,6 @@ public: virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; char m_Status; int m_PosX; diff --git a/source/packets/cPacket_Chat.cpp b/source/packets/cPacket_Chat.cpp index da00c0aae..b475848b0 100644 --- a/source/packets/cPacket_Chat.cpp +++ b/source/packets/cPacket_Chat.cpp @@ -17,13 +17,3 @@ int cPacket_Chat::Parse(cByteBuffer & a_Buffer) - -void cPacket_Chat::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendString16(a_Data, m_Message); -} - - - - diff --git a/source/packets/cPacket_Chat.h b/source/packets/cPacket_Chat.h index cb154f732..ff5c70b5b 100644 --- a/source/packets/cPacket_Chat.h +++ b/source/packets/cPacket_Chat.h @@ -1,20 +1,22 @@ + #pragma once #include "cPacket.h" -class cPacket_Chat : public cPacket + + + +class cPacket_Chat : + public cPacket { public: cPacket_Chat() { m_PacketID = E_CHAT; } - cPacket_Chat( const std::string & a_Message ) : m_Message( a_Message) { m_PacketID = E_CHAT; } virtual cPacket* Clone() const { return new cPacket_Chat(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; AString m_Message; - static const unsigned int c_Size = 3; // Minimum size }; diff --git a/source/packets/cPacket_CollectItem.cpp b/source/packets/cPacket_CollectItem.cpp deleted file mode 100644 index 39f4cdde2..000000000 --- a/source/packets/cPacket_CollectItem.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_CollectItem.h" - - - - - -void cPacket_CollectItem::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_CollectedID); - AppendInteger(a_Data, m_CollectorID); -} - - - - diff --git a/source/packets/cPacket_CollectItem.h b/source/packets/cPacket_CollectItem.h deleted file mode 100644 index 29ab78ff8..000000000 --- a/source/packets/cPacket_CollectItem.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_CollectItem : public cPacket -{ -public: - cPacket_CollectItem() - : m_CollectedID( 0 ) - , m_CollectorID( 0 ) - { m_PacketID = E_COLLECT_ITEM; } - virtual cPacket* Clone() const { return new cPacket_CollectItem(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_CollectedID; - int m_CollectorID; - static const unsigned int c_Size = 1 + 4 + 4; -}; - - - - diff --git a/source/packets/cPacket_CreativeInventoryAction.cpp b/source/packets/cPacket_CreativeInventoryAction.cpp index 85291da3e..41a45125b 100644 --- a/source/packets/cPacket_CreativeInventoryAction.cpp +++ b/source/packets/cPacket_CreativeInventoryAction.cpp @@ -38,14 +38,3 @@ int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer) -void cPacket_CreativeInventoryAction::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendShort(a_Data, m_SlotNum); - - cPacket_ItemData::AppendItem(a_Data, m_ClickedItem); -} - - - - diff --git a/source/packets/cPacket_CreativeInventoryAction.h b/source/packets/cPacket_CreativeInventoryAction.h index ae438a7a8..885478496 100644 --- a/source/packets/cPacket_CreativeInventoryAction.h +++ b/source/packets/cPacket_CreativeInventoryAction.h @@ -22,7 +22,6 @@ public: virtual cPacket* Clone() const { return new cPacket_CreativeInventoryAction(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; short m_SlotNum; cItem m_ClickedItem; diff --git a/source/packets/cPacket_DestroyEntity.cpp b/source/packets/cPacket_DestroyEntity.cpp deleted file mode 100644 index d7e1d085b..000000000 --- a/source/packets/cPacket_DestroyEntity.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_DestroyEntity.h" -#include "../cEntity.h" - - - - - -cPacket_DestroyEntity::cPacket_DestroyEntity(cEntity* a_Entity) -{ - m_PacketID = E_DESTROY_ENT; - - m_UniqueID = a_Entity->GetUniqueID(); -} - - - - - -void cPacket_DestroyEntity::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); -} - - - - diff --git a/source/packets/cPacket_DestroyEntity.h b/source/packets/cPacket_DestroyEntity.h deleted file mode 100644 index b4146e971..000000000 --- a/source/packets/cPacket_DestroyEntity.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "cPacket.h" - - - - - -class cEntity; - - - - - -class cPacket_DestroyEntity : public cPacket -{ -public: - cPacket_DestroyEntity() - : m_UniqueID( 0 ) - { m_PacketID = E_DESTROY_ENT; } - cPacket_DestroyEntity(cEntity* a_Entity); - virtual cPacket* Clone() const { return new cPacket_DestroyEntity(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - - static const unsigned int c_Size = 1 + 4; -}; - - - - diff --git a/source/packets/cPacket_Disconnect.cpp b/source/packets/cPacket_Disconnect.cpp index 19eecd365..d1d433475 100644 --- a/source/packets/cPacket_Disconnect.cpp +++ b/source/packets/cPacket_Disconnect.cpp @@ -18,12 +18,3 @@ int cPacket_Disconnect::Parse(cByteBuffer & a_Buffer) -void cPacket_Disconnect::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendString16(a_Data, m_Reason); -} - - - - diff --git a/source/packets/cPacket_Disconnect.h b/source/packets/cPacket_Disconnect.h index f2a820607..77b6cf615 100644 --- a/source/packets/cPacket_Disconnect.h +++ b/source/packets/cPacket_Disconnect.h @@ -15,7 +15,6 @@ public: virtual cPacket* Clone() const { return new cPacket_Disconnect(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; AString m_Reason; static const unsigned int c_Size = 3; // Minimum size diff --git a/source/packets/cPacket_EntityEquipment.cpp b/source/packets/cPacket_EntityEquipment.cpp deleted file mode 100644 index 6358c4a1f..000000000 --- a/source/packets/cPacket_EntityEquipment.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_EntityEquipment.h" - - - - - -cPacket_EntityEquipment::cPacket_EntityEquipment( const cPacket_EntityEquipment & a_Copy ) -{ - m_PacketID = E_ENTITY_EQUIPMENT; - m_UniqueID = a_Copy.m_UniqueID; - m_SlotNum = a_Copy.m_SlotNum; - m_ItemType = a_Copy.m_ItemType; - m_ItemDamage = a_Copy.m_ItemDamage; -} - - - - - -int cPacket_EntityEquipment::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_UniqueID, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_ItemType, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_ItemDamage, TotalBytes); - return TotalBytes; -} - - - - - -void cPacket_EntityEquipment::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendShort (a_Data, m_SlotNum); - AppendShort (a_Data, m_ItemType); - AppendShort (a_Data, m_ItemDamage); -} - - - - diff --git a/source/packets/cPacket_EntityEquipment.h b/source/packets/cPacket_EntityEquipment.h deleted file mode 100644 index 69260fae4..000000000 --- a/source/packets/cPacket_EntityEquipment.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_EntityEquipment : public cPacket -{ -public: - cPacket_EntityEquipment() - : m_UniqueID( 0 ) - , m_SlotNum( 0 ) - , m_ItemType( 0 ) - , m_ItemDamage( 0 ) - { - m_PacketID = E_ENTITY_EQUIPMENT; - } - - cPacket_EntityEquipment( const cPacket_EntityEquipment & a_Copy ); - virtual cPacket * Clone() const { return new cPacket_EntityEquipment(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - short m_SlotNum; // 0 = hold 1-4 = armor - short m_ItemType; - short m_ItemDamage; -}; - - - - diff --git a/source/packets/cPacket_EntityLook.cpp b/source/packets/cPacket_EntityLook.cpp deleted file mode 100644 index 04fc46d4d..000000000 --- a/source/packets/cPacket_EntityLook.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_EntityLook.h" - -#include "../cEntity.h" - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_EntityLook: - -cPacket_EntityLook::cPacket_EntityLook(const cEntity & a_Entity) -{ - m_PacketID = E_ENT_LOOK; - - m_UniqueID = a_Entity.GetUniqueID(); - m_Rotation = (char)((a_Entity.GetRotation() / 360.f) * 256); - m_Pitch = (char)((a_Entity.GetPitch() / 360.f) * 256); -} - - - - - -void cPacket_EntityLook::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendByte (a_Data, m_Rotation); - AppendByte (a_Data, m_Pitch); -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cPacket_EntityHeadLook: - -cPacket_EntityHeadLook::cPacket_EntityHeadLook(const cEntity & a_Entity) -{ - m_PacketID = E_ENT_HEAD_LOOK; - - m_UniqueID = a_Entity.GetUniqueID(); - m_HeadYaw = (char)((a_Entity.GetRotation() / 360.f) * 256); -} - - - - - -void cPacket_EntityHeadLook::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendByte (a_Data, m_HeadYaw); -} - - - - diff --git a/source/packets/cPacket_EntityLook.h b/source/packets/cPacket_EntityLook.h deleted file mode 100644 index 463faccda..000000000 --- a/source/packets/cPacket_EntityLook.h +++ /dev/null @@ -1,62 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cEntity; - - - - - -class cPacket_EntityLook : - public cPacket -{ -public: - cPacket_EntityLook(void) - : m_UniqueID( 0 ) - , m_Rotation( 0 ) - , m_Pitch( 0 ) - { m_PacketID = E_ENT_LOOK; } - cPacket_EntityLook(const cEntity & a_Entity); - virtual cPacket* Clone(void) const { return new cPacket_EntityLook(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - char m_Rotation; - char m_Pitch; -}; - - - - - -class cPacket_EntityHeadLook : - public cPacket -{ -public: - cPacket_EntityHeadLook(void) - : m_UniqueID( 0 ) - , m_HeadYaw( 0 ) - { - 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; - char m_HeadYaw; -}; - - - - diff --git a/source/packets/cPacket_EntityStatus.cpp b/source/packets/cPacket_EntityStatus.cpp deleted file mode 100644 index 1ea468a51..000000000 --- a/source/packets/cPacket_EntityStatus.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_EntityStatus.h" - - - - - -void cPacket_EntityStatus::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendByte (a_Data, m_Status); -} - - - - diff --git a/source/packets/cPacket_EntityStatus.h b/source/packets/cPacket_EntityStatus.h deleted file mode 100644 index ecacd03c5..000000000 --- a/source/packets/cPacket_EntityStatus.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_EntityStatus : public cPacket -{ -public: - cPacket_EntityStatus() - : m_UniqueID( 0 ) - , m_Status( 0 ) - { m_PacketID = E_ENT_STATUS; } - virtual cPacket* Clone() const { return new cPacket_EntityStatus( *this ); } - - virtual void Serialize(AString & a_Data) const override; - - static const char STATUS_TAKEDAMAGE = 2; - static const char STATUS_DIE = 3; - - int m_UniqueID; - char m_Status; - - static const unsigned int c_Size = 1 + 4 + 1; -}; - - - - diff --git a/source/packets/cPacket_Explosion.h b/source/packets/cPacket_Explosion.h index 5121c9175..468d72fe4 100644 --- a/source/packets/cPacket_Explosion.h +++ b/source/packets/cPacket_Explosion.h @@ -22,7 +22,7 @@ public: ~cPacket_Explosion(); virtual cPacket* Clone() const { return new cPacket_Explosion(*this); } - virtual void Serialize(AString & a_Data) const override; + virtual void Serialize(AString & a_Data) const; double m_PosX; // The entity ID of the thunderbolt double m_PosY; // Always true. Might have a meaning in the future... diff --git a/source/packets/cPacket_Handshake.cpp b/source/packets/cPacket_Handshake.cpp index 76d04883c..5229cdba3 100644 --- a/source/packets/cPacket_Handshake.cpp +++ b/source/packets/cPacket_Handshake.cpp @@ -17,13 +17,3 @@ int cPacket_Handshake::Parse(cByteBuffer & a_Buffer) - -void cPacket_Handshake::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendString16(a_Data, m_Username); -} - - - - diff --git a/source/packets/cPacket_Handshake.h b/source/packets/cPacket_Handshake.h index 0ddddb1c1..86bc8a286 100644 --- a/source/packets/cPacket_Handshake.h +++ b/source/packets/cPacket_Handshake.h @@ -14,7 +14,6 @@ public: virtual cPacket* Clone() const { return new cPacket_Handshake(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; std::string m_Username; }; diff --git a/source/packets/cPacket_InventoryProgressBar.cpp b/source/packets/cPacket_InventoryProgressBar.cpp deleted file mode 100644 index 61541c8e9..000000000 --- a/source/packets/cPacket_InventoryProgressBar.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_InventoryProgressBar.h" - - - - - -void cPacket_InventoryProgressBar::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendByte (a_Data, m_WindowID); - AppendShort(a_Data, m_ProgressBar); - AppendShort(a_Data, m_Value); -} - - - - diff --git a/source/packets/cPacket_InventoryProgressBar.h b/source/packets/cPacket_InventoryProgressBar.h deleted file mode 100644 index b78205efa..000000000 --- a/source/packets/cPacket_InventoryProgressBar.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_InventoryProgressBar : public cPacket -{ -public: - cPacket_InventoryProgressBar() - : m_WindowID( 0 ) - , m_ProgressBar( 0 ) - , m_Value( 0 ) - { - m_PacketID = E_INVENTORY_PROGRESS; - } - - virtual cPacket * Clone() const { return new cPacket_InventoryProgressBar(*this); } - - virtual void Serialize(AString & a_Data) const override; - - char m_WindowID; - short m_ProgressBar; - short m_Value; -}; - - - - diff --git a/source/packets/cPacket_InventorySlot.cpp b/source/packets/cPacket_InventorySlot.cpp deleted file mode 100644 index 5bf247541..000000000 --- a/source/packets/cPacket_InventorySlot.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_InventorySlot.h" -#include "cPacket_WholeInventory.h" -#include "cPacket_ItemData.h" - - - - - -void cPacket_InventorySlot::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendByte (a_Data, m_WindowID); - AppendShort(a_Data, m_SlotNum); - - cPacket_ItemData::AppendItem(a_Data, m_ItemID, m_ItemCount, m_ItemUses); -} - - - - diff --git a/source/packets/cPacket_InventorySlot.h b/source/packets/cPacket_InventorySlot.h deleted file mode 100644 index 3f9fdc13f..000000000 --- a/source/packets/cPacket_InventorySlot.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once - -#include "cPacket.h" - -#include "../BlockID.h" - - - - - -class cPacket_InventorySlot : public cPacket // Set item [S -> C] ? -{ -public: - cPacket_InventorySlot() - : m_WindowID( 0 ) - , m_SlotNum( 0 ) - , m_ItemID( E_ITEM_EMPTY ) - , m_ItemCount( 0 ) - , m_ItemUses( 0 ) - { m_PacketID = E_INVENTORY_SLOT; } - virtual cPacket* Clone() const { return new cPacket_InventorySlot(*this); } - - virtual void Serialize(AString & a_Data) const override; - - char m_WindowID; - short m_SlotNum; // Slot - // 0 = craft result - // 1-4 = crafting table - // 5-8 = armor - // 9-35 = inventory - // 36-44 = Hot bar - - // Below = item - short m_ItemID; // if this is -1 the next stuff dont exist - char m_ItemCount; - short m_ItemUses; - - static const unsigned int c_Size = 1 + 1 + 2; // Minimal size ( +1+1 = max) -}; - - - - diff --git a/source/packets/cPacket_ItemSwitch.cpp b/source/packets/cPacket_ItemSwitch.cpp index 3ea9d26c2..864214a66 100644 --- a/source/packets/cPacket_ItemSwitch.cpp +++ b/source/packets/cPacket_ItemSwitch.cpp @@ -17,13 +17,3 @@ int cPacket_ItemSwitch::Parse(cByteBuffer & a_Buffer) - -void cPacket_ItemSwitch::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendShort(a_Data, m_SlotNum); -} - - - - diff --git a/source/packets/cPacket_ItemSwitch.h b/source/packets/cPacket_ItemSwitch.h index 1b0323ea6..667b24044 100644 --- a/source/packets/cPacket_ItemSwitch.h +++ b/source/packets/cPacket_ItemSwitch.h @@ -16,11 +16,8 @@ public: virtual cPacket* Clone() const { return new cPacket_ItemSwitch(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; short m_SlotNum; - - static const unsigned int c_Size = 1 + 2; }; diff --git a/source/packets/cPacket_KeepAlive.cpp b/source/packets/cPacket_KeepAlive.cpp index 0dc9302b3..090e90671 100644 --- a/source/packets/cPacket_KeepAlive.cpp +++ b/source/packets/cPacket_KeepAlive.cpp @@ -7,16 +7,6 @@ -void cPacket_KeepAlive::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_KeepAliveID); -} - - - - - int cPacket_KeepAlive::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; diff --git a/source/packets/cPacket_KeepAlive.h b/source/packets/cPacket_KeepAlive.h index c3b9d0587..b68aa5691 100644 --- a/source/packets/cPacket_KeepAlive.h +++ b/source/packets/cPacket_KeepAlive.h @@ -14,8 +14,7 @@ public: cPacket_KeepAlive(int a_PingID) { m_KeepAliveID = a_PingID; } virtual cPacket * Clone() const { return new cPacket_KeepAlive(*this); } - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; + virtual int Parse(cByteBuffer & a_Buffer) override; int m_KeepAliveID; }; diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp index b19e389d1..017227071 100644 --- a/source/packets/cPacket_Login.cpp +++ b/source/packets/cPacket_Login.cpp @@ -32,20 +32,3 @@ int cPacket_Login::Parse(cByteBuffer & a_Buffer) - -void cPacket_Login::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger (a_Data, m_ProtocolVersion); - AppendString16(a_Data, m_Username); - AppendString16(a_Data, m_LevelType); - AppendInteger (a_Data, m_ServerMode); - AppendInteger (a_Data, m_Dimension); - AppendByte (a_Data, m_Difficulty); - AppendByte (a_Data, m_WorldHeight); - AppendByte (a_Data, m_MaxPlayers); -} - - - - diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index a93d2807e..df7545edd 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -22,7 +22,6 @@ public: virtual cPacket* Clone() const { return new cPacket_Login(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; int m_ProtocolVersion; AString m_Username; diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp deleted file mode 100644 index 17fbdba24..000000000 --- a/source/packets/cPacket_MapChunk.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_MapChunk.h" -#include "../ChunkDef.h" - - - - - -cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkZ, const AString & a_SerializedData) : - m_PosX(a_ChunkX), - m_PosZ(a_ChunkZ), - m_SerializedData(a_SerializedData) -{ - m_PacketID = E_MAP_CHUNK; -} - - - - - -void cPacket_MapChunk::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - - AppendInteger(a_Data, m_PosX); - AppendInteger(a_Data, m_PosZ); - a_Data.append(m_SerializedData); -} - - - - diff --git a/source/packets/cPacket_MapChunk.h b/source/packets/cPacket_MapChunk.h deleted file mode 100644 index 35b5de08f..000000000 --- a/source/packets/cPacket_MapChunk.h +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "../ChunkDef.h" - - - - - -class cPacket_MapChunk : - public cPacket -{ -public: - cPacket_MapChunk() - : m_PosX( 0 ) - , m_PosZ( 0 ) - { - m_PacketID = E_MAP_CHUNK; - } - - cPacket_MapChunk(int a_ChunkX, int a_ChunkZ, const AString & a_SerializedData); - virtual cPacket* Clone() const { return new cPacket_MapChunk(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_PosX; - int m_PosZ; - AString m_SerializedData; -}; - - - - diff --git a/source/packets/cPacket_Metadata.cpp b/source/packets/cPacket_Metadata.cpp deleted file mode 100644 index 595801b54..000000000 --- a/source/packets/cPacket_Metadata.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Metadata.h" - - - - - -cPacket_Metadata::cPacket_Metadata(int s, int id) - : m_EMetaData( (cPawn::MetaData)s ) - , m_UniqueID( id ) - , m_Type( 0 ) - , m_MetaData( 0 ) -{ - m_PacketID = E_METADATA; - FormPacket(); -} - - - - - -cPacket_Metadata::cPacket_Metadata() - : m_UniqueID( 0 ) - , m_Type( 0 ) - , m_MetaData( 0 ) -{ - m_PacketID = E_METADATA; - m_EMetaData = cPawn::NORMAL; - FormPacket(); -} - - - - - -cPacket_Metadata::cPacket_Metadata(const cPacket_Metadata & a_Other) - : m_EMetaData( a_Other.m_EMetaData ) - , m_UniqueID( a_Other.m_UniqueID ) - , m_Type( a_Other.m_Type ) - , m_MetaData( NULL ) -{ - m_PacketID = E_METADATA; - FormPacket(); -} - - - - - -cPacket_Metadata::~cPacket_Metadata() -{ - delete [] m_MetaData; -} - - - - - -void cPacket_Metadata::FormPacket() -{ - delete [] m_MetaData; - m_MetaData = new char[3]; - m_MetaDataSize = 3; - // m_UniqueID = GetUniqueID(); - m_MetaData[0] = 0x00; - - m_MetaData[2] = 0x7f; - switch(m_EMetaData) - { - case cPawn::NORMAL: - m_MetaData[1] = 0x00; - break; - case cPawn::BURNING: - m_MetaData[1] = 0x01; - break; - case cPawn::CROUCHED: - m_MetaData[1] = 0x02; - break; - case cPawn::RIDING: - m_MetaData[1] = 0x04; - break; - case cPawn::SPRINTING: - m_MetaData[1] = 0x08; - break; - case cPawn::EATING: - case cPawn::BLOCKING: - m_MetaData[1] = 0x10; - break; - default: - m_MetaData[1] = 0x00; - break; - } -} - - - - - -void cPacket_Metadata::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendData (a_Data, m_MetaData, m_MetaDataSize); -} - - - - diff --git a/source/packets/cPacket_Metadata.h b/source/packets/cPacket_Metadata.h deleted file mode 100644 index 24818e379..000000000 --- a/source/packets/cPacket_Metadata.h +++ /dev/null @@ -1,35 +0,0 @@ - -#pragma once -#include "cPacket.h" - -#include "../cPawn.h" - - - - - -class cPacket_Metadata : public cPacket -{ -public: - cPacket_Metadata(int s, int id); - cPacket_Metadata(); - cPacket_Metadata(const cPacket_Metadata & a_Other); - ~cPacket_Metadata(); - - virtual void Serialize(AString & a_Data) const override; - - void FormPacket(); - virtual cPacket* Clone() const { return new cPacket_Metadata( *this ); } - - cPawn::MetaData m_EMetaData; - - static const unsigned int c_Size = 4 + 1; - int m_UniqueID; - char m_Type; - unsigned int m_MetaDataSize; - char* m_MetaData; -}; - - - - diff --git a/source/packets/cPacket_NamedEntitySpawn.cpp b/source/packets/cPacket_NamedEntitySpawn.cpp deleted file mode 100644 index 798376372..000000000 --- a/source/packets/cPacket_NamedEntitySpawn.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_NamedEntitySpawn.h" - - - - - -void cPacket_NamedEntitySpawn::Serialize(AString & a_Data) const -{ - short CurrentItem = m_CurrentItem; - ASSERT(CurrentItem >= 0); - if (CurrentItem <= 0) - { - CurrentItem = 0; - // Fix, to make sure no invalid values are sent. - // WARNING: HERE ITS 0, BUT IN EQUIP PACKET ITS -1 !! - } - - AppendByte (a_Data, m_PacketID); - AppendInteger (a_Data, m_UniqueID); - AppendString16(a_Data, m_PlayerName); - AppendInteger (a_Data, m_PosX); - AppendInteger (a_Data, m_PosY); - AppendInteger (a_Data, m_PosZ); - AppendByte (a_Data, m_Rotation); - AppendByte (a_Data, m_Pitch); - AppendShort (a_Data, CurrentItem); -} - - - - diff --git a/source/packets/cPacket_NamedEntitySpawn.h b/source/packets/cPacket_NamedEntitySpawn.h deleted file mode 100644 index 365d28c37..000000000 --- a/source/packets/cPacket_NamedEntitySpawn.h +++ /dev/null @@ -1,40 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_NamedEntitySpawn : public cPacket -{ -public: - cPacket_NamedEntitySpawn() - : m_UniqueID( 0 ) - , m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_Rotation( 0 ) - , m_Pitch( 0 ) - , m_CurrentItem( 0 ) - { m_PacketID = E_NAMED_ENTITY_SPAWN; } - virtual cPacket* Clone() const { return new cPacket_NamedEntitySpawn(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - AString m_PlayerName; - int m_PosX; // Pixel position, devide by 32 for block position - int m_PosY; - int m_PosZ; - char m_Rotation; - char m_Pitch; - short m_CurrentItem; - - static const unsigned int c_Size = 1 + 4 + 2 + 4 + 4 + 4 + 1 + 1 + 2; // Minimum size -}; - - - - diff --git a/source/packets/cPacket_NewInvalidState.cpp b/source/packets/cPacket_NewInvalidState.cpp deleted file mode 100644 index 3e44a4877..000000000 --- a/source/packets/cPacket_NewInvalidState.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_NewInvalidState.h" - - - - - -cPacket_NewInvalidState::cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ) -{ - m_PacketID = E_NEW_INVALID_STATE; - m_Reason = a_Copy.m_Reason; - m_GameMode = a_Copy.m_GameMode; -} - - - - - -int cPacket_NewInvalidState::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadChar, m_Reason, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_GameMode, TotalBytes); - return TotalBytes; -} - - - - - -void cPacket_NewInvalidState::Serialize(AString & a_Data) const -{ - AppendByte(a_Data, m_PacketID); - AppendByte(a_Data, m_Reason); - AppendByte(a_Data, m_GameMode); -} - - - - diff --git a/source/packets/cPacket_NewInvalidState.h b/source/packets/cPacket_NewInvalidState.h deleted file mode 100644 index 6bfacd17c..000000000 --- a/source/packets/cPacket_NewInvalidState.h +++ /dev/null @@ -1,31 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_NewInvalidState : public cPacket -{ -public: - cPacket_NewInvalidState() - : m_Reason( 0 ) - , m_GameMode( 0 ) - { m_PacketID = E_NEW_INVALID_STATE;} - cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ); - virtual cPacket* Clone() const { return new cPacket_NewInvalidState(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; - - char m_Reason; // 0 = Invalid Bed, 1 = Begin Raining, 2 End Raining, 3 = Change Gamemode - char m_GameMode; // Used only when reason = 3. 0 is survival, 1 is creative. - - static const unsigned int c_Size = 1 + 1 + 1; -}; - - - - diff --git a/source/packets/cPacket_PickupSpawn.cpp b/source/packets/cPacket_PickupSpawn.cpp deleted file mode 100644 index 1d937cd6c..000000000 --- a/source/packets/cPacket_PickupSpawn.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_PickupSpawn.h" - - - - - -int cPacket_PickupSpawn::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt, m_UniqueID, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_ItemType, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_ItemCount, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_ItemDamage, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Rotation, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Pitch, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_Roll, TotalBytes); - return TotalBytes; -} - - - - - -void cPacket_PickupSpawn::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendShort (a_Data, m_ItemType); - AppendByte (a_Data, m_ItemCount); - AppendShort (a_Data, m_ItemDamage); - AppendInteger(a_Data, m_PosX); - AppendInteger(a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendByte (a_Data, m_Rotation); - AppendByte (a_Data, m_Pitch); - AppendByte (a_Data, m_Roll); -} - - - - diff --git a/source/packets/cPacket_PickupSpawn.h b/source/packets/cPacket_PickupSpawn.h deleted file mode 100644 index 91bbba65e..000000000 --- a/source/packets/cPacket_PickupSpawn.h +++ /dev/null @@ -1,47 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_PickupSpawn : public cPacket -{ -public: - cPacket_PickupSpawn() - : m_UniqueID( 0 ) - , m_ItemType( 0 ) - , m_ItemCount( 0 ) - , m_ItemDamage( 0 ) - , m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_Rotation( 0 ) - , m_Pitch( 0 ) - , m_Roll( 0 ) - { - m_PacketID = E_PICKUP_SPAWN; - } - - virtual cPacket* Clone() const { return new cPacket_PickupSpawn(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - short m_ItemType; - char m_ItemCount; - short m_ItemDamage; - int m_PosX; - int m_PosY; - int m_PosZ; - char m_Rotation; - char m_Pitch; - char m_Roll; -}; - - - - diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp index bcfcbfee6..d0acc17d0 100644 --- a/source/packets/cPacket_Player.cpp +++ b/source/packets/cPacket_Player.cpp @@ -36,21 +36,6 @@ int cPacket_PlayerAbilities::Parse(cByteBuffer & a_Buffer) -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: @@ -79,28 +64,6 @@ int cPacket_PlayerListItem::Parse(cByteBuffer & a_Buffer) -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: @@ -129,17 +92,6 @@ int cPacket_PlayerLook::Parse(cByteBuffer & a_Buffer) -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_IsOnGround); -} - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPacket_PlayerMoveLook: @@ -179,26 +131,6 @@ 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_Stance); - AppendDouble(a_Data, m_PosY); - AppendDouble(a_Data, m_PosZ); - AppendFloat (a_Data, m_Rotation); - AppendFloat (a_Data, m_Pitch); - AppendBool (a_Data, m_IsOnGround); -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPacket_PlayerPosition: @@ -232,22 +164,3 @@ 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 9d80eedc9..1a647a5fc 100644 --- a/source/packets/cPacket_Player.h +++ b/source/packets/cPacket_Player.h @@ -34,7 +34,6 @@ public: cPacket_PlayerAbilities(void) { m_PacketID = E_PLAYER_LIST_ITEM; } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; virtual cPacket * Clone() const { return new cPacket_PlayerAbilities(*this); } @@ -55,7 +54,6 @@ public: cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping); virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; virtual cPacket* Clone() const { return new cPacket_PlayerListItem(*this); } @@ -83,7 +81,6 @@ public: virtual cPacket* Clone() const { return new cPacket_PlayerLook(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; float m_Rotation; float m_Pitch; @@ -112,8 +109,7 @@ public: 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; + virtual int Parse(cByteBuffer & a_Buffer) override; double m_PosX; double m_PosY; @@ -142,7 +138,6 @@ public: virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; double m_PosX; double m_PosY; diff --git a/source/packets/cPacket_PreChunk.cpp b/source/packets/cPacket_PreChunk.cpp deleted file mode 100644 index f7824bba2..000000000 --- a/source/packets/cPacket_PreChunk.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_PreChunk.h" - - - - - -void cPacket_PreChunk::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_PosX); - AppendInteger(a_Data, m_PosZ); - AppendBool (a_Data, m_bLoad); -} - - - - diff --git a/source/packets/cPacket_PreChunk.h b/source/packets/cPacket_PreChunk.h deleted file mode 100644 index 902fa2a02..000000000 --- a/source/packets/cPacket_PreChunk.h +++ /dev/null @@ -1,36 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_PreChunk: public cPacket -{ -public: - cPacket_PreChunk() - : m_PosX( 0 ) - , m_PosZ( 0 ) - , m_bLoad( false ) - { m_PacketID = E_PRE_CHUNK; } - cPacket_PreChunk( int a_PosX, int a_PosZ, bool a_bLoad ) - : m_PosX( a_PosX ) - , m_PosZ( a_PosZ ) - , m_bLoad( a_bLoad ) - { m_PacketID = E_PRE_CHUNK; } - virtual cPacket* Clone() const { return new cPacket_PreChunk(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_PosX; - int m_PosZ; - bool m_bLoad; - - static const unsigned int c_Size = 10; -}; - - - - diff --git a/source/packets/cPacket_RelativeEntityMove.cpp b/source/packets/cPacket_RelativeEntityMove.cpp deleted file mode 100644 index de3746024..000000000 --- a/source/packets/cPacket_RelativeEntityMove.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_RelativeEntityMove.h" - - - - - -void cPacket_RelativeEntityMove::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendByte (a_Data, m_MoveX); - AppendByte (a_Data, m_MoveY); - AppendByte (a_Data, m_MoveZ); -} - - - - diff --git a/source/packets/cPacket_RelativeEntityMove.h b/source/packets/cPacket_RelativeEntityMove.h deleted file mode 100644 index 7dd2cbdbc..000000000 --- a/source/packets/cPacket_RelativeEntityMove.h +++ /dev/null @@ -1,33 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_RelativeEntityMove : public cPacket -{ -public: - cPacket_RelativeEntityMove() - : m_UniqueID( 0 ) - , m_MoveX( 0 ) - , m_MoveY( 0 ) - , m_MoveZ( 0 ) - { m_PacketID = E_REL_ENT_MOVE; } - virtual cPacket* Clone() const { return new cPacket_RelativeEntityMove(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - char m_MoveX; // Pixels, devide by 32 for block - char m_MoveY; - char m_MoveZ; - - static const unsigned int c_Size = 1 + 4 + 1 + 1 + 1; -}; - - - - diff --git a/source/packets/cPacket_RelativeEntityMoveLook.cpp b/source/packets/cPacket_RelativeEntityMoveLook.cpp deleted file mode 100644 index fad2c0620..000000000 --- a/source/packets/cPacket_RelativeEntityMoveLook.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_RelativeEntityMoveLook.h" - - - - - -void cPacket_RelativeEntityMoveLook::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendByte (a_Data, m_MoveX); - AppendByte (a_Data, m_MoveY); - AppendByte (a_Data, m_MoveZ); - AppendByte (a_Data, m_Yaw); - AppendByte (a_Data, m_Pitch); -} - - - - - diff --git a/source/packets/cPacket_RelativeEntityMoveLook.h b/source/packets/cPacket_RelativeEntityMoveLook.h deleted file mode 100644 index 8fa6bf015..000000000 --- a/source/packets/cPacket_RelativeEntityMoveLook.h +++ /dev/null @@ -1,37 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_RelativeEntityMoveLook : public cPacket -{ -public: - cPacket_RelativeEntityMoveLook() - : m_UniqueID( 0 ) - , m_MoveX( 0 ) - , m_MoveY( 0 ) - , m_MoveZ( 0 ) - , m_Yaw( 0 ) - , m_Pitch( 0 ) - { m_PacketID = E_REL_ENT_MOVE_LOOK; } - virtual cPacket* Clone() const { return new cPacket_RelativeEntityMoveLook(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - char m_MoveX; // Pixels, divide by 32 for block - char m_MoveY; - char m_MoveZ; - char m_Yaw; - char m_Pitch; - - static const unsigned int c_Size = 1 + 4 + 1 + 1 + 1 + 1 + 1; -}; - - - - diff --git a/source/packets/cPacket_Respawn.cpp b/source/packets/cPacket_Respawn.cpp index 94c757003..0e46ea01e 100644 --- a/source/packets/cPacket_Respawn.cpp +++ b/source/packets/cPacket_Respawn.cpp @@ -7,21 +7,6 @@ -void cPacket_Respawn::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - - AppendInteger (a_Data, m_Dimension); - AppendByte (a_Data, m_Difficulty); - AppendByte (a_Data, m_CreativeMode); - AppendShort (a_Data, m_WorldHeight); - AppendString16(a_Data, m_LevelType); -} - - - - - int cPacket_Respawn::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h index b05f84614..9292658e7 100644 --- a/source/packets/cPacket_Respawn.h +++ b/source/packets/cPacket_Respawn.h @@ -2,7 +2,6 @@ #pragma once #include "cPacket.h" - #include "cPacket_Login.h" @@ -25,8 +24,7 @@ public: virtual cPacket * Clone() const { return new cPacket_Respawn( *this ); } - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; + virtual int Parse(cByteBuffer & a_Buffer) override; int m_Dimension; char m_Difficulty; diff --git a/source/packets/cPacket_SpawnMob.cpp b/source/packets/cPacket_SpawnMob.cpp deleted file mode 100644 index e00952561..000000000 --- a/source/packets/cPacket_SpawnMob.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_SpawnMob.h" -#include "../Vector3i.h" - - - - - -cPacket_SpawnMob::~cPacket_SpawnMob() -{ - if( m_MetaData ) delete [] m_MetaData; -} - - - - - -cPacket_SpawnMob::cPacket_SpawnMob() - : m_UniqueID( 0 ) - , m_Type( 0 ) - , m_Yaw( 0 ) - , m_Pitch( 0 ) - , m_MetaDataSize( 0 ) - , m_MetaData( 0 ) - , m_HeadYaw(0) -{ - m_PacketID = E_SPAWN_MOB; -} - - - - - -cPacket_SpawnMob::cPacket_SpawnMob( const cPacket_SpawnMob & a_Clone ) -{ - m_PacketID = E_SPAWN_MOB; - m_UniqueID = a_Clone.m_UniqueID; - m_Type = a_Clone.m_Type; - m_Pos = a_Clone.m_Pos; - m_Yaw = a_Clone.m_Yaw; - m_Pitch = a_Clone.m_Pitch; - m_HeadYaw = a_Clone.m_HeadYaw; - - m_MetaDataSize = a_Clone.m_MetaDataSize; - m_MetaData = new char[m_MetaDataSize]; - memcpy( m_MetaData, a_Clone.m_MetaData, sizeof( char ) * m_MetaDataSize ); -} - - - - - -void cPacket_SpawnMob::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger (a_Data, m_UniqueID); - AppendByte (a_Data, m_Type); - AppendInteger (a_Data, m_Pos.x); - AppendInteger (a_Data, m_Pos.y); - AppendInteger (a_Data, m_Pos.z); - AppendByte (a_Data, m_Yaw); - AppendByte (a_Data, m_Pitch); - AppendByte (a_Data, m_HeadYaw); - AppendData (a_Data, m_MetaData, m_MetaDataSize); -} - - - - diff --git a/source/packets/cPacket_SpawnMob.h b/source/packets/cPacket_SpawnMob.h deleted file mode 100644 index 9661da771..000000000 --- a/source/packets/cPacket_SpawnMob.h +++ /dev/null @@ -1,35 +0,0 @@ - -#pragma once - -#include "cPacket.h" -#include "../Vector3i.h" - - - - - -class cPacket_SpawnMob : - public cPacket -{ -public: - cPacket_SpawnMob(); - cPacket_SpawnMob( const cPacket_SpawnMob & a_Clone ); - virtual cPacket* Clone() const { return new cPacket_SpawnMob( *this ); } - ~cPacket_SpawnMob(); - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - char m_Type; - Vector3i m_Pos; - char m_Yaw; - char m_Pitch; - char m_HeadYaw; - - unsigned int m_MetaDataSize; - char * m_MetaData; -}; - - - - diff --git a/source/packets/cPacket_TeleportEntity.cpp b/source/packets/cPacket_TeleportEntity.cpp deleted file mode 100644 index 14905701a..000000000 --- a/source/packets/cPacket_TeleportEntity.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_TeleportEntity.h" - -#include "../cEntity.h" - - - - - -cPacket_TeleportEntity::cPacket_TeleportEntity(const cEntity & a_Entity) -{ - m_PacketID = E_ENT_TELEPORT; - - 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); -} - - - - - -void cPacket_TeleportEntity::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger(a_Data, m_UniqueID); - AppendInteger(a_Data, m_PosX); - AppendInteger(a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendByte (a_Data, m_Rotation); - AppendByte (a_Data, m_Pitch); -} - - - - diff --git a/source/packets/cPacket_TeleportEntity.h b/source/packets/cPacket_TeleportEntity.h deleted file mode 100644 index 5203badb6..000000000 --- a/source/packets/cPacket_TeleportEntity.h +++ /dev/null @@ -1,42 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cEntity; -class cPacket_TeleportEntity : public cPacket -{ -public: - cPacket_TeleportEntity() - : m_UniqueID( 0 ) - , m_PosX( 0 ) - , m_PosY( 0 ) - , 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(const cEntity & a_Entity); - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; - int m_PosX; // Pixel position, divide by 32 for block position - int m_PosY; - int m_PosZ; - char m_Rotation; - char m_Pitch; - - static const unsigned int c_Size = 1 + 4 + 4 + 4 + 4 + 1 + 1; -}; - - - - diff --git a/source/packets/cPacket_Thunderbolt.cpp b/source/packets/cPacket_Thunderbolt.cpp deleted file mode 100644 index 81054ad8e..000000000 --- a/source/packets/cPacket_Thunderbolt.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_Thunderbolt.h" - - - - - -cPacket_Thunderbolt::cPacket_Thunderbolt( const cPacket_Thunderbolt & a_Copy ) -{ - m_PacketID = E_THUNDERBOLT; - m_UniqueID = 237183; //just a random Ent ID. I don't think this matters at all. - m_Unknown = true; - m_xLBPos = a_Copy.m_xLBPos; - m_yLBPos = a_Copy.m_yLBPos; - m_zLBPos = a_Copy.m_zLBPos; -} - - - - - -void cPacket_Thunderbolt::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendInteger (a_Data, m_UniqueID); - AppendBool (a_Data, m_Unknown); - AppendInteger (a_Data, m_xLBPos * 32); - AppendInteger (a_Data, m_yLBPos * 32); - AppendInteger (a_Data, m_zLBPos * 32); -} - - - - diff --git a/source/packets/cPacket_Thunderbolt.h b/source/packets/cPacket_Thunderbolt.h deleted file mode 100644 index c3c4e2c98..000000000 --- a/source/packets/cPacket_Thunderbolt.h +++ /dev/null @@ -1,36 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_Thunderbolt : public cPacket -{ -public: - cPacket_Thunderbolt() - : m_UniqueID( 0 ) - , m_Unknown( 0 ) - , m_xLBPos( 0 ) - , m_yLBPos( 0 ) - , m_zLBPos( 0 ) - { m_PacketID = E_THUNDERBOLT; m_Unknown = true; } - cPacket_Thunderbolt( const cPacket_Thunderbolt & a_Copy ); - virtual cPacket* Clone() const { return new cPacket_Thunderbolt(*this); } - - virtual void Serialize(AString & a_Data) const override; - - int m_UniqueID; // The entity ID of the thunderbolt - bool m_Unknown; // Always true. Might have a meaning in the future... - int m_xLBPos; // Thunderbolt X as Absolute Integer - int m_yLBPos; // Thunderbolt Y as Absolute Integer - int m_zLBPos; // Thunderbolt Z as Absolute Integer - - static const unsigned int c_Size = 1 + 4 + 1 + 4 + 4 + 4; -}; - - - - diff --git a/source/packets/cPacket_TimeUpdate.cpp b/source/packets/cPacket_TimeUpdate.cpp deleted file mode 100644 index 1195305d4..000000000 --- a/source/packets/cPacket_TimeUpdate.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_TimeUpdate.h" - - - - - -int cPacket_TimeUpdate::Parse(cByteBuffer & a_Buffer) -{ - int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEInt64, m_Time, TotalBytes); - return TotalBytes; -} - - - - - -void cPacket_TimeUpdate::Serialize(AString & a_Data) const -{ - AppendByte(a_Data, m_PacketID); - AppendLong(a_Data, m_Time); -} - - - - diff --git a/source/packets/cPacket_TimeUpdate.h b/source/packets/cPacket_TimeUpdate.h deleted file mode 100644 index 9aaa02cae..000000000 --- a/source/packets/cPacket_TimeUpdate.h +++ /dev/null @@ -1,29 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_TimeUpdate : public cPacket -{ -public: - cPacket_TimeUpdate() - : m_Time( 0 ) - { m_PacketID = E_UPDATE_TIME; } - cPacket_TimeUpdate( long long a_Time ) { m_PacketID = E_UPDATE_TIME; m_Time = a_Time; } - virtual cPacket* Clone() const { return new cPacket_TimeUpdate(*this); } - - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; - - long long m_Time; - - static const unsigned int c_Size = 1 + 8; -}; - - - - diff --git a/source/packets/cPacket_UpdateHealth.cpp b/source/packets/cPacket_UpdateHealth.cpp deleted file mode 100644 index ff54b6530..000000000 --- a/source/packets/cPacket_UpdateHealth.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_UpdateHealth.h" - - - - - -void cPacket_UpdateHealth::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendShort(a_Data, m_Health); - AppendShort(a_Data, m_Food); - AppendFloat(a_Data, m_Saturation); -} - - - - diff --git a/source/packets/cPacket_UpdateHealth.h b/source/packets/cPacket_UpdateHealth.h deleted file mode 100644 index 67fd32399..000000000 --- a/source/packets/cPacket_UpdateHealth.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_UpdateHealth : public cPacket -{ -public: - cPacket_UpdateHealth() - : m_Health( 0 ) - , m_Food( 0 ) - , m_Saturation( 0.f ) - { m_PacketID = E_UPDATE_HEALTH; } - cPacket_UpdateHealth( short a_Health ) { m_Health = a_Health; m_PacketID = E_UPDATE_HEALTH; } - virtual cPacket* Clone() const { return new cPacket_UpdateHealth( *this ); } - - virtual void Serialize(AString & a_Data) const override; - - short m_Health; - short m_Food; - float m_Saturation; - - static const unsigned int c_Size = 1 + 2 + 2 + 4; -}; - - - - diff --git a/source/packets/cPacket_UpdateSign.cpp b/source/packets/cPacket_UpdateSign.cpp index 564debf01..b258fc9c3 100644 --- a/source/packets/cPacket_UpdateSign.cpp +++ b/source/packets/cPacket_UpdateSign.cpp @@ -23,19 +23,3 @@ int cPacket_UpdateSign::Parse(cByteBuffer & a_Buffer) - -void cPacket_UpdateSign::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - 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); - AppendString16(a_Data, m_Line4); -} - - - - diff --git a/source/packets/cPacket_UpdateSign.h b/source/packets/cPacket_UpdateSign.h index 0704a926a..e7b4977b2 100644 --- a/source/packets/cPacket_UpdateSign.h +++ b/source/packets/cPacket_UpdateSign.h @@ -21,7 +21,6 @@ public: 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_BlockX; short m_BlockY; diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp deleted file mode 100644 index 69ea33580..000000000 --- a/source/packets/cPacket_WholeInventory.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_WholeInventory.h" -#include "../cItem.h" -#include "../cInventory.h" -#include "../cWindow.h" -#include "cPacket_ItemData.h" - - - - - -cPacket_WholeInventory::cPacket_WholeInventory( const cPacket_WholeInventory & a_Clone ) -{ - m_PacketID = E_INVENTORY_WHOLE; - m_WindowID = a_Clone.m_WindowID; - m_Count = a_Clone.m_Count; - m_Items = new cItem[m_Count]; - // TODO: copy items one by one, they may have some values that needn't be shallow-copiable - memcpy(m_Items, a_Clone.m_Items, sizeof(cItem) * m_Count); -} - - - - - -cPacket_WholeInventory::cPacket_WholeInventory(const cInventory & a_Inventory) -{ - m_PacketID = E_INVENTORY_WHOLE; - m_WindowID = 0; // Inventory window has a constant ID of 0 - m_Count = a_Inventory.c_NumSlots; - m_Items = new cItem[m_Count]; - // TODO: copy items one by one, they may have some values that needn't be shallow-copiable - memcpy( m_Items, a_Inventory.GetSlots(), sizeof(cItem) * m_Count); -} - - - - - -cPacket_WholeInventory::cPacket_WholeInventory(const cWindow & a_Window) -{ - m_PacketID = E_INVENTORY_WHOLE; - m_WindowID = (char)a_Window.GetWindowID(); - m_Count = (short)a_Window.GetNumSlots(); - m_Items = new cItem[m_Count]; - // TODO: copy items one by one, they may have some values that needn't be shallow-copiable - memcpy( m_Items, a_Window.GetSlots(), sizeof(cItem) * m_Count); -} - - - - - -cPacket_WholeInventory::~cPacket_WholeInventory() -{ - delete [] m_Items; -} - - - - - -void cPacket_WholeInventory::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendByte (a_Data, m_WindowID); - AppendShort(a_Data, m_Count); - - for (int j = 0; j < m_Count; j++) - { - cPacket_ItemData::AppendItem(a_Data, m_Items[j]); - } -} - - - - -
\ No newline at end of file diff --git a/source/packets/cPacket_WholeInventory.h b/source/packets/cPacket_WholeInventory.h deleted file mode 100644 index 6582fe6fe..000000000 --- a/source/packets/cPacket_WholeInventory.h +++ /dev/null @@ -1,47 +0,0 @@ - -#pragma once - -#include "cPacket.h" - -#include "../BlockID.h" - - - - - -class cInventory; -class cWindow; -class cItem; - - - - - -class cPacket_WholeInventory : - public cPacket // full inventory [S -> C] ? -{ -public: - cPacket_WholeInventory(const cPacket_WholeInventory & a_Clone); - cPacket_WholeInventory(const cInventory & a_Inventory); - cPacket_WholeInventory(const cWindow & a_Window); - ~cPacket_WholeInventory(); - cPacket_WholeInventory() - : m_WindowID( 0 ) - , m_Count( 0 ) - , m_Items( 0 ) - { - m_PacketID = E_INVENTORY_WHOLE; - } - - virtual cPacket * Clone() const { return new cPacket_WholeInventory(*this); } - - virtual void Serialize(AString & a_Data) const override; - - char m_WindowID; - short m_Count; - cItem * m_Items; -}; - - - - diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp index 1d4304917..a0a7afbda 100644 --- a/source/packets/cPacket_WindowClick.cpp +++ b/source/packets/cPacket_WindowClick.cpp @@ -2,7 +2,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "cPacket_WindowClick.h" -#include "cPacket_WholeInventory.h" #include "cPacket_ItemData.h" diff --git a/source/packets/cPacket_WindowClose.cpp b/source/packets/cPacket_WindowClose.cpp index 9991ab500..f1280ae28 100644 --- a/source/packets/cPacket_WindowClose.cpp +++ b/source/packets/cPacket_WindowClose.cpp @@ -17,13 +17,3 @@ int cPacket_WindowClose::Parse(cByteBuffer & a_Buffer) - -void cPacket_WindowClose::Serialize(AString & a_Data) const -{ - AppendByte(a_Data, m_PacketID); - AppendByte(a_Data, m_WindowID); -} - - - - diff --git a/source/packets/cPacket_WindowClose.h b/source/packets/cPacket_WindowClose.h index de40ab446..0851fa20d 100644 --- a/source/packets/cPacket_WindowClose.h +++ b/source/packets/cPacket_WindowClose.h @@ -18,8 +18,7 @@ public: virtual cPacket* Clone() const { return new cPacket_WindowClose(*this); } - virtual int Parse(cByteBuffer & a_Buffer) override; - virtual void Serialize(AString & a_Data) const override; + virtual int Parse(cByteBuffer & a_Buffer) override; char m_WindowID; }; diff --git a/source/packets/cPacket_WindowOpen.cpp b/source/packets/cPacket_WindowOpen.cpp deleted file mode 100644 index 8c4402139..000000000 --- a/source/packets/cPacket_WindowOpen.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket_WindowOpen.h" - - - - - -void cPacket_WindowOpen::Serialize(AString & a_Data) const -{ - AppendByte (a_Data, m_PacketID); - AppendByte (a_Data, m_WindowID); - AppendByte (a_Data, m_InventoryType); - AppendString16(a_Data, m_WindowTitle); - AppendByte (a_Data, m_NumSlots); -} - - - - diff --git a/source/packets/cPacket_WindowOpen.h b/source/packets/cPacket_WindowOpen.h deleted file mode 100644 index 3896f5f02..000000000 --- a/source/packets/cPacket_WindowOpen.h +++ /dev/null @@ -1,32 +0,0 @@ - -#pragma once - -#include "cPacket.h" - - - - - -class cPacket_WindowOpen : public cPacket -{ -public: - cPacket_WindowOpen() - : m_WindowID( 0 ) - , m_InventoryType( 0 ) - , m_NumSlots( 0 ) - { m_PacketID = E_WINDOW_OPEN; } - virtual cPacket* Clone() const { return new cPacket_WindowOpen(*this); } - - virtual void Serialize(AString & a_Data) const override; - - char m_WindowID; - char m_InventoryType; - AString m_WindowTitle; - char m_NumSlots; - - static const unsigned int c_Size = 1 + 1 + 1 + 2 + 1; // + sizeof(string) -}; - - - - |