Commit 9751aea6 authored by Hubert Denkmair's avatar Hubert Denkmair

fix Tick message, save stats message

parent c2c6743c
......@@ -95,8 +95,11 @@ void TcpProtocol::OnMessageReceived(const char* data, size_t count)
break;
case MsgPackProtocol::MESSAGE_TYPE_TICK:
OnTickReceived(obj.get().as<MsgPackProtocol::TickMessage>());
{
auto msg = std::make_unique<MsgPackProtocol::TickMessage>();
OnTickReceived(std::move(msg));
break;
}
case MsgPackProtocol::MESSAGE_TYPE_BOT_SPAWN:
OnBotSpawnReceived(obj.get().as<MsgPackProtocol::BotSpawnMessage>());
......@@ -172,9 +175,11 @@ void TcpProtocol::OnWorldUpdateReceived(const MsgPackProtocol::WorldUpdateMessag
}
}
void TcpProtocol::OnTickReceived(const MsgPackProtocol::TickMessage &msg)
void TcpProtocol::OnTickReceived(std::unique_ptr<MsgPackProtocol::TickMessage> msg)
{
_frameCompleteCallback(msg.frame_id);
auto frame_id = msg->frame_id;
_pendingMessages.push_back(std::move(msg));
_frameCompleteCallback(frame_id);
_pendingMessages.clear();
}
......@@ -246,6 +251,7 @@ void TcpProtocol::OnBotLogReceived(std::unique_ptr<MsgPackProtocol::BotLogMessag
void TcpProtocol::OnBotStatsReceived(std::unique_ptr<MsgPackProtocol::BotStatsMessage> msg)
{
_botStats = *msg;
_pendingMessages.push_back(std::move(msg));
}
......
......@@ -37,6 +37,7 @@ class TcpProtocol
FrameCompleteCallback _frameCompleteCallback;
MsgPackProtocol::GameInfoMessage _gameInfo;
MsgPackProtocol::BotStatsMessage _botStats;
std::map<guid_t,FoodItem> _foodMap;
std::map<guid_t,BotItem> _botsMap;
std::vector<std::unique_ptr<MsgPackProtocol::Message>> _pendingMessages;
......@@ -47,7 +48,7 @@ class TcpProtocol
void OnGameInfoReceived(const MsgPackProtocol::GameInfoMessage& msg);
void OnWorldUpdateReceived(const MsgPackProtocol::WorldUpdateMessage& msg);
void OnTickReceived(const MsgPackProtocol::TickMessage& msg);
void OnTickReceived(std::unique_ptr<MsgPackProtocol::TickMessage> msg);
void OnFoodSpawnReceived(const MsgPackProtocol::FoodSpawnMessage& msg);
void OnFoodConsumedReceived(const MsgPackProtocol::FoodConsumeMessage& msg);
......
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