From ff7f9de199213ea6d4832c0b91f2a96f5edc6bb2 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 13 Jun 2011 13:17:50 +0200 Subject: Added id (uint32_t) to message::Pos. --- messages.cpp | 14 ++++++++++++++ messages.h | 3 +++ 2 files changed, 17 insertions(+) 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; } diff --git a/messages.h b/messages.h index 62f5a03..743914e 100644 --- a/messages.h +++ b/messages.h @@ -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(); }; -- cgit v1.2.3