diff options
author | rubidium <rubidium@openttd.org> | 2007-02-02 23:16:58 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-02-02 23:16:58 +0000 |
commit | 2f249e650b05238cc4248640c2d8de83a3f77d19 (patch) | |
tree | ece046363ec9db44c4f305a66b7863bd5113cfb2 /src/network/core/packet.cpp | |
parent | e50cc1ae49f2b7f9ec82ed0dbcf951fa6368a6c3 (diff) | |
download | openttd-2f249e650b05238cc4248640c2d8de83a3f77d19.tar.xz |
(svn r8546) -Codechange: add a seperate (wrapper) functions to send/receive booleans.
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; |