diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-02 02:13:49 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-02 02:13:49 +0100 |
commit | fdd3d58c92fc924c31c3acad69dcb3d0dac06ac0 (patch) | |
tree | fedc2b0ca0f46ab0df97c3b42a11189396ac3b21 | |
parent | 088b544805f90515d626b1e140060f7666c94910 (diff) |
Send current_player with RoundState.
-rw-r--r-- | common/message.h | 5 | ||||
-rw-r--r-- | server/client.cpp | 6 | ||||
-rw-r--r-- | server/client.h | 6 | ||||
-rw-r--r-- | server/game.cpp | 4 |
4 files changed, 11 insertions, 10 deletions
diff --git a/common/message.h b/common/message.h index 1d78889..0051e03 100644 --- a/common/message.h +++ b/common/message.h @@ -175,8 +175,8 @@ namespace Message { }; RoundState() : Base(Types::RoundState) {} - RoundState(const Player& pl_d, const Player& pl_r, const Player& pl_u, const Player& pl_l, const Tiles& d, const Actions& a) - : Base(Types::RoundState), dora(d), possible_actions(a) { + RoundState(const Player& pl_d, const Player& pl_r, const Player& pl_u, const Player& pl_l, const Tiles& d, const Actions& a, int p) + : Base(Types::RoundState), dora(d), possible_actions(a), current_player(p) { players[0] = pl_d; players[1] = pl_r; players[2] = pl_u; @@ -200,6 +200,7 @@ namespace Message { ar & players; ar & dora; ar & possible_actions; + ar & current_player; } }; diff --git a/server/client.cpp b/server/client.cpp index 95f7e1d..1fbef6d 100644 --- a/server/client.cpp +++ b/server/client.cpp @@ -104,8 +104,8 @@ void Client::round_start() { connection->send(make_shared<Message::RoundStart>()); } -void Client::round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a) { - connection->send(make_shared<Message::RoundState>(pl_d, pl_r, pl_u, pl_l, d, a)); +void Client::round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a, int p) { + connection->send(make_shared<Message::RoundState>(pl_d, pl_r, pl_u, pl_l, d, a, p)); } void Client::round_end(boost::function<void ()> callback) { @@ -133,7 +133,7 @@ void ClientDumb::round_start() { } -void ClientDumb::round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a) { +void ClientDumb::round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a, int p) { } diff --git a/server/client.h b/server/client.h index 91fd4b6..add78f0 100644 --- a/server/client.h +++ b/server/client.h @@ -28,7 +28,7 @@ class ClientBase { typedef Message::RoundState::Player PlayerState; //! Send round state. - virtual 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) = 0; + virtual 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, int p) = 0; //! Send round end. virtual void round_end(boost::function<void ()> callback) = 0; @@ -83,7 +83,7 @@ class Client : public ClientBase, public boost::enable_shared_from_this<Client> virtual void round_start(); //! Send round state. - virtual 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); + virtual 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, int p); //! Send round end. virtual void round_end(boost::function<void ()> callback); @@ -102,7 +102,7 @@ class ClientDumb : public ClientBase { virtual void round_start(); - virtual 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); + virtual 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, int p); virtual void round_end(boost::function<void ()> callback); diff --git a/server/game.cpp b/server/game.cpp index 2e96578..628a966 100644 --- a/server/game.cpp +++ b/server/game.cpp @@ -128,7 +128,7 @@ void Game::round_update_draw() { a = possible_actions; } - players[player].client->round_state(state[0], state[1], state[2], state[3], dora, a); + players[player].client->round_state(state[0], state[1], state[2], state[3], dora, a, current_player - player); } while(++player); // Await action from client. @@ -157,7 +157,7 @@ void Game::round_update_discard() { } } - players[player].client->round_state(state[0], state[1], state[2], state[3], dora, a); + players[player].client->round_state(state[0], state[1], state[2], state[3], dora, a, current_player - player); } while(++player); preceding_action = Action::Pass; |