summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/net/messagein.cpp18
-rw-r--r--src/net/messagein.h4
-rw-r--r--src/net/messageout.cpp18
-rw-r--r--src/net/messageout.h4
5 files changed, 47 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d0116a45..3b3c2d4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2005-09-14 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/net/messagein.cpp, src/net/messagein.h, src/net/messageout.cpp,
+ src/net/messageout.h: Added stream operators for char, short and long
+ reading and writing.
* src/game.cpp, src/log.cpp, src/main.cpp, src/gui/char_select.cpp,
src/gui/char_server.cpp, src/gui/login.cpp, src/net/messageout.cpp,
src/net/messageout.h, src/net/network.cpp, src/net/network.h,
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 6eb56180..ebf1366f 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -151,3 +151,21 @@ MessageIn::readString(int length)
return readString;
}
+
+char& operator<<(char &lhs, MessageIn &msg)
+{
+ lhs = msg.readByte();
+ return lhs;
+}
+
+short& operator<<(short &lhs, MessageIn &msg)
+{
+ lhs = msg.readShort();
+ return lhs;
+}
+
+long& operator<<(long &lhs, MessageIn &msg)
+{
+ lhs = msg.readLong();
+ return lhs;
+}
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 9a61ce7d..087d325c 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -31,6 +31,10 @@
*/
class MessageIn
{
+ friend char& operator<<(char &lhs, MessageIn &msg);
+ friend short& operator<<(short &lhs, MessageIn &msg);
+ friend long& operator<<(long &lhs, MessageIn &msg);
+
public:
/**
* Constructor.
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 272cac4e..d25cc62b 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -129,3 +129,21 @@ const Packet *MessageOut::getPacket()
return mPacket;
}
+
+MessageOut& operator<<(MessageOut &msg, const char &rhs)
+{
+ msg.writeByte(rhs);
+ return msg;
+}
+
+MessageOut& operator<<(MessageOut &msg, const short &rhs)
+{
+ msg.writeShort(rhs);
+ return msg;
+}
+
+MessageOut& operator<<(MessageOut &msg, const long &rhs)
+{
+ msg.writeLong(rhs);
+ return msg;
+}
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 7cbca165..a312cefe 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -33,6 +33,10 @@ class Packet;
*/
class MessageOut
{
+ friend MessageOut& operator<<(MessageOut &msg, const char &rhs);
+ friend MessageOut& operator<<(MessageOut &msg, const short &rhs);
+ friend MessageOut& operator<<(MessageOut &msg, const long &rhs);
+
public:
/**
* Constructor.