diff options
Diffstat (limited to '')
-rw-r--r-- | source/packets/cPacket_NewInvalidState.cpp | 30 | ||||
-rw-r--r-- | source/packets/cPacket_NewInvalidState.h | 24 | ||||
-rw-r--r-- | source/packets/cPacket_Thunderbolt.cpp | 19 | ||||
-rw-r--r-- | source/packets/cPacket_Thunderbolt.h | 27 |
4 files changed, 100 insertions, 0 deletions
diff --git a/source/packets/cPacket_NewInvalidState.cpp b/source/packets/cPacket_NewInvalidState.cpp new file mode 100644 index 000000000..6755ec207 --- /dev/null +++ b/source/packets/cPacket_NewInvalidState.cpp @@ -0,0 +1,30 @@ +#include "cPacket_NewInvalidState.h" + +cPacket_NewInvalidState::cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ) +{ + m_PacketID = E_NEW_INVALID_STATE; + m_Reason = a_Copy.m_Reason; + m_GameMode = a_Copy.m_GameMode; +} + +bool cPacket_NewInvalidState::Parse(cSocket & a_Socket) { + m_Socket = a_Socket; + if( !ReadByte ( m_Reason ) ) return false; + if( !ReadByte ( m_GameMode ) ) return false; + return true; +} + +bool cPacket_NewInvalidState::Send(cSocket & a_Socket) +{ + unsigned int TotalSize = c_Size; + char* Message = new char[TotalSize]; + + unsigned int i = 0; + AppendByte ( (char)m_PacketID, Message, i ); + AppendByte ( m_Reason, Message, i ); + AppendByte ( m_GameMode, Message, i ); + + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); + delete [] Message; + return RetVal; +} diff --git a/source/packets/cPacket_NewInvalidState.h b/source/packets/cPacket_NewInvalidState.h new file mode 100644 index 000000000..a83cb8080 --- /dev/null +++ b/source/packets/cPacket_NewInvalidState.h @@ -0,0 +1,24 @@ +#pragma once + +#include "cPacket.h" +#include "PacketID.h" + + +class cPacket_NewInvalidState : public cPacket +{ +public: + cPacket_NewInvalidState() + : m_Reason( 0 ) + , m_GameMode( 0 ) + { m_PacketID = E_NEW_INVALID_STATE;} + cPacket_NewInvalidState( const cPacket_NewInvalidState & a_Copy ); + virtual cPacket* Clone() const { return new cPacket_NewInvalidState(*this); } + + bool Parse(cSocket & a_Socket); + bool Send(cSocket & a_Socket); + + char m_Reason; // 0 = Invalid Bed, 1 = Begin Raining, 2 End Raining, 3 = Change Gamemode + char m_GameMode; // Used only when reason = 3. 0 is survival, 1 is creative. + + static const unsigned int c_Size = 1 + 1 + 1; +}; diff --git a/source/packets/cPacket_Thunderbolt.cpp b/source/packets/cPacket_Thunderbolt.cpp new file mode 100644 index 000000000..c6fdefb60 --- /dev/null +++ b/source/packets/cPacket_Thunderbolt.cpp @@ -0,0 +1,19 @@ +#include "cPacket_Thunderbolt.h" + +bool cPacket_Thunderbolt::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_UniqueID, Message, i ); + AppendBool ( m_Unknown, Message, i ); + AppendInteger ( m_xLBPos, Message, i ); + AppendInteger ( m_yLBPos, Message, i ); + AppendInteger ( m_zLBPos, Message, i ); + + bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); + delete [] Message; + return RetVal; +} diff --git a/source/packets/cPacket_Thunderbolt.h b/source/packets/cPacket_Thunderbolt.h new file mode 100644 index 000000000..51dad5814 --- /dev/null +++ b/source/packets/cPacket_Thunderbolt.h @@ -0,0 +1,27 @@ +#pragma once + +#include "cPacket.h" +#include "PacketID.h" + +class cPacket_Thunderbolt : public cPacket +{ +public: + cPacket_Thunderbolt() + : m_UniqueID( 0 ) + , m_Unknown( 0 ) + , m_xLBPos( 0 ) + , m_yLBPos( 0 ) + , m_zLBPos( 0 ) + { m_PacketID = E_THUNDERBOLT;} + virtual cPacket* Clone() const { return new cPacket_Thunderbolt(*this); } + + bool Send(cSocket & a_Socket); + + int m_UniqueID; // The entity ID of the thunderbolt + bool m_Unknown; // Always true. Might have a meaning in the future... + int m_xLBPos; // Thunderbolt X as Absolute Integer + int m_yLBPos; // Thunderbolt Y as Absolute Integer + int m_zLBPos; // Thunderbolt Z as Absolute Integer + + static const unsigned int c_Size = 1 + 4 + 1 + 4 + 4 + 4; +}; |