#include <game.hpp>
Public Member Functions | |
MAKE_ENUM (CONTROLLER,(HUMAN, "human")(AI, "ai")(EMPTY, "null")) game(player_connections &player_connections | |
~game () | |
int | id () const |
const std::string & | name () const |
bool | is_owner (const socket_ptr &player) const |
bool | is_member (const socket_ptr &player) const |
bool | allow_observers () const |
bool | registered_users_only () const |
bool | is_observer (const socket_ptr &player) const |
bool | is_player (const socket_ptr &player) const |
bool | player_is_banned (const socket_ptr &player, const std::string &name) const |
Checks whether the connection's ip address or username is banned. More... | |
void | new_scenario (const socket_ptr &player) |
when the host sends the new scenario of a mp campaign More... | |
bool | level_init () const |
const simple_wml::node::child_list & | get_sides_list () const |
bool | started () const |
std::size_t | nplayers () const |
std::size_t | nobservers () const |
std::size_t | current_turn () const |
void | set_current_turn (int turn) |
std::string | get_replay_filename () |
void | mute_all_observers () |
void | mute_observer (const simple_wml::node &mute, const socket_ptr &muter) |
Mute an observer or give a message of all currently muted observers if no name is given. More... | |
void | unmute_observer (const simple_wml::node &unmute, const socket_ptr &unmuter) |
socket_ptr | kick_member (const simple_wml::node &kick, const socket_ptr &kicker) |
Kick a member by name. More... | |
socket_ptr | ban_user (const simple_wml::node &ban, const socket_ptr &banner) |
Ban and kick a user by name. More... | |
void | unban_user (const simple_wml::node &unban, const socket_ptr &unbanner) |
bool | add_player (const socket_ptr &player, bool observer=false) |
Add a user to the game. More... | |
bool | remove_player (const socket_ptr &player, const bool disconnect=false, const bool destruct=false) |
Removes a user from the game. More... | |
const user_vector | all_game_users () const |
Adds players and observers into one vector and returns that. More... | |
void | start_game (const socket_ptr &starter) |
void | perform_controller_tweaks () |
void | update_game () |
void | load_next_scenario (const socket_ptr &user) |
A user (player only?) asks for the next scenario to advance to. More... | |
void | update_side_data () |
Resets the side configuration according to the scenario data. More... | |
void | transfer_side_control (const socket_ptr &sock, const simple_wml::node &cfg) |
Let's a player owning a side give it to another player or observer. More... | |
void | process_message (simple_wml::document &data, const socket_ptr &user) |
bool | process_turn (simple_wml::document &data, const socket_ptr &user) |
Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data. More... | |
void | process_whiteboard (simple_wml::document &data, const socket_ptr &user) |
Handles incoming [whiteboard] data. More... | |
void | process_change_turns_wml (simple_wml::document &data, const socket_ptr &user) |
Handles incoming [change_turns_wml] data. More... | |
bool | describe_slots () |
Set the description to the number of available slots. More... | |
void | send_server_message_to_all (const char *message, const socket_ptr &exclude=socket_ptr()) const |
void | send_server_message_to_all (const std::string &message, const socket_ptr &exclude=socket_ptr()) const |
void | send_server_message (const char *message, const socket_ptr &sock=socket_ptr(), simple_wml::document *doc=nullptr) const |
void | send_server_message (const std::string &message, const socket_ptr &sock=socket_ptr(), simple_wml::document *doc=nullptr) const |
void | send_and_record_server_message (const char *message, const socket_ptr &exclude=socket_ptr()) |
Send data to all players in this game except 'exclude'. More... | |
void | send_and_record_server_message (const std::string &message, const socket_ptr &exclude=socket_ptr()) |
void | send_data (simple_wml::document &data, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const |
void | clear_history () |
void | record_data (simple_wml::document *data) |
void | save_replay () |
simple_wml::document & | level () |
The full scenario data. More... | |
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. More... | |
simple_wml::node * | description () const |
void | set_password (const std::string &passwd) |
void | set_name_bans (const std::vector< std::string > name_bans) |
bool | password_matches (const std::string &passwd) const |
bool | has_password () const |
const std::string & | termination_reason () const |
void | set_termination_reason (const std::string &reason) |
void | handle_choice (const simple_wml::node &data, const socket_ptr &user) |
void | handle_random_choice (const simple_wml::node &data) |
void | handle_controller_choice (const simple_wml::node &data) |
void | handle_add_side_wml (const simple_wml::node &req) |
void | reset_last_synced_context_id () |
bool | controls_side (const std::vector< int > &sides, const socket_ptr &player) const |
Function which returns true iff 'player' controls any of the sides spcified in 'sides'. More... | |
bool | is_reload () const |
Static Public Member Functions | |
static simple_wml::node * | starting_pos (simple_wml::node &data) |
static const simple_wml::node * | starting_pos (const simple_wml::node &data) |
Public Attributes | |
const socket_ptr & | host |
const socket_ptr const std::string & | name = "" |
const socket_ptr const std::string bool | save_replays = false |
const socket_ptr const std::string bool const std::string & | replay_save_path = "") |
Private Types | |
typedef boost::ptr_vector< simple_wml::document > | history |
Replay data. More... | |
Private Member Functions | |
game (const game &)=delete | |
void | operator= (const game &)=delete |
std::size_t | current_side () const |
const socket_ptr | current_player () const |
bool | is_current_player (const socket_ptr &player) const |
bool | is_muted_observer (const socket_ptr &player) const |
bool | all_observers_muted () const |
void | send_muted_observers (const socket_ptr &user) const |
bool | send_taken_side (simple_wml::document &cfg, const simple_wml::node *side) const |
bool | take_side (const socket_ptr &user) |
Figures out which side to take and tells that side to the game owner. More... | |
void | change_controller (const std::size_t side_num, const socket_ptr &sock, const std::string &player_name, const bool player_left=true) |
Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai). More... | |
void | transfer_ai_sides (const socket_ptr &player) |
void | send_leave_game (const socket_ptr &user) const |
void | send_data_sides (simple_wml::document &data, const simple_wml::string_span &sides, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const |
void | send_data_observers (simple_wml::document &data, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const |
void | send_observerjoins (const socket_ptr &sock=socket_ptr()) const |
Send [observer] tags of all the observers in the game to the user or everyone if none given. More... | |
void | send_observerquit (const socket_ptr &observer) const |
void | send_history (const socket_ptr &sock) const |
void | notify_new_host () |
In case of a host transfer, notify the new host about its status. More... | |
socket_ptr | find_user (const simple_wml::string_span &name) |
Shortcut to a convenience function for finding a user by name. More... | |
bool | observers_can_label () const |
bool | observers_can_chat () const |
bool | is_legal_command (const simple_wml::node &command, const socket_ptr &user) |
std::string | has_same_ip (const socket_ptr &user) const |
Checks whether a user has the same IP as any other members of this game. More... | |
bool | end_turn (int new_side) |
Function which should be called every time a player ends their turn (i.e. More... | |
void | update_turn_data () |
void | send_user_list (const socket_ptr &exclude=socket_ptr()) const |
Function to send a list of users to all clients. More... | |
std::string | username (const socket_ptr &pl) const |
Returns the name of the user or "(unfound)". More... | |
std::string | list_users (user_vector users, const std::string &func) const |
Returns a comma separated list of user names. More... | |
void | missing_user (socket_ptr socket, const std::string &func) const |
Function to log when we don't find a connection in player_info_. More... | |
void | reset_sides () |
calculates the initial value for sides_, side_controllerds_, nsides_ More... | |
std::string | debug_player_info () const |
Helps debugging player and observer lists. More... | |
std::string | debug_sides_info () const |
Helps debugging controller tweaks. More... | |
Private Attributes | |
player_connections & | player_connections_ |
int | id_ |
std::string | name_ |
The name of the game. More... | |
std::string | password_ |
socket_ptr | owner_ |
The game host or later owner (if the host left). More... | |
user_vector | players_ |
A vector of players (members owning a side). More... | |
user_vector | observers_ |
A vector of observers (members not owning a side). More... | |
user_vector | muted_observers_ |
side_vector | sides_ |
A vector of side owners. More... | |
std::vector< CONTROLLER > | side_controllers_ |
int | nsides_ |
Number of sides in the current scenario. More... | |
bool | started_ |
simple_wml::document | level_ |
The current scenario data. More... | |
history | history_ |
simple_wml::node * | description_ |
Pointer to the game's description in the games_and_users_list_. More... | |
int | current_turn_ |
int | current_side_index_ |
int | num_turns_ |
bool | all_observers_muted_ |
std::vector< std::string > | bans_ |
std::vector< std::string > | name_bans_ |
std::set< socket_ptr > | players_not_advanced_ |
in multiplayer campaigns it can happen that some players are still in the previousl scenario keep track of those players because processing certain input from those side wil lead to error (oos) More... | |
std::string | termination_ |
bool | save_replays_ |
std::string | replay_save_path_ |
randomness::mt_rng | rng_ |
A wrapper for mersenne twister rng which generates randomness for this game. More... | |
int | last_choice_request_id_ |
Static Private Attributes | |
static int | id_num = 1 |
|
private |
wesnothd::game::~game | ( | ) |
Definition at line 141 of file game.cpp.
References all_game_users(), clear_history(), remove_player(), and save_replay().
|
privatedelete |
Definition at line 94 of file game.cpp.
References id_, missing_user(), name_, owner_, player_connections_, players_, and wesnothd::player::PLAYING.
Referenced by reset_last_synced_context_id().
bool wesnothd::game::add_player | ( | const socket_ptr & | player, |
bool | observer = false |
||
) |
Add a user to the game.
Definition at line 1393 of file game.cpp.
References simple_wml::node::add_child(), allow_observers(), client_address(), DBG_GAME, debug_player_info(), ERR_GAME, has_same_ip(), id_, simple_wml::INIT_COMPRESSED, is_member(), level_, LOG_GAME, name_, observers_, wesnothd::player::OBSERVING, player_connections_, players_, wesnothd::player::PLAYING, simple_wml::document::root(), send_and_record_server_message(), send_data(), send_history(), send_observerjoins(), send_server_message(), wesnothd::send_to_player(), send_user_list(), simple_wml::node::set_attr_dup(), started_, and take_side().
Referenced by set_current_turn().
const user_vector wesnothd::game::all_game_users | ( | ) | const |
Adds players and observers into one vector and returns that.
Definition at line 1935 of file game.cpp.
References observers_, and players_.
Referenced by has_same_ip(), new_scenario(), send_data(), send_user_list(), set_current_turn(), update_side_data(), and ~game().
|
inlineprivate |
Definition at line 353 of file game.hpp.
References all_observers_muted_, change_controller(), find_user(), notify_new_host(), game_config::images::observer, send_data_observers(), send_data_sides(), send_history(), send_leave_game(), send_muted_observers(), send_observerjoins(), send_observerquit(), send_taken_side(), take_side(), and transfer_ai_sides().
bool wesnothd::game::allow_observers | ( | ) | const |
Definition at line 166 of file game.cpp.
References wesnothd::get_multiplayer(), level_, and simple_wml::document::root().
Referenced by add_player(), and is_member().
socket_ptr wesnothd::game::ban_user | ( | const simple_wml::node & | ban, |
const socket_ptr & | banner | ||
) |
Ban and kick a user by name.
The user does not need to be in this game but logged in.
Definition at line 849 of file game.cpp.
References bans_, client_address(), find_user(), id_, is_member(), LOG_GAME, name_, name_bans_, owner_, player_connections_, 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 wesnothd::server::handle_player_in_game(), and set_current_turn().
|
private |
Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai).
Definition at line 623 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::document::clone(), DBG_GAME, record_data(), simple_wml::document::root(), send_and_record_server_message(), send_data(), wesnothd::send_to_player(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), side_controllers_, sides_, and started_.
Referenced by all_observers_muted(), perform_controller_tweaks(), remove_player(), and transfer_side_control().
void wesnothd::game::clear_history | ( | ) |
Definition at line 1908 of file game.cpp.
References history_.
Referenced by send_and_record_server_message(), start_game(), and ~game().
bool wesnothd::game::controls_side | ( | const std::vector< int > & | sides, |
const socket_ptr & | player | ||
) | const |
Function which returns true iff 'player' controls any of the sides spcified in 'sides'.
Definition at line 1725 of file game.cpp.
References sides_.
Referenced by reset_last_synced_context_id().
|
inlineprivate |
Definition at line 342 of file game.hpp.
References current_side(), nsides_, and sides_.
Referenced by handle_controller_choice(), is_current_player(), and process_turn().
|
inlineprivate |
Definition at line 337 of file game.hpp.
References current_side_index_, and nsides_.
Referenced by current_player(), end_turn(), and process_turn().
|
inline |
Definition at line 130 of file game.hpp.
References current_turn_.
Referenced by get_replay_filename(), process_change_turns_wml(), remove_player(), and update_turn_data().
|
private |
Helps debugging player and observer lists.
Definition at line 1945 of file game.cpp.
References id_, observers_, p, player_connections_, and players_.
Referenced by add_player(), observers_can_chat(), remove_player(), and update_side_data().
|
private |
Helps debugging controller tweaks.
Definition at line 1979 of file game.cpp.
References get_sides_list(), id_, s, side_controllers_, and sides_.
Referenced by load_next_scenario(), observers_can_chat(), perform_controller_tweaks(), and start_game().
bool wesnothd::game::describe_slots | ( | ) |
Set the description to the number of available slots.
Definition at line 676 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::child(), description_, get_sides_list(), i, simple_wml::node::set_attr_int(), sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), set_current_turn(), and update_game().
|
inline |
Definition at line 277 of file game.hpp.
References description_.
Referenced by wesnothd::server::cleanup_game(), wesnothd::server::handle_player_in_game(), and wesnothd::server::update_game_in_lobby().
|
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 1343 of file game.cpp.
References current_side(), current_side_index_, current_turn_, description_, i, nsides_, side_controllers_, and update_turn_data().
Referenced by observers_can_chat(), and process_turn().
|
private |
Shortcut to a convenience function for finding a user by name.
Definition at line 1999 of file game.cpp.
References gui2::event::find(), player_connections_, and simple_wml::string_span::to_string().
Referenced by all_observers_muted(), ban_user(), kick_member(), mute_observer(), transfer_side_control(), unban_user(), and unmute_observer().
std::string wesnothd::game::get_replay_filename | ( | ) |
Definition at line 1836 of file game.cpp.
References current_turn(), id_, wesnothd::is_invalid_filename_char(), level_, name(), simple_wml::document::root(), and starting_pos().
Referenced by wesnothd::server::cleanup_game(), save_replay(), and set_current_turn().
|
inline |
Definition at line 110 of file game.hpp.
References level_, simple_wml::document::root(), and starting_pos().
Referenced by debug_sides_info(), describe_slots(), wesnothd::server::handle_player_in_game(), perform_controller_tweaks(), reset_sides(), start_game(), take_side(), transfer_side_control(), and update_side_data().
void wesnothd::game::handle_add_side_wml | ( | const simple_wml::node & | req | ) |
Definition at line 1171 of file game.cpp.
References nsides_, side_controllers_, and sides_.
Referenced by handle_choice(), and termination_reason().
void wesnothd::game::handle_choice | ( | const simple_wml::node & | data, |
const socket_ptr & | user | ||
) |
Definition at line 1243 of file game.cpp.
References simple_wml::node::child(), DBG_GAME, handle_add_side_wml(), handle_controller_choice(), handle_random_choice(), is_player(), last_choice_request_id_, owner_, player_connections_, players_not_advanced_, send_and_record_server_message(), and started_.
Referenced by wesnothd::server::handle_player_in_game(), and termination_reason().
void wesnothd::game::handle_controller_choice | ( | const simple_wml::node & | data | ) |
Definition at line 1178 of file game.cpp.
References simple_wml::node::add_child(), current_player(), record_data(), simple_wml::document::root(), send_and_record_server_message(), send_data(), wesnothd::send_to_player(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), side_controllers_, and sides_.
Referenced by handle_choice(), and termination_reason().
void wesnothd::game::handle_random_choice | ( | const simple_wml::node & | data | ) |
Definition at line 1150 of file game.cpp.
References simple_wml::node::add_child(), randomness::mt_rng::get_next_random(), record_data(), rng_, simple_wml::document::root(), send_data(), simple_wml::node::set_attr(), and simple_wml::node::set_attr_dup().
Referenced by handle_choice(), and termination_reason().
|
inline |
Definition at line 297 of file game.hpp.
References password_.
Referenced by wesnothd::server::handle_player_in_game().
|
private |
Checks whether a user has the same IP as any other members of this game.
Definition at line 1738 of file game.cpp.
References all_game_users(), client_address(), and player_connections_.
Referenced by add_player(), and observers_can_chat().
|
inline |
Definition at line 52 of file game.hpp.
References id_.
Referenced by wesnothd::server::cleanup_game(), wesnothd::server::create_game(), and wesnothd::server::handle_player_in_game().
|
inlineprivate |
Definition at line 347 of file game.hpp.
References current_player(), and is_muted_observer().
Referenced by is_legal_command(), and process_turn().
|
private |
Definition at line 937 of file game.cpp.
References simple_wml::node::attr(), simple_wml::node::child(), simple_wml::node::has_attr(), is_current_player(), simple_wml::string_span::is_null(), is_player(), simple_wml::node::one_child(), owner_, sides_, and simple_wml::string_span::to_int().
Referenced by observers_can_chat(), and process_turn().
|
inline |
Definition at line 67 of file game.hpp.
References allow_observers(), is_observer(), is_player(), name(), new_scenario(), player_is_banned(), and registered_users_only().
Referenced by add_player(), ban_user(), kick_member(), remove_player(), and transfer_side_control().
|
private |
Definition at line 181 of file game.cpp.
References all_observers_muted_, gui2::event::find(), is_observer(), and muted_observers_.
Referenced by is_current_player(), mute_observer(), process_turn(), and unmute_observer().
bool wesnothd::game::is_observer | ( | const socket_ptr & | player | ) | const |
Definition at line 176 of file game.cpp.
References gui2::event::find(), and observers_.
Referenced by is_member(), is_muted_observer(), mute_observer(), remove_player(), send_user_list(), transfer_side_control(), and unmute_observer().
|
inline |
Definition at line 62 of file game.hpp.
References owner_.
Referenced by wesnothd::server::handle_player_in_game(), and send_user_list().
bool wesnothd::game::is_player | ( | const socket_ptr & | player | ) | const |
Definition at line 194 of file game.cpp.
References gui2::event::find(), and players_.
Referenced by handle_choice(), wesnothd::server::handle_player_in_game(), is_legal_command(), is_member(), process_change_turns_wml(), process_turn(), process_whiteboard(), remove_player(), and transfer_side_control().
bool wesnothd::game::is_reload | ( | ) | const |
Definition at line 2058 of file game.cpp.
References wesnothd::get_multiplayer(), simple_wml::node::has_attr(), level_, and simple_wml::document::root().
Referenced by wesnothd::server::handle_player_in_game(), and reset_last_synced_context_id().
socket_ptr wesnothd::game::kick_member | ( | const simple_wml::node & | kick, |
const socket_ptr & | kicker | ||
) |
Kick a member by name.
Definition at line 817 of file game.cpp.
References client_address(), find_user(), id_, is_member(), LOG_GAME, name_, owner_, player_connections_, remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), simple_wml::string_span::to_string(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
|
inline |
The full scenario data.
Definition at line 266 of file game.hpp.
References level_, and set_description().
Referenced by wesnothd::server::create_game(), and wesnothd::server::handle_player_in_game().
|
inline |
Definition at line 83 of file game.hpp.
References simple_wml::document::child(), and level_.
Referenced by wesnothd::server::handle_player_in_game().
|
private |
Returns a comma separated list of user names.
Definition at line 209 of file game.cpp.
References missing_user(), and player_connections_.
Referenced by observers_can_chat(), send_muted_observers(), and start_game().
void wesnothd::game::load_next_scenario | ( | const socket_ptr & | user | ) |
A user (player only?) asks for the next scenario to advance to.
Definition at line 1631 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::copy_into(), DBG_GAME, debug_sides_info(), level_, player_connections_, players_not_advanced_, simple_wml::document::root(), send_history(), send_observerjoins(), send_server_message_to_all(), wesnothd::send_to_player(), simple_wml::node::set_attr(), sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
wesnothd::game::MAKE_ENUM | ( | CONTROLLER | , |
(HUMAN, "human")(AI, "ai")(EMPTY, "null") | |||
) | & |
|
private |
Function to log when we don't find a connection in player_info_.
Definition at line 88 of file game.cpp.
References WRN_GAME.
Referenced by game(), list_users(), observers_can_chat(), perform_controller_tweaks(), transfer_side_control(), and update_side_data().
void wesnothd::game::mute_all_observers | ( | ) |
Definition at line 715 of file game.cpp.
References all_observers_muted_, and send_and_record_server_message().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::mute_observer | ( | const simple_wml::node & | mute, |
const socket_ptr & | muter | ||
) |
Mute an observer or give a message of all currently muted observers if no name is given.
Definition at line 737 of file game.cpp.
References client_address(), simple_wml::string_span::empty(), find_user(), id_, is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, send_and_record_server_message(), send_muted_observers(), send_server_message(), simple_wml::string_span::to_string(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
|
inline |
Definition at line 57 of file game.hpp.
References name_.
Referenced by get_replay_filename(), is_member(), and player_is_banned().
void wesnothd::game::new_scenario | ( | const socket_ptr & | player | ) |
when the host sends the new scenario of a mp campaign
Definition at line 1619 of file game.cpp.
References all_game_users(), owner_, players_not_advanced_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), and is_member().
|
inline |
Definition at line 125 of file game.hpp.
References observers_.
|
private |
In case of a host transfer, notify the new host about its status.
Definition at line 665 of file game.cpp.
References simple_wml::node::add_child(), owner_, simple_wml::document::root(), send_and_record_server_message(), wesnothd::send_to_player(), and username().
Referenced by all_observers_muted(), and remove_player().
|
inline |
|
inlineprivate |
Definition at line 414 of file game.hpp.
References debug_player_info(), debug_sides_info(), end_turn(), has_same_ip(), is_legal_command(), list_users(), missing_user(), reset_sides(), send_user_list(), update_turn_data(), and username().
|
inlineprivate |
|
privatedelete |
Referenced by reset_last_synced_context_id().
|
inline |
void wesnothd::game::perform_controller_tweaks | ( | ) |
Definition at line 230 of file game.cpp.
References change_controller(), DBG_GAME, debug_sides_info(), get_sides_list(), id_, LOG_GAME, missing_user(), wfl::msg(), owner_, player_connections_, send_and_record_server_message(), simple_wml::node::set_attr(), sides_, update_side_data(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
bool wesnothd::game::player_is_banned | ( | const socket_ptr & | player, |
const std::string & | name | ||
) | const |
Checks whether the connection's ip address or username is banned.
Definition at line 707 of file game.cpp.
References bans_, client_address(), gui2::event::find(), name(), and name_bans_.
Referenced by ban_user(), is_member(), and unban_user().
void wesnothd::game::process_change_turns_wml | ( | simple_wml::document & | data, |
const socket_ptr & | user | ||
) |
Handles incoming [change_turns_wml] data.
Definition at line 1314 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::child(), simple_wml::document::child(), simple_wml::node::copy_into(), current_turn(), description_, is_player(), num_turns_, set_current_turn(), and started_.
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::process_message | ( | simple_wml::document & | data, |
const socket_ptr & | user | ||
) |
Definition at line 921 of file game.cpp.
References simple_wml::node::child(), ERR_GAME, wfl::msg(), owner_, player_connections_, simple_wml::document::root(), send_data(), simple_wml::node::set_attr_dup(), and wesnothd::chat_message::truncate_message().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
bool wesnothd::game::process_turn | ( | simple_wml::document & | data, |
const socket_ptr & | user | ||
) |
Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data.
Also filters commands from all but the current player. Currently removes all commands but [speak] for observers and all but [speak], [label] and [rename] for players.
Definition at line 1002 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::child(), simple_wml::node::children(), simple_wml::document::clone(), simple_wml::node::copy_into(), current_player(), current_side(), current_side_index_, current_turn_, DBG_GAME, simple_wml::string_span::empty(), end_turn(), gui2::event::find(), id_, utf8::index(), is_current_player(), is_legal_command(), is_muted_observer(), is_player(), LOG_GAME, wfl::msg(), simple_wml::node::no_children(), simple_wml::node_to_string(), nsides_, game_config::observer_team_name, observers_, owner_, player_connections_, record_data(), simple_wml::node::remove_child(), simple_wml::document::root(), s, send_and_record_server_message(), send_data(), send_data_sides(), send_server_message(), wesnothd::send_to_players(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), sides_, started_, transfer_side_control(), wesnothd::chat_message::truncate_message(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::process_whiteboard | ( | simple_wml::document & | data, |
const socket_ptr & | user | ||
) |
Handles incoming [whiteboard] data.
Definition at line 1287 of file game.cpp.
References simple_wml::document::child(), is_player(), LOG_GAME, wfl::msg(), player_connections_, send_and_record_server_message(), send_data_sides(), sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::record_data | ( | simple_wml::document * | data | ) |
Definition at line 1902 of file game.cpp.
References simple_wml::document::compress(), and history_.
Referenced by change_controller(), handle_controller_choice(), handle_random_choice(), process_turn(), and send_and_record_server_message().
bool wesnothd::game::registered_users_only | ( | ) | const |
Definition at line 171 of file game.cpp.
References wesnothd::get_multiplayer(), level_, and simple_wml::document::root().
Referenced by is_member().
bool wesnothd::game::remove_player | ( | const socket_ptr & | player, |
const bool | disconnect = false , |
||
const bool | destruct = false |
||
) |
Removes a user from the game.
Definition at line 1477 of file game.cpp.
References simple_wml::node::add_child(), change_controller(), client_address(), current_turn(), DBG_GAME, debug_player_info(), ERR_GAME, host, id_, is_member(), is_observer(), is_player(), LOG_GAME, name_, notify_new_host(), game_config::images::observer, observers_, owner_, player_connections_, players_, players_not_advanced_, wesnothd::player::PLAYING, gui2::dialogs::tip::remove(), simple_wml::document::root(), send_and_record_server_message(), send_observerquit(), send_server_message_to_all(), wesnothd::send_to_player(), send_user_list(), simple_wml::node::set_attr_dup(), side_controllers_, sides_, started_, termination_reason(), and username().
Referenced by ban_user(), wesnothd::server::handle_player_in_game(), kick_member(), set_current_turn(), and ~game().
|
inline |
Definition at line 320 of file game.hpp.
References controls_side(), game(), is_reload(), last_choice_request_id_, and operator=().
Referenced by wesnothd::server::handle_player_in_game().
|
private |
calculates the initial value for sides_, side_controllerds_, nsides_
Definition at line 444 of file game.cpp.
References get_sides_list(), nsides_, side_controllers_, and sides_.
Referenced by observers_can_chat(), and update_side_data().
void wesnothd::game::save_replay | ( | ) |
Definition at line 1846 of file game.cpp.
References simple_wml::document::child(), DBG_GAME, e, ERR_GAME, get_replay_filename(), h, history_, simple_wml::INIT_STATIC, level_, game::error::message, name_, simple_wml::node_to_string(), filesystem::ostream_file(), simple_wml::document::output(), replay_save_path_, save_replays_, simple_wml::document::set_attr_dup(), started_, and WRN_CONFIG.
Referenced by wesnothd::server::handle_player_in_game(), send_and_record_server_message(), and ~game().
void wesnothd::game::send_and_record_server_message | ( | const char * | message, |
const socket_ptr & | exclude = socket_ptr() |
||
) |
Send data to all players in this game except 'exclude'.
Definition at line 2009 of file game.cpp.
References record_data(), send_data(), send_server_message(), and started_.
Referenced by add_player(), ban_user(), change_controller(), handle_choice(), handle_controller_choice(), kick_member(), mute_all_observers(), mute_observer(), notify_new_host(), perform_controller_tweaks(), process_turn(), process_whiteboard(), remove_player(), send_and_record_server_message(), send_server_message(), start_game(), transfer_side_control(), unban_user(), and unmute_observer().
|
inline |
Definition at line 253 of file game.hpp.
References clear_history(), record_data(), save_replay(), send_and_record_server_message(), and send_data().
void wesnothd::game::send_data | ( | simple_wml::document & | data, |
const socket_ptr & | exclude = socket_ptr() , |
||
std::string | packet_type = "" |
||
) | const |
Definition at line 1683 of file game.cpp.
References all_game_users(), and wesnothd::send_to_players().
Referenced by add_player(), change_controller(), handle_controller_choice(), wesnothd::server::handle_player_in_game(), handle_random_choice(), process_message(), process_turn(), send_and_record_server_message(), send_observerjoins(), send_observerquit(), send_server_message_to_all(), send_user_list(), and transfer_side_control().
|
private |
Referenced by all_observers_muted().
|
private |
sides | a comma sperated list of side numbers to which the package should be sent, |
Definition at line 1708 of file game.cpp.
References DBG_GAME, players_, and wesnothd::send_to_players().
Referenced by all_observers_muted(), process_turn(), and process_whiteboard().
|
private |
Definition at line 1789 of file game.cpp.
References simple_wml::document::compress(), e, h, history_, simple_wml::INIT_STATIC, game::error::message, wesnothd::send_to_player(), and WRN_CONFIG.
Referenced by add_player(), all_observers_muted(), and load_next_scenario().
|
private |
Definition at line 811 of file game.cpp.
References simple_wml::INIT_COMPRESSED, and wesnothd::send_to_player().
Referenced by all_observers_muted(), ban_user(), and kick_member().
|
private |
Definition at line 725 of file game.cpp.
References all_observers_muted_, list_users(), muted_observers_, and send_server_message().
Referenced by all_observers_muted(), and mute_observer().
|
private |
Send [observer] tags of all the observers in the game to the user or everyone if none given.
Definition at line 1757 of file game.cpp.
References simple_wml::node::add_child(), observers_, player_connections_, simple_wml::document::root(), send_data(), wesnothd::send_to_player(), and simple_wml::node::set_attr_dup().
Referenced by add_player(), all_observers_muted(), load_next_scenario(), and start_game().
|
private |
Definition at line 1777 of file game.cpp.
References simple_wml::node::add_child(), player_connections_, simple_wml::document::root(), send_data(), and simple_wml::node::set_attr_dup().
Referenced by all_observers_muted(), remove_player(), and transfer_side_control().
void wesnothd::game::send_server_message | ( | const char * | message, |
const socket_ptr & | sock = socket_ptr() , |
||
simple_wml::document * | doc = nullptr |
||
) | const |
Definition at line 2029 of file game.cpp.
References simple_wml::node::add_child(), wfl::msg(), simple_wml::document::root(), wesnothd::send_to_player(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), and started_.
Referenced by add_player(), ban_user(), wesnothd::server::handle_player_in_game(), kick_member(), mute_observer(), process_turn(), send_and_record_server_message(), send_muted_observers(), send_server_message(), send_server_message_to_all(), transfer_side_control(), unban_user(), and unmute_observer().
|
inline |
Definition at line 245 of file game.hpp.
References send_and_record_server_message(), and send_server_message().
void wesnothd::game::send_server_message_to_all | ( | const char * | message, |
const socket_ptr & | exclude = socket_ptr() |
||
) | const |
Definition at line 2022 of file game.cpp.
References send_data(), and send_server_message().
Referenced by wesnothd::server::handle_player_in_game(), load_next_scenario(), remove_player(), send_server_message_to_all(), and set_current_turn().
|
inline |
Definition at line 238 of file game.hpp.
References send_server_message(), and send_server_message_to_all().
|
private |
Definition at line 382 of file game.cpp.
References owner_, simple_wml::document::root(), wesnothd::send_to_player(), simple_wml::node::set_attr_dup(), and sides_.
Referenced by all_observers_muted(), and take_side().
|
private |
Function to send a list of users to all clients.
Only sends data if the game is initialized but not yet started.
Definition at line 1592 of file game.cpp.
References simple_wml::node::add_child(), all_game_users(), is_observer(), is_owner(), player_connections_, simple_wml::document::root(), send_data(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), and started_.
Referenced by add_player(), observers_can_chat(), and remove_player().
|
inline |
Definition at line 135 of file game.hpp.
References add_player(), all_game_users(), ban_user(), current_turn_, describe_slots(), get_replay_filename(), kick_member(), load_next_scenario(), mute_all_observers(), mute_observer(), game_config::images::observer, perform_controller_tweaks(), process_change_turns_wml(), process_message(), process_turn(), process_whiteboard(), remove_player(), send_server_message_to_all(), start_game(), transfer_side_control(), unban_user(), unmute_observer(), update_game(), and update_side_data().
Referenced by process_change_turns_wml().
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 1913 of file game.cpp.
References description_, password_, and simple_wml::node::set_attr().
Referenced by wesnothd::server::handle_player_in_game(), and level().
|
inline |
Definition at line 287 of file game.hpp.
References name_bans_.
Referenced by wesnothd::server::create_game().
|
inline |
Definition at line 282 of file game.hpp.
References password_.
Referenced by wesnothd::server::create_game().
void wesnothd::game::set_termination_reason | ( | const std::string & | reason | ) |
Definition at line 1921 of file game.cpp.
References termination_.
Referenced by wesnothd::server::handle_player_in_game(), and termination_reason().
void wesnothd::game::start_game | ( | const socket_ptr & | starter | ) |
Definition at line 295 of file game.cpp.
References simple_wml::node::child(), clear_history(), client_address(), current_side_index_, current_turn_, DBG_GAME, debug_sides_info(), wesnothd::get_multiplayer(), get_sides_list(), id_, level_, list_users(), LOG_GAME, wfl::msg(), name_, nsides_, num_turns_, player_connections_, players_, simple_wml::document::root(), save(), send_and_record_server_message(), send_observerjoins(), sides_, started_, starting_pos(), and update_turn_data().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
|
inline |
|
inlinestatic |
Definition at line 88 of file game.hpp.
References simple_wml::node::child().
Referenced by get_replay_filename(), get_sides_list(), wesnothd::server::handle_player_in_game(), and start_game().
|
inlinestatic |
Definition at line 99 of file game.hpp.
References simple_wml::node::child().
|
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 403 of file game.cpp.
References DBG_GAME, get_sides_list(), player_connections_, simple_wml::document::root(), send_taken_side(), simple_wml::node::set_attr_dup(), and started_.
Referenced by add_player(), and all_observers_muted().
|
inline |
Definition at line 302 of file game.hpp.
References handle_add_side_wml(), handle_choice(), handle_controller_choice(), handle_random_choice(), set_termination_reason(), started_, and termination_.
Referenced by wesnothd::server::cleanup_game(), and remove_player().
|
private |
Referenced by all_observers_muted().
void wesnothd::game::transfer_side_control | ( | const socket_ptr & | sock, |
const simple_wml::node & | cfg | ||
) |
Let's a player owning a side give it to another player or observer.
Definition at line 527 of file game.cpp.
References simple_wml::node::add_child(), change_controller(), DBG_GAME, simple_wml::string_span::empty(), gui2::event::find(), find_user(), get_sides_list(), is_member(), is_observer(), is_player(), missing_user(), wfl::msg(), observers_, wesnothd::player::OBSERVING, owner_, player_connections_, players_, wesnothd::player::PLAYING, gui2::dialogs::tip::remove(), simple_wml::document::root(), send_and_record_server_message(), send_data(), send_observerquit(), send_server_message(), simple_wml::node::set_attr_dup(), sides_, simple_wml::string_span::to_string(), and username().
Referenced by wesnothd::server::handle_player_in_game(), process_turn(), and set_current_turn().
void wesnothd::game::unban_user | ( | const simple_wml::node & | unban, |
const socket_ptr & | unbanner | ||
) |
Definition at line 891 of file game.cpp.
References bans_, client_address(), find_user(), id_, LOG_GAME, name_, name_bans_, owner_, player_connections_, player_is_banned(), gui2::dialogs::tip::remove(), send_and_record_server_message(), send_server_message(), simple_wml::string_span::to_string(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::unmute_observer | ( | const simple_wml::node & | unmute, |
const socket_ptr & | unmuter | ||
) |
Definition at line 779 of file game.cpp.
References client_address(), simple_wml::string_span::empty(), find_user(), id_, is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, gui2::dialogs::tip::remove(), send_and_record_server_message(), send_server_message(), simple_wml::string_span::to_string(), and username().
Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().
void wesnothd::game::update_game | ( | ) |
Definition at line 374 of file game.cpp.
References describe_slots(), started_, and update_side_data().
Referenced by set_current_turn().
void wesnothd::game::update_side_data | ( | ) |
Resets the side configuration according to the scenario data.
Definition at line 455 of file game.cpp.
References all_game_users(), DBG_GAME, debug_player_info(), get_sides_list(), missing_user(), observers_, wesnothd::player::OBSERVING, owner_, player_connections_, players_, wesnothd::player::PLAYING, reset_sides(), side_controllers_, sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), perform_controller_tweaks(), set_current_turn(), and update_game().
|
private |
Definition at line 1375 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::child(), current_turn(), description_, num_turns_, and simple_wml::node::set_attr_int().
Referenced by end_turn(), observers_can_chat(), and start_game().
|
private |
Returns the name of the user or "(unfound)".
Definition at line 199 of file game.cpp.
References player_connections_.
Referenced by ban_user(), kick_member(), mute_observer(), notify_new_host(), observers_can_chat(), perform_controller_tweaks(), process_turn(), remove_player(), transfer_side_control(), unban_user(), and unmute_observer().
|
private |
Definition at line 517 of file game.hpp.
Referenced by all_observers_muted(), is_muted_observer(), mute_all_observers(), and send_muted_observers().
|
private |
Definition at line 520 of file game.hpp.
Referenced by ban_user(), player_is_banned(), and unban_user().
|
private |
Definition at line 515 of file game.hpp.
Referenced by current_side(), end_turn(), process_turn(), and start_game().
|
private |
Definition at line 514 of file game.hpp.
Referenced by current_turn(), end_turn(), process_turn(), set_current_turn(), and start_game().
|
private |
Pointer to the game's description in the games_and_users_list_.
Definition at line 512 of file game.hpp.
Referenced by describe_slots(), description(), end_turn(), process_change_turns_wml(), set_description(), and update_turn_data().
|
mutableprivate |
Definition at line 509 of file game.hpp.
Referenced by clear_history(), record_data(), save_replay(), and send_history().
const socket_ptr& wesnothd::game::host |
Definition at line 45 of file game.hpp.
Referenced by remove_player().
|
private |
Definition at line 464 of file game.hpp.
Referenced by add_player(), ban_user(), debug_player_info(), debug_sides_info(), game(), get_replay_filename(), id(), kick_member(), mute_observer(), perform_controller_tweaks(), process_turn(), remove_player(), start_game(), unban_user(), and unmute_observer().
|
private |
Definition at line 534 of file game.hpp.
Referenced by handle_choice(), and reset_last_synced_context_id().
|
private |
The current scenario data.
ยด WRONG! This contains the initial state or the state from which the game was loaded from. Using this to make assumptions about the current gamestate is extremely dangerous and should especially not be done for anything that can be nodified by wml (especially by [modify_side]), like team_name, controller ... in [side]. FIXME: move every code here that uses this object to query those information to the clients. But note that there are some checks (like controller == null) that are definitely needed by the server and in this case we should try to modify the client to inform the server if a change of those properties occur. Ofc we shouldn't update level_ then, but rather store that information in a separate object (like in side_controllers_).
Definition at line 505 of file game.hpp.
Referenced by add_player(), allow_observers(), get_replay_filename(), get_sides_list(), is_reload(), level(), level_init(), load_next_scenario(), registered_users_only(), save_replay(), and start_game().
|
private |
Definition at line 478 of file game.hpp.
Referenced by is_muted_observer(), mute_observer(), send_muted_observers(), and unmute_observer().
const socket_ptr const std::string& wesnothd::game::name = "" |
Definition at line 46 of file game.hpp.
Referenced by wesnothd::server::create_game(), and wesnothd::server::handle_player_in_game().
|
private |
The name of the game.
Definition at line 467 of file game.hpp.
Referenced by add_player(), ban_user(), game(), kick_member(), mute_observer(), name(), remove_player(), save_replay(), start_game(), unban_user(), and unmute_observer().
|
private |
Definition at line 521 of file game.hpp.
Referenced by ban_user(), player_is_banned(), set_name_bans(), and unban_user().
|
private |
Number of sides in the current scenario.
Definition at line 486 of file game.hpp.
Referenced by current_player(), current_side(), end_turn(), handle_add_side_wml(), process_turn(), reset_sides(), and start_game().
|
private |
Definition at line 516 of file game.hpp.
Referenced by process_change_turns_wml(), start_game(), and update_turn_data().
|
private |
A vector of observers (members not owning a side).
Definition at line 477 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().
|
private |
The game host or later owner (if the host left).
Definition at line 471 of file game.hpp.
Referenced by ban_user(), game(), handle_choice(), is_legal_command(), is_owner(), kick_member(), mute_observer(), new_scenario(), notify_new_host(), perform_controller_tweaks(), process_message(), process_turn(), remove_player(), send_taken_side(), transfer_side_control(), unban_user(), unmute_observer(), and update_side_data().
|
private |
Definition at line 468 of file game.hpp.
Referenced by has_password(), password_matches(), set_description(), and set_password().
|
private |
Definition at line 461 of file game.hpp.
Referenced by add_player(), ban_user(), debug_player_info(), find_user(), game(), handle_choice(), has_same_ip(), kick_member(), list_users(), load_next_scenario(), perform_controller_tweaks(), process_message(), process_turn(), process_whiteboard(), remove_player(), send_observerjoins(), send_observerquit(), send_user_list(), start_game(), take_side(), transfer_side_control(), unban_user(), update_side_data(), and username().
|
private |
A vector of players (members owning a side).
Definition at line 474 of file game.hpp.
Referenced by add_player(), all_game_users(), debug_player_info(), game(), is_player(), nplayers(), remove_player(), send_data_sides(), start_game(), transfer_side_control(), and update_side_data().
|
private |
in multiplayer campaigns it can happen that some players are still in the previousl scenario keep track of those players because processing certain input from those side wil lead to error (oos)
Definition at line 525 of file game.hpp.
Referenced by handle_choice(), load_next_scenario(), new_scenario(), and remove_player().
const socket_ptr const std::string bool const std::string& wesnothd::game::replay_save_path = "") |
|
private |
Definition at line 530 of file game.hpp.
Referenced by save_replay().
|
private |
A wrapper for mersenne twister rng which generates randomness for this game.
Definition at line 533 of file game.hpp.
Referenced by handle_random_choice().
const socket_ptr const std::string bool wesnothd::game::save_replays = false |
|
private |
Definition at line 529 of file game.hpp.
Referenced by save_replay().
|
private |
Definition at line 483 of file game.hpp.
Referenced by change_controller(), debug_sides_info(), end_turn(), handle_add_side_wml(), handle_controller_choice(), remove_player(), reset_sides(), and update_side_data().
|
private |
A vector of side owners.
Definition at line 481 of file game.hpp.
Referenced by change_controller(), controls_side(), current_player(), debug_sides_info(), describe_slots(), handle_add_side_wml(), handle_controller_choice(), is_legal_command(), load_next_scenario(), perform_controller_tweaks(), process_turn(), process_whiteboard(), remove_player(), reset_sides(), send_taken_side(), start_game(), transfer_side_control(), and update_side_data().
|
private |
Definition at line 487 of file game.hpp.
Referenced by add_player(), change_controller(), describe_slots(), handle_choice(), load_next_scenario(), new_scenario(), process_change_turns_wml(), process_turn(), process_whiteboard(), remove_player(), save_replay(), send_and_record_server_message(), send_server_message(), send_user_list(), start_game(), started(), take_side(), termination_reason(), update_game(), and update_side_data().
|
private |
Definition at line 527 of file game.hpp.
Referenced by set_termination_reason(), and termination_reason().