summaryrefslogtreecommitdiff
path: root/src/network/core/packet.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-02 23:16:58 +0000
committerrubidium <rubidium@openttd.org>2007-02-02 23:16:58 +0000
commit500f9a971ac2d1a723fceaf499117de85396ff65 (patch)
treeece046363ec9db44c4f305a66b7863bd5113cfb2 /src/network/core/packet.cpp
parent9ddd227eb3757473bce23b4cafec894a4e4eaa36 (diff)
downloadopenttd-500f9a971ac2d1a723fceaf499117de85396ff65.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.cpp15
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;