Commit d964bcb6 authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

cleanup

parent 8259ad8b
......@@ -2,7 +2,6 @@
#include <cstdint>
#include <vector>
#include <msgpack.hpp>
#include "types.h"
......@@ -149,9 +148,9 @@ namespace msgpack {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
auto& a = o.via.array;
if (a.size != 5) throw msgpack::type_error();
v.world_size_x = a.ptr[2].via.f64;
v.world_size_y = a.ptr[3].via.f64;
v.food_decay_per_frame = a.ptr[4].via.f64;
a.ptr[2].convert(v.world_size_x);
a.ptr[3].convert(v.world_size_y);
a.ptr[4].convert(v.food_decay_per_frame);
return o;
}
};
......@@ -274,10 +273,10 @@ namespace msgpack {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
auto& a = o.via.array;
if (a.size != 4) throw msgpack::type_error();
v.bot_id = a.ptr[0].via.u64;
a.ptr[0].convert(v.bot_id);
a.ptr[1].convert(v.new_segments);
v.current_length = a.ptr[2].via.u64;
v.current_segment_radius = a.ptr[3].via.f64;
a.ptr[2].convert(v.current_length);
a.ptr[3].convert(v.current_segment_radius);
return o;
}
};
......@@ -302,8 +301,8 @@ namespace msgpack {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
auto& a = o.via.array;
if (a.size != 4) throw msgpack::type_error();
v.killer_id = a.ptr[2].via.u64;
v.victim_id = a.ptr[3].via.u64;
a.ptr[2].convert(v.killer_id);
a.ptr[3].convert(v.victim_id);
return o;
}
};
......@@ -374,8 +373,8 @@ namespace msgpack {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
auto& a = o.via.array;
if (a.size != 2) throw msgpack::type_error();
v.food_id = a.ptr[0].via.u64;
v.bot_id = a.ptr[1].via.u64;
a.ptr[0].convert(v.food_id);
a.ptr[1].convert(v.bot_id);
return o;
}
};
......@@ -450,12 +449,12 @@ namespace msgpack {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
auto &a = o.via.array;
if (a.size != 4) throw msgpack::type_error();
v.guid = a.ptr[0].via.u64;
a.ptr[0].convert(v.guid);
v.position = {
a.ptr[1].via.f64,
a.ptr[2].via.f64,
};
v.value = a.ptr[3].via.f64;
a.ptr[3].convert(v.value);
return o;
}
};
......@@ -490,15 +489,15 @@ namespace msgpack {
auto& a = o.via.array;
if (a.size != 5) throw msgpack::type_error();
v.guid = a.ptr[0].via.u64;
a.ptr[0].convert(v.guid);
a.ptr[1].convert(v.name);
v.segment_radius = a.ptr[2].via.f64;
a.ptr[2].convert(v.segment_radius);
a.ptr[3].convert(v.segments);
a.ptr[4].convert(v.color);
for (auto &segmentItem: v.segments)
{
segmentItem.bot_id = v.guid;
}
a.ptr[4].convert(v.color);
return o;
}
};
......
Supports Markdown
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