#include <multiplayer_connect.hpp>
Public Types | |
typedef std::vector < connected_user > | connected_user_list |
typedef std::vector< side > | side_list |
Public Member Functions | |
connect (game_display &disp, const config &game_config, chat &c, config &gamelist, const create::parameters ¶ms, mp::controller default_controller) | |
virtual void | process_event () |
const game_state & | get_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 () |
config * | current_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 |
Definition at line 33 of file multiplayer_connect.hpp.
typedef std::vector<connected_user> mp::connect::connected_user_list |
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.
mp::connect::connect | ( | game_display & | disp, | |
const config & | game_config, | |||
chat & | c, | |||
config & | gamelist, | |||
const create::parameters & | params, | |||
mp::controller | default_controller | |||
) |
Definition at line 907 of file multiplayer_connect.cpp.
References _, config::add_child(), mp::CNTR_LOCAL, mp::ui::CREATE, mp::ui::get_result(), level_, lists_init(), load_game(), preferences::login(), mp::create::parameters::name, mp::create::parameters::password, mp::ui::QUIT, network::send_data(), sides_, update_level(), update_playerlist_state(), update_user_combos(), and users_.
void mp::connect::process_event | ( | ) | [virtual] |
Reimplemented from mp::ui.
Definition at line 997 of file multiplayer_connect.cpp.
References config::add_child(), cancel_, cfg, launch_, network::nconnections(), mp::ui::PLAY, gui::button::pressed(), mp::ui::QUIT, network::send_data(), mp::ui::set_result(), sides_, sides_available(), update_and_send_diff(), and update_playerlist_state().
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] |
Reimplemented from mp::ui.
Definition at line 1284 of file multiplayer_connect.cpp.
References gui::ButtonHPadding, gui::ButtonVPadding, cancel_, mp::ui::client_area(), colour_title_label_, faction_title_label_, gold_title_label_, gui::widget::height(), income_title_label_, launch_, mp::ui::layout_children(), gui::widget::location(), scroll_pane_, gui::scrollpane::set_location(), gui::widget::set_location(), team_title_label_, type_title_label_, waiting_label_, and gui::widget::width().
void mp::connect::process_network_data | ( | const config & | data, | |
const network::connection | sock | |||
) | [protected, virtual] |
Reimplemented from mp::ui.
Definition at line 1085 of file multiplayer_connect.cpp.
References config::add_child(), config::child(), mp::CNTR_NETWORK, t_string::empty(), ERR_CF, find_player(), find_player_side(), config::get_attribute(), gui2::get_id(), LOG_CF, LOG_NW, name, mp::ui::process_network_data(), mp::ui::QUIT, network::send_data(), mp::ui::set_result(), sides_, update_and_send_diff(), update_playerlist_state(), update_user_combos(), users_, and config::values.
void mp::connect::process_network_error | ( | network::error & | error | ) | [protected, virtual] |
Reimplemented from mp::ui.
Definition at line 1226 of file multiplayer_connect.cpp.
References default_controller_, network::error::disconnect(), find_player_side(), network::is_server(), network::error::message, sides_, network::error::socket, update_and_send_diff(), update_playerlist_state(), update_user_combos(), and users_.
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] |
Reimplemented from mp::ui.
Definition at line 1063 of file multiplayer_connect.cpp.
References cancel_, colour_title_label_, faction_title_label_, gold_title_label_, gui::scrollpane::hide(), gui::widget::hide(), mp::ui::hide_children(), income_title_label_, launch_, params_, mp::create::parameters::saved_game, scroll_pane_, sides_, team_title_label_, and waiting_label_.
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] |
Definition at line 1323 of file multiplayer_connect.cpp.
References _, ai_algorithms_, config::child_range(), current_config(), t_string::empty(), era_sides_, get_available_ais(), mp::get_colour_string(), lexical_cast(), gamemap::MAX_PLAYERS, params_, player_colours_, player_factions_, player_teams_, player_types_, scroll_pane_, side, sides_, t_string::str(), team_names_, team_prefix_, mp::create::parameters::use_map_settings, and user_team_names_.
Referenced by connect().
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] |
Removes a player and kicks it from the game.
Definition at line 1695 of file multiplayer_connect.cpp.
References config::add_child(), mp::CNTR_NETWORK, network::disconnect(), find_player(), find_player_side(), network::is_server(), network::send_data(), sides_, update_user_combos(), and users_.
Referenced by mp::connect::side::process_event().
friend class side [friend] |
config mp::connect::level_ [private] |
Definition at line 213 of file multiplayer_connect.hpp.
Referenced by connect(), current_config(), load_game(), process_network_connection(), start_game(), update_and_send_diff(), and update_level().
game_state mp::connect::state_ [private] |
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().
create::parameters mp::connect::params_ [private] |
Definition at line 218 of file multiplayer_connect.hpp.
Referenced by mp::connect::side::get_config(), hide_children(), lists_init(), load_game(), mp::connect::side::side(), and start_game().
config::child_list mp::connect::era_sides_ [private] |
The list of available sides for the current era.
Definition at line 221 of file multiplayer_connect.hpp.
Referenced by mp::connect::side::get_config(), mp::connect::side::import_network_user(), lists_init(), load_game(), mp::connect::side::reset(), mp::connect::side::resolve_random(), and mp::connect::side::side().
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] |
std::vector<std::string> mp::connect::player_teams_ [private] |
std::vector<std::string> mp::connect::player_colours_ [private] |
std::vector<std::string> mp::connect::ai_algorithms_ [private] |
Definition at line 228 of file multiplayer_connect.hpp.
Referenced by mp::connect::side::init_ai_algorithm_combo(), lists_init(), and mp::connect::side::process_event().
std::vector<std::string> mp::connect::team_names_ [private] |
Definition at line 231 of file multiplayer_connect.hpp.
Referenced by mp::connect::side::get_config(), lists_init(), and mp::connect::side::side().
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] |
side_list mp::connect::sides_ [private] |
Definition at line 235 of file multiplayer_connect.hpp.
Referenced by connect(), find_player_side(), hide_children(), kick_player(), lists_init(), process_event(), mp::connect::side::process_event(), process_network_data(), process_network_error(), sides_available(), start_game(), update_level(), and update_user_combos().
connected_user_list mp::connect::users_ [private] |
Definition at line 236 of file multiplayer_connect.hpp.
Referenced by connect(), find_player(), kick_player(), mp::connect::side::process_event(), process_network_data(), process_network_error(), mp::connect::side::set_id(), mp::connect::side::update_controller_ui(), update_playerlist_state(), and mp::connect::side::update_user_list().
gui::label mp::connect::waiting_label_ [private] |
Definition at line 238 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), and update_playerlist_state().
bool mp::connect::message_full_ [private] |
Definition at line 239 of file multiplayer_connect.hpp.
controller mp::connect::default_controller_ [private] |
Definition at line 241 of file multiplayer_connect.hpp.
Referenced by mp::connect::side::process_event(), process_network_error(), and mp::connect::side::side().
gui::scrollpane mp::connect::scroll_pane_ [private] |
Definition at line 244 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), and lists_init().
gui::label mp::connect::type_title_label_ [private] |
gui::label mp::connect::faction_title_label_ [private] |
Definition at line 247 of file multiplayer_connect.hpp.
Referenced by hide_children(), and layout_children().
gui::label mp::connect::team_title_label_ [private] |
Definition at line 248 of file multiplayer_connect.hpp.
Referenced by hide_children(), and layout_children().
gui::label mp::connect::colour_title_label_ [private] |
Definition at line 249 of file multiplayer_connect.hpp.
Referenced by hide_children(), and layout_children().
gui::label mp::connect::gold_title_label_ [private] |
Definition at line 250 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), and load_game().
gui::label mp::connect::income_title_label_ [private] |
Definition at line 251 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), and load_game().
gui::button mp::connect::launch_ [private] |
Definition at line 253 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), process_event(), and update_playerlist_state().
gui::button mp::connect::cancel_ [private] |
Definition at line 254 of file multiplayer_connect.hpp.
Referenced by hide_children(), layout_children(), and process_event().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |