diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-06-13 13:17:50 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-06-13 13:17:50 +0200 |
commit | ff7f9de199213ea6d4832c0b91f2a96f5edc6bb2 (patch) | |
tree | c427e6c2b677ff8b2e81b53132d4c7434b359350 | |
parent | ed2a562372f15a0bf0f60ac47f89fa11d331776e (diff) |
Added id (uint32_t) to message::Pos.
-rw-r--r-- | messages.cpp | 14 | ||||
-rw-r--r-- | messages.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/messages.cpp b/messages.cpp index b7b7b38..ff4a6db 100644 --- a/messages.cpp +++ b/messages.cpp @@ -75,21 +75,35 @@ Pos::Pos() { Pos::Pos(Vector3 pos) { type = MSG_TYPE_POS; + this->id = 0; + this->pos = pos; +} + +Pos::Pos(uint32_t id, Vector3 pos) { + type = MSG_TYPE_POS; + + this->id = id; this->pos = pos; } void Pos::do_send(boost::asio::ip::tcp::socket& socket) { + write(socket, id); write(socket, pos.x); write(socket, pos.y); write(socket, pos.z); } void Pos::recv(boost::asio::ip::tcp::socket& socket) { + read(socket, id); read(socket, pos.x); read(socket, pos.y); read(socket, pos.z); } +uint32_t Pos::get_id() { + return id; +} + Vector3 Pos::get_pos() { return pos; } @@ -64,6 +64,7 @@ class Hello : public MessageBase { class Pos : public MessageBase { protected: + uint32_t id; Vector3 pos; virtual void do_send(boost::asio::ip::tcp::socket& socket); @@ -71,9 +72,11 @@ class Pos : public MessageBase { public: Pos(); Pos(Vector3 pos); + Pos(uint32_t id, Vector3 pos); virtual void recv(boost::asio::ip::tcp::socket& socket); + uint32_t get_id(); Vector3 get_pos(); }; |