diff options
author | Atle Hellvik Havsø <atle@havso.net> | 2010-11-20 13:35:37 +0100 |
---|---|---|
committer | Atle Hellvik Havsø <atle@havso.net> | 2010-11-20 13:35:37 +0100 |
commit | 93763b9327c6b11016d1b20ea2bb7882f915e33e (patch) | |
tree | 3e49d876c095fcbfea822752b31d0545a802e4da | |
parent | 6caa3da6a2da23fe8cd8e8fdc8074a1022a00163 (diff) |
Made the Player class have a ID (That gets set during a game) which they add to the Action-message. So we can keep track of which player did what action.
Signed-off-by: Atle Hellvik Havsø <atle@havso.net>
-rw-r--r-- | common/action.h | 4 | ||||
-rw-r--r-- | server/player.cpp | 1 | ||||
-rw-r--r-- | server/player.h | 3 |
3 files changed, 8 insertions, 0 deletions
diff --git a/common/action.h b/common/action.h index 21fc7d0..1c07086 100644 --- a/common/action.h +++ b/common/action.h @@ -24,10 +24,14 @@ class Action { //! Target of action (if applicable). int target; + //! Player doing this action + int player; + template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & type; ar & target; + ar & player; } }; diff --git a/server/player.cpp b/server/player.cpp index cb84c9a..72ab99b 100644 --- a/server/player.cpp +++ b/server/player.cpp @@ -56,6 +56,7 @@ void Player::handle_action(Message::p msg) { Message::RoundAction::p action_msg = dynamic_pointer_cast<Message::RoundAction>(msg); + action_msg->action.player = id; action_callback(action_msg->action); } diff --git a/server/player.h b/server/player.h index ce37d0a..27b2757 100644 --- a/server/player.h +++ b/server/player.h @@ -41,6 +41,9 @@ class Player : public boost::enable_shared_from_this<Player> { void handle_action(Message::p msg); public: + //! The ID of the player + int id; + //! Return player's nick. std::string nick(); |