summaryrefslogtreecommitdiffstats
path: root/source/packets/cPacket_Metadata.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-03 20:41:19 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-03 20:41:19 +0200
commit386d58b5862d8b76925c6523721594887606e82a (patch)
treeef073e7a843f4b75a4008d4b7383f7cdf08ceee5 /source/packets/cPacket_Metadata.cpp
parentVisual Studio 2010 solution and project files (diff)
downloadcuberite-386d58b5862d8b76925c6523721594887606e82a.tar
cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.gz
cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.bz2
cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.lz
cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.xz
cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.zst
cuberite-386d58b5862d8b76925c6523721594887606e82a.zip
Diffstat (limited to '')
-rw-r--r--source/packets/cPacket_Metadata.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/source/packets/cPacket_Metadata.cpp b/source/packets/cPacket_Metadata.cpp
new file mode 100644
index 000000000..3d3df3b9c
--- /dev/null
+++ b/source/packets/cPacket_Metadata.cpp
@@ -0,0 +1,65 @@
+#include "cPacket_Metadata.h"
+
+cPacket_Metadata::cPacket_Metadata(int s, int id)
+ : EMetaState( (MetaState)s )
+ , m_UniqueID( id )
+ , m_Type( 0 )
+ , m_MetaData( 0 )
+{
+ m_PacketID = E_METADATA;
+ FormPacket();
+}
+
+cPacket_Metadata::cPacket_Metadata()
+ : EMetaState(NORMAL)
+ , m_UniqueID( 0 )
+ , m_Type( 0 )
+ , m_MetaData( 0 )
+{
+ m_PacketID = E_METADATA;
+ FormPacket();
+}
+
+cPacket_Metadata::~cPacket_Metadata() {
+ //if( m_MetaData ) delete [] m_MetaData;
+}
+
+void cPacket_Metadata::FormPacket() {
+ if( m_MetaData ) delete [] m_MetaData;
+ m_MetaData = new char[3];
+ m_MetaDataSize = 3;
+ //m_UniqueID = GetUniqueID();
+ m_MetaData[0] = 0x00;
+ //m_MetaData[1] = 0x01; //Burning
+ m_MetaData[2] = 0x7f;
+ switch(EMetaState) {
+ case NORMAL:
+ m_MetaData[1] = 0x00;
+ break;
+ case BURNING:
+ m_MetaData[1] = 0x01;
+ break;
+ case CROUCHED:
+ m_MetaData[1] = 0x02;
+ break;
+ case RIDING:
+ m_MetaData[1] = 0x04;
+ break;
+ default:
+ m_MetaData[1] = 0x00;
+ break;
+ }
+}
+
+bool cPacket_Metadata::Send(cSocket & a_Socket) {
+ unsigned int TotalSize = c_Size + m_MetaDataSize;
+ char* Message = new char[TotalSize];
+ unsigned int i = 0;
+
+ AppendByte ( (char)m_PacketID, Message, i );
+ AppendInteger ( m_UniqueID, Message, i );
+ AppendData ( m_MetaData, m_MetaDataSize, Message, i );
+
+ bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
+ return RetVal;
+}