summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 11:15:39 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 11:15:39 +0100
commit4b2dbb4076d0e2844433674329076fedd59f8b96 (patch)
tree2a08f4da8aa9815f4a68398c2b58958bc6b7ec28
parentc55c46cee617e5b3af68bb134f8210221c2ebf8e (diff)
Client::game_start() now take list of nicks, not list of clients. Minor cleanup.
-rw-r--r--server/client.cpp15
-rw-r--r--server/client.h9
2 files changed, 7 insertions, 17 deletions
diff --git a/server/client.cpp b/server/client.cpp
index 533f6ee..465da3b 100644
--- a/server/client.cpp
+++ b/server/client.cpp
@@ -60,7 +60,7 @@ void Client::handle_action(Message::p msg, boost::function<void (Action)> action
if(possible_actions.contains(action_msg->action)) {
action_callback(action_msg->action);
} else {
- action_callback(possible_actions[0]);
+ action_callback(possible_actions.back());
}
}
@@ -68,13 +68,12 @@ std::string Client::nick() {
return nick_;
}
-void Client::game_start(boost::function<void ()> callback, std::vector<Client::p> players) {
+void Client::game_start(boost::function<void ()> callback, std::vector<std::string> players) {
Message::GameStart::p msg = make_shared<Message::GameStart>();
- for(std::vector<Client::p>::iterator i = players.begin(); i != players.end(); i++) {
- msg->players.push_back((*i)->nick());
- }
- msg->player_id = id;
+ msg->players = players;
+
+ msg->player_id = 0;
connection->send(msg);
@@ -96,7 +95,3 @@ void Client::round_end() {
void Client::get_action(boost::function<void (Action)> callback, Actions expected_actions) {
connection->recv(boost::bind(&Client::handle_action, shared_from_this(), _1, callback, expected_actions));
}
-
-void Client::kill_action() {
-
-}
diff --git a/server/client.h b/server/client.h
index ad5df64..ec22e85 100644
--- a/server/client.h
+++ b/server/client.h
@@ -37,14 +37,11 @@ class Client : public boost::enable_shared_from_this<Client> {
void handle_action(Message::p msg, boost::function<void (Action)> action_callback, Actions expected_actions);
public:
- //! The ID of the client
- int id;
-
//! Return client's nick.
std::string nick();
//! Notify client of a game start.
- void game_start(boost::function<void ()> callback, std::vector<Client::p> players);
+ void game_start(boost::function<void ()> callback, std::vector<std::string> players);
//! Notify client of a round start.
void round_start();
@@ -55,10 +52,8 @@ class Client : public boost::enable_shared_from_this<Client> {
//! Send round end.
void round_end();
- //! Get action.
+ //! Get action. Upon connection error, last element of expected_actions will be provided.
void get_action(boost::function<void (Action)> callback, Actions expected_actions);
-
- void kill_action();
};
typedef std::vector<Client> Clients;