summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--VC2010/MCServer.vcxproj6
-rw-r--r--VC2010/MCServer.vcxproj.filters27
-rw-r--r--makefile18
-rw-r--r--source/PacketID.h81
-rw-r--r--source/packets/cPacket_BlockAction.cpp29
-rw-r--r--source/packets/cPacket_BlockAction.h28
-rw-r--r--source/packets/cPacket_Explosion.cpp42
-rw-r--r--source/packets/cPacket_Explosion.h32
-rw-r--r--source/packets/cPacket_SoundEffect.cpp30
-rw-r--r--source/packets/cPacket_SoundEffect.h28
-rw-r--r--source/packets/cPacket_Thunderbolt.cpp12
11 files changed, 283 insertions, 50 deletions
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj
index d9253c701..c761becb2 100644
--- a/VC2010/MCServer.vcxproj
+++ b/VC2010/MCServer.vcxproj
@@ -305,6 +305,7 @@
<ClCompile Include="..\source\packets\cPacket_13.cpp" />
<ClCompile Include="..\source\packets\cPacket_AddToInventory.cpp" />
<ClCompile Include="..\source\packets\cPacket_ArmAnim.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_BlockAction.cpp" />
<ClCompile Include="..\source\packets\cPacket_BlockChange.cpp" />
<ClCompile Include="..\source\packets\cPacket_BlockDig.cpp" />
<ClCompile Include="..\source\packets\cPacket_BlockPlace.cpp" />
@@ -314,7 +315,9 @@
<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_Explosion.cpp" />
<ClCompile Include="..\source\packets\cPacket_NewInvalidState.cpp" />
+ <ClCompile Include="..\source\packets\cPacket_SoundEffect.cpp" />
<ClCompile Include="..\source\packets\cPacket_Thunderbolt.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityLook.cpp" />
<ClCompile Include="..\source\packets\cPacket_EntityStatus.cpp" />
@@ -449,6 +452,7 @@
<ClInclude Include="..\source\packets\cPacket_13.h" />
<ClInclude Include="..\source\packets\cPacket_AddToInventory.h" />
<ClInclude Include="..\source\packets\cPacket_ArmAnim.h" />
+ <ClInclude Include="..\source\packets\cPacket_BlockAction.h" />
<ClInclude Include="..\source\packets\cPacket_BlockChange.h" />
<ClInclude Include="..\source\packets\cPacket_BlockDig.h" />
<ClInclude Include="..\source\packets\cPacket_BlockPlace.h" />
@@ -458,7 +462,9 @@
<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_Explosion.h" />
<ClInclude Include="..\source\packets\cPacket_NewInvalidState.h" />
+ <ClInclude Include="..\source\packets\cPacket_SoundEffect.h" />
<ClInclude Include="..\source\packets\cPacket_Thunderbolt.h" />
<ClInclude Include="..\source\packets\cPacket_EntityLook.h" />
<ClInclude Include="..\source\packets\cPacket_EntityStatus.h" />
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters
index 70a4a6d3f..7bdb69d87 100644
--- a/VC2010/MCServer.vcxproj.filters
+++ b/VC2010/MCServer.vcxproj.filters
@@ -385,6 +385,15 @@
<Filter Include="cLavaSimulator">
<UniqueIdentifier>{b0401fd9-4021-4ab7-bf61-c8de112b4196}</UniqueIdentifier>
</Filter>
+ <Filter Include="Packets\cPacket_Explosion">
+ <UniqueIdentifier>{0a6d025d-4fb8-4557-a348-004b819ea477}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Packets\cPacket_BlockAction">
+ <UniqueIdentifier>{e7503f74-0963-428a-a0fc-0b3bc1c81f99}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Packets\cPacket_SoundEffect">
+ <UniqueIdentifier>{faf55c04-f56e-4f41-a948-54232627c3a9}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\cServer.cpp">
@@ -772,6 +781,15 @@
<ClCompile Include="..\source\cLavaSimulator.cpp">
<Filter>cLavaSimulator</Filter>
</ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_Explosion.cpp">
+ <Filter>Packets\cPacket_Explosion</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_BlockAction.cpp">
+ <Filter>Packets\cPacket_BlockAction</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\packets\cPacket_SoundEffect.cpp">
+ <Filter>Packets\cPacket_SoundEffect</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\cServer.h">
@@ -1194,6 +1212,15 @@
<ClInclude Include="..\source\cLavaSimulator.h">
<Filter>cLavaSimulator</Filter>
</ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_Explosion.h">
+ <Filter>Packets\cPacket_Explosion</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_BlockAction.h">
+ <Filter>Packets\cPacket_BlockAction</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\packets\cPacket_SoundEffect.h">
+ <Filter>Packets\cPacket_SoundEffect</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\source\AllToLua.pkg">
diff --git a/makefile b/makefile
index 13eb768b6..818678093 100644
--- a/makefile
+++ b/makefile
@@ -122,6 +122,9 @@ MCServer : \
build/cPacket_AddToInventory.o\
build/cPacket_ArmAnim.o\
build/cPacket_BlockChange.o\
+ build/cPacket_BlockAction.o\
+ build/cPacket_Explosion.o\
+ build/cPacket_SoundEffect.o\
build/cPacket_BlockDig.o\
build/cPacket_BlockPlace.o\
build/cPacket_Chat.o\
@@ -310,6 +313,9 @@ MCServer : \
build/cPacket_AddToInventory.o\
build/cPacket_ArmAnim.o\
build/cPacket_BlockChange.o\
+ build/cPacket_BlockAction.o\
+ build/cPacket_Explosion.o\
+ build/cPacket_SoundEffect.o\
build/cPacket_BlockDig.o\
build/cPacket_BlockPlace.o\
build/cPacket_Chat.o\
@@ -501,6 +507,9 @@ clean :
build/cPacket_AddToInventory.o\
build/cPacket_ArmAnim.o\
build/cPacket_BlockChange.o\
+ build/cPacket_BlockAction.o\
+ build/cPacket_Explosion.o\
+ build/cPacket_SoundEffect.o\
build/cPacket_BlockDig.o\
build/cPacket_BlockPlace.o\
build/cPacket_Chat.o\
@@ -880,6 +889,15 @@ build/cPacket_ArmAnim.o : source/packets/cPacket_ArmAnim.cpp
build/cPacket_BlockChange.o : source/packets/cPacket_BlockChange.cpp
$(CC) $(CC_OPTIONS) source/packets/cPacket_BlockChange.cpp -c $(INCLUDE) -o build/cPacket_BlockChange.o
+build/cPacket_BlockAction.o : source/packets/cPacket_BlockAction.cpp
+ $(CC) $(CC_OPTIONS) source/packets/cPacket_BlockAction.cpp -c $(INCLUDE) -o build/cPacket_BlockAction.o
+
+build/cPacket_Explosion.o : source/packets/cPacket_Explosion.cpp
+ $(CC) $(CC_OPTIONS) source/packets/cPacket_Explosion.cpp -c $(INCLUDE) -o build/cPacket_Explosion.o
+
+build/cPacket_SoundEffect.o : source/packets/cPacket_SoundEffect.cpp
+ $(CC) $(CC_OPTIONS) source/packets/cPacket_SoundEffect.cpp -c $(INCLUDE) -o build/cPacket_SoundEffect.o
+
build/cPacket_BlockDig.o : source/packets/cPacket_BlockDig.cpp
$(CC) $(CC_OPTIONS) source/packets/cPacket_BlockDig.cpp -c $(INCLUDE) -o build/cPacket_BlockDig.o
diff --git a/source/PacketID.h b/source/PacketID.h
index 98d6fc415..b346e4239 100644
--- a/source/PacketID.h
+++ b/source/PacketID.h
@@ -3,47 +3,50 @@
//tolua_begin
enum ENUM_PACKET_ID
{
- E_KEEP_ALIVE = 0x00,
- E_LOGIN = 0x01,
- E_HANDSHAKE = 0x02,
- E_CHAT = 0x03,
- E_UPDATE_TIME = 0x04,
- E_ENTITY_EQUIPMENT = 0x05,
- E_USE_ENTITY = 0x07,
- E_UPDATE_HEALTH = 0x08,
- E_RESPAWN = 0x09,
- E_FLYING = 0x0a,
- E_PLAYERPOS = 0x0b,
- E_PLAYERLOOK = 0x0c,
- E_PLAYERMOVELOOK= 0x0d,
- E_BLOCK_DIG = 0x0e,
- E_BLOCK_PLACE = 0x0f,
- E_ITEM_SWITCH = 0x10,
- E_ADD_TO_INV = 0x11,
- E_ANIMATION = 0x12,
- E_PACKET_13 = 0x13,
- E_NAMED_ENTITY_SPAWN = 0x14,
- E_PICKUP_SPAWN = 0x15,
- E_COLLECT_ITEM = 0x16,
- E_ADD_VEHICLE = 0x17,
- E_SPAWN_MOB = 0x18,
- E_DESTROY_ENT = 0x1d,
- E_ENTITY = 0x1e,
- E_REL_ENT_MOVE = 0x1f,
- E_ENT_LOOK = 0x20,
+ E_KEEP_ALIVE = 0x00,
+ E_LOGIN = 0x01,
+ E_HANDSHAKE = 0x02,
+ E_CHAT = 0x03,
+ E_UPDATE_TIME = 0x04,
+ E_ENTITY_EQUIPMENT = 0x05,
+ E_USE_ENTITY = 0x07,
+ E_UPDATE_HEALTH = 0x08,
+ E_RESPAWN = 0x09,
+ E_FLYING = 0x0a,
+ E_PLAYERPOS = 0x0b,
+ E_PLAYERLOOK = 0x0c,
+ E_PLAYERMOVELOOK = 0x0d,
+ E_BLOCK_DIG = 0x0e,
+ E_BLOCK_PLACE = 0x0f,
+ E_ITEM_SWITCH = 0x10,
+ E_ADD_TO_INV = 0x11,
+ E_ANIMATION = 0x12,
+ E_PACKET_13 = 0x13,
+ E_NAMED_ENTITY_SPAWN= 0x14,
+ E_PICKUP_SPAWN = 0x15,
+ E_COLLECT_ITEM = 0x16,
+ E_ADD_VEHICLE = 0x17,
+ E_SPAWN_MOB = 0x18,
+ E_DESTROY_ENT = 0x1d,
+ E_ENTITY = 0x1e,
+ E_REL_ENT_MOVE = 0x1f,
+ E_ENT_LOOK = 0x20,
E_REL_ENT_MOVE_LOOK = 0x21,
- E_ENT_TELEPORT = 0x22,
- E_ENT_STATUS = 0x26,
- E_METADATA = 0x28,
- E_PRE_CHUNK = 0x32,
- E_MAP_CHUNK = 0x33,
- E_MULTI_BLOCK = 0x34,
- E_BLOCK_CHANGE = 0x35,
+ E_ENT_TELEPORT = 0x22,
+ E_ENT_STATUS = 0x26,
+ E_METADATA = 0x28,
+ E_PRE_CHUNK = 0x32,
+ E_MAP_CHUNK = 0x33,
+ E_MULTI_BLOCK = 0x34,
+ E_BLOCK_CHANGE = 0x35,
+ E_BLOCK_ACTION = 0x36,
+ E_EXPLOSION = 0x3C,
+ E_SOUND_EFFECT = 0x3D,
E_NEW_INVALID_STATE = 0x46,
- E_THUNDERBOLT = 0x47,
- E_WINDOW_OPEN = 0x64,
- E_WINDOW_CLOSE = 0x65,
- E_WINDOW_CLICK = 0x66,
+ E_THUNDERBOLT = 0x47,
+ E_WINDOW_OPEN = 0x64,
+ E_WINDOW_CLOSE = 0x65,
+ E_WINDOW_CLICK = 0x66,
E_INVENTORY_SLOT = 0x67,
E_INVENTORY_WHOLE = 0x68,
E_INVENTORY_PROGRESS= 0x69,
diff --git a/source/packets/cPacket_BlockAction.cpp b/source/packets/cPacket_BlockAction.cpp
new file mode 100644
index 000000000..c19cf82f1
--- /dev/null
+++ b/source/packets/cPacket_BlockAction.cpp
@@ -0,0 +1,29 @@
+#include "cPacket_BlockAction.h"
+
+cPacket_BlockAction::cPacket_BlockAction( const cPacket_BlockAction & a_Copy )
+{
+ m_PacketID = E_BLOCK_ACTION;
+ m_PosX = a_Copy.m_PosX;
+ m_PosY = a_Copy.m_PosY;
+ m_PosZ = a_Copy.m_PosZ;
+ m_Byte1 = a_Copy.m_Byte1;
+ m_Byte2 = a_Copy.m_Byte2;
+}
+
+bool cPacket_BlockAction::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_PosX, Message, i );
+ AppendShort ( m_PosY, Message, i );
+ AppendInteger ( m_PosZ, Message, i );
+ AppendByte ( m_Byte1, Message, i );
+ AppendByte ( m_Byte1, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_BlockAction.h b/source/packets/cPacket_BlockAction.h
new file mode 100644
index 000000000..11633859d
--- /dev/null
+++ b/source/packets/cPacket_BlockAction.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_BlockAction : public cPacket
+{
+public:
+ cPacket_BlockAction()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Byte1( 0 )
+ , m_Byte2( 0 )
+ { m_PacketID = E_BLOCK_ACTION; }
+ cPacket_BlockAction( const cPacket_BlockAction & a_Copy );
+ virtual cPacket* Clone() const { return new cPacket_BlockAction(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_PosX; // Block X Coordinate
+ short m_PosY; // Block Y Coordinate
+ int m_PosZ; // Block Z Coordinate
+ char m_Byte1; // Varies
+ char m_Byte2; // Varies
+
+ static const unsigned int c_Size = 1 + 4 + 2 + 4 + 1 + 1;
+}; \ No newline at end of file
diff --git a/source/packets/cPacket_Explosion.cpp b/source/packets/cPacket_Explosion.cpp
new file mode 100644
index 000000000..e1de9d6ff
--- /dev/null
+++ b/source/packets/cPacket_Explosion.cpp
@@ -0,0 +1,42 @@
+#include "cPacket_Explosion.h"
+
+cPacket_Explosion::~cPacket_Explosion()
+{
+ if( m_Records )
+ {
+ delete [] m_Records;
+ }
+}
+
+cPacket_Explosion::cPacket_Explosion( const cPacket_Explosion & a_Copy )
+{
+ m_PacketID = E_EXPLOSION;
+ m_PosX = a_Copy.m_PosX;
+ m_PosY = a_Copy.m_PosY;
+ m_PosZ = a_Copy.m_PosZ;
+ m_Radius = a_Copy.m_Radius; //might not be radius
+ m_RecordsCount= a_Copy.m_RecordsCount;
+
+ m_Records = new char[(m_RecordsCount * 3)];
+ memcpy( m_Records, a_Copy.m_Records, (m_RecordsCount * 3) );
+
+}
+
+bool cPacket_Explosion::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size + (m_RecordsCount * 3);
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendDouble ( m_PosX, Message, i );
+ AppendDouble ( m_PosY, Message, i );
+ AppendDouble ( m_PosZ, Message, i );
+ AppendFloat ( m_Radius, Message, i );
+ AppendInteger ( m_RecordsCount, Message, i );
+ AppendData ( m_Records, (m_RecordsCount * 3),Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_Explosion.h b/source/packets/cPacket_Explosion.h
new file mode 100644
index 000000000..587f1683b
--- /dev/null
+++ b/source/packets/cPacket_Explosion.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_Explosion : public cPacket
+{
+public:
+ cPacket_Explosion()
+ : m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_Radius( 0 )
+ , m_RecordsCount( 0 )
+ , m_Records( 0 )
+ { m_PacketID = E_EXPLOSION; m_Records = 0; }
+ cPacket_Explosion( const cPacket_Explosion & a_Copy );
+ ~cPacket_Explosion();
+ virtual cPacket* Clone() const { return new cPacket_Explosion(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ double m_PosX; // The entity ID of the thunderbolt
+ double m_PosY; // Always true. Might have a meaning in the future...
+ double m_PosZ; // Thunderbolt X as Absolute Integer
+ float m_Radius; // Thunderbolt Y as Absolute Integer
+ int m_RecordsCount; // Thunderbolt Z as Absolute Integer
+
+ static const unsigned int c_Size = 1 + 8 + 8 + 8 + 4 + 4;
+
+ char* m_Records;
+};
diff --git a/source/packets/cPacket_SoundEffect.cpp b/source/packets/cPacket_SoundEffect.cpp
new file mode 100644
index 000000000..962c0b709
--- /dev/null
+++ b/source/packets/cPacket_SoundEffect.cpp
@@ -0,0 +1,30 @@
+#include "cPacket_SoundEffect.h"
+
+cPacket_SoundEffect::cPacket_SoundEffect( const cPacket_SoundEffect & a_Copy )
+{
+ m_PacketID = E_SOUND_EFFECT;
+ m_SoundID = a_Copy.m_SoundID;
+ m_PosX = a_Copy.m_PosX;
+ m_PosY = a_Copy.m_PosY;
+ m_PosZ = a_Copy.m_PosZ;
+ m_SoundData = a_Copy.m_SoundData;
+}
+
+
+bool cPacket_SoundEffect::Send(cSocket & a_Socket)
+{
+ unsigned int TotalSize = c_Size;
+ char* Message = new char[TotalSize];
+
+ unsigned int i = 0;
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_SoundID, Message, i );
+ AppendInteger ( m_PosX, Message, i );
+ AppendByte ( (char)m_PosY, Message, i );
+ AppendInteger ( m_PosZ, Message, i );
+ AppendInteger ( m_SoundData, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ delete [] Message;
+ return RetVal;
+}
diff --git a/source/packets/cPacket_SoundEffect.h b/source/packets/cPacket_SoundEffect.h
new file mode 100644
index 000000000..f502e6d0f
--- /dev/null
+++ b/source/packets/cPacket_SoundEffect.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "cPacket.h"
+#include "PacketID.h"
+
+class cPacket_SoundEffect : public cPacket
+{
+public:
+ cPacket_SoundEffect()
+ : m_SoundID( 0 )
+ , m_PosX( 0 )
+ , m_PosY( 0 )
+ , m_PosZ( 0 )
+ , m_SoundData( 0 )
+ { m_PacketID = E_SOUND_EFFECT; }
+ cPacket_SoundEffect( const cPacket_SoundEffect & a_Copy );
+ virtual cPacket* Clone() const { return new cPacket_SoundEffect(*this); }
+
+ bool Send(cSocket & a_Socket);
+
+ int m_SoundID; // Sound ID
+ int m_PosX; // Block X Coordinate
+ char m_PosY; // Block Y Coordinate
+ int m_PosZ; // Block Z Coordinate
+ int m_SoundData;// Extra Sound Data
+
+ static const unsigned int c_Size = 1 + 4 + 4 + 1 + 4 + 4;
+};
diff --git a/source/packets/cPacket_Thunderbolt.cpp b/source/packets/cPacket_Thunderbolt.cpp
index dd61bc815..48e8f1573 100644
--- a/source/packets/cPacket_Thunderbolt.cpp
+++ b/source/packets/cPacket_Thunderbolt.cpp
@@ -4,17 +4,12 @@ cPacket_Thunderbolt::cPacket_Thunderbolt( const cPacket_Thunderbolt & a_Copy )
{
m_PacketID = E_THUNDERBOLT;
m_UniqueID = 237183; //just a random Ent ID. I don't think this matters at all.
- m_Unknown = true;
+ m_Unknown = true;
m_xLBPos = a_Copy.m_xLBPos;
m_yLBPos = a_Copy.m_yLBPos;
m_zLBPos = a_Copy.m_zLBPos;
-printf("blot-packet %i %i %i\n", m_xLBPos,m_yLBPos,m_zLBPos);
-
-
-
}
-
bool cPacket_Thunderbolt::Send(cSocket & a_Socket)
{
unsigned int TotalSize = c_Size;
@@ -28,11 +23,6 @@ bool cPacket_Thunderbolt::Send(cSocket & a_Socket)
AppendInteger ( m_yLBPos*32, Message, i );
AppendInteger ( m_zLBPos*32, Message, i );
- for( unsigned int iii = 1; iii < TotalSize; ++iii ){
-
- printf("packetdata %i\n", (int)Message[iii]);
- }
-
bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
delete [] Message;
return RetVal;