diff options
-rw-r--r-- | VC2010/MCServer.vcxproj | 4 | ||||
-rw-r--r-- | VC2010/MCServer.vcxproj.filters | 11 | ||||
-rw-r--r-- | makefile | 6 | ||||
-rw-r--r-- | settings.ini | 2 | ||||
-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 |
12 files changed, 101 insertions, 9 deletions
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj index e4b042c56..2c428a718 100644 --- a/VC2010/MCServer.vcxproj +++ b/VC2010/MCServer.vcxproj @@ -308,6 +308,7 @@ <ClCompile Include="..\source\packets\cPacket_DestroyEntity.cpp" />
<ClCompile Include="..\source\packets\cPacket_Disconnect.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityEquipment.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_CreateInventoryAction.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityLook.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityStatus.cpp" />
<ClCompile Include="..\source\packets\cPacket_Flying.cpp" />
@@ -445,6 +446,7 @@ <ClInclude Include="..\source\packets\cPacket_DestroyEntity.h" />
<ClInclude Include="..\source\packets\cPacket_Disconnect.h" />
<ClInclude Include="..\source\packets\cPacket_EntityEquipment.h" />
+ <ClInclude Include="..\source\packets\cPacket_CreateInventoryAction.h" />
<ClInclude Include="..\source\packets\cPacket_EntityLook.h" />
<ClInclude Include="..\source\packets\cPacket_EntityStatus.h" />
<ClInclude Include="..\source\packets\cPacket_Flying.h" />
@@ -513,4 +515,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file +</Project>
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters index 62e144e32..55edac971 100644 --- a/VC2010/MCServer.vcxproj.filters +++ b/VC2010/MCServer.vcxproj.filters @@ -283,6 +283,9 @@ <Filter Include="Packets\cPacket_EntityEquipment">
<UniqueIdentifier>{0f48e5f8-ea4d-41dc-ab9e-750c5912c778}</UniqueIdentifier>
</Filter>
+ <Filter Include="Packets\cPacket_CreateInventoryAction">
+ <UniqueIdentifier>{0c47e5f8-ea4d-40dc-ac8e-740c5512c768}</UniqueIdentifier>
+ </Filter>
<Filter Include="Packets\cPacket_UseEntity">
<UniqueIdentifier>{bff5658b-0806-430c-9929-062f4bd4760b}</UniqueIdentifier>
</Filter>
@@ -646,6 +649,9 @@ <ClCompile Include="..\source\packets\cPacket_EntityEquipment.cpp">
<Filter>Packets\cPacket_EntityEquipment</Filter>
</ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_CreateInventoryAction.cpp">
+ <Filter>Packets\cPacket_CreateInventoryAction</Filter>
+ </ClCompile>
<ClCompile Include="..\source\packets\cPacket_UseEntity.cpp">
<Filter>Packets\cPacket_UseEntity</Filter>
</ClCompile>
@@ -1041,6 +1047,9 @@ <ClInclude Include="..\source\packets\cPacket_EntityEquipment.h">
<Filter>Packets\cPacket_EntityEquipment</Filter>
</ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_CreateInventoryAction.h">
+ <Filter>Packets\cPacket_CreateInventoryAction</Filter>
+ </ClInclude>
<ClInclude Include="..\source\packets\cPacket_UseEntity.h">
<Filter>Packets\cPacket_UseEntity</Filter>
</ClInclude>
@@ -1138,4 +1147,4 @@ <ItemGroup>
<ResourceCompile Include="MCServer.rc" />
</ItemGroup>
-</Project>
\ No newline at end of file +</Project>
@@ -127,6 +127,7 @@ MCServer : \ build/cPacket_DestroyEntity.o\ build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ + build/cPacket_CreateInventoryAction.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -307,6 +308,7 @@ MCServer : \ build/cPacket_DestroyEntity.o\ build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ + build/cPacket_CreateInventoryAction.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -490,6 +492,7 @@ clean : build/cPacket_DestroyEntity.o\ build/cPacket_Disconnect.o\ build/cPacket_EntityEquipment.o\ + build/cPacket_CreateInventoryAction.o\ build/cPacket_EntityLook.o\ build/cPacket_EntityStatus.o\ build/cPacket_Flying.o\ @@ -867,6 +870,9 @@ build/cPacket_Disconnect.o : source/packets/cPacket_Disconnect.cpp build/cPacket_EntityEquipment.o : source/packets/cPacket_EntityEquipment.cpp $(CC) $(CC_OPTIONS) source/packets/cPacket_EntityEquipment.cpp -c $(INCLUDE) -o build/cPacket_EntityEquipment.o +build/cPacket_CreateInventoryAction.o : source/packets/cPacket_CreateInventoryAction.cpp + $(CC) $(CC_OPTIONS) source/packets/cPacket_CreateInventoryAction.cpp -c $(INCLUDE) -o build/cPacket_CreateInventoryAction.o + build/cPacket_EntityLook.o : source/packets/cPacket_EntityLook.cpp $(CC) $(CC_OPTIONS) source/packets/cPacket_EntityLook.cpp -c $(INCLUDE) -o build/cPacket_EntityLook.o diff --git a/settings.ini b/settings.ini index 306b1ddf6..bf242acf6 100644 --- a/settings.ini +++ b/settings.ini @@ -1,5 +1,5 @@ [Server] -Port=25565 +Port=11111 ServerID=- [Plugins] 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 )
|