game Namespace Reference


Classes

struct  error
struct  load_game_failed
struct  save_game_failed
struct  game_error
struct  load_game_exception

Functions

 game (player_map &players, const network::connection host, const std::string name)
 ~game ()
bool allow_observers () const
bool is_observer (const network::connection player) const
bool is_muted_observer (const network::connection player) const
bool is_player (const network::connection player) const
void start_game (const player_map::const_iterator starter)
bool take_side (const player_map::const_iterator user)
 Figures out which side to take and tells that side to the game owner.
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)
void send_change_controller (const size_t side_num, const player_map::const_iterator newplayer, const bool player_left)
 Send [change_controller] message to tell all clients the new controller's name.
void transfer_ai_sides ()
void notify_new_host ()
bool describe_slots ()
bool player_is_banned (const network::connection sock) const
 Checks whether the connection's ip address is banned.
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.
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 a user by name.
void process_message (simple_wml::document &data, const player_map::iterator user)
bool is_legal_command (const simple_wml::node &command, bool is_player)
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.
bool end_turn ()
void add_player (const network::connection player, bool observer)
bool remove_player (const network::connection player, const bool disconnect)
 Removes a user from the game.
void send_user_list (const network::connection exclude) const
void load_next_scenario (const player_map::const_iterator user) const
 A member asks for the next scenario to advance to.
void send_data (simple_wml::document &data, const network::connection exclude) const
void send_to_one (simple_wml::document &data, const network::connection sock) const
void send_data_team (simple_wml::document &data, const simple_wml::string_span &team, const network::connection exclude) const
void send_data_observers (simple_wml::document &data, const network::connection exclude) const
bool is_on_team (const simple_wml::string_span &team, const network::connection player) const
void send_observerjoins (const network::connection sock) 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 record_data (simple_wml::document *data)
void set_description (simple_wml::node *desc)
void set_termination_reason (const std::string &reason)
void add_players (const game &other_game, const bool observer)
const user_vector all_game_users () const
std::string debug_player_info () const
player_map::const_iterator find_user (const simple_wml::string_span &name) const
 Find a user by name.
void send_and_record_server_message (const char *message, const network::connection exclude)
void send_server_message_to_all (const char *message, network::connection exclude) const
void send_server_message (const char *message, network::connection sock, simple_wml::document *docptr) const


Function Documentation

void game::add_player ( const network::connection  player,
bool  observer 
)

void game::add_players ( const game other_game,
const bool  observer 
)

Definition at line 1194 of file server/game.cpp.

References all_game_users(), observers_, and players_.

const user_vector game::all_game_users (  )  const

Definition at line 1204 of file server/game.cpp.

References observers_, and players_.

bool game::allow_observers (  )  const

Definition at line 81 of file server/game.cpp.

References level_.

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

std::string game::debug_player_info (  )  const

Definition at line 1213 of file server/game.cpp.

References id_, observers_, player_info_, and players_.

bool game::describe_slots (  ) 

bool game::end_turn (  ) 

player_map::const_iterator game::find_user ( const simple_wml::string_span name  )  const

Find a user by name.

Definition at line 1245 of file server/game.cpp.

References player_info_.

game::game ( player_map players,
const network::connection  host,
const std::string  name 
)

Definition at line 54 of file server/game.cpp.

References ERR_GAME, id_, name_, owner_, player_info_, and players_.

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

bool game::is_legal_command ( const simple_wml::node command,
bool  is_player 
)

Definition at line 696 of file server/game.cpp.

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

bool game::is_muted_observer ( const network::connection  player  )  const

Definition at line 89 of file server/game.cpp.

References all_observers_muted_, is_observer(), and muted_observers_.

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

Definition at line 85 of file server/game.cpp.

References observers_.

bool game::is_on_team ( const simple_wml::string_span team,
const network::connection  player 
) const

Definition at line 1091 of file server/game.cpp.

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

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

Definition at line 99 of file server/game.cpp.

References players_.

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

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

void game::mute_all_observers (  ) 

Definition at line 530 of file server/game.cpp.

References all_observers_muted_, and send_and_record_server_message().

void 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 vector of strings and also allow muting of usernames not in the game.

Prevent muting ourselves.

Definition at line 541 of file server/game.cpp.

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

void game::notify_new_host (  ) 

bool game::player_is_banned ( const network::connection  sock  )  const

Checks whether the connection's ip address is banned.

Definition at line 524 of file server/game.cpp.

References bans_, and network::ip_address().

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

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

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

Definition at line 1171 of file server/game.cpp.

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

bool game::remove_player ( const network::connection  player,
const bool  disconnect 
)

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

Definition at line 1255 of file server/game.cpp.

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

void game::send_change_controller ( const size_t  side_num,
const player_map::const_iterator  newplayer,
const bool  player_left 
)

Send [change_controller] message to tell all clients the new controller's name.

Definition at line 421 of file server/game.cpp.

References level_, lexical_cast(), player_info_, simple_wml::document::root(), send_and_record_server_message(), send_data(), send_to_one(), simple_wml::node::set_attr(), and started_.

void game::send_data ( simple_wml::document data,
const network::connection  exclude 
) const

void game::send_data_observers ( simple_wml::document data,
const network::connection  exclude 
) const

void game::send_data_team ( simple_wml::document data,
const simple_wml::string_span team,
const network::connection  exclude 
) const

void game::send_history ( const network::connection  sock  )  const

void game::send_observerjoins ( const network::connection  sock  )  const

Send [observer] tags of all the observers in the game to the user or everyone if none given.

Definition at line 1111 of file server/game.cpp.

References simple_wml::string_span::begin(), cfg, data, ERR_GAME, id_, observers_, simple_wml::document::output_compressed(), player_info_, simple_wml::document::root(), send_data(), network::send_raw_data(), and simple_wml::string_span::size().

void game::send_observerquit ( const player_map::const_iterator  observer  )  const

Definition at line 1135 of file server/game.cpp.

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

void game::send_server_message ( const char *  message,
network::connection  sock,
simple_wml::document docptr 
) const

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

Definition at line 1264 of file server/game.cpp.

References send_data(), and send_server_message().

void game::send_to_one ( simple_wml::document data,
const network::connection  sock 
) const

void game::send_user_list ( const network::connection  exclude  )  const

Todo:
Should be renamed to userlist.

Definition at line 1021 of file server/game.cpp.

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

void game::set_description ( simple_wml::node desc  ) 

Definition at line 1176 of file server/game.cpp.

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

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

void game::start_game ( const player_map::const_iterator  starter  ) 

bool game::take_side ( const player_map::const_iterator  user  ) 

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 186 of file server/game.cpp.

References simple_wml::string_span::begin(), cfg, data, DBG_GAME, debug_player_info(), level_, gamemap::MAX_PLAYERS, simple_wml::document::output_compressed(), owner_, simple_wml::document::root(), network::send_raw_data(), side_controllers_, sides_, sides_taken_, simple_wml::string_span::size(), and started_.

void game::transfer_ai_sides (  ) 

void game::transfer_side_control ( const network::connection  sock,
const simple_wml::node cfg 
)

void game::update_side_data (  ) 

Resets the side configuration according to the scenario data.

Definition at line 251 of file server/game.cpp.

References all_game_users(), DBG_GAME, debug_player_info(), ERR_GAME, id_, lg::info, level_, gamemap::MAX_PLAYERS, observers_, owner_, player_info_, players_, simple_wml::document::root(), side_controllers_, sides_, and sides_taken_.

game::~game (  ) 

Definition at line 74 of file server/game.cpp.

References history_.


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs