Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

wesnothd::game Class Reference

#include <game.hpp>

Collaboration diagram for wesnothd::game:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 game (player_map &players, const network::connection host=0, const std::string &name="", bool save_replays=false, const std::string &replay_save_path="")
 ~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
 Checks whether the connection's ip address is banned.
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 or give a message of all currently muted observers if no name is given.
void unmute_observer (const simple_wml::node &unmute, const player_map::const_iterator unmuter)
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.
void unban_user (const simple_wml::node &unban, const player_map::const_iterator unbanner)
bool add_player (const network::connection player, bool observer=false)
 Add a user to the game.
bool remove_player (const network::connection player, const bool disconnect=false, const bool destruct=false)
 Removes a user from the game.
const user_vector all_game_users () const
 Adds players and observers into one vector and returns that.
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)
 Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data.
void process_whiteboard (simple_wml::document &data, const player_map::const_iterator user)
 Handles incoming [whiteboard] data.
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_to_all (const std::string &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_server_message (const std::string &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_and_record_server_message (const std::string &message, const network::connection exclude=0)
void send_data (simple_wml::document &data, const network::connection exclude=0, std::string packet_type="") const
void clear_history ()
void record_data (simple_wml::document *data)
void save_replay ()
simple_wml::documentlevel ()
 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::nodedescription () 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)
void allow_global (const simple_wml::document &data)

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
void send_muted_observers (const player_map::const_iterator user) const
bool send_taken_side (simple_wml::document &cfg, const simple_wml::node::child_list::const_iterator side) 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 change_controller (const size_t side_num, const network::connection sock, const std::string &player_name, const bool player_left=true, const std::string &controller="")
 Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai).
void transfer_ai_sides (const network::connection player)
void send_leave_game (network::connection user) const
void send_data_team (simple_wml::document &data, const simple_wml::string_span &team, const network::connection exclude=0, std::string packet_type="") const
void send_data_observers (simple_wml::document &data, const network::connection exclude=0, std::string packet_type="") 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::iterator find_user (const simple_wml::string_span &name)
 Shortcut to a 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'.
std::string has_same_ip (const network::connection &user, bool observer) const
 Checks whether a user has the same IP as members of this game.
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 username (const player_map::const_iterator pl) const
 Returns the name of the user or "(unfound)".
std::string list_users (user_vector users, const std::string &func) const
 Returns a comma separated list of user names.
void missing_user (network::connection socket, const std::string &func) const
 Function to log when we don't find a connection in player_info_.
std::string debug_player_info () const
 Helps debugging player and observer lists.

Private Attributes

player_mapplayer_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< 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::nodedescription_
 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_
bool save_replays_
std::string replay_save_path_
int global_wait_side_
 The side from which global variable data is expected.

Static Private Attributes

static int id_num = 1

Detailed Description

Definition at line 35 of file game.hpp.


Constructor & Destructor Documentation

wesnothd::game::game ( player_map players,
const network::connection  host = 0,
const std::string &  name = "",
bool  save_replays = false,
const std::string &  replay_save_path = "" 
)

Definition at line 47 of file game.cpp.

References id_, missing_user(), name_, owner_, player_info_, players_, and wesnothd::player::PLAYING.

Here is the call graph for this function:

wesnothd::game::~game (  ) 

Definition at line 85 of file game.cpp.

References all_game_users(), clear_history(), remove_player(), and save_replay().

Here is the call graph for this function:

wesnothd::game::game ( const game  )  [private]

Member Function Documentation

bool wesnothd::game::add_player ( const network::connection  player,
bool  observer = false 
)

Add a user to the game.

Returns:
True iff the user successfully joined the game.
Todo:
differentiate between "observers not allowed" and "player already in the game" errors.

Definition at line 947 of file game.cpp.

References allow_observers(), DBG_GAME, debug_player_info(), ERR_GAME, has_same_ip(), id_, simple_wml::INIT_COMPRESSED, network::ip_address(), is_member(), level_, LOG_GAME, missing_user(), name_, observers_, wesnothd::player::OBSERVING, player_info_, players_, wesnothd::player::PLAYING, send_and_record_server_message(), send_data(), send_history(), send_observerjoins(), send_server_message(), wesnothd::send_to_one(), send_user_list(), started_, and take_side().

Here is the call graph for this function:

const user_vector wesnothd::game::all_game_users (  )  const

Adds players and observers into one vector and returns that.

Definition at line 1345 of file game.cpp.

References observers_, and players_.

Referenced by wesnothd::room_manager::enter_lobby(), has_same_ip(), send_data(), send_user_list(), update_side_data(), and ~game().

Here is the caller graph for this function:

bool wesnothd::game::all_observers_muted (  )  const [inline, private]

Definition at line 206 of file game.hpp.

References all_observers_muted_.

void wesnothd::game::allow_global ( const simple_wml::document data  ) 

Definition at line 1338 of file game.cpp.

References global_wait_side_, nsides_, and simple_wml::document::root().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::allow_observers (  )  const

Definition at line 96 of file game.cpp.

References level_.

Referenced by add_player().

Here is the caller graph for this function:

network::connection wesnothd::game::ban_user ( const simple_wml::node ban,
const player_map::const_iterator  banner 
)

Ban and kick a user by name.

The user does not need to be in this game but logged in.

Returns:
The network handle of the banned player if he was in this game, '0' otherwise.

Definition at line 663 of file game.cpp.

References bans_, find_user(), id_, network::ip_address(), is_member(), LOG_GAME, name_, owner_, player_info_, player_is_banned(), remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::change_controller ( const size_t  side_num,
const network::connection  sock,
const std::string &  player_name,
const bool  player_left = true,
const std::string &  controller = "" 
) [private]

Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai).

Definition at line 435 of file game.cpp.

References DBG_GAME, level_, lexical_cast(), simple_wml::document::root(), send_and_record_server_message(), send_data(), wesnothd::send_to_one(), simple_wml::node::set_attr(), side_controllers_, sides_, and started_.

Referenced by remove_player(), and transfer_side_control().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::clear_history (  ) 

Definition at line 1312 of file game.cpp.

References history_.

Referenced by start_game(), and ~game().

Here is the caller graph for this function:

network::connection wesnothd::game::current_player (  )  const [inline, private]

Definition at line 201 of file game.hpp.

References current_side(), nsides_, and sides_.

Referenced by is_current_player(), and process_turn().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t wesnothd::game::current_side (  )  const [inline, private]

Definition at line 200 of file game.hpp.

References end_turn_, and nsides_.

Referenced by current_player(), end_turn(), and process_turn().

Here is the caller graph for this function:

size_t wesnothd::game::current_turn (  )  const [inline]

Definition at line 60 of file game.hpp.

References end_turn_, and nsides_.

Referenced by end_turn(), remove_player(), and save_replay().

Here is the caller graph for this function:

std::string wesnothd::game::debug_player_info (  )  const [private]

Helps debugging player and observer lists.

Definition at line 1354 of file game.cpp.

References id_, observers_, player_info_, and players_.

Referenced by add_player(), remove_player(), and update_side_data().

Here is the caller graph for this function:

bool wesnothd::game::describe_slots (  ) 

Set the description to the number of available slots.

Returns:
True iff the number of slots has changed.

Definition at line 500 of file game.cpp.

References description_, level_, simple_wml::document::root(), simple_wml::node::set_attr_dup(), sides_, and started_.

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

simple_wml::node* wesnothd::game::description (  )  const [inline]

Definition at line 178 of file game.hpp.

References description_.

Referenced by server::process_data_game(), and server::update_game_in_lobby().

Here is the caller graph for this function:

bool wesnothd::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.

Definition at line 920 of file game.cpp.

References current_side(), current_turn(), description_, end_turn_, level_, gamemap::MAX_PLAYERS, nsides_, simple_wml::node::set_attr_dup(), and side_controllers_.

Referenced by process_turn(), and start_game().

Here is the call graph for this function:

Here is the caller graph for this function:

player_map::iterator wesnothd::game::find_user ( const simple_wml::string_span name  )  [private]

Shortcut to a convenience function for finding a user by name.

Definition at line 1385 of file game.cpp.

References player_info_.

Referenced by ban_user(), kick_member(), mute_observer(), transfer_side_control(), unban_user(), and unmute_observer().

Here is the caller graph for this function:

std::string wesnothd::game::has_same_ip ( const network::connection user,
bool  observer 
) const [private]

Checks whether a user has the same IP as members of this game.

If observer is true it only checks against players.

Returns:
A comma separated string of members with matching IPs.

Definition at line 1173 of file game.cpp.

References all_game_users(), network::ip_address(), player_info_, and players_.

Referenced by add_player().

Here is the call graph for this function:

Here is the caller graph for this function:

int wesnothd::game::id (  )  const [inline]

Definition at line 43 of file game.hpp.

References id_.

Referenced by wesnothd::game_id_matches::operator()(), and server::process_data_game().

Here is the caller graph for this function:

bool wesnothd::game::is_current_player ( const network::connection  player  )  const [inline, private]

Definition at line 203 of file game.hpp.

References current_player().

Referenced by process_turn().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::is_legal_command ( const simple_wml::node command,
bool  is_player 
) [private]

Definition at line 741 of file game.cpp.

References simple_wml::node::child(), global_wait_side_, and simple_wml::node::one_child().

Referenced by process_turn().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::is_member ( const network::connection  player  )  const [inline]

Definition at line 47 of file game.hpp.

References is_observer(), and is_player().

Referenced by add_player(), ban_user(), kick_member(), wesnothd::game_is_member::operator()(), remove_player(), and transfer_side_control().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::is_muted_observer ( const network::connection  player  )  const [private]

Definition at line 104 of file game.cpp.

References all_observers_muted_, gui2::event::find(), is_observer(), and muted_observers_.

Referenced by mute_observer(), process_turn(), and unmute_observer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::is_observer ( const network::connection  player  )  const

Definition at line 100 of file game.cpp.

References gui2::event::find(), and observers_.

Referenced by is_member(), is_muted_observer(), mute_observer(), remove_player(), transfer_side_control(), and unmute_observer().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::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'.

AI controlled sides are not considered on a team.

Definition at line 1153 of file game.cpp.

References DBG_GAME, level_, simple_wml::document::root(), side_controllers_, and sides_.

Referenced by process_turn(), process_whiteboard(), and send_data_team().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::is_owner ( const network::connection  player  )  const [inline]

Definition at line 46 of file game.hpp.

References owner_.

Referenced by wesnothd::game_is_member::operator()(), and server::process_data_game().

Here is the caller graph for this function:

bool wesnothd::game::is_player ( const network::connection  player  )  const

Definition at line 114 of file game.cpp.

References gui2::event::find(), and players_.

Referenced by is_member(), server::process_data_game(), process_turn(), process_whiteboard(), remove_player(), and transfer_side_control().

Here is the call graph for this function:

Here is the caller graph for this function:

network::connection wesnothd::game::kick_member ( const simple_wml::node kick,
const player_map::const_iterator  kicker 
)

Kick a member by name.

Returns:
The network handle of the removed member if successful, '0' otherwise.

Definition at line 632 of file game.cpp.

References find_user(), id_, network::ip_address(), is_member(), LOG_GAME, name_, owner_, player_info_, remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

simple_wml::document& wesnothd::game::level (  )  [inline]

The full scenario data.

Definition at line 171 of file game.hpp.

References level_.

Referenced by server::process_data_game(), and server::process_data_lobby().

Here is the caller graph for this function:

bool wesnothd::game::level_init (  )  const [inline]

Definition at line 55 of file game.hpp.

References simple_wml::document::child(), and level_.

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string wesnothd::game::list_users ( user_vector  users,
const std::string &  func 
) const [private]

Returns a comma separated list of user names.

Definition at line 142 of file game.cpp.

References missing_user(), and player_info_.

Referenced by send_muted_observers(), and start_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::load_next_scenario ( const player_map::const_iterator  user  )  const

A user (player only?) asks for the next scenario to advance to.

Definition at line 1123 of file game.cpp.

References level_, simple_wml::document::root(), send_history(), send_observerjoins(), send_server_message_to_all(), and wesnothd::send_to_one().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::missing_user ( network::connection  socket,
const std::string &  func 
) const [private]

Function to log when we don't find a connection in player_info_.

Definition at line 41 of file game.cpp.

References id_, name_, and WRN_GAME.

Referenced by add_player(), game(), list_users(), remove_player(), send_observerjoins(), transfer_side_control(), and update_side_data().

Here is the caller graph for this function:

void wesnothd::game::mute_all_observers (  ) 

Definition at line 532 of file game.cpp.

References all_observers_muted_, and send_and_record_server_message().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::mute_observer ( const simple_wml::node mute,
const player_map::const_iterator  muter 
)

Mute an observer or give a message of all currently muted observers if no name is given.

Todo:
FIXME: Maybe rather save muted nicks as a set of strings and also allow muting of usernames not in the game.

Definition at line 552 of file game.cpp.

References simple_wml::string_span::empty(), find_user(), id_, network::ip_address(), is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, player_info_, send_and_record_server_message(), send_muted_observers(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& wesnothd::game::name (  )  const [inline]

Definition at line 44 of file game.hpp.

References name_.

Referenced by server::process_data_game().

Here is the caller graph for this function:

size_t wesnothd::game::nobservers (  )  const [inline]

Definition at line 59 of file game.hpp.

References observers_.

void wesnothd::game::notify_new_host (  )  [private]

In case of a host transfer, notify the new host about its status.

Definition at line 485 of file game.cpp.

References owner_, player_info_, send_and_record_server_message(), wesnothd::send_to_one(), simple_wml::node::set_attr(), and username().

Referenced by remove_player().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t wesnothd::game::nplayers (  )  const [inline]

Definition at line 58 of file game.hpp.

References players_.

Referenced by server::process_data_game().

Here is the caller graph for this function:

bool wesnothd::game::observers_can_chat (  )  const [inline, private]

Definition at line 251 of file game.hpp.

bool wesnothd::game::observers_can_label (  )  const [inline, private]

Definition at line 250 of file game.hpp.

void wesnothd::game::operator= ( const game  )  [private]
bool wesnothd::game::password_matches ( const std::string &  passwd  )  const [inline]

Definition at line 181 of file game.hpp.

References password_.

bool wesnothd::game::player_is_banned ( const network::connection  player  )  const

Checks whether the connection's ip address is banned.

Definition at line 526 of file game.cpp.

References bans_, gui2::event::find(), and network::ip_address().

Referenced by ban_user(), and unban_user().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::process_message ( simple_wml::document data,
const player_map::iterator  user 
)

Definition at line 726 of file game.cpp.

References ERR_GAME, game_logic::msg(), owner_, simple_wml::document::root(), send_data(), simple_wml::node::set_attr_dup(), and wesnothd::chat_message::truncate_message().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::process_turn ( simple_wml::document data,
const player_map::const_iterator  user 
)
void wesnothd::game::process_whiteboard ( simple_wml::document data,
const player_map::const_iterator  user 
)

Handles incoming [whiteboard] data.

Definition at line 893 of file game.cpp.

References simple_wml::string_span::begin(), simple_wml::document::child(), simple_wml::string_span::end(), is_on_team(), is_player(), LOG_GAME, gamemap::MAX_PLAYERS, send_and_record_server_message(), send_data_team(), sides_, and started_.

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::record_data ( simple_wml::document data  ) 

Definition at line 1307 of file game.cpp.

References simple_wml::document::compress(), and history_.

Referenced by process_turn(), and send_and_record_server_message().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::remove_player ( const network::connection  player,
const bool  disconnect = false,
const bool  destruct = false 
)

Removes a user from the game.

Returns:
True iff the game ends. That is, if there are no more players or the host left on a not yet started game.

Definition at line 1018 of file game.cpp.

References change_controller(), current_turn(), DBG_GAME, debug_player_info(), ERR_GAME, id_, if(), network::ip_address(), is_member(), is_observer(), is_player(), lexical_cast(), LOG_GAME, missing_user(), name_, notify_new_host(), game_config::images::observer, observers_, owner_, player_info_, players_, wesnothd::player::PLAYING, schema_validation::remove, send_and_record_server_message(), send_observerquit(), send_server_message_to_all(), wesnothd::send_to_one(), send_user_list(), side_controllers_, sides_, started_, termination_reason(), and username().

Referenced by ban_user(), kick_member(), server::process_data_game(), and ~game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::save_replay (  ) 

Definition at line 1258 of file game.cpp.

References current_turn(), DBG_GAME, ERR_GAME, history_, id_, level_, game::error::message, name_, simple_wml::node_to_string(), ostream_file(), simple_wml::document::output(), replay_save_path_, save_replays_, started_, and WRN_CONFIG.

Referenced by server::process_data_game(), and ~game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_and_record_server_message ( const std::string &  message,
const network::connection  exclude = 0 
) [inline]

Definition at line 159 of file game.hpp.

References send_and_record_server_message().

Here is the call graph for this function:

void wesnothd::game::send_and_record_server_message ( const char *  message,
const network::connection  exclude = 0 
)

Send data to all players in this game except 'exclude'.

Definition at line 1396 of file game.cpp.

References record_data(), send_data(), send_server_message(), and started_.

Referenced by add_player(), ban_user(), change_controller(), kick_member(), mute_all_observers(), mute_observer(), notify_new_host(), process_turn(), process_whiteboard(), remove_player(), send_and_record_server_message(), start_game(), transfer_side_control(), unban_user(), and unmute_observer().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_data ( simple_wml::document data,
const network::connection  exclude = 0,
std::string  packet_type = "" 
) const
void wesnothd::game::send_data_observers ( simple_wml::document data,
const network::connection  exclude = 0,
std::string  packet_type = "" 
) const [private]
void wesnothd::game::send_data_team ( simple_wml::document data,
const simple_wml::string_span team,
const network::connection  exclude = 0,
std::string  packet_type = "" 
) const [private]

Definition at line 1141 of file game.cpp.

References DBG_GAME, is_on_team(), players_, and wesnothd::send_to_many().

Referenced by process_turn(), and process_whiteboard().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_history ( const network::connection  sock  )  const [private]

Definition at line 1221 of file game.cpp.

References simple_wml::document::compress(), history_, game::error::message, simple_wml::document::output_compressed(), network::send_raw_data(), and WRN_CONFIG.

Referenced by add_player(), and load_next_scenario().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_leave_game ( network::connection  user  )  const [private]

Definition at line 626 of file game.cpp.

References simple_wml::INIT_COMPRESSED, and wesnothd::send_to_one().

Referenced by ban_user(), and kick_member().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_muted_observers ( const player_map::const_iterator  user  )  const [private]

Definition at line 541 of file game.cpp.

References all_observers_muted_, list_users(), muted_observers_, and send_server_message().

Referenced by mute_observer().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::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.

Definition at line 1188 of file game.cpp.

References missing_user(), observers_, player_info_, simple_wml::document::root(), send_data(), and wesnothd::send_to_one().

Referenced by add_player(), load_next_scenario(), and start_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_observerquit ( const player_map::const_iterator  observer  )  const [private]

Definition at line 1209 of file game.cpp.

References player_info_, simple_wml::document::root(), and send_data().

Referenced by remove_player(), and transfer_side_control().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::send_server_message ( const char *  message,
network::connection  sock = 0,
simple_wml::document doc = NULL 
) const
void wesnothd::game::send_server_message ( const std::string &  message,
network::connection  sock = 0,
simple_wml::document doc = NULL 
) const [inline]

Definition at line 152 of file game.hpp.

References send_server_message().

Here is the call graph for this function:

void wesnothd::game::send_server_message_to_all ( const std::string &  message,
network::connection  exclude = 0 
) const [inline]

Definition at line 146 of file game.hpp.

References send_server_message_to_all().

Here is the call graph for this function:

void wesnothd::game::send_server_message_to_all ( const char *  message,
network::connection  exclude = 0 
) const

Definition at line 1404 of file game.cpp.

References send_data(), and send_server_message().

Referenced by load_next_scenario(), server::process_data_game(), remove_player(), and send_server_message_to_all().

Here is the call graph for this function:

Here is the caller graph for this function:

bool wesnothd::game::send_taken_side ( simple_wml::document cfg,
const simple_wml::node::child_list::const_iterator  side 
) const [private]

Definition at line 227 of file game.cpp.

References gamemap::MAX_PLAYERS, owner_, simple_wml::document::root(), wesnothd::send_to_one(), and sides_.

Referenced by take_side().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::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.

Todo:
Should be renamed to userlist.

Definition at line 1104 of file game.cpp.

References all_game_users(), description_, player_info_, simple_wml::document::root(), send_data(), and started_.

Referenced by add_player(), and remove_player().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::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.

Definition at line 1320 of file game.cpp.

References description_, password_, and simple_wml::node::set_attr().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::set_password ( const std::string &  passwd  )  [inline]

Definition at line 180 of file game.hpp.

References password_.

Referenced by server::process_data_lobby().

Here is the caller graph for this function:

void wesnothd::game::set_termination_reason ( const std::string &  reason  ) 

Definition at line 1327 of file game.cpp.

References termination_.

Referenced by server::process_data_game().

Here is the caller graph for this function:

void wesnothd::game::start_game ( const player_map::const_iterator  starter  ) 
bool wesnothd::game::started (  )  const [inline]

Definition at line 56 of file game.hpp.

References started_.

Referenced by server::process_data_game().

Here is the caller graph for this function:

bool wesnothd::game::take_side ( const player_map::const_iterator  user  )  [private]

Figures out which side to take and tells that side to the game owner.

The owner then should send a [scenario_diff] that implements the side change and a subsequent update_side_data() call makes it actually happen. First we look for a side where save_id= or current_player= matches the new user's name then we search for the first controller="network" side.

Definition at line 239 of file game.cpp.

References DBG_GAME, level_, simple_wml::document::root(), send_taken_side(), and started_.

Referenced by add_player().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& wesnothd::game::termination_reason (  )  const [inline]

Definition at line 185 of file game.hpp.

References started_, and termination_.

Referenced by remove_player().

Here is the caller graph for this function:

void wesnothd::game::transfer_ai_sides ( const network::connection  player  )  [private]
void wesnothd::game::transfer_side_control ( const network::connection  sock,
const simple_wml::node cfg 
)
void wesnothd::game::unban_user ( const simple_wml::node unban,
const player_map::const_iterator  unbanner 
)

Definition at line 701 of file game.cpp.

References bans_, find_user(), id_, network::ip_address(), LOG_GAME, name_, owner_, player_info_, player_is_banned(), schema_validation::remove, send_and_record_server_message(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by server::process_data_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void wesnothd::game::unmute_observer ( const simple_wml::node unmute,
const player_map::const_iterator  unmuter 
)
void wesnothd::game::update_side_data (  ) 

Resets the side configuration according to the scenario data.

Definition at line 272 of file game.cpp.

References all_game_users(), DBG_GAME, debug_player_info(), lg::info, level_, gamemap::MAX_PLAYERS, missing_user(), observers_, wesnothd::player::OBSERVING, owner_, player_info_, players_, wesnothd::player::PLAYING, simple_wml::document::root(), side_controllers_, and sides_.

Referenced by server::process_data_game(), and start_game().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string wesnothd::game::username ( const player_map::const_iterator  pl  )  const [private]

Returns the name of the user or "(unfound)".

Definition at line 133 of file game.cpp.

References player_info_.

Referenced by ban_user(), kick_member(), mute_observer(), notify_new_host(), process_turn(), remove_player(), transfer_side_control(), unban_user(), and unmute_observer().

Here is the caller graph for this function:


Member Data Documentation

std::vector<std::string> wesnothd::game::bans_ [private]

Definition at line 340 of file game.hpp.

Referenced by ban_user(), player_is_banned(), and unban_user().

Pointer to the game's description in the games_and_users_list_.

Definition at line 334 of file game.hpp.

Referenced by describe_slots(), description(), end_turn(), send_user_list(), and set_description().

Definition at line 336 of file game.hpp.

Referenced by current_side(), current_turn(), end_turn(), process_turn(), and start_game().

The side from which global variable data is expected.

Definition at line 348 of file game.hpp.

Referenced by allow_global(), and is_legal_command().

std::vector<simple_wml::document*> wesnothd::game::history_ [mutable, private]

Replay data.

Definition at line 331 of file game.hpp.

Referenced by clear_history(), record_data(), save_replay(), and send_history().

int wesnothd::game::id_ [private]
int wesnothd::game::id_num = 1 [static, private]

Definition at line 295 of file game.hpp.

Definition at line 310 of file game.hpp.

Referenced by is_muted_observer(), mute_observer(), send_muted_observers(), and unmute_observer().

std::string wesnothd::game::name_ [private]
int wesnothd::game::nsides_ [private]

Number of sides in the current scenario.

Definition at line 324 of file game.hpp.

Referenced by allow_global(), current_player(), current_side(), current_turn(), end_turn(), process_turn(), and start_game().

A vector of observers (members not owning a side).

Definition at line 309 of file game.hpp.

Referenced by add_player(), all_game_users(), debug_player_info(), is_observer(), nobservers(), process_turn(), remove_player(), send_observerjoins(), transfer_side_control(), and update_side_data().

std::string wesnothd::game::password_ [private]

Definition at line 300 of file game.hpp.

Referenced by password_matches(), set_description(), and set_password().

std::string wesnothd::game::replay_save_path_ [private]

Definition at line 345 of file game.hpp.

Referenced by save_replay().

Definition at line 344 of file game.hpp.

Referenced by save_replay().

std::vector<std::string> wesnothd::game::side_controllers_ [private]

A vector of controller strings indicating the type.

"human" - a side controlled by a human "ai" - a side controlled by an AI "null" - an empty side

Definition at line 321 of file game.hpp.

Referenced by change_controller(), end_turn(), is_on_team(), remove_player(), and update_side_data().

bool wesnothd::game::started_ [private]
std::string wesnothd::game::termination_ [private]

Definition at line 342 of file game.hpp.

Referenced by set_termination_reason(), and termination_reason().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:26:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs