diff options
Diffstat (limited to 'src/network/core/packet.cpp')
-rw-r--r-- | src/network/core/packet.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 28d6ea377..e5f4493ed 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -80,8 +80,16 @@ void Packet::PrepareToSend(void) * sent first. * * So 0x01234567 would be sent as 67 45 23 01. + * + * A bool is sent as a uint8 where zero means false + * and non-zero means true. */ +void Packet::Send_bool(bool data) +{ + this->Send_uint8(data ? 1 : 0); +} + void Packet::Send_uint8(uint8 data) { assert(this->size < sizeof(this->buffer) - sizeof(data)); @@ -133,7 +141,7 @@ void Packet::Send_string(const char* data) /** * Receiving commands * Again, the next couple of functions are endian-safe - * see the comment before NetworkSend_uint8 for more info. + * see the comment before Send_bool for more info. */ @@ -173,6 +181,11 @@ void Packet::PrepareToRead(void) this->pos = sizeof(PacketSize); } +bool Packet::Recv_bool(void) +{ + return this->Recv_uint8() != 0; +} + uint8 Packet::Recv_uint8(void) { uint8 n; |