summaryrefslogtreecommitdiff
path: root/messages.h
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-07-01 17:40:37 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-07-01 17:40:37 +0200
commit6e746716d6a5c72fbd42539c6d5d92da8830cb9e (patch)
tree44dbe0cdb8f821a75d8ba0a832ceffd150ceb583 /messages.h
parentfbf91c0782c6b9cbf48209714c650cca45e8a836 (diff)
Overload read and write for Vector3.
Diffstat (limited to 'messages.h')
-rw-r--r--messages.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/messages.h b/messages.h
index f1625f8..f388805 100644
--- a/messages.h
+++ b/messages.h
@@ -25,12 +25,22 @@ class MessageBase {
static inline void read(boost::asio::ip::tcp::socket& socket, T& v) {
boost::asio::read(socket, boost::asio::buffer(&v, sizeof(T)));
}
+ static inline void read(boost::asio::ip::tcp::socket& socket, Vector3& pos) {
+ read(socket, pos.x);
+ read(socket, pos.y);
+ read(socket, pos.z);
+ }
static std::string read_string(boost::asio::ip::tcp::socket& socket);
template<typename T>
static inline void write(boost::asio::ip::tcp::socket& socket, T& v) {
boost::asio::write(socket, boost::asio::buffer(&v, sizeof(T)));
}
+ static inline void write(boost::asio::ip::tcp::socket& socket, Vector3& pos) {
+ write(socket, pos.x);
+ write(socket, pos.y);
+ write(socket, pos.z);
+ }
static void write_string(boost::asio::ip::tcp::socket& socket, std::string str);