From 2691e8daed826e944ca38f4787c77273edbf9404 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 18 Aug 2012 09:56:28 +0000 Subject: Packet refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects. This breaks plugin API! Plugins need to modify their hook functions to match those used in the Core plugin git-svn-id: http://mc-server.googlecode.com/svn/trunk@750 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_CreativeInventoryAction.cpp | 32 ++++++---------------- 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'source/packets/cPacket_CreativeInventoryAction.cpp') 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); } -- cgit v1.2.3