summaryrefslogtreecommitdiffstats
path: root/source/packets
diff options
context:
space:
mode:
Diffstat (limited to 'source/packets')
-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
7 files changed, 190 insertions, 11 deletions
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;