From b7d524423c23470cd11e720eeb48368c072838cb Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 7 Feb 2012 20:49:52 +0000 Subject: Rewritten all packets to use buffers instead of direct sockets, for future cSocketThreads compatibility. Moved data sending from cPacket into cSocket git-svn-id: http://mc-server.googlecode.com/svn/trunk@240 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_WindowClick.cpp | 40 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'source/packets/cPacket_WindowClick.cpp') diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp index 2df2108e1..0b2d18415 100644 --- a/source/packets/cPacket_WindowClick.cpp +++ b/source/packets/cPacket_WindowClick.cpp @@ -9,31 +9,35 @@ -bool cPacket_WindowClick::Parse(cSocket & a_Socket) +int cPacket_WindowClick::Parse(const char * a_Data, int a_Size) { -// LOG("-----------INV66-----------"); - m_Socket = a_Socket; + int TotalBytes = 0; + HANDLE_PACKET_READ(ReadByte, m_WindowID, TotalBytes); + HANDLE_PACKET_READ(ReadShort, m_SlotNum, TotalBytes); + HANDLE_PACKET_READ(ReadByte, m_RightMouse, TotalBytes); + HANDLE_PACKET_READ(ReadShort, m_NumClicks, TotalBytes); + HANDLE_PACKET_READ(ReadBool, m_Bool, TotalBytes); - if( !ReadByte(m_WindowID) ) return false; - if( !ReadShort(m_SlotNum) ) return false; - if( !ReadByte(m_RightMouse) ) return false; - if( !ReadShort(m_NumClicks) ) return false; - if( !ReadBool(m_Bool) ) return false; - -// LOG("WindowID : %i", m_Type ); -// LOG("FromSlot: %i", m_SlotNum ); -// LOG("Right/Le: %i", m_RightMouse ); -// LOG("NumClick: %i", m_NumClicks ); + // LOG("WindowClick: WindowID: %i; FromSlot: %i; Right/Le: %i; NumClick: %i", m_Type, m_SlotNum, m_RightMouse, m_NumClicks ); cPacket_ItemData Item; - Item.Parse(m_Socket); + int res = Item.Parse(a_Data + TotalBytes, a_Size - TotalBytes); + if (res < 0) + { + return res; + } + TotalBytes += res; - m_ItemID = Item.m_ItemID; + m_ItemID = Item.m_ItemID; m_ItemCount = Item.m_ItemCount; - m_ItemUses = Item.m_ItemUses; + m_ItemUses = Item.m_ItemUses; m_EnchantNums = Item.m_EnchantNums; - return true; -} \ No newline at end of file + return TotalBytes; +} + + + + -- cgit v1.2.3