From 02f05f749645d3ef211676e6745d3feda2cd0513 Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Wed, 21 Dec 2011 20:42:34 +0000 Subject: =?UTF-8?q?-=20Crafting=20fixed=20in=201.0.0=20-=20Server=20compat?= =?UTF-8?q?ible=20with=20the=20weapons=20and=20equip=20again.=20(Some=20Pa?= =?UTF-8?q?ckets=20were=20incompatible)=20-=20fixed=20bucket=20bugs=20(not?= =?UTF-8?q?=20all)=20-=20Fixed=20clients=20getting=20crashed=20by=20wrong?= =?UTF-8?q?=20Pickups=20-=20fixed=20nearly=20all=20mob=20drops.=20(Check?= =?UTF-8?q?=20wheather=20they=20are=20burning=20is=20missing=20Big=20Grin)?= =?UTF-8?q?=20-=20maybe=20some=20other=20things=20I=20can=C2=B4t=20recall?= =?UTF-8?q?=20atm=20Big=20Grin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://mc-server.googlecode.com/svn/trunk@94 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_AddToInventory.cpp | 15 +++- source/packets/cPacket_AddToInventory.h | 7 +- source/packets/cPacket_BlockPlace.cpp | 13 ++- source/packets/cPacket_CreateInventoryAction.cpp | 101 +++++++++++++---------- source/packets/cPacket_CreateInventoryAction.h | 6 +- source/packets/cPacket_InventorySlot.cpp | 20 +++-- source/packets/cPacket_InventorySlot.h | 5 +- source/packets/cPacket_WholeInventory.cpp | 21 +++-- source/packets/cPacket_WholeInventory.h | 3 + source/packets/cPacket_WindowClick.cpp | 26 +++--- source/packets/cPacket_WindowClick.h | 5 +- 11 files changed, 133 insertions(+), 89 deletions(-) (limited to 'source/packets') diff --git a/source/packets/cPacket_AddToInventory.cpp b/source/packets/cPacket_AddToInventory.cpp index 5d3274229..0a9dad8c0 100644 --- a/source/packets/cPacket_AddToInventory.cpp +++ b/source/packets/cPacket_AddToInventory.cpp @@ -1,15 +1,22 @@ #include "cPacket_AddToInventory.h" +#include "cPacket_WholeInventory.h" +#include "cItem.h" +#include "cPacket_ItemData.h" bool cPacket_AddToInventory::Send( cSocket & a_Socket ) { unsigned int TotalSize = c_Size; + + cPacket_ItemData Item; + + TotalSize += Item.GetSize(m_ItemType); + char* Message = new char[TotalSize]; unsigned int i = 0; - AppendByte ( (char)m_PacketID, Message, i ); - AppendShort ( m_ItemType, Message, i ); - AppendByte ( m_Count, Message, i ); - AppendShort ( m_Life, Message, i ); + AppendByte ( (char) m_PacketID, Message, i ); + + Item.AppendItem(Message, i, m_ItemType, m_Count, this->m_Life); bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); delete [] Message; diff --git a/source/packets/cPacket_AddToInventory.h b/source/packets/cPacket_AddToInventory.h index 8029a53d0..f6710e521 100644 --- a/source/packets/cPacket_AddToInventory.h +++ b/source/packets/cPacket_AddToInventory.h @@ -2,12 +2,13 @@ #include "cPacket.h" #include "PacketID.h" +#include "../BlockID.h" class cPacket_AddToInventory : public cPacket { public: cPacket_AddToInventory() - : m_ItemType( 0 ) + : m_ItemType( E_ITEM_EMPTY ) , m_Count( 0 ) , m_Life( 0 ) { m_PacketID = E_ADD_TO_INV; } @@ -16,8 +17,8 @@ public: bool Parse( cSocket & a_Socket ); bool Send( cSocket & a_Socket ); - short m_ItemType; + ENUM_ITEM_ID m_ItemType; char m_Count; short m_Life; - static const unsigned int c_Size = 1 + 2 + 1 + 2; + static const unsigned int c_Size = 1; }; \ No newline at end of file diff --git a/source/packets/cPacket_BlockPlace.cpp b/source/packets/cPacket_BlockPlace.cpp index 08bc1c40c..9943ae38e 100644 --- a/source/packets/cPacket_BlockPlace.cpp +++ b/source/packets/cPacket_BlockPlace.cpp @@ -1,4 +1,5 @@ #include "cPacket_BlockPlace.h" +#include "cPacket_ItemData.h" bool cPacket_BlockPlace::Parse(cSocket & a_Socket) { @@ -8,11 +9,21 @@ bool cPacket_BlockPlace::Parse(cSocket & a_Socket) if( !ReadInteger( m_PosZ ) ) return false; if( !ReadByte ( m_Direction ) ) return false; + /* if( !ReadShort ( m_ItemType ) ) return false; if( m_ItemType > -1 ) { if( !ReadByte ( m_Count ) ) return false; if( !ReadShort ( m_Uses ) ) return false; - } + }*/ + + cPacket_ItemData Item; + + Item.Parse(m_Socket); + + m_ItemType = Item.m_ItemID; + m_Count = Item.m_ItemCount; + m_Uses = Item.m_ItemUses; + return true; } \ No newline at end of file diff --git a/source/packets/cPacket_CreateInventoryAction.cpp b/source/packets/cPacket_CreateInventoryAction.cpp index 40aad22e8..9ccc9f383 100644 --- a/source/packets/cPacket_CreateInventoryAction.cpp +++ b/source/packets/cPacket_CreateInventoryAction.cpp @@ -1,42 +1,59 @@ -#include "cPacket_CreateInventoryAction.h" - -cPacket_CreateInventoryAction::cPacket_CreateInventoryAction( const cPacket_CreateInventoryAction & a_Copy ) -{ - m_PacketID = E_CREATE_INVENTORY_ACTION; - m_Slot = a_Copy.m_Slot; - m_ItemID = a_Copy.m_ItemID; - m_Quantity = 0; - m_Damage = 0; -} - -bool cPacket_CreateInventoryAction::Parse(cSocket & a_Socket) -{ - m_Socket = a_Socket; - if( !ReadShort ( m_Slot ) ) return false; - if( !ReadShort ( m_ItemID ) ) return false; - if( !ReadShort ( m_Quantity ) ) return false; - if( !ReadShort ( m_Damage ) ) return false; - return true; -} - -bool cPacket_CreateInventoryAction::Send(cSocket & a_Socket) -{ - //LOG("InventoryChange:"); - unsigned int TotalSize = c_Size; - char* Message = new char[TotalSize]; - - if( m_ItemID <= 0 ) m_ItemID = -1; // Fix, to make sure no invalid values are sent. - // WARNING: HERE ITS -1, BUT IN NAMED ENTITY SPAWN PACKET ITS 0 !! - //LOG("cPacket_CreateInventoryAction: Sending Creative item ID: %i", m_ItemID ); - - unsigned int i = 0; - AppendByte ( (char)m_PacketID, Message, i ); - AppendShort ( m_Slot, Message, i ); - AppendShort ( m_ItemID, Message, i ); - AppendShort ( m_Quantity, Message, i ); - AppendShort ( m_Damage, Message, i ); - - bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); - delete [] Message; - return RetVal; -} +#include "cPacket_CreateInventoryAction.h" +#include "cPacket_ItemData.h" + +cPacket_CreateInventoryAction::cPacket_CreateInventoryAction( const cPacket_CreateInventoryAction & a_Copy ) +{ + m_PacketID = E_CREATE_INVENTORY_ACTION; + m_Slot = a_Copy.m_Slot; + m_ItemID = a_Copy.m_ItemID; + m_Quantity = 0; + m_Damage = 0; +} + +bool cPacket_CreateInventoryAction::Parse(cSocket & a_Socket) +{ + m_Socket = a_Socket; + if( !ReadShort ( m_Slot ) ) return false; + /* + if( !ReadShort ( m_ItemID ) ) return false; + if( !ReadShort ( m_Quantity ) ) return false; + if( !ReadShort ( m_Damage ) ) return false; + */ + + cPacket_ItemData Item; + + Item.Parse(m_Socket); + + m_ItemID = Item.m_ItemID; + m_Quantity = Item.m_ItemCount; + m_Damage = Item.m_ItemUses; + + + return true; +} + +bool cPacket_CreateInventoryAction::Send(cSocket & a_Socket) +{ + //LOG("InventoryChange:"); + unsigned int TotalSize = c_Size; + + cPacket_ItemData Item; + + TotalSize += Item.GetSize(m_ItemID); + + char* Message = new char[TotalSize]; + + if( m_ItemID <= 0 ) m_ItemID = -1; // Fix, to make sure no invalid values are sent. + // WARNING: HERE ITS -1, BUT IN NAMED ENTITY SPAWN PACKET ITS 0 !! + //LOG("cPacket_CreateInventoryAction: Sending Creative item ID: %i", m_ItemID ); + + unsigned int i = 0; + AppendByte ( (char)m_PacketID, Message, i ); + AppendShort ( m_Slot, Message, i ); + + Item.AppendItem(Message, i, m_ItemID, m_Quantity, m_Damage); + + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); + delete [] Message; + return RetVal; +} diff --git a/source/packets/cPacket_CreateInventoryAction.h b/source/packets/cPacket_CreateInventoryAction.h index 02af3a64e..083e05446 100644 --- a/source/packets/cPacket_CreateInventoryAction.h +++ b/source/packets/cPacket_CreateInventoryAction.h @@ -3,6 +3,8 @@ #include "cPacket.h" #include "PacketID.h" +//Sure itīs not Creative Inventory? + class cPacket_CreateInventoryAction : public cPacket { public: @@ -20,8 +22,8 @@ public: short m_Slot; // 0 = hold 1-4 = armor short m_ItemID; - short m_Quantity; + char m_Quantity; //Byte not short ;) short m_Damage; - static const unsigned int c_Size = 1 + 2 + 2 + 2 + 2; + static const unsigned int c_Size = 1 + 2; }; diff --git a/source/packets/cPacket_InventorySlot.cpp b/source/packets/cPacket_InventorySlot.cpp index 13b41b7b1..3c3a40210 100644 --- a/source/packets/cPacket_InventorySlot.cpp +++ b/source/packets/cPacket_InventorySlot.cpp @@ -1,21 +1,25 @@ #include "cPacket_InventorySlot.h" +#include "cPacket_WholeInventory.h" +#include "cPacket_ItemData.h" bool cPacket_InventorySlot::Send(cSocket & a_Socket) { unsigned int TotalSize = c_Size; - if( m_ItemID > -1 ) TotalSize += 1 + 2; + + cPacket_ItemData Item; + + TotalSize += Item.GetSize(m_ItemID); + char* Message = new char[TotalSize]; unsigned int i = 0; - AppendByte ( (char)m_PacketID, Message, i ); + AppendByte ( (char)m_PacketID, Message, i ); AppendByte ( m_WindowID, Message, i ); AppendShort ( m_SlotNum, Message, i ); - AppendShort ( m_ItemID, Message, i ); - if( m_ItemID > -1 ) - { - AppendByte ( m_ItemCount, Message, i ); - AppendShort ( m_ItemUses, Message, i ); - } + + + Item.AppendItem(Message, i, m_ItemID, m_ItemCount, m_ItemUses); + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); delete [] Message; diff --git a/source/packets/cPacket_InventorySlot.h b/source/packets/cPacket_InventorySlot.h index 95711c98d..47672989e 100644 --- a/source/packets/cPacket_InventorySlot.h +++ b/source/packets/cPacket_InventorySlot.h @@ -2,6 +2,7 @@ #include "cPacket.h" #include "PacketID.h" +#include "../BlockID.h" class cPacket_InventorySlot : public cPacket // Set item [S -> C] ? { @@ -9,7 +10,7 @@ public: cPacket_InventorySlot() : m_WindowID( 0 ) , m_SlotNum( 0 ) - , m_ItemID( 0 ) + , m_ItemID( E_ITEM_EMPTY ) , m_ItemCount( 0 ) , m_ItemUses( 0 ) { m_PacketID = E_INVENTORY_SLOT; } @@ -30,5 +31,5 @@ public: char m_ItemCount; short m_ItemUses; - static const unsigned int c_Size = 1 + 1 + 2 + 2; // Minimal size ( +1+1 = max) + static const unsigned int c_Size = 1 + 1 + 2; // Minimal size ( +1+1 = max) }; \ No newline at end of file diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp index 3ee047239..4bc68ed0b 100644 --- a/source/packets/cPacket_WholeInventory.cpp +++ b/source/packets/cPacket_WholeInventory.cpp @@ -2,6 +2,7 @@ #include "../cItem.h" #include "../cInventory.h" #include "../cWindow.h" +#include "cPacket_ItemData.h" cPacket_WholeInventory::cPacket_WholeInventory( const cPacket_WholeInventory & a_Clone ) { @@ -39,11 +40,11 @@ bool cPacket_WholeInventory::Send(cSocket & a_Socket) { unsigned int TotalSize = c_Size; + cPacket_ItemData Item; + for(int i = 0; i < m_Count; i++) { - if( m_Items[i].m_ItemID > -1 ) - TotalSize+=3; - TotalSize+=2; + TotalSize += Item.GetSize(m_Items[i].m_ItemID); } char* Message = new char[TotalSize]; @@ -51,18 +52,16 @@ bool cPacket_WholeInventory::Send(cSocket & a_Socket) unsigned int i = 0; AppendByte ( (char)m_PacketID, Message, i ); AppendByte ( m_WindowID, Message, i ); - AppendShort ( m_Count, Message, i ); + AppendShort ( m_Count, Message, i ); + for(int j = 0; j < m_Count; j++) { - AppendShort ( (short)m_Items[j].m_ItemID, Message, i ); - if( m_Items[j].m_ItemID > -1 ) - { - AppendByte ( m_Items[j].m_ItemCount, Message, i ); - AppendShort ( m_Items[j].m_ItemHealth, Message, i ); - } + Item.AppendItem(Message, i, &(m_Items[j])); } bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); delete [] Message; return RetVal; -} \ No newline at end of file +} + + \ No newline at end of file diff --git a/source/packets/cPacket_WholeInventory.h b/source/packets/cPacket_WholeInventory.h index a2e76658e..766342cd2 100644 --- a/source/packets/cPacket_WholeInventory.h +++ b/source/packets/cPacket_WholeInventory.h @@ -2,6 +2,7 @@ #include "cPacket.h" #include "PacketID.h" +#include "BlockID.h" class cInventory; class cWindow; @@ -18,6 +19,8 @@ public: , m_Count( 0 ) , m_Items( 0 ) { m_PacketID = E_INVENTORY_WHOLE; } + + virtual cPacket* Clone() const { return new cPacket_WholeInventory(*this); } bool Send(cSocket & a_Socket); diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp index 6b295b4d5..a84fbd34a 100644 --- a/source/packets/cPacket_WindowClick.cpp +++ b/source/packets/cPacket_WindowClick.cpp @@ -1,5 +1,6 @@ #include "cPacket_WindowClick.h" - +#include "cPacket_WholeInventory.h" +#include "cPacket_ItemData.h" bool cPacket_WindowClick::Parse(cSocket & a_Socket) { @@ -17,20 +18,15 @@ bool cPacket_WindowClick::Parse(cSocket & a_Socket) // LOG("Right/Le: %i", m_RightMouse ); // LOG("NumClick: %i", m_NumClicks ); - if( !ReadShort(m_ItemID) ) return false; -// LOG("ItemID: %i", m_ItemID ); - if( m_ItemID > -1 ) - { - if( !ReadByte(m_ItemCount) ) return false; - if( !ReadShort(m_ItemUses) ) return false; -// LOG("Count : %i", m_ItemCount ); -// LOG("Uses : %i", m_ItemUses ); - } - else - { - m_ItemCount = 0; - m_ItemUses = 0; - } + cPacket_ItemData Item; + + Item.Parse(m_Socket); + + m_ItemID = Item.m_ItemID; + m_ItemCount = Item.m_ItemCount; + m_ItemUses = Item.m_ItemUses; + + m_EnchantNums = Item.m_EnchantNums; return true; } \ No newline at end of file diff --git a/source/packets/cPacket_WindowClick.h b/source/packets/cPacket_WindowClick.h index d6f38e9ab..e330584e1 100644 --- a/source/packets/cPacket_WindowClick.h +++ b/source/packets/cPacket_WindowClick.h @@ -15,6 +15,7 @@ public: , m_ItemID( 0 ) , m_ItemCount( 0 ) , m_ItemUses( 0 ) + , m_EnchantNums(-1) { m_PacketID = E_WINDOW_CLICK; } virtual cPacket* Clone() const { return new cPacket_WindowClick(*this); } @@ -30,12 +31,14 @@ public: char m_RightMouse; // 0 = left 1 = Right mb short m_NumClicks; // Num clicks - bool m_Bool; // unkown???????????? + bool m_Bool; // unkown???????????? SHIFT clicked // Below = item short m_ItemID; // if this is -1 the next stuff dont exist char m_ItemCount; short m_ItemUses; + short m_EnchantNums; + static const unsigned int c_Size = 1 + 1 + 2 + 1 + 2 + 2; // Minimal size ( +1+1 = max) }; \ No newline at end of file -- cgit v1.2.3