summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/client.cpp7
-rw-r--r--server/client.h2
-rw-r--r--server/game.cpp10
3 files changed, 13 insertions, 6 deletions
diff --git a/server/client.cpp b/server/client.cpp
index 3977b53..af2c55d 100644
--- a/server/client.cpp
+++ b/server/client.cpp
@@ -88,8 +88,13 @@ void Client::round_state(const PlayerState& pl_d, const PlayerState& pl_r, const
connection->send(make_shared<Message::RoundState>(pl_d, pl_r, pl_u, pl_l, d, a));
}
-void Client::round_end() {
+void Client::round_end(boost::function<void ()> callback) {
connection->send(make_shared<Message::RoundEnd>());
+
+ // Check if we're waiting for ready.
+ if(callback) {
+ connection->recv(boost::bind(&Client::handle_ready, shared_from_this(), _1, callback));
+ }
}
void Client::get_action(boost::function<void (Action)> callback, Actions expected_actions) {
diff --git a/server/client.h b/server/client.h
index b8e11c2..4ba36d7 100644
--- a/server/client.h
+++ b/server/client.h
@@ -52,7 +52,7 @@ class Client : public boost::enable_shared_from_this<Client> {
void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a);
//! Send round end.
- void round_end();
+ void round_end(boost::function<void ()> callback);
//! Get action. Upon connection error, last element of expected_actions will be provided.
void get_action(boost::function<void (Action)> callback, Actions expected_actions);
diff --git a/server/game.cpp b/server/game.cpp
index 407df34..f4d5dec 100644
--- a/server/game.cpp
+++ b/server/game.cpp
@@ -297,10 +297,12 @@ void Game::handle_action_discard(Action action, int player) {
}
void Game::round_end() {
- players[0].client->round_end();
- players[1].client->round_end();
- players[2].client->round_end();
- players[3].client->round_end();
+ awaiting_players = 4;
+
+ players[0].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
+ players[1].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
+ players[2].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
+ players[3].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
// Flere runder? round_start()
// Ferdig? game_end()