mp::connect Class Reference

#include <multiplayer_connect.hpp>

Inheritance diagram for mp::connect:

Inheritance graph
[legend]
Collaboration diagram for mp::connect:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector
< connected_user
connected_user_list
typedef std::vector< sideside_list

Public Member Functions

 connect (game_display &disp, const config &game_config, chat &c, config &gamelist, const create::parameters &params, mp::controller default_controller)
virtual void process_event ()
const game_stateget_state ()
 Returns the game state, which contains all information about the current scenario.
void start_game ()
 Updates the current game state, resolves random factions, and sends a "start game" message to the network.

Protected Member Functions

virtual void layout_children (const SDL_Rect &rect)
virtual void process_network_data (const config &data, const network::connection sock)
virtual void process_network_error (network::error &error)
virtual bool accept_connections ()
virtual void process_network_connection (const network::connection sock)
virtual void hide_children (bool hide=true)

Private Member Functions

void load_game ()
 Called by the constructor to initialize the game from a create::parameters structure.
void lists_init ()
configcurrent_config ()
void update_level ()
 Updates the level_ variable to reflect the sides in the sides_ vector.
void update_and_send_diff (bool update_time_of_day=false)
 Updates the level, and send a diff to the clients.
bool sides_available ()
 Returns true if there still are sides available for this game.
void update_playerlist_state (bool silent=true)
 Updates the state of the player list, the launch button and of the start game label, to reflect the actual state.
connected_user_list::iterator find_player (const std::string &id)
 Returns the index of a player, from its id, or -1 if the player was not found.
int find_player_side (const std::string &id) const
 Returns the side which is taken by a given player, or -1 if none was found.
void update_user_combos ()
 Adds a player.
void kick_player (const std::string &name)
 Removes a player and kicks it from the game.

Private Attributes

config level_
game_state state_
 This is the "game state" object which is created by this dialog.
create::parameters params_
config::child_list era_sides_
 The list of available sides for the current era.
std::vector< std::string > player_types_
std::vector< std::string > player_factions_
std::vector< std::string > player_teams_
std::vector< std::string > player_colours_
std::vector< std::string > ai_algorithms_
std::vector< std::string > team_names_
std::vector< std::string > user_team_names_
const std::string team_prefix_
side_list sides_
connected_user_list users_
gui::label waiting_label_
bool message_full_
controller default_controller_
gui::scrollpane scroll_pane_
gui::label type_title_label_
gui::label faction_title_label_
gui::label team_title_label_
gui::label colour_title_label_
gui::label gold_title_label_
gui::label income_title_label_
gui::button launch_
gui::button cancel_

Friends

class side

Classes

struct  connected_user
class  side


Detailed Description

Definition at line 33 of file multiplayer_connect.hpp.


Member Typedef Documentation

Definition at line 46 of file multiplayer_connect.hpp.

typedef std::vector<side> mp::connect::side_list

Definition at line 149 of file multiplayer_connect.hpp.


Constructor & Destructor Documentation

mp::connect::connect ( game_display disp,
const config game_config,
chat c,
config gamelist,
const create::parameters params,
mp::controller  default_controller 
)


Member Function Documentation

void mp::connect::process_event (  )  [virtual]

const game_state & mp::connect::get_state (  ) 

Returns the game state, which contains all information about the current scenario.

Definition at line 1031 of file multiplayer_connect.cpp.

References state_.

Referenced by enter_connect_mode().

void mp::connect::start_game (  ) 

Updates the current game state, resolves random factions, and sends a "start game" message to the network.

Definition at line 1036 of file multiplayer_connect.cpp.

References config::add_child(), game_events::add_events(), config::child(), lg::config, config::get_children(), level_, mp::level_to_gamestate(), params_, mp::create::parameters::saved_game, network::send_data(), sides_, state_, and update_and_send_diff().

Referenced by enter_connect_mode().

void mp::connect::layout_children ( const SDL_Rect &  rect  )  [protected, virtual]

void mp::connect::process_network_data ( const config data,
const network::connection  sock 
) [protected, virtual]

void mp::connect::process_network_error ( network::error error  )  [protected, virtual]

bool mp::connect::accept_connections (  )  [protected, virtual]

Reimplemented from mp::ui.

Definition at line 1268 of file multiplayer_connect.cpp.

References sides_available().

void mp::connect::process_network_connection ( const network::connection  sock  )  [protected, virtual]

Reimplemented from mp::ui.

Definition at line 1275 of file multiplayer_connect.cpp.

References lg::config, level_, mp::ui::process_network_connection(), and network::send_data().

void mp::connect::hide_children ( bool  hide = true  )  [protected, virtual]

void mp::connect::load_game (  )  [private]

Called by the constructor to initialize the game from a create::parameters structure.

Definition at line 1417 of file multiplayer_connect.cpp.

References _, config::add_child(), mp::create::parameters::allow_observers, mp::ui::append_to_title(), game_state::campaign_type, config::child(), mp::ui::CREATE, mp::ui::disp(), config::empty(), mp::create::parameters::era, preferences::era(), era_sides_, config::find_child(), mp::create::parameters::fog_game, mp::ui::game_config(), config::get_attribute(), config::get_children(), simple_rng::get_random_seed(), gold_title_label_, config::hash(), gui::widget::hide(), income_title_label_, gamestatus::is_start_ToD(), level_, lexical_cast(), dialogs::load_game_dialog(), game_config::min_savegame_version, mp::create::parameters::mp_countdown, mp::create::parameters::mp_countdown_action_bonus, mp::create::parameters::mp_countdown_init_time, mp::create::parameters::mp_countdown_reservoir_time, mp::create::parameters::mp_countdown_turn_bonus, N_, mp::create::parameters::name, mp::create::parameters::num_turns, params_, mp::create::parameters::random_start_time, game_state::replay_data, game_state::rng(), mp::create::parameters::saved_game, mp::create::parameters::scenario_data, mp::ui::set_result(), gui::message_dialog::show(), gui::show_error_message(), mp::create::parameters::shroud_game, game_state::snapshot, game_state::starting_pos, state_, game_config::test_version, mp::create::parameters::use_map_settings, game_config::version, game_state::version, vgettext(), mp::create::parameters::village_gold, cursor::WAIT, statistics::write_stats(), WRN_CF, mp::create::parameters::xp_modifier, and gui::YES_NO.

Referenced by connect().

void mp::connect::lists_init (  )  [private]

config * mp::connect::current_config (  )  [private]

Definition at line 1588 of file multiplayer_connect.cpp.

References config::child(), and level_.

Referenced by lists_init().

void mp::connect::update_level (  )  [private]

Updates the level_ variable to reflect the sides in the sides_ vector.

Definition at line 1603 of file multiplayer_connect.cpp.

References config::add_child(), config::clear_children(), level_, and sides_.

Referenced by connect(), and update_and_send_diff().

void mp::connect::update_and_send_diff ( bool  update_time_of_day = false  )  [private]

Updates the level, and send a diff to the clients.

Definition at line 1614 of file multiplayer_connect.cpp.

References config::add_child(), config::empty(), config::get_diff(), level_, network::send_data(), state_, and update_level().

Referenced by process_event(), process_network_data(), process_network_error(), and start_game().

bool mp::connect::sides_available (  )  [private]

Returns true if there still are sides available for this game.

Definition at line 1632 of file multiplayer_connect.cpp.

References sides_.

Referenced by accept_connections(), process_event(), and update_playerlist_state().

void mp::connect::update_playerlist_state ( bool  silent = true  )  [private]

Updates the state of the player list, the launch button and of the start game label, to reflect the actual state.

Definition at line 1641 of file multiplayer_connect.cpp.

References _, gui::button::enable(), mp::ui::gamelist(), mp::ui::gamelist_updated(), launch_, gui::label::set_text(), mp::ui::set_user_list(), mp::ui::set_user_menu_items(), sides_available(), users_, and waiting_label_.

Referenced by connect(), process_event(), process_network_data(), and process_network_error().

connect::connected_user_list::iterator mp::connect::find_player ( const std::string &  id  )  [private]

Returns the index of a player, from its id, or -1 if the player was not found.

Definition at line 1663 of file multiplayer_connect.cpp.

References users_.

Referenced by kick_player(), process_network_data(), mp::connect::side::set_id(), and mp::connect::side::update_controller_ui().

int mp::connect::find_player_side ( const std::string &  id  )  const [private]

Returns the side which is taken by a given player, or -1 if none was found.

Definition at line 1673 of file multiplayer_connect.cpp.

References sides_.

Referenced by kick_player(), mp::connect::side::process_event(), process_network_data(), and process_network_error().

void mp::connect::update_user_combos (  )  [private]

Adds a player.

Definition at line 1687 of file multiplayer_connect.cpp.

References sides_.

Referenced by connect(), kick_player(), process_network_data(), and process_network_error().

void mp::connect::kick_player ( const std::string &  name  )  [private]


Friends And Related Function Documentation

friend class side [friend]

Definition at line 147 of file multiplayer_connect.hpp.

Referenced by lists_init().


Member Data Documentation

This is the "game state" object which is created by this dialog.

Reimplemented from gui::widget.

Definition at line 216 of file multiplayer_connect.hpp.

Referenced by get_state(), load_game(), start_game(), and update_and_send_diff().

std::vector<std::string> mp::connect::player_types_ [private]

Definition at line 224 of file multiplayer_connect.hpp.

Referenced by lists_init(), and mp::connect::side::update_user_list().

std::vector<std::string> mp::connect::player_factions_ [private]

Definition at line 225 of file multiplayer_connect.hpp.

Referenced by lists_init().

std::vector<std::string> mp::connect::player_teams_ [private]

Definition at line 226 of file multiplayer_connect.hpp.

Referenced by lists_init().

std::vector<std::string> mp::connect::player_colours_ [private]

Definition at line 227 of file multiplayer_connect.hpp.

Referenced by lists_init().

std::vector<std::string> mp::connect::ai_algorithms_ [private]

std::vector<std::string> mp::connect::team_names_ [private]

std::vector<std::string> mp::connect::user_team_names_ [private]

Definition at line 232 of file multiplayer_connect.hpp.

Referenced by mp::connect::side::get_config(), and lists_init().

const std::string mp::connect::team_prefix_ [private]

Definition at line 233 of file multiplayer_connect.hpp.

Referenced by lists_init().

Definition at line 239 of file multiplayer_connect.hpp.

Definition at line 244 of file multiplayer_connect.hpp.

Referenced by hide_children(), layout_children(), and lists_init().

Definition at line 246 of file multiplayer_connect.hpp.

Referenced by layout_children().

Definition at line 247 of file multiplayer_connect.hpp.

Referenced by hide_children(), and layout_children().

Definition at line 248 of file multiplayer_connect.hpp.

Referenced by hide_children(), and layout_children().

Definition at line 249 of file multiplayer_connect.hpp.

Referenced by hide_children(), and layout_children().

Definition at line 250 of file multiplayer_connect.hpp.

Referenced by hide_children(), layout_children(), and load_game().

Definition at line 251 of file multiplayer_connect.hpp.

Referenced by hide_children(), layout_children(), and load_game().

Definition at line 254 of file multiplayer_connect.hpp.

Referenced by hide_children(), layout_children(), and process_event().


The documentation for this class was generated from the following files:

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