Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cPacketizer Class Reference

Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destructed. More...

#include <Packetizer.h>

Collaboration diagram for cPacketizer:
Collaboration graph
[legend]

Public Member Functions

 cPacketizer (cProtocol &a_Protocol, cProtocol::ePacketType a_PacketType)
 Starts serializing a new packet into the protocol's m_OutPacketBuffer. More...
 
cProtocol::ePacketType GetPacketType () const
 
void WriteBEDouble (double a_Value)
 
void WriteBEFloat (float a_Value)
 
void WriteBEInt16 (Int16 a_Value)
 
void WriteBEInt32 (Int32 a_Value)
 
void WriteBEInt64 (Int64 a_Value)
 
void WriteBEInt8 (Int8 a_Value)
 
void WriteBEUInt16 (UInt16 a_Value)
 
void WriteBEUInt32 (UInt32 a_Value)
 
void WriteBEUInt64 (UInt64 a_Value)
 
void WriteBEUInt8 (UInt8 a_Value)
 
void WriteBool (bool a_Value)
 
void WriteBuf (const ContiguousByteBufferView a_Data)
 
void WriteByteAngle (double a_Angle)
 Writes the specified angle using a single byte. More...
 
void WriteFPInt (double a_Value)
 Writes the double value as a 27:5 fixed-point integer. More...
 
void WriteString (const AString &a_Value)
 
void WriteUUID (const cUUID &a_UUID)
 Writes the specified UUID as a 128-bit BigEndian integer. More...
 
void WriteVarInt32 (UInt32 a_Value)
 
void WriteXYZPosition64 (const Vector3i a_Position)
 Writes the specified block position as a single encoded 64-bit BigEndian integer. More...
 
void WriteXYZPosition64 (int a_BlockX, int a_BlockY, int a_BlockZ)
 Writes the specified block position as a single encoded 64-bit BigEndian integer. More...
 
void WriteXZYPosition64 (const Vector3i a_Position)
 Writes the specified block position as a single encoded 64-bit BigEndian integer. More...
 
void WriteXZYPosition64 (int a_BlockX, int a_BlockY, int a_BlockZ)
 Writes the specified block position as a single encoded 64-bit BigEndian integer. More...
 
 ~cPacketizer ()
 Sends the packet via the contained protocol's SendPacket() function. More...
 

Static Public Member Functions

static AString PacketTypeToStr (cProtocol::ePacketType a_PacketType)
 Returns the human-readable representation of the packet type. More...
 

Protected Attributes

cCSLock m_Lock
 The RAII lock preventing multithreaded access to the protocol buffer while constructing the packet. More...
 
cByteBufferm_Out
 The protocol's buffer for the constructed packet data. More...
 
cProtocol::ePacketType m_PacketType
 Type of the contained packet. More...
 
cProtocolm_Protocol
 The protocol instance in which the packet is being constructed. More...
 

Detailed Description

Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destructed.

Definition at line 59 of file Packetizer.h.

Constructor & Destructor Documentation

◆ cPacketizer()

cPacketizer::cPacketizer ( cProtocol a_Protocol,
cProtocol::ePacketType  a_PacketType 
)
inline

Starts serializing a new packet into the protocol's m_OutPacketBuffer.

Locks the protocol's m_CSPacket to avoid multithreading issues.

Definition at line 64 of file Packetizer.h.

◆ ~cPacketizer()

cPacketizer::~cPacketizer ( )

Sends the packet via the contained protocol's SendPacket() function.

Definition at line 17 of file Packetizer.cpp.

Member Function Documentation

◆ GetPacketType()

cProtocol::ePacketType cPacketizer::GetPacketType ( ) const
inline

Definition at line 196 of file Packetizer.h.

◆ PacketTypeToStr()

AString cPacketizer::PacketTypeToStr ( cProtocol::ePacketType  a_PacketType)
static

Returns the human-readable representation of the packet type.

Used for logging the packets.

Definition at line 56 of file Packetizer.cpp.

◆ WriteBEDouble()

void cPacketizer::WriteBEDouble ( double  a_Value)
inline

Definition at line 135 of file Packetizer.h.

◆ WriteBEFloat()

void cPacketizer::WriteBEFloat ( float  a_Value)
inline

Definition at line 129 of file Packetizer.h.

◆ WriteBEInt16()

void cPacketizer::WriteBEInt16 ( Int16  a_Value)
inline

Definition at line 93 of file Packetizer.h.

◆ WriteBEInt32()

void cPacketizer::WriteBEInt32 ( Int32  a_Value)
inline

Definition at line 105 of file Packetizer.h.

◆ WriteBEInt64()

void cPacketizer::WriteBEInt64 ( Int64  a_Value)
inline

Definition at line 117 of file Packetizer.h.

◆ WriteBEInt8()

void cPacketizer::WriteBEInt8 ( Int8  a_Value)
inline

Definition at line 87 of file Packetizer.h.

◆ WriteBEUInt16()

void cPacketizer::WriteBEUInt16 ( UInt16  a_Value)
inline

Definition at line 99 of file Packetizer.h.

◆ WriteBEUInt32()

void cPacketizer::WriteBEUInt32 ( UInt32  a_Value)
inline

Definition at line 111 of file Packetizer.h.

◆ WriteBEUInt64()

void cPacketizer::WriteBEUInt64 ( UInt64  a_Value)
inline

Definition at line 123 of file Packetizer.h.

◆ WriteBEUInt8()

void cPacketizer::WriteBEUInt8 ( UInt8  a_Value)
inline

Definition at line 81 of file Packetizer.h.

◆ WriteBool()

void cPacketizer::WriteBool ( bool  a_Value)
inline

Definition at line 76 of file Packetizer.h.

◆ WriteBuf()

void cPacketizer::WriteBuf ( const ContiguousByteBufferView  a_Data)
inline

Definition at line 153 of file Packetizer.h.

◆ WriteByteAngle()

void cPacketizer::WriteByteAngle ( double  a_Angle)

Writes the specified angle using a single byte.

Definition at line 26 of file Packetizer.cpp.

◆ WriteFPInt()

void cPacketizer::WriteFPInt ( double  a_Value)

Writes the double value as a 27:5 fixed-point integer.

Definition at line 35 of file Packetizer.cpp.

◆ WriteString()

void cPacketizer::WriteString ( const AString a_Value)
inline

Definition at line 147 of file Packetizer.h.

◆ WriteUUID()

void cPacketizer::WriteUUID ( const cUUID a_UUID)

Writes the specified UUID as a 128-bit BigEndian integer.

Definition at line 44 of file Packetizer.cpp.

◆ WriteVarInt32()

void cPacketizer::WriteVarInt32 ( UInt32  a_Value)
inline

Definition at line 141 of file Packetizer.h.

◆ WriteXYZPosition64() [1/2]

void cPacketizer::WriteXYZPosition64 ( const Vector3i  a_Position)
inline

Writes the specified block position as a single encoded 64-bit BigEndian integer.

The three coordinates are written in XYZ order.

Definition at line 168 of file Packetizer.h.

◆ WriteXYZPosition64() [2/2]

void cPacketizer::WriteXYZPosition64 ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)
inline

Writes the specified block position as a single encoded 64-bit BigEndian integer.

The three coordinates are written in XYZ order.

Definition at line 161 of file Packetizer.h.

◆ WriteXZYPosition64() [1/2]

void cPacketizer::WriteXZYPosition64 ( const Vector3i  a_Position)
inline

Writes the specified block position as a single encoded 64-bit BigEndian integer.

The three coordinates are written in XZY order, in 1.14+.

Definition at line 182 of file Packetizer.h.

◆ WriteXZYPosition64() [2/2]

void cPacketizer::WriteXZYPosition64 ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)
inline

Writes the specified block position as a single encoded 64-bit BigEndian integer.

The three coordinates are written in XZY order, in 1.14+.

Definition at line 175 of file Packetizer.h.

Member Data Documentation

◆ m_Lock

cCSLock cPacketizer::m_Lock
protected

The RAII lock preventing multithreaded access to the protocol buffer while constructing the packet.

Definition at line 210 of file Packetizer.h.

◆ m_Out

cByteBuffer& cPacketizer::m_Out
protected

The protocol's buffer for the constructed packet data.

Definition at line 207 of file Packetizer.h.

◆ m_PacketType

cProtocol::ePacketType cPacketizer::m_PacketType
protected

Type of the contained packet.

Used for logging purposes, the packet type is encoded into m_Out immediately in constructor.

Definition at line 214 of file Packetizer.h.

◆ m_Protocol

cProtocol& cPacketizer::m_Protocol
protected

The protocol instance in which the packet is being constructed.

Definition at line 204 of file Packetizer.h.


The documentation for this class was generated from the following files: