diff options
Diffstat (limited to '')
-rw-r--r-- | source/PacketID.h | 81 | ||||
-rw-r--r-- | source/packets/cPacket_BlockAction.cpp | 29 | ||||
-rw-r--r-- | source/packets/cPacket_BlockAction.h | 28 | ||||
-rw-r--r-- | source/packets/cPacket_Explosion.cpp | 42 | ||||
-rw-r--r-- | source/packets/cPacket_Explosion.h | 32 | ||||
-rw-r--r-- | source/packets/cPacket_SoundEffect.cpp | 30 | ||||
-rw-r--r-- | source/packets/cPacket_SoundEffect.h | 28 | ||||
-rw-r--r-- | source/packets/cPacket_Thunderbolt.cpp | 12 |
8 files changed, 232 insertions, 50 deletions
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; |