summaryrefslogtreecommitdiff
path: root/server/packetwriter.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-12-25 09:00:59 +0100
committerTreeki <treeki@gmail.com>2013-12-25 09:00:59 +0100
commitb7a8b597b00eedde277836eb8530ba742edcad5d (patch)
tree1b959fa0eec02ff4e22e168aa4379b2b64575ce3 /server/packetwriter.cpp
downloadbounce_qt-b7a8b597b00eedde277836eb8530ba742edcad5d.tar.gz
bounce_qt-b7a8b597b00eedde277836eb8530ba742edcad5d.zip
commit initial bitsHEADmaster
Diffstat (limited to '')
-rw-r--r--server/packetwriter.cpp28
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);
+}
+*/