From 4b2dbb4076d0e2844433674329076fedd59f8b96 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 25 Nov 2010 11:15:39 +0100 Subject: Client::game_start() now take list of nicks, not list of clients. Minor cleanup. --- server/client.cpp | 15 +++++---------- server/client.h | 9 ++------- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'server') 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 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 callback, std::vector players) { +void Client::game_start(boost::function callback, std::vector players) { Message::GameStart::p msg = make_shared(); - for(std::vector::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 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 { void handle_action(Message::p msg, boost::function 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 callback, std::vector players); + void game_start(boost::function callback, std::vector players); //! Notify client of a round start. void round_start(); @@ -55,10 +52,8 @@ class Client : public boost::enable_shared_from_this { //! 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 callback, Actions expected_actions); - - void kill_action(); }; typedef std::vector Clients; -- cgit v1.2.3