Commit 19bb6c71 authored by Thomas Kolb's avatar Thomas Kolb
Browse files

Added movement parameters to GameInfo

parent 7d9a683c
......@@ -40,6 +40,11 @@ namespace MsgPackProtocol
double world_size_x = 0;
double world_size_y = 0;
double food_decay_per_frame = 0;
double snake_distance_per_step = 0;
double snake_segment_distance_factor = 0;
double snake_segment_distance_exponent = 0;
double snake_pull_factor = 0;
};
struct PlayerInfoMessage
......@@ -150,12 +155,16 @@ namespace msgpack {
{
template <typename Stream> msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, MsgPackProtocol::GameInfoMessage const& v) const
{
o.pack_array(5);
o.pack_array(9);
o.pack(MsgPackProtocol::PROTOCOL_VERSION);
o.pack(static_cast<int>(MsgPackProtocol::MESSAGE_TYPE_GAME_INFO));
o.pack(v.world_size_x);
o.pack(v.world_size_y);
o.pack(v.food_decay_per_frame);
o.pack(v.snake_distance_per_step);
o.pack(v.snake_segment_distance_factor);
o.pack(v.snake_segment_distance_exponent);
o.pack(v.snake_pull_factor);
return o;
}
};
......
......@@ -106,10 +106,15 @@ void MsgPackUpdateTracker::gameInfo(void)
{
MsgPackProtocol::GameInfoMessage msg;
msg.world_size_x = config::FIELD_SIZE_X;
msg.world_size_y = config::FIELD_SIZE_Y;
msg.world_size_x = config::FIELD_SIZE_X;
msg.world_size_y = config::FIELD_SIZE_Y;
msg.food_decay_per_frame = config::FOOD_DECAY_STEP;
msg.snake_distance_per_step = config::SNAKE_DISTANCE_PER_STEP;
msg.snake_segment_distance_factor = config::SNAKE_SEGMENT_DISTANCE_FACTOR;
msg.snake_segment_distance_exponent = config::SNAKE_SEGMENT_DISTANCE_EXPONENT;
msg.snake_pull_factor = config::SNAKE_PULL_FACTOR;
msgpack::sbuffer buf;
msgpack::pack(buf, msg);
appendMessage(buf);
......
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