- Crafting fixed in 1.0.0
- Server compatible with the weapons and equip again. (Some Packets were incompatible) - fixed bucket bugs (not all) - Fixed clients getting crashed by wrong Pickups - fixed nearly all mob drops. (Check wheather they are burning is missing Big Grin) - maybe some other things I can´t recall atm Big Grin git-svn-id: http://mc-server.googlecode.com/svn/trunk@94 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
};
|
||||
Reference in New Issue
Block a user