Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jochen Bauer
spn-relayserver
Commits
9751aea6
Commit
9751aea6
authored
May 07, 2018
by
Hubert Denkmair
Browse files
fix Tick message, save stats message
parent
c2c6743c
Changes
2
Hide whitespace changes
Inline
Side-by-side
relayserver/TcpProtocol.cpp
View file @
9751aea6
...
...
@@ -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
));
}
...
...
relayserver/TcpProtocol.h
View file @
9751aea6
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment