#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 |
Checks whether the connection's ip address is banned. More... | |
bool | level_init () const |
const simple_wml::node::child_list & | get_sides_list () const |
bool | started () const |
size_t | nplayers () const |
size_t | nobservers () const |
size_t | current_turn () const |
void | set_current_turn (int turn) |
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, socket_ptr exclude=socket_ptr()) const |
void | send_server_message_to_all (const std::string &message, socket_ptr exclude=socket_ptr()) const |
void | send_server_message (const char *message, socket_ptr sock=socket_ptr(), simple_wml::document *doc=nullptr) const |
void | send_server_message (const std::string &message, 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) |
bool | password_matches (const std::string &passwd) 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 | 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... | |
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 | |
socket_ptr | host |
socket_ptr const std::string & | name ="" |
socket_ptr const std::string bool | save_replays =false |
socket_ptr const std::string bool const std::string & | replay_save_path ="") |
Private Types | |
typedef boost::ptr_vector < simple_wml::document > | t_history |
Replay data. More... | |
Private Member Functions | |
game (const game &) | |
void | operator= (const game &) |
size_t | current_side () 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::child_list::const_iterator 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 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 (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, bool observer) const |
Checks whether a user has the same IP as members of this game. More... | |
bool | end_turn () |
Function which should be called every time a player ends their turn (i.e. More... | |
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... | |
t_history | history_ |
simple_wml::node * | description_ |
Pointer to the game's description in the games_and_users_list_. More... | |
int | end_turn_ |
int | num_turns_ |
bool | all_observers_muted_ |
std::vector< std::string > | bans_ |
std::string | termination_ |
bool | save_replays_ |
std::string | replay_save_path_ |
rand_rng::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 120 of file game.cpp.
References all_game_users(), clear_history(), remove_player(), and save_replay().
|
private |
Definition at line 80 of file game.cpp.
References id_, missing_user(), name_, owner_, player_connections_, players_, and wesnothd::player::PLAYING.
bool wesnothd::game::add_player | ( | const socket_ptr | player, |
bool | observer = false |
||
) |
Add a user to the game.
Definition at line 1165 of file game.cpp.
References simple_wml::node::add_child(), allow_observers(), wesnothd::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().
const user_vector wesnothd::game::all_game_users | ( | ) | const |
Adds players and observers into one vector and returns that.
Definition at line 1586 of file game.cpp.
References observers_, and players_.
Referenced by wesnothd::room_manager::enter_lobby(), has_same_ip(), send_data(), send_user_list(), update_side_data(), and ~game().
|
inlineprivate |
Definition at line 260 of file game.hpp.
References all_observers_muted_.
bool wesnothd::game::allow_observers | ( | ) | const |
Definition at line 145 of file game.cpp.
References wesnothd::get_multiplayer(), level_, and simple_wml::document::root().
Referenced by add_player().
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 767 of file game.cpp.
References bans_, wesnothd::client_address(), find_user(), id_, is_member(), LOG_GAME, name_, 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().
|
private |
Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai).
Definition at line 551 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(), side_controllers_, sides_, and started_.
Referenced by perform_controller_tweaks(), remove_player(), and transfer_side_control().
void wesnothd::game::clear_history | ( | ) |
Definition at line 1563 of file game.cpp.
References history_.
Referenced by start_game(), and ~game().
bool wesnothd::game::controls_side | ( | const std::vector< int > & | sides, |
const socket_ptr | player | ||
) | const |
|
inlineprivate |
Definition at line 255 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 254 of file game.hpp.
References end_turn_, and nsides_.
Referenced by current_player(), end_turn(), process_turn(), and set_current_turn().
|
inline |
Definition at line 91 of file game.hpp.
References end_turn_, and nsides_.
Referenced by end_turn(), process_change_turns_wml(), remove_player(), and save_replay().
|
private |
Helps debugging player and observer lists.
Definition at line 1595 of file game.cpp.
References id_, observers_, player_connections_, and players_.
Referenced by add_player(), remove_player(), and update_side_data().
|
private |
Helps debugging controller tweaks.
Definition at line 1626 of file game.cpp.
References get_sides_list(), id_, side_controllers_, and sides_.
Referenced by load_next_scenario(), perform_controller_tweaks(), and start_game().
bool wesnothd::game::describe_slots | ( | ) |
Set the description to the number of available slots.
Definition at line 604 of file game.cpp.
References description_, get_sides_list(), i, simple_wml::node::set_attr_dup(), sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game(), and update_game().
|
inline |
Definition at line 223 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 1138 of file game.cpp.
References current_side(), current_turn(), description_, end_turn_, i, nsides_, num_turns_, simple_wml::node::set_attr_dup(), and side_controllers_.
Referenced by process_turn(), and start_game().
|
private |
Shortcut to a convenience function for finding a user by name.
Definition at line 1642 of file game.cpp.
References gui2::event::find(), player_connections_, and simple_wml::string_span::to_string().
Referenced by ban_user(), kick_member(), mute_observer(), transfer_side_control(), unban_user(), and unmute_observer().
|
inline |
Definition at line 83 of file game.hpp.
References level_, simple_wml::document::root(), and starting_pos().
Referenced by debug_sides_info(), describe_slots(), perform_controller_tweaks(), reset_sides(), start_game(), take_side(), transfer_side_control(), and update_side_data().
void wesnothd::game::handle_choice | ( | const simple_wml::node & | data, |
const socket_ptr | user | ||
) |
Definition at line 1059 of file game.cpp.
References simple_wml::node::child(), DBG_GAME, handle_controller_choice(), handle_random_choice(), is_player(), last_choice_request_id_, owner_, player_connections_, send_and_record_server_message(), and started_.
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::handle_controller_choice | ( | const simple_wml::node & | data | ) |
Definition at line 1011 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(), side_controllers_, and sides_.
Referenced by handle_choice().
void wesnothd::game::handle_random_choice | ( | const simple_wml::node & | data | ) |
Definition at line 993 of file game.cpp.
References simple_wml::node::add_child(), rand_rng::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().
|
private |
Checks whether a user has the same IP as members of this game.
If observer is true it only checks against players.
Definition at line 1432 of file game.cpp.
References all_game_users(), wesnothd::client_address(), i, player_connections_, and players_.
Referenced by add_player().
|
inline |
Definition at line 51 of file game.hpp.
References id_.
Referenced by wesnothd::server::cleanup_game(), wesnothd::server::handle_player_in_game(), and wesnothd::game_id_matches::operator()().
|
inlineprivate |
Definition at line 257 of file game.hpp.
References current_player().
Referenced by is_legal_command(), and process_turn().
|
private |
Definition at line 845 of file game.cpp.
References simple_wml::node::child(), simple_wml::node::has_attr(), is_current_player(), is_player(), simple_wml::node::one_child(), owner_, and sides_.
Referenced by process_turn().
|
inline |
Definition at line 55 of file game.hpp.
References is_observer(), and is_player().
Referenced by add_player(), ban_user(), kick_member(), wesnothd::game_is_member::operator()(), remove_player(), and transfer_side_control().
|
private |
Definition at line 157 of file game.cpp.
References all_observers_muted_, gui2::event::find(), is_observer(), and muted_observers_.
Referenced by mute_observer(), process_turn(), and unmute_observer().
bool wesnothd::game::is_observer | ( | const socket_ptr | player | ) | const |
Definition at line 153 of file game.cpp.
References gui2::event::find(), and observers_.
Referenced by is_member(), is_muted_observer(), mute_observer(), remove_player(), transfer_side_control(), and unmute_observer().
|
inline |
Definition at line 54 of file game.hpp.
References owner_.
Referenced by wesnothd::server::handle_player_in_game(), and wesnothd::game_is_member::operator()().
bool wesnothd::game::is_player | ( | const socket_ptr | player | ) | const |
Definition at line 168 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().
socket_ptr wesnothd::game::kick_member | ( | const simple_wml::node & | kick, |
const socket_ptr | kicker | ||
) |
Kick a member by name.
Definition at line 736 of file game.cpp.
References wesnothd::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().
|
inline |
The full scenario data.
Definition at line 216 of file game.hpp.
References level_.
Referenced by wesnothd::server::create_game(), and wesnothd::server::handle_player_in_game().
|
inline |
Definition at line 64 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 197 of file game.cpp.
References missing_user(), and player_connections_.
Referenced by 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 1338 of file game.cpp.
References simple_wml::node::add_child(), simple_wml::node::copy_into(), DBG_GAME, debug_sides_info(), level_, player_connections_, 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().
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 74 of file game.cpp.
References id_, name_, and WRN_GAME.
Referenced by game(), list_users(), perform_controller_tweaks(), transfer_side_control(), and update_side_data().
void wesnothd::game::mute_all_observers | ( | ) |
Definition at line 636 of file game.cpp.
References all_observers_muted_, and send_and_record_server_message().
Referenced by wesnothd::server::handle_player_in_game().
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 656 of file game.cpp.
References wesnothd::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().
|
inline |
|
inline |
Definition at line 90 of file game.hpp.
References observers_.
|
private |
In case of a host transfer, notify the new host about its status.
Definition at line 594 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 remove_player().
|
inline |
Definition at line 89 of file game.hpp.
References players_.
Referenced by wesnothd::server::handle_player_in_game().
|
inlineprivate |
|
inlineprivate |
|
inline |
void wesnothd::game::perform_controller_tweaks | ( | ) |
Definition at line 212 of file game.cpp.
References change_controller(), DBG_GAME, debug_sides_info(), get_sides_list(), id_, LOG_GAME, missing_user(), game_logic::msg(), owner_, player_connections_, send_and_record_server_message(), sides_, update_side_data(), and username().
Referenced by wesnothd::server::handle_player_in_game().
bool wesnothd::game::player_is_banned | ( | const socket_ptr | player | ) | const |
Checks whether the connection's ip address is banned.
Definition at line 630 of file game.cpp.
References bans_, wesnothd::client_address(), and gui2::event::find().
Referenced by ban_user(), 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 1118 of file game.cpp.
References simple_wml::document::child(), current_turn(), description_, is_player(), num_turns_, simple_wml::node::set_attr_dup(), set_current_turn(), and started_.
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::process_message | ( | simple_wml::document & | data, |
const socket_ptr | user | ||
) |
Definition at line 830 of file game.cpp.
References simple_wml::node::child(), ERR_GAME, game_logic::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().
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 886 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(), DBG_GAME, end_turn(), end_turn_, gui2::event::find(), id_, is_current_player(), is_legal_command(), is_muted_observer(), is_player(), LOG_GAME, game_logic::msg(), simple_wml::node::no_children(), simple_wml::node_to_string(), nsides_, game_config::observer_team_name, observers_, player_connections_, record_data(), simple_wml::node::remove_child(), simple_wml::document::root(), send_and_record_server_message(), send_data(), send_data_sides(), send_server_message(), wesnothd::send_to_players(), simple_wml::node::set_attr_dup(), sides_, started_, wesnothd::chat_message::truncate_message(), and username().
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::process_whiteboard | ( | simple_wml::document & | data, |
const socket_ptr | user | ||
) |
Handles incoming [whiteboard] data.
Definition at line 1093 of file game.cpp.
References simple_wml::document::child(), is_player(), LOG_GAME, game_logic::msg(), player_connections_, send_and_record_server_message(), send_data_sides(), sides_, and started_.
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::record_data | ( | simple_wml::document * | data | ) |
Definition at line 1558 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 149 of file game.cpp.
References wesnothd::get_multiplayer(), level_, and simple_wml::document::root().
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 1234 of file game.cpp.
References change_controller(), wesnothd::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_, wesnothd::player::PLAYING, schema_validation::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(), side_controllers_, sides_, started_, termination_reason(), and username().
Referenced by ban_user(), wesnothd::server::handle_player_in_game(), kick_member(), and ~game().
|
inline |
Definition at line 244 of file game.hpp.
References last_choice_request_id_.
Referenced by wesnothd::server::handle_player_in_game().
|
private |
calculates the initial value for sides_, side_controllerds_, nsides_
Definition at line 391 of file game.cpp.
References get_sides_list(), nsides_, side_controllers_, and sides_.
Referenced by update_side_data().
void wesnothd::game::save_replay | ( | ) |
Definition at line 1506 of file game.cpp.
References simple_wml::document::child(), current_turn(), DBG_GAME, e, ERR_GAME, history_, i, id_, simple_wml::INIT_STATIC, wesnothd::is_invalid_filename_char(), level_, game::error::message, name(), name_, simple_wml::node_to_string(), filesystem::ostream_file(), simple_wml::document::output(), utils::replace(), replay_save_path_, simple_wml::document::root(), save_replays_, simple_wml::document::set_attr_dup(), started_, starting_pos(), and WRN_CONFIG.
Referenced by wesnothd::server::handle_player_in_game(), 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 1651 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(), start_game(), transfer_side_control(), unban_user(), and unmute_observer().
|
inline |
Definition at line 204 of file game.hpp.
References send_and_record_server_message().
void wesnothd::game::send_data | ( | simple_wml::document & | data, |
const socket_ptr | exclude = socket_ptr() , |
||
std::string | packet_type = "" |
||
) | const |
Definition at line 1384 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 |
|
private |
sides | a comma sperated list of side numbers to which the package should be sent, |
Definition at line 1408 of file game.cpp.
References DBG_GAME, players_, and wesnothd::send_to_players().
Referenced by process_turn(), and process_whiteboard().
|
private |
Definition at line 1472 of file game.cpp.
References simple_wml::document::compress(), e, history_, i, simple_wml::INIT_STATIC, game::error::message, wesnothd::send_to_player(), and WRN_CONFIG.
Referenced by add_player(), and load_next_scenario().
|
private |
Definition at line 730 of file game.cpp.
References simple_wml::INIT_COMPRESSED, and wesnothd::send_to_player().
Referenced by ban_user(), and kick_member().
|
private |
Definition at line 645 of file game.cpp.
References all_observers_muted_, list_users(), muted_observers_, and send_server_message().
Referenced by mute_observer().
|
private |
Send [observer] tags of all the observers in the game to the user or everyone if none given.
Definition at line 1447 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(), load_next_scenario(), and start_game().
|
private |
Definition at line 1463 of file game.cpp.
References simple_wml::node::add_child(), player_connections_, simple_wml::document::root(), send_data(), and simple_wml::node::set_attr().
Referenced by remove_player(), and transfer_side_control().
void wesnothd::game::send_server_message | ( | const char * | message, |
socket_ptr | sock = socket_ptr() , |
||
simple_wml::document * | doc = nullptr |
||
) | const |
Definition at line 1667 of file game.cpp.
References simple_wml::node::add_child(), game_logic::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 197 of file game.hpp.
References send_server_message().
void wesnothd::game::send_server_message_to_all | ( | const char * | message, |
socket_ptr | exclude = socket_ptr() |
||
) | const |
Definition at line 1660 of file game.cpp.
References send_data(), and send_server_message().
Referenced by wesnothd::server::handle_player_in_game(), load_next_scenario(), remove_player(), and send_server_message_to_all().
|
inline |
Definition at line 191 of file game.hpp.
References send_server_message_to_all().
|
private |
Definition at line 347 of file game.cpp.
References owner_, simple_wml::document::root(), wesnothd::send_to_player(), simple_wml::node::set_attr_dup(), and sides_.
Referenced by 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 1319 of file game.cpp.
References simple_wml::node::add_child(), all_game_users(), description_, player_connections_, simple_wml::document::root(), send_data(), simple_wml::node::set_attr(), and started_.
Referenced by add_player(), and remove_player().
Definition at line 92 of file game.hpp.
References current_side(), end_turn_, and nsides_.
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 1568 of file game.cpp.
References description_, password_, and simple_wml::node::set_attr().
Referenced by wesnothd::server::handle_player_in_game().
|
inline |
Definition at line 225 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 1575 of file game.cpp.
References termination_.
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::start_game | ( | const socket_ptr | starter | ) |
Definition at line 271 of file game.cpp.
References simple_wml::node::child(), clear_history(), wesnothd::client_address(), DBG_GAME, debug_sides_info(), end_turn(), end_turn_, wesnothd::get_multiplayer(), get_sides_list(), id_, level_, list_users(), LOG_GAME, game_logic::msg(), name_, nsides_, num_turns_, player_connections_, players_, simple_wml::document::root(), save(), send_and_record_server_message(), send_observerjoins(), sides_, started_, and starting_pos().
Referenced by wesnothd::server::handle_player_in_game().
|
inline |
Definition at line 87 of file game.hpp.
References started_.
Referenced by wesnothd::server::handle_player_in_game().
|
inlinestatic |
Definition at line 65 of file game.hpp.
References simple_wml::node::child().
Referenced by get_sides_list(), wesnothd::server::handle_player_in_game(), save_replay(), and start_game().
|
inlinestatic |
Definition at line 74 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 361 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().
|
inline |
Definition at line 230 of file game.hpp.
References started_, and termination_.
Referenced by wesnothd::server::cleanup_game(), and remove_player().
|
private |
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 464 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(), game_logic::msg(), observers_, wesnothd::player::OBSERVING, owner_, player_connections_, players_, wesnothd::player::PLAYING, schema_validation::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().
void wesnothd::game::unban_user | ( | const simple_wml::node & | unban, |
const socket_ptr | unbanner | ||
) |
Definition at line 805 of file game.cpp.
References bans_, wesnothd::client_address(), find_user(), id_, LOG_GAME, name_, owner_, player_connections_, player_is_banned(), schema_validation::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().
void wesnothd::game::unmute_observer | ( | const simple_wml::node & | unmute, |
const socket_ptr | unmuter | ||
) |
Definition at line 696 of file game.cpp.
References wesnothd::client_address(), simple_wml::string_span::empty(), find_user(), id_, is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, schema_validation::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().
void wesnothd::game::update_game | ( | ) |
Definition at line 338 of file game.cpp.
References describe_slots(), description_, simple_wml::node::set_attr(), started_, and update_side_data().
Referenced by wesnothd::server::handle_player_in_game().
void wesnothd::game::update_side_data | ( | ) |
Resets the side configuration according to the scenario data.
Definition at line 400 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(), and update_game().
|
private |
Returns the name of the user or "(unfound)".
Definition at line 187 of file game.cpp.
References player_connections_.
Referenced by ban_user(), kick_member(), mute_observer(), notify_new_host(), perform_controller_tweaks(), process_turn(), remove_player(), transfer_side_control(), unban_user(), and unmute_observer().
|
private |
Definition at line 403 of file game.hpp.
Referenced by all_observers_muted(), is_muted_observer(), mute_all_observers(), and send_muted_observers().
|
private |
Definition at line 405 of file game.hpp.
Referenced by ban_user(), player_is_banned(), and unban_user().
|
private |
Pointer to the game's description in the games_and_users_list_.
Definition at line 399 of file game.hpp.
Referenced by describe_slots(), description(), end_turn(), process_change_turns_wml(), send_user_list(), set_description(), and update_game().
|
private |
Definition at line 401 of file game.hpp.
Referenced by current_side(), current_turn(), end_turn(), process_turn(), set_current_turn(), and start_game().
|
mutableprivate |
Definition at line 396 of file game.hpp.
Referenced by clear_history(), record_data(), save_replay(), and send_history().
socket_ptr wesnothd::game::host |
Definition at line 46 of file game.hpp.
Referenced by remove_player().
|
private |
Definition at line 351 of file game.hpp.
Referenced by add_player(), ban_user(), debug_player_info(), debug_sides_info(), game(), id(), kick_member(), missing_user(), mute_observer(), perform_controller_tweaks(), process_turn(), remove_player(), save_replay(), start_game(), unban_user(), and unmute_observer().
|
private |
Definition at line 414 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 seperate object (like in side_controllers_).
Definition at line 392 of file game.hpp.
Referenced by add_player(), allow_observers(), get_sides_list(), level(), level_init(), load_next_scenario(), registered_users_only(), save_replay(), and start_game().
|
private |
Definition at line 365 of file game.hpp.
Referenced by is_muted_observer(), mute_observer(), send_muted_observers(), and unmute_observer().
socket_ptr const std::string& wesnothd::game::name ="" |
Definition at line 47 of file game.hpp.
Referenced by wesnothd::server::handle_player_in_game().
|
private |
The name of the game.
Definition at line 354 of file game.hpp.
Referenced by add_player(), ban_user(), game(), kick_member(), missing_user(), mute_observer(), name(), remove_player(), save_replay(), start_game(), unban_user(), and unmute_observer().
|
private |
Number of sides in the current scenario.
Definition at line 373 of file game.hpp.
Referenced by current_player(), current_side(), current_turn(), end_turn(), process_turn(), reset_sides(), set_current_turn(), and start_game().
|
private |
Definition at line 402 of file game.hpp.
Referenced by end_turn(), process_change_turns_wml(), and start_game().
|
private |
A vector of observers (members not owning a side).
Definition at line 364 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 358 of file game.hpp.
Referenced by ban_user(), game(), handle_choice(), is_legal_command(), is_owner(), kick_member(), mute_observer(), notify_new_host(), perform_controller_tweaks(), process_message(), remove_player(), send_taken_side(), transfer_side_control(), unban_user(), unmute_observer(), and update_side_data().
|
private |
Definition at line 355 of file game.hpp.
Referenced by password_matches(), set_description(), and set_password().
|
private |
Definition at line 348 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 361 of file game.hpp.
Referenced by add_player(), all_game_users(), debug_player_info(), game(), has_same_ip(), is_player(), nplayers(), remove_player(), send_data_sides(), start_game(), transfer_side_control(), and update_side_data().
socket_ptr const std::string bool const std::string& wesnothd::game::replay_save_path ="") |
|
private |
Definition at line 410 of file game.hpp.
Referenced by save_replay().
|
private |
A wrapper for mersenne twister rng which generates randomness for this game.
Definition at line 413 of file game.hpp.
Referenced by handle_random_choice().
socket_ptr const std::string bool wesnothd::game::save_replays =false |
|
private |
Definition at line 409 of file game.hpp.
Referenced by save_replay().
|
private |
Definition at line 370 of file game.hpp.
Referenced by change_controller(), debug_sides_info(), end_turn(), handle_controller_choice(), remove_player(), reset_sides(), and update_side_data().
|
private |
A vector of side owners.
Definition at line 368 of file game.hpp.
Referenced by change_controller(), controls_side(), current_player(), debug_sides_info(), describe_slots(), 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 374 of file game.hpp.
Referenced by add_player(), change_controller(), describe_slots(), handle_choice(), load_next_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 407 of file game.hpp.
Referenced by set_termination_reason(), and termination_reason().