#include <game.hpp>
Public Member Functions | |
game (player_map &players, const network::connection host=0, const std::string name="") | |
~game () | |
int | id () const |
const std::string & | name () const |
bool | is_owner (const network::connection player) const |
bool | is_member (const network::connection player) const |
bool | allow_observers () const |
bool | is_observer (const network::connection player) const |
bool | is_player (const network::connection player) const |
bool | player_is_banned (const network::connection player) const |
bool | level_init () const |
bool | started () const |
size_t | nplayers () const |
size_t | nobservers () const |
size_t | current_turn () const |
void | mute_all_observers () |
void | mute_observer (const simple_wml::node &mute, const player_map::const_iterator muter) |
Mute an observer by name. | |
network::connection | kick_member (const simple_wml::node &kick, const player_map::const_iterator kicker) |
Kick a member by name. | |
network::connection | ban_user (const simple_wml::node &ban, const player_map::const_iterator banner) |
Ban and kick a user by name. He doesn't need to be in this game. | |
void | add_player (const network::connection player, bool observer=false) |
bool | remove_player (const network::connection player, const bool disconnect=false) |
const user_vector | all_game_users () const |
Adds players and observers into one vector and returns that. | |
void | add_players (const game &other_game, const bool observer=true) |
Adds players from one game to another. | |
void | start_game (const player_map::const_iterator starter) |
void | load_next_scenario (const player_map::const_iterator user) const |
A user (player only?) asks for the next scenario to advance to. | |
void | update_side_data () |
Resets the side configuration according to the scenario data. | |
void | transfer_side_control (const network::connection sock, const simple_wml::node &cfg) |
Let's a player owning a side give it to another player or observer. | |
void | process_message (simple_wml::document &data, const player_map::iterator user) |
bool | process_turn (simple_wml::document &data, const player_map::const_iterator user) |
Filters and processes (some) commands. | |
bool | describe_slots () |
Set the description to the number of available slots. | |
void | send_server_message_to_all (const char *message, network::connection exclude=0) const |
void | send_server_message (const char *message, network::connection sock=0, simple_wml::document *doc=NULL) const |
void | send_and_record_server_message (const char *message, const network::connection exclude=0) |
Send data to all players in this game except 'exclude'. | |
void | send_data (simple_wml::document &data, const network::connection exclude=0) const |
void | send_to_one (simple_wml::document &data, const network::connection sock) const |
void | record_data (simple_wml::document *data) |
simple_wml::document & | level () |
The full scenario data. | |
void | set_description (simple_wml::node *desc) |
Functions to set/get the address of the game's summary description as sent to players in the lobby. | |
simple_wml::node * | description () const |
void | set_password (const std::string &passwd) |
bool | password_matches (const std::string &passwd) const |
const std::string & | termination_reason () const |
void | set_termination_reason (const std::string &reason) |
Private Member Functions | |
game (const game &) | |
void | operator= (const game &) |
size_t | current_side () const |
network::connection | current_player () const |
bool | is_current_player (const network::connection player) const |
bool | is_muted_observer (const network::connection player) const |
bool | all_observers_muted () const |
bool | take_side (const player_map::const_iterator user) |
Figures out which side to take and tells that side to the game owner. | |
void | send_change_controller (const size_t side_num, const player_map::const_iterator newplayer, const bool player_left=true) |
Send [change_controller] message to tell all clients the new controller's name. | |
void | transfer_ai_sides () |
void | send_data_team (simple_wml::document &data, const simple_wml::string_span &team, const network::connection exclude=0) const |
void | send_data_observers (simple_wml::document &data, const network::connection exclude=0) const |
void | send_observerjoins (const network::connection sock=0) const |
Send [observer] tags of all the observers in the game to the user or everyone if none given. | |
void | send_observerquit (const player_map::const_iterator observer) const |
void | send_history (const network::connection sock) const |
void | notify_new_host () |
In case of a host transfer, notify the new host about its status. | |
player_map::const_iterator | find_user (const simple_wml::string_span &name) const |
Convenience function for finding a user by name. | |
bool | observers_can_label () const |
bool | observers_can_chat () const |
bool | is_legal_command (const simple_wml::node &command, bool is_player) |
bool | is_on_team (const simple_wml::string_span &team, const network::connection player) const |
Function which returns true iff 'player' is on 'team'. | |
bool | end_turn () |
Function which should be called every time a player ends their turn (i.e. | |
void | send_user_list (const network::connection exclude=0) const |
Function to send a list of users to all clients. | |
std::string | debug_player_info () const |
Helps debugging player and observer lists. | |
Private Attributes | |
player_map * | player_info_ |
int | id_ |
std::string | name_ |
The name of the game. | |
std::string | password_ |
network::connection | owner_ |
The game host or later owner (if the host left). | |
user_vector | players_ |
A vector of players (members owning a side). | |
user_vector | observers_ |
A vector of observers (members not owning a side). | |
user_vector | muted_observers_ |
side_vector | sides_ |
A vector of side owners. | |
std::vector< bool > | sides_taken_ |
A vector indicating what sides are actually taken. (Really needed?). | |
std::vector< std::string > | side_controllers_ |
A vector of controller strings indicating the type. | |
int | nsides_ |
Number of sides in the current scenario. | |
bool | started_ |
simple_wml::document | level_ |
The current scenario data. | |
std::vector < simple_wml::document * > | history_ |
Replay data. | |
simple_wml::node * | description_ |
Pointer to the game's description in the games_and_users_list_. | |
int | end_turn_ |
bool | all_observers_muted_ |
std::vector< std::string > | bans_ |
std::string | termination_ |
Static Private Attributes | |
static int | id_num = 1 |
Definition at line 32 of file game.hpp.
game::game | ( | player_map & | players, | |
const network::connection | host = 0 , |
|||
const std::string | name = "" | |||
) |
game::~game | ( | ) |
game::game | ( | const game & | ) | [private] |
int game::id | ( | ) | const [inline] |
Definition at line 38 of file game.hpp.
References id_.
Referenced by game_id_matches::operator()(), and server::process_data_game().
const std::string& game::name | ( | ) | const [inline] |
Definition at line 39 of file game.hpp.
References name_.
Referenced by ban_user(), kick_member(), mute_observer(), and server::process_data_game().
bool game::is_owner | ( | const network::connection | player | ) | const [inline] |
Definition at line 41 of file game.hpp.
References owner_.
Referenced by server::process_data_game().
bool game::is_member | ( | const network::connection | player | ) | const [inline] |
Definition at line 42 of file game.hpp.
References is_observer(), and is_player().
Referenced by add_player(), ban_user(), kick_member(), remove_player(), server::run(), and transfer_side_control().
bool game::allow_observers | ( | ) | const |
Referenced by add_player().
bool game::is_observer | ( | const network::connection | player | ) | const |
Referenced by is_member(), is_muted_observer(), mute_observer(), server::process_data(), remove_player(), server::run(), and transfer_side_control().
bool game::is_player | ( | const network::connection | player | ) | const |
Referenced by is_member(), server::process_data_game(), process_turn(), remove_player(), and transfer_side_control().
bool game::player_is_banned | ( | const network::connection | player | ) | const |
Referenced by ban_user().
bool game::level_init | ( | ) | const [inline] |
Definition at line 48 of file game.hpp.
References simple_wml::document::child(), and level_.
Referenced by server::process_data_game().
bool game::started | ( | ) | const [inline] |
Definition at line 49 of file game.hpp.
References started_.
Referenced by server::process_data_game().
size_t game::nplayers | ( | ) | const [inline] |
Definition at line 51 of file game.hpp.
References players_.
Referenced by server::process_data_game().
size_t game::nobservers | ( | ) | const [inline] |
Definition at line 52 of file game.hpp.
References observers_.
Referenced by server::dump_stats(), and server::process_command().
size_t game::current_turn | ( | ) | const [inline] |
Definition at line 53 of file game.hpp.
References end_turn_, and nsides_.
Referenced by end_turn(), server::process_data_game(), and remove_player().
void game::mute_all_observers | ( | ) |
Referenced by server::process_data_game().
void game::mute_observer | ( | const simple_wml::node & | mute, | |
const player_map::const_iterator | muter | |||
) |
network::connection game::kick_member | ( | const simple_wml::node & | kick, | |
const player_map::const_iterator | kicker | |||
) |
network::connection game::ban_user | ( | const simple_wml::node & | ban, | |
const player_map::const_iterator | banner | |||
) |
Ban and kick a user by name. He doesn't need to be in this game.
Referenced by server::process_data_game().
void game::add_player | ( | const network::connection | player, | |
bool | observer = false | |||
) |
Referenced by server::process_data_game(), server::process_login(), and server::run().
bool game::remove_player | ( | const network::connection | player, | |
const bool | disconnect = false | |||
) |
Referenced by ban_user(), kick_member(), server::process_data_game(), server::process_data_lobby(), server::process_login(), and server::run().
const user_vector game::all_game_users | ( | ) | const |
Adds players and observers into one vector and returns that.
Referenced by add_players(), send_data(), send_user_list(), and update_side_data().
void game::add_players | ( | const game & | other_game, | |
const bool | observer = true | |||
) |
Adds players from one game to another.
This is used to add players and observers from a game to the lobby (which is also implemented as a game), if that game ends. The second parameter controls, wether the players are added to the players_ or observers_ vector (default observers_).
Referenced by server::delete_game().
void game::start_game | ( | const player_map::const_iterator | starter | ) |
Referenced by add_player(), and server::process_data_game().
void game::load_next_scenario | ( | const player_map::const_iterator | user | ) | const |
A user (player only?) asks for the next scenario to advance to.
Referenced by server::process_data_game().
void game::update_side_data | ( | ) |
Resets the side configuration according to the scenario data.
Referenced by server::process_data_game(), and start_game().
void game::transfer_side_control | ( | const network::connection | sock, | |
const simple_wml::node & | cfg | |||
) |
Let's a player owning a side give it to another player or observer.
Referenced by server::process_data_game().
void game::process_message | ( | simple_wml::document & | data, | |
const player_map::iterator | user | |||
) |
Referenced by server::process_data_game(), and server::process_data_lobby().
bool game::process_turn | ( | simple_wml::document & | data, | |
const player_map::const_iterator | user | |||
) |
Filters and processes (some) commands.
Returns true iff the turn ended.
Referenced by server::process_data_game().
bool game::describe_slots | ( | ) |
Set the description to the number of available slots.
Returns true iff the number of slots has changed.
Referenced by server::process_data_game().
void game::send_server_message_to_all | ( | const char * | message, | |
network::connection | exclude = 0 | |||
) | const |
Referenced by load_next_scenario(), server::process_command(), server::process_data_game(), and remove_player().
void game::send_server_message | ( | const char * | message, | |
network::connection | sock = 0 , |
|||
simple_wml::document * | doc = NULL | |||
) | const |
Referenced by add_player(), ban_user(), kick_member(), mute_observer(), server::process_data_game(), server::process_data_lobby(), server::process_login(), process_message(), server::process_query(), process_turn(), send_and_record_server_message(), send_server_message_to_all(), and transfer_side_control().
void game::send_and_record_server_message | ( | const char * | message, | |
const network::connection | exclude = 0 | |||
) |
Send data to all players in this game except 'exclude'.
Referenced by ban_user(), kick_member(), mute_all_observers(), mute_observer(), notify_new_host(), process_turn(), remove_player(), send_change_controller(), transfer_ai_sides(), and transfer_side_control().
void game::send_data | ( | simple_wml::document & | data, | |
const network::connection | exclude = 0 | |||
) | const |
Referenced by add_player(), server::delete_game(), server::process_data_game(), server::process_data_lobby(), server::process_login(), process_message(), process_turn(), server::run(), send_and_record_server_message(), send_change_controller(), send_observerjoins(), send_observerquit(), send_server_message_to_all(), send_user_list(), start_game(), transfer_side_control(), and server::update_game_in_lobby().
void game::send_to_one | ( | simple_wml::document & | data, | |
const network::connection | sock | |||
) | const |
Referenced by remove_player(), send_change_controller(), and send_server_message().
void game::record_data | ( | simple_wml::document * | data | ) |
Referenced by process_turn(), and send_and_record_server_message().
simple_wml::document& game::level | ( | ) | [inline] |
The full scenario data.
Definition at line 102 of file game.hpp.
References level_.
Referenced by server::process_data_game(), and server::process_data_lobby().
void game::set_description | ( | simple_wml::node * | desc | ) |
Functions to set/get the address of the game's summary description as sent to players in the lobby.
Referenced by server::process_data_game().
simple_wml::node* game::description | ( | ) | const [inline] |
Definition at line 107 of file game.hpp.
References description_.
Referenced by server::process_data_game(), and server::update_game_in_lobby().
void game::set_password | ( | const std::string & | passwd | ) | [inline] |
Definition at line 109 of file game.hpp.
References password_.
Referenced by server::process_data_lobby().
bool game::password_matches | ( | const std::string & | passwd | ) | const [inline] |
const std::string& game::termination_reason | ( | ) | const [inline] |
Definition at line 114 of file game.hpp.
References started_, and termination_.
Referenced by server::process_data_game(), and remove_player().
void game::set_termination_reason | ( | const std::string & | reason | ) |
Referenced by server::process_data_game().
void game::operator= | ( | const game & | ) | [private] |
size_t game::current_side | ( | ) | const [inline, private] |
Definition at line 127 of file game.hpp.
References end_turn_, and nsides_.
Referenced by current_player(), end_turn(), and process_turn().
network::connection game::current_player | ( | ) | const [inline, private] |
Definition at line 128 of file game.hpp.
References current_side(), nsides_, and sides_.
Referenced by is_current_player(), and process_turn().
bool game::is_current_player | ( | const network::connection | player | ) | const [inline, private] |
bool game::is_muted_observer | ( | const network::connection | player | ) | const [private] |
Referenced by mute_observer(), and process_turn().
bool game::all_observers_muted | ( | ) | const [inline, private] |
bool game::take_side | ( | const player_map::const_iterator | user | ) | [private] |
void game::send_change_controller | ( | const size_t | side_num, | |
const player_map::const_iterator | newplayer, | |||
const bool | player_left = true | |||
) | [private] |
Send [change_controller] message to tell all clients the new controller's name.
Referenced by remove_player(), and transfer_side_control().
void game::transfer_ai_sides | ( | ) | [private] |
Referenced by remove_player(), and transfer_side_control().
void game::send_data_team | ( | simple_wml::document & | data, | |
const simple_wml::string_span & | team, | |||
const network::connection | exclude = 0 | |||
) | const [private] |
Referenced by process_turn().
void game::send_data_observers | ( | simple_wml::document & | data, | |
const network::connection | exclude = 0 | |||
) | const [private] |
Referenced by process_turn().
void game::send_observerjoins | ( | const network::connection | sock = 0 |
) | const [private] |
Send [observer] tags of all the observers in the game to the user or everyone if none given.
Referenced by add_player(), load_next_scenario(), and start_game().
void game::send_observerquit | ( | const player_map::const_iterator | observer | ) | const [private] |
Referenced by remove_player(), and transfer_side_control().
void game::send_history | ( | const network::connection | sock | ) | const [private] |
Referenced by add_player(), and load_next_scenario().
void game::notify_new_host | ( | ) | [private] |
player_map::const_iterator game::find_user | ( | const simple_wml::string_span & | name | ) | const [private] |
Convenience function for finding a user by name.
Referenced by ban_user(), kick_member(), and mute_observer().
bool game::is_legal_command | ( | const simple_wml::node & | command, | |
bool | is_player | |||
) | [private] |
Referenced by process_turn().
bool game::is_on_team | ( | const simple_wml::string_span & | team, | |
const network::connection | player | |||
) | const [private] |
Function which returns true iff 'player' is on 'team'.
Referenced by process_turn(), and send_data_team().
bool game::end_turn | ( | ) | [private] |
Function which should be called every time a player ends their turn (i.e.
[end_turn] received). This will update the 'turn' attribute for the game's description when appropriate. Will return true iff there has been a change.
Referenced by process_turn(), and start_game().
void game::send_user_list | ( | const network::connection | exclude = 0 |
) | const [private] |
Function to send a list of users to all clients.
Only sends data if the game is initialized but not yet started.
Referenced by add_player(), and remove_player().
std::string game::debug_player_info | ( | ) | const [private] |
Helps debugging player and observer lists.
Referenced by add_player(), remove_player(), take_side(), and update_side_data().
player_map* game::player_info_ [private] |
Definition at line 174 of file game.hpp.
Referenced by add_player(), ban_user(), debug_player_info(), find_user(), game(), kick_member(), mute_observer(), notify_new_host(), process_turn(), remove_player(), send_change_controller(), send_observerjoins(), send_observerquit(), send_user_list(), transfer_side_control(), and update_side_data().
int game::id_num = 1 [static, private] |
int game::id_ [private] |
Definition at line 177 of file game.hpp.
Referenced by add_player(), ban_user(), debug_player_info(), game(), id(), kick_member(), mute_observer(), remove_player(), send_observerjoins(), start_game(), and update_side_data().
std::string game::name_ [private] |
The name of the game.
Definition at line 179 of file game.hpp.
Referenced by add_player(), ban_user(), game(), kick_member(), mute_observer(), name(), remove_player(), and start_game().
std::string game::password_ [private] |
Definition at line 180 of file game.hpp.
Referenced by password_matches(), set_description(), and set_password().
network::connection game::owner_ [private] |
The game host or later owner (if the host left).
Definition at line 182 of file game.hpp.
Referenced by add_player(), ban_user(), game(), is_owner(), kick_member(), mute_observer(), notify_new_host(), process_message(), remove_player(), take_side(), transfer_ai_sides(), transfer_side_control(), and update_side_data().
user_vector game::players_ [private] |
A vector of players (members owning a side).
Definition at line 184 of file game.hpp.
Referenced by add_player(), add_players(), all_game_users(), debug_player_info(), game(), is_player(), nplayers(), remove_player(), send_data_team(), transfer_side_control(), and update_side_data().
user_vector game::observers_ [private] |
A vector of observers (members not owning a side).
Definition at line 186 of file game.hpp.
Referenced by add_player(), add_players(), all_game_users(), debug_player_info(), is_observer(), nobservers(), remove_player(), send_data_observers(), send_observerjoins(), transfer_side_control(), and update_side_data().
user_vector game::muted_observers_ [private] |
side_vector game::sides_ [private] |
A vector of side owners.
Definition at line 189 of file game.hpp.
Referenced by current_player(), is_on_team(), process_turn(), remove_player(), take_side(), transfer_ai_sides(), transfer_side_control(), and update_side_data().
std::vector<bool> game::sides_taken_ [private] |
A vector indicating what sides are actually taken. (Really needed?).
Definition at line 191 of file game.hpp.
Referenced by describe_slots(), remove_player(), take_side(), transfer_side_control(), and update_side_data().
std::vector<std::string> game::side_controllers_ [private] |
A vector of controller strings indicating the type.
"network" - a side controlled by some member of the game (not the owner) "human" - a side controlled by the owner "ai" - a side of the owner controlled by an AI "null" - an empty side
Definition at line 197 of file game.hpp.
Referenced by end_turn(), remove_player(), take_side(), transfer_ai_sides(), transfer_side_control(), and update_side_data().
int game::nsides_ [private] |
Number of sides in the current scenario.
Definition at line 200 of file game.hpp.
Referenced by current_player(), current_side(), current_turn(), end_turn(), and start_game().
bool game::started_ [private] |
Definition at line 201 of file game.hpp.
Referenced by add_player(), describe_slots(), process_turn(), remove_player(), send_and_record_server_message(), send_change_controller(), send_server_message(), send_user_list(), start_game(), started(), take_side(), and termination_reason().
simple_wml::document game::level_ [private] |
The current scenario data.
Definition at line 204 of file game.hpp.
Referenced by add_player(), allow_observers(), describe_slots(), end_turn(), is_on_team(), level(), level_init(), load_next_scenario(), send_change_controller(), set_termination_reason(), start_game(), take_side(), transfer_side_control(), and update_side_data().
std::vector<simple_wml::document*> game::history_ [mutable, private] |
Replay data.
Definition at line 206 of file game.hpp.
Referenced by record_data(), send_history(), start_game(), and ~game().
simple_wml::node* game::description_ [private] |
Pointer to the game's description in the games_and_users_list_.
Definition at line 208 of file game.hpp.
Referenced by describe_slots(), description(), end_turn(), send_user_list(), and set_description().
int game::end_turn_ [private] |
Definition at line 210 of file game.hpp.
Referenced by current_side(), current_turn(), end_turn(), and start_game().
bool game::all_observers_muted_ [private] |
Definition at line 212 of file game.hpp.
Referenced by all_observers_muted(), is_muted_observer(), mute_all_observers(), and mute_observer().
std::vector<std::string> game::bans_ [private] |
std::string game::termination_ [private] |
Definition at line 216 of file game.hpp.
Referenced by set_termination_reason(), and termination_reason().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |