Commit 143d569b authored by Hubert Denkmair's avatar Hubert Denkmair

implement botitem protocol changes

parent 844db501
......@@ -85,10 +85,13 @@ void MsgPackProtocol::to_json(nlohmann::json &j, const MsgPackProtocol::BotItem
{
j = json {
{"id", item.guid},
{"db_id", item.database_id},
{"name", item.name},
{"segment_radius", item.segment_radius},
{"db_id", item.database_id},
{"face", item.face_id},
{"dog_tag", item.dog_tag_id},
{"color", item.color},
{"mass", item.mass},
{"segment_radius", item.segment_radius},
{"snake_segments", item.segments},
{"heading", 0}
};
......
......@@ -22,6 +22,12 @@ void MsgPackProtocol::pack(msgpack::sbuffer &buf, const Message &msg)
case MESSAGE_TYPE_BOT_MOVE:
msgpack::pack(buf, *static_cast<const BotMoveMessage*>(&msg));
break;
case MESSAGE_TYPE_BOT_MOVE_HEAD:
msgpack::pack(buf, *static_cast<const BotMoveHeadMessage*>(&msg));
break;
case MESSAGE_TYPE_BOT_STATS:
msgpack::pack(buf, *static_cast<const BotStatsMessage*>(&msg));
break;
case MESSAGE_TYPE_BOT_LOG:
msgpack::pack(buf, *static_cast<const BotLogMessage*>(&msg));
break;
......
......@@ -49,10 +49,14 @@ namespace MsgPackProtocol
{
guid_t guid;
std::string name;
int database_id;
uint32_t face_id;
uint32_t dog_tag_id;
std::vector<uint32_t> color;
real_t mass;
real_t segment_radius;
std::vector<SnakeSegmentItem> segments;
std::vector<uint32_t> color;
int database_id;
};
struct BotLogItem
......@@ -718,22 +722,16 @@ namespace msgpack {
{
template <typename Stream> msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, MsgPackProtocol::BotItem const& v) const
{
o.pack_array(6);
o.pack_array(9);
o.pack(v.guid);
o.pack(v.name);
o.pack(v.database_id);
o.pack(v.face_id);
o.pack(v.dog_tag_id);
o.pack(v.color);
o.pack(v.mass);
o.pack(v.segment_radius);
// segments
o.pack(v.segments);
// FIXME: colormap: array of RGB values
o.pack_array(3);
o.pack(0xFF0000);
o.pack(0x00FF00);
o.pack(0x0000FF);
o.pack(v.database_id);
return o;
}
};
......@@ -743,13 +741,16 @@ namespace msgpack {
msgpack::object const& operator()(msgpack::object const& o, MsgPackProtocol::BotItem& v) const
{
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
if (o.via.array.size != 6) throw msgpack::type_error();
if (o.via.array.size != 9) throw msgpack::type_error();
o.via.array.ptr[0] >> v.guid;
o.via.array.ptr[1] >> v.name;
o.via.array.ptr[2] >> v.segment_radius;
o.via.array.ptr[3] >> v.segments;
o.via.array.ptr[4] >> v.color;
o.via.array.ptr[5] >> v.database_id;
o.via.array.ptr[2] >> v.database_id;
o.via.array.ptr[3] >> v.face_id;
o.via.array.ptr[4] >> v.dog_tag_id;
o.via.array.ptr[5] >> v.color;
o.via.array.ptr[6] >> v.mass;
o.via.array.ptr[7] >> v.segment_radius;
o.via.array.ptr[8] >> v.segments;
for (auto &segmentItem: v.segments)
{
segmentItem.bot_id = v.guid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment