diff options
Diffstat (limited to '')
-rw-r--r-- | source/Bindings.cpp | 1 | ||||
-rw-r--r-- | source/PacketID.h | 9 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 2 | ||||
-rw-r--r-- | source/cInventory.h | 3 | ||||
-rw-r--r-- | source/cPlugin.h | 1 | ||||
-rw-r--r-- | source/packets/cPacket_CreateInventoryAction.cpp | 42 | ||||
-rw-r--r-- | source/packets/cPacket_CreateInventoryAction.h | 27 | ||||
-rw-r--r-- | source/packets/cPacket_Login.h | 2 |
8 files changed, 81 insertions, 6 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 7a0174852..3104dc702 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -14816,6 +14816,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_CHAT",E_CHAT);
tolua_constant(tolua_S,"E_UPDATE_TIME",E_UPDATE_TIME);
tolua_constant(tolua_S,"E_ENTITY_EQUIPMENT",E_ENTITY_EQUIPMENT);
+ tolua_constant(tolua_S,"E_CREATE_INVENTORY_ACTION",E_CREATE_INVENTORY_ACTION);
tolua_constant(tolua_S,"E_USE_ENTITY",E_USE_ENTITY);
tolua_constant(tolua_S,"E_UPDATE_HEALTH",E_UPDATE_HEALTH);
tolua_constant(tolua_S,"E_RESPAWN",E_RESPAWN);
diff --git a/source/PacketID.h b/source/PacketID.h index 6a5611ae0..75482bbb0 100644 --- a/source/PacketID.h +++ b/source/PacketID.h @@ -1,8 +1,8 @@ #pragma once
//tolua_begin
-enum ENUM_PACKET_ID
-{
+enum ENUM_PACKET_ID
+{
E_KEEP_ALIVE = 0x00,
E_LOGIN = 0x01,
E_HANDSHAKE = 0x02,
@@ -45,8 +45,9 @@ enum ENUM_PACKET_ID E_INVENTORY_SLOT = 0x67,
E_INVENTORY_WHOLE = 0x68,
E_INVENTORY_PROGRESS= 0x69,
+ E_CREATE_INVENTORY_ACTION = 0x6B,
E_UPDATE_SIGN = 0x82,
E_PING = 0xfe,
E_DISCONNECT = 0xff,
-};
-//tolua_end
\ No newline at end of file +};
+//tolua_end
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 99b8c040c..f21815e52 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -55,6 +55,7 @@ #include "packets/cPacket_PickupSpawn.h"
#include "packets/cPacket_ItemSwitch.h"
#include "packets/cPacket_EntityEquipment.h"
+#include "packets/cPacket_CreateInventoryAction.h"
#include "packets/cPacket_UseEntity.h"
#include "packets/cPacket_WindowClose.h"
#include "packets/cPacket_13.h"
@@ -134,6 +135,7 @@ cClientHandle::cClientHandle(const cSocket & a_Socket) m_pState->PacketMap[E_DISCONNECT] = new cPacket_Disconnect;
m_pState->PacketMap[E_ITEM_SWITCH] = new cPacket_ItemSwitch;
m_pState->PacketMap[E_ENTITY_EQUIPMENT] = new cPacket_EntityEquipment;
+ m_pState->PacketMap[E_CREATE_INVENTORY_ACTION] = new cPacket_CreateInventoryAction;
m_pState->PacketMap[E_PICKUP_SPAWN] = new cPacket_PickupSpawn;
m_pState->PacketMap[E_USE_ENTITY] = new cPacket_UseEntity;
m_pState->PacketMap[E_WINDOW_CLOSE] = new cPacket_WindowClose;
diff --git a/source/cInventory.h b/source/cInventory.h index 19460142f..01f505ab1 100644 --- a/source/cInventory.h +++ b/source/cInventory.h @@ -9,6 +9,7 @@ class cClientHandle; class cPlayer;
class cPacket_WindowClick;
class cPacket_EntityEquipment;
+class cPacket_CreateInventoryAction;
class cInventory //tolua_export
: public cWindowOwner
{ //tolua_export
@@ -64,4 +65,4 @@ private: short m_EquippedSlot;
cPlayer* m_Owner;
-}; //tolua_export
\ No newline at end of file +}; //tolua_export
diff --git a/source/cPlugin.h b/source/cPlugin.h index 6c38871f3..add455006 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -8,6 +8,7 @@ class cPacket_BlockPlace;
class cPacket_PickupSpawn;
class cPacket_EntityEquipment;
+class cPacket_CreateInventoryAction;
class cPacket_Disconnect;
class cPacket_Chat;
class cPacket_BlockDig;
diff --git a/source/packets/cPacket_CreateInventoryAction.cpp b/source/packets/cPacket_CreateInventoryAction.cpp new file mode 100644 index 000000000..19996769f --- /dev/null +++ b/source/packets/cPacket_CreateInventoryAction.cpp @@ -0,0 +1,42 @@ +#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_Short = 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_Short ) ) 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_Short, Message, i ); + + 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 new file mode 100644 index 000000000..e4ed2d9f8 --- /dev/null +++ b/source/packets/cPacket_CreateInventoryAction.h @@ -0,0 +1,27 @@ +#pragma once + +#include "cPacket.h" +#include "PacketID.h" + +class cPacket_CreateInventoryAction : public cPacket +{ +public: + cPacket_CreateInventoryAction() + : m_Slot( 0 ) + , m_ItemID( 0 ) + , m_Quantity( 0 ) + , m_Short( 0 ) + { m_PacketID = E_CREATE_INVENTORY_ACTION; m_Short = 0; m_Quantity = 1; } + cPacket_CreateInventoryAction( const cPacket_CreateInventoryAction & a_Copy ); + virtual cPacket* Clone() const { return new cPacket_CreateInventoryAction(*this); } + + bool Parse(cSocket & a_Socket); + bool Send(cSocket & a_Socket); + + short m_Slot; // 0 = hold 1-4 = armor + short m_ItemID; + short m_Quantity; + short m_Short; + + static const unsigned int c_Size = 1 + 4 + 2 + 2 + 2; +}; diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index 91919a799..812893d54 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -10,7 +10,7 @@ public: cPacket_Login()
: m_ProtocolVersion( 0 )
, m_MapSeed( 0 )
- , m_ServerMode( 0 )
+ , m_ServerMode( 1 ) //0 for survival, 1 for creative
, m_Dimension( 0 )
, m_Difficulty( 0 )
, m_WorldHeight( 0 )
|