diff options
Diffstat (limited to '')
-rw-r--r-- | server/packetwriter.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/packetwriter.cpp b/server/packetwriter.cpp new file mode 100644 index 0000000..e1fe700 --- /dev/null +++ b/server/packetwriter.cpp @@ -0,0 +1,28 @@ +#include "packetwriter.h" + +PacketWriter::PacketWriter(int reservedSize) { + m_buffer.reserve(reservedSize); +} + +void PacketWriter::writeU32(quint32 value) { + writeBytes((const quint8 *)(&value), 4); +} + +void PacketWriter::writeBytes(const quint8 *input, int size) { + m_buffer.append((const char *)input, size); +} + +void PacketWriter::writeString(const QString &string) { + writeU32(string.length() * 2); + writeBytes((const quint8 *)string.constData(), string.length() * 2); +} + + +/* +inline void writeU32(quint8 *buf, quint32 value) { + buf[0] = (value & 0xFF); + buf[1] = ((value >> 8) & 0xFF); + buf[2] = ((value >> 16) & 0xFF); + buf[3] = ((value >> 24) & 0xFF); +} +*/ |