summaryrefslogtreecommitdiffstats
path: root/source/packets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/packets/cPacket_BlockDig.h32
-rw-r--r--source/packets/cPacket_BlockPlace.cpp7
-rw-r--r--source/packets/cPacket_BlockPlace.h30
-rw-r--r--source/packets/cPacket_CreativeInventoryAction.cpp32
-rw-r--r--source/packets/cPacket_CreativeInventoryAction.h28
-rw-r--r--source/packets/cPacket_Handshake.h1
-rw-r--r--source/packets/cPacket_ItemData.cpp39
-rw-r--r--source/packets/cPacket_ItemData.h29
-rw-r--r--source/packets/cPacket_Login.cpp5
-rw-r--r--source/packets/cPacket_Login.h28
-rw-r--r--source/packets/cPacket_Player.cpp24
-rw-r--r--source/packets/cPacket_Player.h8
-rw-r--r--source/packets/cPacket_WholeInventory.cpp13
-rw-r--r--source/packets/cPacket_WindowClick.cpp12
-rw-r--r--source/packets/cPacket_WindowClick.h33
15 files changed, 146 insertions, 175 deletions
diff --git a/source/packets/cPacket_BlockDig.h b/source/packets/cPacket_BlockDig.h
index e1bdc14f1..01eb54377 100644
--- a/source/packets/cPacket_BlockDig.h
+++ b/source/packets/cPacket_BlockDig.h
@@ -1,31 +1,37 @@
+
#pragma once
#include "cPacket.h"
-class cPacket_BlockDig : public cPacket //tolua_export
-{ //tolua_export
+
+
+
+class cPacket_BlockDig :
+ public cPacket
+{
public:
- cPacket_BlockDig() //tolua_export
+ cPacket_BlockDig()
: m_Status( 0 )
, m_PosX( 0 )
, m_PosY( 0 )
, m_PosZ( 0 )
, m_Direction( 0 )
- { m_PacketID = E_BLOCK_DIG; } //tolua_export
- virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } //tolua_export
+ {
+ m_PacketID = E_BLOCK_DIG;
+ }
+
+ 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; // tolua_export
- int m_PosX; // tolua_export
- char m_PosY; // tolua_export
- int m_PosZ; // tolua_export
- char m_Direction; // tolua_export
-
- static const unsigned int c_Size = 12;
-}; //tolua_export
+ char m_Status;
+ int m_PosX;
+ char m_PosY;
+ int m_PosZ;
+ char m_Direction;
+};
diff --git a/source/packets/cPacket_BlockPlace.cpp b/source/packets/cPacket_BlockPlace.cpp
index f767456a2..6b4219a8b 100644
--- a/source/packets/cPacket_BlockPlace.cpp
+++ b/source/packets/cPacket_BlockPlace.cpp
@@ -16,18 +16,13 @@ int cPacket_BlockPlace::Parse(cByteBuffer & a_Buffer)
HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes);
HANDLE_PACKET_READ(ReadChar, m_Direction, TotalBytes);
- cPacket_ItemData Item;
+ cPacket_ItemData Item(m_HeldItem);
int res = Item.Parse(a_Buffer);
if (res < 0)
{
return res;
}
TotalBytes += res;
-
- m_ItemType = Item.m_ItemID;
- m_Count = Item.m_ItemCount;
- m_Uses = Item.m_ItemUses;
-
return TotalBytes;
}
diff --git a/source/packets/cPacket_BlockPlace.h b/source/packets/cPacket_BlockPlace.h
index fa8aae585..187abf549 100644
--- a/source/packets/cPacket_BlockPlace.h
+++ b/source/packets/cPacket_BlockPlace.h
@@ -2,38 +2,36 @@
#pragma once
#include "cPacket.h"
+#include "../cItem.h"
-class cPacket_BlockPlace : public cPacket //tolua_export
-{ //tolua_export
+class cPacket_BlockPlace :
+ public cPacket
+{
public:
cPacket_BlockPlace()
: m_PosX( 0 )
, m_PosY( 0 )
, m_PosZ( 0 )
, m_Direction( 0 )
- , m_ItemType( 0 )
- , m_Count( 0 )
- , m_Uses( 0 )
- { m_PacketID = E_BLOCK_PLACE; }
+ {
+ m_PacketID = E_BLOCK_PLACE;
+ }
+
virtual cPacket* Clone() const { return new cPacket_BlockPlace(*this); }
virtual int Parse(cByteBuffer & a_Buffer) override;
- int m_PosX; //tolua_export
- unsigned char m_PosY; //tolua_export
- int m_PosZ; //tolua_export
- char m_Direction; //tolua_export
+ int m_PosX;
+ unsigned char m_PosY;
+ int m_PosZ;
+ char m_Direction;
- short m_ItemType; //tolua_export
- char m_Count; //tolua_export
- short m_Uses; //tolua_export
-
- static const unsigned int c_Size = 1 + 4 + 1 + 4 + 1 + 2;// ( + 2 )
-}; //tolua_export
+ cItem m_HeldItem;
+} ;
diff --git a/source/packets/cPacket_CreativeInventoryAction.cpp b/source/packets/cPacket_CreativeInventoryAction.cpp
index a71585df3..85291da3e 100644
--- a/source/packets/cPacket_CreativeInventoryAction.cpp
+++ b/source/packets/cPacket_CreativeInventoryAction.cpp
@@ -10,11 +10,9 @@
cPacket_CreativeInventoryAction::cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy )
{
- m_PacketID = E_CREATIVE_INVENTORY_ACTION;
- m_Slot = a_Copy.m_Slot;
- m_ItemID = a_Copy.m_ItemID;
- m_Quantity = a_Copy.m_Quantity;
- m_Damage = a_Copy.m_Damage;
+ m_PacketID = E_CREATIVE_INVENTORY_ACTION;
+ m_SlotNum = a_Copy.m_SlotNum;
+ m_ClickedItem = a_Copy.m_ClickedItem;
}
@@ -24,20 +22,15 @@ cPacket_CreativeInventoryAction::cPacket_CreativeInventoryAction( const cPacket_
int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer)
{
int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadBEShort, m_Slot, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes);
- cPacket_ItemData Item;
+ cPacket_ItemData Item(m_ClickedItem);
int res = Item.Parse(a_Buffer);
if (res < 0)
{
return res;
}
TotalBytes += res;
-
- m_ItemID = Item.m_ItemID;
- m_Quantity = Item.m_ItemCount;
- m_Damage = Item.m_ItemUses;
-
return TotalBytes;
}
@@ -47,19 +40,10 @@ int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer)
void cPacket_CreativeInventoryAction::Serialize(AString & a_Data) const
{
- short ItemID = m_ItemID;
- ASSERT(ItemID >= -1); // Check validity of packets in debug runtime
- if (ItemID <= 0)
- {
- ItemID = -1;
- // Fix, to make sure no invalid values are sent.
- // WARNING: HERE ITS -1, BUT IN NAMED ENTITY SPAWN PACKET ITS 0 !!
- }
-
- AppendByte (a_Data, m_PacketID);
- AppendShort (a_Data, m_Slot);
+ AppendByte (a_Data, m_PacketID);
+ AppendShort(a_Data, m_SlotNum);
- cPacket_ItemData::AppendItem(a_Data, ItemID, m_Quantity, m_Damage);
+ cPacket_ItemData::AppendItem(a_Data, m_ClickedItem);
}
diff --git a/source/packets/cPacket_CreativeInventoryAction.h b/source/packets/cPacket_CreativeInventoryAction.h
index 4d983e51d..ae438a7a8 100644
--- a/source/packets/cPacket_CreativeInventoryAction.h
+++ b/source/packets/cPacket_CreativeInventoryAction.h
@@ -2,35 +2,31 @@
#pragma once
#include "cPacket.h"
+#include "../cItem.h"
-//Sure itīs not Creative Inventory?
-
-class cPacket_CreativeInventoryAction : public cPacket
+class cPacket_CreativeInventoryAction :
+ public cPacket
{
public:
- cPacket_CreativeInventoryAction()
- : m_Slot( 0 )
- , m_ItemID( 0 )
- , m_Quantity( 0 )
- , m_Damage( 0 )
- { m_PacketID = E_CREATIVE_INVENTORY_ACTION; m_Quantity = 1; }
+ cPacket_CreativeInventoryAction() :
+ m_SlotNum(0)
+ {
+ m_PacketID = E_CREATIVE_INVENTORY_ACTION;
+ }
+
cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy );
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_Slot; // 0 = hold 1-4 = armor
- short m_ItemID;
- char m_Quantity; //Byte not short ;)
- short m_Damage;
-
- static const unsigned int c_Size = 1 + 2;
-};
+ short m_SlotNum;
+ cItem m_ClickedItem;
+} ;
diff --git a/source/packets/cPacket_Handshake.h b/source/packets/cPacket_Handshake.h
index d1b06dacc..0ddddb1c1 100644
--- a/source/packets/cPacket_Handshake.h
+++ b/source/packets/cPacket_Handshake.h
@@ -17,7 +17,6 @@ public:
virtual void Serialize(AString & a_Data) const override;
std::string m_Username;
- static const unsigned int c_Size = 3; // Minimal size
};
diff --git a/source/packets/cPacket_ItemData.cpp b/source/packets/cPacket_ItemData.cpp
index 2e4203bfc..4f0803475 100644
--- a/source/packets/cPacket_ItemData.cpp
+++ b/source/packets/cPacket_ItemData.cpp
@@ -10,25 +10,26 @@
int cPacket_ItemData::Parse(cByteBuffer & a_Buffer)
{
int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadBEShort, m_ItemID, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemType, TotalBytes);
- if (m_ItemID <= -1)
+ if (m_Dst.m_ItemType <= -1)
{
- m_ItemCount = 0;
- m_ItemUses = 0;
+ m_Dst.Empty();
return TotalBytes;
}
- HANDLE_PACKET_READ(ReadChar, m_ItemCount, TotalBytes);
- HANDLE_PACKET_READ(ReadBEShort, m_ItemUses, TotalBytes);
+ HANDLE_PACKET_READ(ReadChar, m_Dst.m_ItemCount, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemDamage, TotalBytes);
- if (cItem::IsEnchantable((ENUM_ITEM_ID) m_ItemID))
+ if (cItem::IsEnchantable(m_Dst.m_ItemType))
{
- HANDLE_PACKET_READ(ReadBEShort, m_EnchantNums, TotalBytes);
+ short EnchantNumBytes;
+ HANDLE_PACKET_READ(ReadBEShort, EnchantNumBytes, TotalBytes);
- if ( m_EnchantNums > -1 )
+ if (EnchantNumBytes > 0)
{
// TODO: Enchantment not implemented yet!
+ a_Buffer.SkipRead(EnchantNumBytes);
}
}
return TotalBytes;
@@ -51,24 +52,32 @@ int cPacket_ItemData::GetSize(short a_ItemID)
-void cPacket_ItemData::AppendItem(AString & a_Data, const cItem * a_Item)
+void cPacket_ItemData::AppendItem(AString & a_Data, const cItem & a_Item)
{
- return AppendItem(a_Data, a_Item->m_ItemID, a_Item->m_ItemCount, a_Item->m_ItemHealth);
+ return AppendItem(a_Data, a_Item.m_ItemType, a_Item.m_ItemCount, a_Item.m_ItemDamage);
}
-void cPacket_ItemData::AppendItem(AString & a_Data, short a_ItemID, char a_Quantity, short a_Damage)
+void cPacket_ItemData::AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage)
{
- AppendShort(a_Data, (short) a_ItemID);
- if (a_ItemID > -1)
+ short ItemType = a_ItemType;
+ ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
+ if (ItemType <= 0)
+ {
+ // Fix, to make sure no invalid values are sent.
+ ItemType = -1;
+ }
+
+ AppendShort(a_Data, ItemType);
+ if (a_ItemType > -1)
{
AppendByte (a_Data, a_Quantity);
AppendShort(a_Data, a_Damage);
- if (cItem::IsEnchantable((ENUM_ITEM_ID) a_ItemID))
+ if (cItem::IsEnchantable(a_ItemType))
{
// TODO: Implement enchantments
AppendShort(a_Data, (short) -1);
diff --git a/source/packets/cPacket_ItemData.h b/source/packets/cPacket_ItemData.h
index 5a1554b19..e1a6c547d 100644
--- a/source/packets/cPacket_ItemData.h
+++ b/source/packets/cPacket_ItemData.h
@@ -1,35 +1,34 @@
+
#pragma once
#include "cPacket.h"
#include "../cItem.h"
+
+
+
+
class cPacket_ItemData : public cPacket
{
+ cItem & m_Dst;
+
public:
- cPacket_ItemData()
- : m_ItemID( 0 )
- , m_ItemCount( 0 )
- , m_ItemUses( 0 )
- , m_EnchantNums(-1)
+ cPacket_ItemData(cItem & a_Dst) :
+ m_Dst(a_Dst)
{
}
- virtual cPacket* Clone() const { return new cPacket_ItemData(*this); }
+ virtual cPacket * Clone() const { return new cPacket_ItemData(*this); }
virtual int Parse(cByteBuffer & a_Buffer) override;
- static void AppendItem(AString & a_Data, short a_ItemID, char a_Quantity, short a_Damage);
- static void AppendItem(AString & a_Data, const cItem * a_Item);
+ static void AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage);
+ static void AppendItem(AString & a_Data, const cItem & a_Item);
int GetSize(short a_ItemID);
+} ;
+
- // Below = item
- short m_ItemID; // if this is -1 the next stuff dont exist
- char m_ItemCount;
- short m_ItemUses;
- short m_EnchantNums;
- static unsigned int c_Size; // Minimal size ( +1+1 = max)
-}; \ No newline at end of file
diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp
index 90da4c009..b19e389d1 100644
--- a/source/packets/cPacket_Login.cpp
+++ b/source/packets/cPacket_Login.cpp
@@ -7,8 +7,8 @@
-const std::string cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT";
-const std::string cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT";
+const char * cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT";
+const char * cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT";
@@ -16,7 +16,6 @@ const std::string cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT";
int cPacket_Login::Parse(cByteBuffer & a_Buffer)
{
- //printf("Parse: NEW Login\n");
int TotalBytes = 0;
m_Username.clear();
HANDLE_PACKET_READ(ReadBEInt, m_ProtocolVersion, TotalBytes);
diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h
index f512b098a..a93d2807e 100644
--- a/source/packets/cPacket_Login.h
+++ b/source/packets/cPacket_Login.h
@@ -7,8 +7,8 @@
-class cPacket_Login : public cPacket //tolua_export
-{ //tolua_export
+class cPacket_Login : public cPacket
+{
public:
cPacket_Login()
: m_ProtocolVersion( 0 )
@@ -24,18 +24,18 @@ public:
virtual int Parse(cByteBuffer & a_Buffer) override;
virtual void Serialize(AString & a_Data) const override;
- int m_ProtocolVersion; //tolua_export
- AString m_Username; //tolua_export
- AString m_LevelType; //tolua_export
- int m_ServerMode; //tolua_export
- int m_Dimension;
- char m_Difficulty; //tolua_export
- unsigned char m_WorldHeight; //tolua_export
- unsigned char m_MaxPlayers; //tolua_export
-
- static const AString LEVEL_TYPE_DEFAULT;
- static const AString LEVEL_TYPE_SUPERFLAT;
-}; //tolua_export
+ int m_ProtocolVersion;
+ AString m_Username;
+ AString m_LevelType;
+ int m_ServerMode;
+ int m_Dimension;
+ char m_Difficulty;
+ unsigned char m_WorldHeight;
+ unsigned char m_MaxPlayers;
+
+ static const char * LEVEL_TYPE_DEFAULT;
+ static const char * LEVEL_TYPE_SUPERFLAT;
+};
diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp
index a71cdee33..3a897a1ea 100644
--- a/source/packets/cPacket_Player.cpp
+++ b/source/packets/cPacket_Player.cpp
@@ -195,15 +195,15 @@ void cPacket_PlayerMoveLook::Serialize(AString & a_Data) const
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cPacket_PlayerPosition:
-cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player )
+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();
+ m_PosX = a_Player->GetPosX();
+ m_PosY = a_Player->GetPosY() + 1.65;
+ m_PosZ = a_Player->GetPosZ();
+ m_Stance = a_Player->GetStance();
+ m_IsOnGround = a_Player->IsOnGround();
}
@@ -213,11 +213,11 @@ cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player )
int cPacket_PlayerPosition::Parse(cByteBuffer & a_Buffer)
{
int TotalBytes = 0;
- HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes);
- HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes);
- HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes);
- HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes);
- HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes);
return TotalBytes;
}
@@ -232,7 +232,7 @@ void cPacket_PlayerPosition::Serialize(AString & a_Data) const
AppendDouble (a_Data, m_PosY);
AppendDouble (a_Data, m_Stance);
AppendDouble (a_Data, m_PosZ);
- AppendBool (a_Data, m_bFlying);
+ AppendBool (a_Data, m_IsOnGround);
}
diff --git a/source/packets/cPacket_Player.h b/source/packets/cPacket_Player.h
index 8dadcdaea..05b75d9d1 100644
--- a/source/packets/cPacket_Player.h
+++ b/source/packets/cPacket_Player.h
@@ -129,9 +129,9 @@ public:
cPacket_PlayerPosition()
: m_PosX( 0.0 )
, m_PosY( 0.0 )
- , m_Stance( 0.0 )
, m_PosZ( 0.0 )
- , m_bFlying( false )
+ , m_Stance( 0.0 )
+ , m_IsOnGround(true)
{ m_PacketID = E_PLAYERPOS; }
virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); }
@@ -140,9 +140,9 @@ public:
double m_PosX;
double m_PosY;
- double m_Stance;
double m_PosZ;
- bool m_bFlying; // Yeah.. wtf
+ double m_Stance;
+ bool m_IsOnGround;
} ;
diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp
index 3b8fa5cde..fd6a6b457 100644
--- a/source/packets/cPacket_WholeInventory.cpp
+++ b/source/packets/cPacket_WholeInventory.cpp
@@ -17,19 +17,21 @@ cPacket_WholeInventory::cPacket_WholeInventory( const cPacket_WholeInventory & a
m_WindowID = a_Clone.m_WindowID;
m_Count = a_Clone.m_Count;
m_Items = new cItem[m_Count];
- memcpy( m_Items, a_Clone.m_Items, sizeof(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( cInventory* a_Inventory )
+cPacket_WholeInventory::cPacket_WholeInventory(cInventory * a_Inventory)
{
m_PacketID = E_INVENTORY_WHOLE;
m_WindowID = 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 );
}
@@ -37,13 +39,14 @@ cPacket_WholeInventory::cPacket_WholeInventory( cInventory* a_Inventory )
-cPacket_WholeInventory::cPacket_WholeInventory( cWindow* a_Window )
+cPacket_WholeInventory::cPacket_WholeInventory(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];
- memcpy( m_Items, a_Window->GetSlots(), sizeof(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);
}
@@ -67,7 +70,7 @@ void cPacket_WholeInventory::Serialize(AString & a_Data) const
for (int j = 0; j < m_Count; j++)
{
- cPacket_ItemData::AppendItem(a_Data, &(m_Items[j]));
+ cPacket_ItemData::AppendItem(a_Data, m_Items[j]);
}
}
diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp
index c250c187e..1d4304917 100644
--- a/source/packets/cPacket_WindowClick.cpp
+++ b/source/packets/cPacket_WindowClick.cpp
@@ -14,11 +14,11 @@ int cPacket_WindowClick::Parse(cByteBuffer & a_Buffer)
int TotalBytes = 0;
HANDLE_PACKET_READ(ReadChar, m_WindowID, TotalBytes);
HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes);
- HANDLE_PACKET_READ(ReadChar, m_RightMouse, TotalBytes);
- HANDLE_PACKET_READ(ReadBEShort, m_NumClicks, TotalBytes);
+ HANDLE_PACKET_READ(ReadBool, m_IsRightClick, TotalBytes);
+ HANDLE_PACKET_READ(ReadBEShort, m_TransactionID, TotalBytes);
HANDLE_PACKET_READ(ReadBool, m_IsShiftPressed, TotalBytes);
- cPacket_ItemData Item;
+ cPacket_ItemData Item(m_HeldItem);
int res = Item.Parse(a_Buffer);
if (res < 0)
{
@@ -26,12 +26,6 @@ int cPacket_WindowClick::Parse(cByteBuffer & a_Buffer)
}
TotalBytes += res;
- m_ItemID = Item.m_ItemID;
- m_ItemCount = Item.m_ItemCount;
- m_ItemUses = Item.m_ItemUses;
-
- m_EnchantNums = Item.m_EnchantNums;
-
return TotalBytes;
}
diff --git a/source/packets/cPacket_WindowClick.h b/source/packets/cPacket_WindowClick.h
index 72ebad2a1..e0f6f964e 100644
--- a/source/packets/cPacket_WindowClick.h
+++ b/source/packets/cPacket_WindowClick.h
@@ -2,6 +2,7 @@
#pragma once
#include "cPacket.h"
+#include "../cItem.h"
@@ -13,36 +14,24 @@ public:
cPacket_WindowClick()
: m_WindowID( 0 )
, m_SlotNum( 0 )
- , m_RightMouse( 0 )
- , m_NumClicks( 0 )
+ , m_IsRightClick(false)
+ , m_TransactionID( 0 )
, m_IsShiftPressed( false )
- , m_ItemID( 0 )
- , m_ItemCount( 0 )
- , m_ItemUses( 0 )
- , m_EnchantNums(-1)
- { m_PacketID = E_WINDOW_CLICK; }
+ {
+ m_PacketID = E_WINDOW_CLICK;
+ }
+
virtual cPacket* Clone() const { return new cPacket_WindowClick(*this); }
virtual int Parse(cByteBuffer & a_Buffer) 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
-
- char m_RightMouse; // 0 = Left 1 = Right mb
- short m_NumClicks; // Num clicks
+ short m_SlotNum;
+ bool m_IsRightClick;
+ short m_TransactionID;
bool m_IsShiftPressed; // Shift pressed when clicked?
- // Below = item
- short m_ItemID; // if this is -1 the next stuff dont exist
- char m_ItemCount;
- short m_ItemUses;
-
- short m_EnchantNums;
+ cItem m_HeldItem;
};