The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wesnothd::game Class Reference

#include <game.hpp>

Public Member Functions

 game (wesnothd::server &server, player_connections &player_connections, player_iterator host, const std::string &name="", bool save_replays=false, const std::string &replay_save_path="")
 
 ~game ()
 
int id () const
 This ID is reused between scenarios of MP campaigns. More...
 
int db_id () const
 This ID is not reused between scenarios of MP campaigns. More...
 
void next_db_id ()
 Increments the ID used when running database queries. More...
 
const std::string & name () const
 
bool is_owner (player_iterator player) const
 
bool is_member (player_iterator player) const
 
bool allow_observers () const
 
bool is_observer (player_iterator player) const
 
bool is_player (player_iterator player) const
 
bool player_is_banned (player_iterator player, const std::string &name) const
 
void new_scenario (player_iterator sender)
 When the host sends the new scenario of a mp campaign. More...
 
bool level_init () const
 
const simple_wml::node::child_listget_sides_list () const
 
bool started () const
 
std::size_t nplayers () const
 
std::size_t nobservers () const
 
std::size_t current_turn () const
 
std::string get_replay_filename ()
 
void mute_all_observers ()
 Toggles whether all observers are muted or not. More...
 
void mute_observer (const simple_wml::node &mute, player_iterator 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, player_iterator unmuter)
 Unmute an observer or unmute all currently muted observers if no name is given. More...
 
utils::optional< player_iteratorkick_member (const simple_wml::node &kick, player_iterator kicker)
 Kick a user from this game by name. More...
 
utils::optional< player_iteratorban_user (const simple_wml::node &ban, player_iterator banner)
 Ban a user by name. More...
 
void unban_user (const simple_wml::node &unban, player_iterator unbanner)
 Unban a user by name. More...
 
bool add_player (player_iterator player, bool observer=false)
 Add a user to the game. More...
 
bool remove_player (player_iterator player, const bool disconnect=false, const bool destruct=false)
 Removes a user from the game. More...
 
const user_vector all_game_users () const
 
void start_game (player_iterator starter)
 Starts the game (if a new game) or starts the next scenario of an MP campaign. More...
 
void perform_controller_tweaks ()
 This is performed just before starting and before the [start_game] signal. More...
 
void load_next_scenario (player_iterator user)
 A user 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 (player_iterator player, const simple_wml::node &cfg)
 Lets a player owning a side give it to another player or observer. More...
 
void process_message (simple_wml::document &data, player_iterator user)
 Sends an ingame message to all other players. More...
 
bool process_turn (simple_wml::document &data, player_iterator user)
 Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data. More...
 
void process_whiteboard (simple_wml::document &data, player_iterator user)
 Handles incoming [whiteboard] data. More...
 
void process_change_turns_wml (simple_wml::document &data, player_iterator 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, utils::optional< player_iterator > exclude={})
 Sends a message to all players in this game that aren't excluded. More...
 
void send_server_message_to_all (const std::string &message, utils::optional< player_iterator > exclude={})
 send_server_message_to_all More...
 
void send_server_message (const char *message, utils::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
 Send a server message to the specified player. More...
 
void send_server_message (const std::string &message, utils::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
 send_server_message More...
 
void send_and_record_server_message (const char *message, utils::optional< player_iterator > exclude={})
 Send data to all players in this game except 'exclude'. More...
 
void send_and_record_server_message (const std::string &message, utils::optional< player_iterator > exclude={})
 send_and_record_server_message More...
 
template<typename Container >
void send_to_players (simple_wml::document &data, const Container &players, utils::optional< player_iterator > exclude={})
 Send data to all players except those excluded. More...
 
void send_data (simple_wml::document &data, utils::optional< player_iterator > exclude={})
 Send data to all players and observers except those excluded. More...
 
void clear_history ()
 Clears the history of recorded WML documents. More...
 
void clear_chat_history ()
 Clears the history of recorded chat WML documents. More...
 
void record_data (std::unique_ptr< simple_wml::document > data)
 Records a WML document in the game's history. More...
 
void save_replay ()
 Move the level information and recorded history into a replay file and save it. More...
 
simple_wml::documentlevel ()
 
void set_description (simple_wml::node *desc)
 Set the game's description. More...
 
simple_wml::nodedescription () const
 
void set_password (const std::string &passwd)
 Sets the password required to access the game. More...
 
void set_name_bans (const std::vector< std::string > name_bans)
 Set a list of usernames that should all be banned from joining the game. More...
 
bool password_matches (const std::string &passwd) const
 
bool has_password () const
 
const std::string & termination_reason () const
 Provides the reason the game was ended. More...
 
void set_termination_reason (const std::string &reason)
 Sets the termination reason for this game. More...
 
void handle_choice (const simple_wml::node &data, player_iterator user)
 Handle a choice requested by a client, such as changing a side's controller, if initiated by WML/lua. More...
 
void handle_random_choice ()
 Send a randomly generated number to the requestor. More...
 
void handle_controller_choice (const simple_wml::node &data)
 Handle a request to change a side's controller. More...
 
void handle_add_side_wml ()
 Adds a new, empty side owned by no one. More...
 
void reset_last_synced_context_id ()
 Reset the internal counter for choice requests made by clients to the server. More...
 
bool controls_side (const std::vector< int > &sides, player_iterator player) const
 Function which returns true if 'player' controls any of the sides specified in 'sides'. More...
 
bool is_reload () const
 
void emergency_cleanup ()
 

Static Public Member Functions

static simple_wml::nodestarting_pos (simple_wml::node &data)
 The non-const version. More...
 
static const simple_wml::nodestarting_pos (const simple_wml::node &data)
 The const version. More...
 

Private Member Functions

 game (const game &)=delete
 
gameoperator= (const game &)=delete
 
std::size_t current_side () const
 
utils::optional< player_iteratorcurrent_player () const
 
bool is_current_player (player_iterator player) const
 
bool is_muted_observer (player_iterator player) const
 
bool all_observers_muted () const
 
void send_muted_observers (player_iterator user) const
 Sends a message either stating that all observers are muted or listing the observers that are muted. More...
 
bool send_taken_side (simple_wml::document &cfg, const simple_wml::node *side) const
 Tell the host who owns a side. More...
 
bool take_side (player_iterator user)
 Figures out which side to take and tells that side to the game owner. More...
 
void change_controller (const std::size_t side_index, player_iterator player, 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...
 
std::unique_ptr< simple_wml::documentchange_controller_type (const std::size_t side_index, player_iterator player, const std::string &player_name)
 Tell everyone else but the source player that the controller type changed. More...
 
void send_leave_game (player_iterator user) const
 Tells a player to leave the game. More...
 
void send_data_sides (simple_wml::document &data, const simple_wml::string_span &sides, utils::optional< player_iterator > exclude={})
 Sends a document to the provided list of sides. More...
 
void send_observerjoins (utils::optional< player_iterator > player={})
 Send a document per observer in the game. More...
 
void send_observerquit (player_iterator observer)
 
void send_history (player_iterator sock) const
 
void send_chat_history (player_iterator sock) const
 
void notify_new_host ()
 In case of a host transfer, notify the new host about its status. More...
 
utils::optional< player_iteratorfind_user (const simple_wml::string_span &name)
 Shortcut to a convenience function for finding a user by name. More...
 
bool is_legal_command (const simple_wml::node &command, player_iterator user)
 
std::string has_same_ip (player_iterator 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 ()
 Set or update the current and max turn values in the game's description. More...
 
void send_user_list (utils::optional< player_iterator > exclude={})
 Function to send a list of users to all clients. More...
 
std::string username (player_iterator pl) const
 
std::string list_users (user_vector users) const
 
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

wesnothd::serverserver
 The wesnothd server instance this game exists on. More...
 
player_connectionsplayer_connections_
 
int id_
 This game's ID within wesnothd. More...
 
int db_id_
 Used for unique identification of games played in the database. More...
 
std::string name_
 The name of the game. More...
 
std::string password_
 The password needed to join the game. More...
 
player_iterator 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_
 A vector of muted observers. More...
 
side_vector sides_
 A vector of side owners. More...
 
std::vector< side_controller::type > side_controllers_
 A vector containiner the controller type for each side. More...
 
int nsides_
 Number of sides in the current scenario. More...
 
bool started_
 Whether the game has been started or not. More...
 
simple_wml::document level_
 The current scenario data. More...
 
std::vector< std::unique_ptr< simple_wml::document > > history_
 Replay data. More...
 
std::vector< std::unique_ptr< simple_wml::document > > chat_history_
 Replay chat history data. More...
 
simple_wml::nodedescription_
 Pointer to the game's description in the games_and_users_list_. More...
 
int current_turn_
 The game's current turn. More...
 
int current_side_index_
 The index of the current side. More...
 
int num_turns_
 The maximum number of turns before the game ends. More...
 
bool all_observers_muted_
 Whether all observers should be treated as muted. More...
 
std::vector< std::string > bans_
 List of banned IPs. More...
 
std::vector< std::string > name_bans_
 List of banned usernames. More...
 
std::set< const player_record * > players_not_advanced_
 in multiplayer campaigns it can happen that some players are still in the previous scenario keep track of those players because processing certain input from those side wil lead to error (oos) More...
 
std::string termination_
 The reason the game ended. More...
 
bool save_replays_
 Whether to save a replay of this game. More...
 
std::string replay_save_path_
 Where to save the replay of this game. More...
 
randomness::mt_rng rng_
 A wrapper for mersenne twister rng which generates randomness for this game. More...
 
int last_choice_request_id_
 The ID of the last request received from a client. More...
 

Static Private Attributes

static int id_num = 1
 Incremented to retrieve a unique ID for game instances within wesnothd. More...
 
static int db_id_num = 1
 Incremented to retrieve a unique ID per wesnothd instance for game instances within the database. More...
 

Detailed Description

Definition at line 35 of file game.hpp.

Constructor & Destructor Documentation

◆ game() [1/2]

wesnothd::game::game ( wesnothd::server server,
player_connections player_connections,
player_iterator  host,
const std::string &  name = "",
bool  save_replays = false,
const std::string &  replay_save_path = "" 
)

Definition at line 75 of file game.cpp.

References id_, name_, owner_, players_, and wesnothd::player::PLAYING.

◆ ~game()

wesnothd::game::~game ( )

◆ game() [2/2]

wesnothd::game::game ( const game )
privatedelete

Member Function Documentation

◆ add_player()

bool wesnothd::game::add_player ( player_iterator  player,
bool  observer = false 
)

Add a user to the game.

Todo:
differentiate between "observers not allowed" and "player already in the game" errors. maybe return a string with an error message.
Parameters
playerThe player to add.
observerWhether to add the player as an observer.
Returns
True if the user successfully joined the game, false otherwise.

Definition at line 1353 of file game.cpp.

References simple_wml::node::add_child(), allow_observers(), db_id_, DBG_GAME, debug_player_info(), ERR_GAME, has_same_ip(), id_, simple_wml::INIT_COMPRESSED, is_member(), level_, LOG_GAME, wesnothd::player::name(), name_, game_config::images::observer, observers_, wesnothd::player::OBSERVING, players_, wesnothd::player::PLAYING, simple_wml::document::root(), send_and_record_server_message(), send_chat_history(), send_data(), send_history(), send_observerjoins(), send_server_message(), wesnothd::server::send_to_player(), send_user_list(), simple_wml::node::set_attr_dup(), started_, and take_side().

◆ all_game_users()

const user_vector wesnothd::game::all_game_users ( ) const
Returns
A vector containing all players and observers currently in this game.

Definition at line 1888 of file game.cpp.

References observers_, and players_.

Referenced by has_same_ip(), new_scenario(), send_data(), send_user_list(), update_side_data(), and ~game().

◆ all_observers_muted()

bool wesnothd::game::all_observers_muted ( ) const
inlineprivate
Returns
True if all observers have been muted via that command (not if each individual observer happens to have been manually muted).

Definition at line 634 of file game.hpp.

References all_observers_muted_.

◆ allow_observers()

bool wesnothd::game::allow_observers ( ) const
Returns
Whether observers are allowed to join.

Definition at line 146 of file game.cpp.

References wesnothd::get_multiplayer(), level_, and simple_wml::document::root().

Referenced by add_player().

◆ ban_user()

utils::optional< player_iterator > wesnothd::game::ban_user ( const simple_wml::node ban,
player_iterator  banner 
)

Ban a user by name.

The user does not need to be in this game but logged in.

Parameters
banThe user to ban.
bannerThe player doing the banning.
Returns
The iterator to the banned player if he was in this game, empty optional otherwise.

Definition at line 805 of file game.cpp.

References bans_, db_id_, find_user(), id_, is_member(), LOG_GAME, name_, name_bans_, owner_, player_is_banned(), remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), and username().

◆ change_controller()

void wesnothd::game::change_controller ( const std::size_t  side_index,
player_iterator  player,
const std::string &  player_name,
const bool  player_left = true 
)
private

Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai).

Parameters
side_indexThe index of the side whose controller is changing.
playerThe player who is taking control of the side.
player_nameThe name of the player who is taking control of the side.
player_leftWe use the "player_left" field as follows. Normally change_controller sends one message to the owner, and one message to everyone else. In case that a player drops, the owner is gone and should not get a message, instead the host gets a [side_drop] message.

Definition at line 574 of file game.cpp.

References change_controller_type(), DBG_GAME, record_data(), send_and_record_server_message(), wesnothd::server::send_to_player(), side_controllers_, sides_, and started_.

Referenced by perform_controller_tweaks(), remove_player(), and transfer_side_control().

◆ change_controller_type()

std::unique_ptr< simple_wml::document > wesnothd::game::change_controller_type ( const std::size_t  side_index,
player_iterator  player,
const std::string &  player_name 
)
private

Tell everyone else but the source player that the controller type changed.

Parameters
side_indexThe index of the side whose controller type is changing.
playerThe player who owns the side whose controller type is changing.
player_nameThe name of the player who owns the side whose controller type is changing.
Returns
The document that was sent to all other players.

Definition at line 606 of file game.cpp.

References simple_wml::node::add_child(), simple_wml::document::clone(), string_enums::enum_base< Definition >::get_string(), simple_wml::document::root(), send_data(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), and side_controllers_.

Referenced by change_controller(), and transfer_side_control().

◆ clear_chat_history()

void wesnothd::game::clear_chat_history ( )

Clears the history of recorded chat WML documents.

Definition at line 1861 of file game.cpp.

References chat_history_.

Referenced by start_game().

◆ clear_history()

void wesnothd::game::clear_history ( )

Clears the history of recorded WML documents.

Definition at line 1856 of file game.cpp.

References history_.

Referenced by start_game(), and ~game().

◆ controls_side()

bool wesnothd::game::controls_side ( const std::vector< int > &  sides,
player_iterator  player 
) const

Function which returns true if 'player' controls any of the sides specified in 'sides'.

Parameters
sidesThe list of sides in this game.
playerThe player being checked for whether they own any sides.

Definition at line 1666 of file game.cpp.

References sides_.

◆ current_player()

utils::optional<player_iterator> wesnothd::game::current_player ( ) const
inlineprivate
Returns
The player who owns the current side.

Definition at line 611 of file game.hpp.

References current_side(), and sides_.

Referenced by handle_controller_choice(), is_current_player(), and process_turn().

◆ current_side()

std::size_t wesnothd::game::current_side ( ) const
inlineprivate
Returns
0 if there are no sides, or the current side index otherwise.

Definition at line 603 of file game.hpp.

References current_side_index_, and nsides_.

Referenced by current_player(), end_turn(), and process_turn().

◆ current_turn()

std::size_t wesnothd::game::current_turn ( ) const
inline
Returns
This game's current turn.

Definition at line 211 of file game.hpp.

References current_turn_.

Referenced by get_replay_filename(), process_change_turns_wml(), remove_player(), and update_turn_data().

◆ db_id()

int wesnothd::game::db_id ( ) const
inline

This ID is not reused between scenarios of MP campaigns.

This ID resets when wesnothd is restarted. This is generally used during database queries.

Returns
an ID that uniquely identifies the game within the currently running wesnothd instance.

Definition at line 64 of file game.hpp.

References db_id_.

Referenced by wesnothd::server::cleanup_game().

◆ debug_player_info()

std::string wesnothd::game::debug_player_info ( ) const
private

Helps debugging player and observer lists.

Returns
A string listing the game IDs, players, and observers.

Definition at line 1898 of file game.cpp.

References db_id_, id_, observers_, and players_.

Referenced by add_player(), remove_player(), and update_side_data().

◆ debug_sides_info()

std::string wesnothd::game::debug_sides_info ( ) const
private

Helps debugging controller tweaks.

Returns
A string listing the game IDs and side information.

Definition at line 1914 of file game.cpp.

References db_id_, get_sides_list(), string_enums::enum_base< Definition >::get_string(), id_, s, and side_controllers_.

Referenced by load_next_scenario(), perform_controller_tweaks(), and start_game().

◆ describe_slots()

bool wesnothd::game::describe_slots ( )

Set the description to the number of available slots.

Returns
True if the number of slots has changed.

Definition at line 633 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_.

◆ description()

simple_wml::node* wesnothd::game::description ( ) const
inline
Returns
The node containing the game's current description.

Definition at line 480 of file game.hpp.

References description_.

Referenced by wesnothd::server::cleanup_game().

◆ emergency_cleanup()

void wesnothd::game::emergency_cleanup ( )
inline

Definition at line 589 of file game.hpp.

References observers_, and players_.

Referenced by wesnothd::server::cleanup_game().

◆ end_turn()

bool wesnothd::game::end_turn ( int  new_side)
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.

Parameters
new_sideThe side number whose turn to move it has become.
Returns
True if the current side and-or current turn values have been updated, false otherwise.

Definition at line 1306 of file game.cpp.

References current_side(), current_side_index_, current_turn_, description_, i, nsides_, side_controllers_, and update_turn_data().

Referenced by process_turn().

◆ find_user()

utils::optional< player_iterator > wesnothd::game::find_user ( const simple_wml::string_span name)
private

Shortcut to a convenience function for finding a user by name.

Parameters
nameThe name of the user to find.
Returns
The player if found, else empty.

Definition at line 1933 of file game.cpp.

References name(), and player_connections_.

Referenced by ban_user(), kick_member(), mute_observer(), transfer_side_control(), unban_user(), and unmute_observer().

◆ get_replay_filename()

std::string wesnothd::game::get_replay_filename ( )
Returns
The name of the replay for this game.

Definition at line 1784 of file game.cpp.

References current_turn(), db_id_, utils::erase_if(), filename, wesnothd::is_invalid_filename_char(), level_, name(), simple_wml::document::root(), and starting_pos().

Referenced by wesnothd::server::cleanup_game(), and save_replay().

◆ get_sides_list()

const simple_wml::node::child_list& wesnothd::game::get_sides_list ( ) const
inline

◆ handle_add_side_wml()

void wesnothd::game::handle_add_side_wml ( )

Adds a new, empty side owned by no one.

Definition at line 1134 of file game.cpp.

References nsides_, side_controllers_, and sides_.

Referenced by handle_choice().

◆ handle_choice()

void wesnothd::game::handle_choice ( const simple_wml::node data,
player_iterator  user 
)

Handle a choice requested by a client, such as changing a side's controller, if initiated by WML/lua.

Parameters
dataThe data needed to process the choice.
userThe player making the request.

Definition at line 1206 of file game.cpp.

References data, DBG_GAME, handle_add_side_wml(), handle_controller_choice(), handle_random_choice(), is_player(), last_choice_request_id_, owner_, players_not_advanced_, send_and_record_server_message(), and started_.

◆ handle_controller_choice()

void wesnothd::game::handle_controller_choice ( const simple_wml::node data)

Handle a request to change a side's controller.

Note that this does not change who owns a side.

Parameters
dataContains the information about which side to change the controller of.

Definition at line 1141 of file game.cpp.

References simple_wml::node::add_child(), current_player(), string_enums::enum_base< Definition >::get_enum(), string_enums::enum_base< Definition >::get_string(), last_choice_request_id_, record_data(), send_and_record_server_message(), send_data(), wesnothd::server::send_to_player(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), simple_wml::node::set_attr_int(), side_controllers_, and sides_.

Referenced by handle_choice().

◆ handle_random_choice()

void wesnothd::game::handle_random_choice ( )

◆ has_password()

bool wesnothd::game::has_password ( ) const
inline
Returns
Whether the game has a password set.

Definition at line 517 of file game.hpp.

References password_.

◆ has_same_ip()

std::string wesnothd::game::has_same_ip ( player_iterator  user) const
private

Checks whether a user has the same IP as any other members of this game.

Returns
A comma separated string of members with matching IPs.

Definition at line 1679 of file game.cpp.

References all_game_users().

Referenced by add_player().

◆ id()

int wesnothd::game::id ( ) const
inline

This ID is reused between scenarios of MP campaigns.

This ID resets when wesnothd is restarted. This is generally used when needing to find a particular running game.

Returns
an ID that uniquely identifies the game within the currently running wesnothd instance.

Definition at line 52 of file game.hpp.

References id_.

Referenced by wesnothd::server::cleanup_game().

◆ is_current_player()

bool wesnothd::game::is_current_player ( player_iterator  player) const
inlineprivate
Parameters
playerThe player being checked.
Returns
Whether the player being checked is the current player taking their turn.

Definition at line 620 of file game.hpp.

References current_player().

Referenced by is_legal_command(), and process_turn().

◆ is_legal_command()

bool wesnothd::game::is_legal_command ( const simple_wml::node command,
player_iterator  user 
)
private

◆ is_member()

bool wesnothd::game::is_member ( player_iterator  player) const
inline
Parameters
playerThe player being checked.
Returns
Whether the provided player has joined the game.

Definition at line 98 of file game.hpp.

References is_observer(), and is_player().

Referenced by add_player(), ban_user(), kick_member(), remove_player(), and transfer_side_control().

◆ is_muted_observer()

bool wesnothd::game::is_muted_observer ( player_iterator  player) const
private
Parameters
playerThe observer being checked.
Returns
True if the observer is muted or if all observers are muted, false otherwise.

Definition at line 156 of file game.cpp.

References all_observers_muted_, is_observer(), and muted_observers_.

Referenced by mute_observer(), process_turn(), and unmute_observer().

◆ is_observer()

bool wesnothd::game::is_observer ( player_iterator  player) const
Parameters
playerThe player being checked.
Returns
Whether the provided player is an observer of this game.

Definition at line 151 of file game.cpp.

References observers_.

Referenced by is_member(), is_muted_observer(), mute_observer(), remove_player(), send_user_list(), transfer_side_control(), and unmute_observer().

◆ is_owner()

bool wesnothd::game::is_owner ( player_iterator  player) const
inline
Parameters
playerThe player being checked.
Returns
Whether the provided player is the game's owner(host).

Definition at line 89 of file game.hpp.

References owner_.

Referenced by send_user_list().

◆ is_player()

bool wesnothd::game::is_player ( player_iterator  player) const
Parameters
playerThe player being checked.
Returns
Whether the provided player is playing this game (aka owns one or more sides).

Definition at line 169 of file game.cpp.

References players_.

Referenced by handle_choice(), is_legal_command(), is_member(), process_change_turns_wml(), process_turn(), process_whiteboard(), remove_player(), and transfer_side_control().

◆ is_reload()

bool wesnothd::game::is_reload ( ) const
Returns
Whether the loaded WML has the attribute indicating that this is a reloaded savegame rather than a brand new game.

Definition at line 1993 of file game.cpp.

References wesnothd::get_multiplayer(), simple_wml::node::has_attr(), level_, and simple_wml::document::root().

◆ kick_member()

utils::optional< player_iterator > wesnothd::game::kick_member ( const simple_wml::node kick,
player_iterator  kicker 
)

Kick a user from this game by name.

Parameters
kickThe user to kick.
kickerThe player doing the kicking.
Returns
The iterator to the removed member if successful, empty optional otherwise.

Definition at line 773 of file game.cpp.

References db_id_, find_user(), id_, is_member(), LOG_GAME, name_, owner_, remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), and username().

◆ level()

simple_wml::document& wesnothd::game::level ( )
inline
Returns
The full scenario data.

Definition at line 464 of file game.hpp.

References level_.

◆ level_init()

bool wesnothd::game::level_init ( ) const
inline
Returns
Whether this game contains scenario data and thus has been initialized.

Definition at line 137 of file game.hpp.

References simple_wml::document::child(), and level_.

◆ list_users()

std::string wesnothd::game::list_users ( user_vector  users) const
private
Parameters
usersThe users to create a comma separated list from.
Returns
A comma separated list of user names.

Definition at line 179 of file game.cpp.

Referenced by send_muted_observers(), and start_game().

◆ load_next_scenario()

void wesnothd::game::load_next_scenario ( player_iterator  user)

◆ mute_all_observers()

void wesnothd::game::mute_all_observers ( )

Toggles whether all observers are muted or not.

Definition at line 672 of file game.cpp.

References all_observers_muted_, and send_and_record_server_message().

◆ mute_observer()

void wesnothd::game::mute_observer ( const simple_wml::node mute,
player_iterator  muter 
)

Mute an observer or give a message of all currently muted observers if no name is given.

Parameters
muteThe observer to mute. Empty if sending a message to muted observers.
muterThe player doing the muting.

Definition at line 694 of file game.cpp.

References db_id_, 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(), and username().

◆ name()

const std::string& wesnothd::game::name ( ) const
inline
Returns
The game's name.

Definition at line 80 of file game.hpp.

References name_.

Referenced by find_user(), get_replay_filename(), and player_is_banned().

◆ new_scenario()

void wesnothd::game::new_scenario ( player_iterator  sender)

When the host sends the new scenario of a mp campaign.

Parameters
senderThe player sending the scenario data.

Definition at line 1571 of file game.cpp.

References all_game_users(), owner_, players_not_advanced_, and started_.

◆ next_db_id()

void wesnothd::game::next_db_id ( )
inline

Increments the ID used when running database queries.

Definition at line 72 of file game.hpp.

References db_id_, and db_id_num.

◆ nobservers()

std::size_t wesnothd::game::nobservers ( ) const
inline
Returns
The number of observers in this game.

Definition at line 203 of file game.hpp.

References observers_.

◆ notify_new_host()

void wesnothd::game::notify_new_host ( )
private

In case of a host transfer, notify the new host about its status.

Definition at line 622 of file game.cpp.

References simple_wml::node::add_child(), owner_, simple_wml::document::root(), send_and_record_server_message(), wesnothd::server::send_to_player(), and username().

Referenced by remove_player().

◆ nplayers()

std::size_t wesnothd::game::nplayers ( ) const
inline
Returns
The number of players. One player can have multiple sides.

Definition at line 195 of file game.hpp.

References players_.

◆ operator=()

game& wesnothd::game::operator= ( const game )
privatedelete

◆ password_matches()

bool wesnothd::game::password_matches ( const std::string &  passwd) const
inline
Parameters
passwdThe password to join with.
Returns
True if the game's password is empty or if the provided password matches, false otherwise.

Definition at line 509 of file game.hpp.

References password_.

◆ perform_controller_tweaks()

void wesnothd::game::perform_controller_tweaks ( )

This is performed just before starting and before the [start_game] signal.

Sends [scenario_diff]s specific to each client so that they locally control their human sides.

Definition at line 194 of file game.cpp.

References change_controller(), db_id_, DBG_GAME, debug_sides_info(), get_sides_list(), id_, LOG_GAME, wfl::msg(), owner_, send_and_record_server_message(), simple_wml::node::set_attr(), sides_, update_side_data(), and username().

◆ player_is_banned()

bool wesnothd::game::player_is_banned ( player_iterator  player,
const std::string &  name 
) const
Parameters
playerThe player being checked (by iterator).
nameThe player being checked (by username).
Returns
Whether the connection's ip address or username is banned from this game.

Definition at line 664 of file game.cpp.

References bans_, name(), and name_bans_.

Referenced by ban_user(), and unban_user().

◆ process_change_turns_wml()

void wesnothd::game::process_change_turns_wml ( simple_wml::document data,
player_iterator  user 
)

Handles incoming [change_turns_wml] data.

Parameters
dataThe [change_turns_wml] data.
userThe player changing turns.

Definition at line 1277 of file game.cpp.

References simple_wml::node::add_child(), simple_wml::node::child(), simple_wml::node::copy_into(), current_turn(), current_turn_, data, description_, is_player(), num_turns_, and started_.

◆ process_message()

void wesnothd::game::process_message ( simple_wml::document data,
player_iterator  user 
)

Sends an ingame message to all other players.

Parameters
dataThe message to send.
userThe user sending the message.

Definition at line 877 of file game.cpp.

References chat_history_, data, wfl::msg(), send_data(), and wesnothd::chat_message::truncate_message().

◆ process_turn()

bool wesnothd::game::process_turn ( simple_wml::document data,
player_iterator  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.

Parameters
dataThe turn commands.
userThe user who sent a command to be processed during the turn. This may not be the player whose turn it currently is.
Returns
True if the turn ended.

Definition at line 954 of file game.cpp.

References simple_wml::node::add_child(), simple_wml::node::child(), simple_wml::node::children(), simple_wml::node::copy_into(), current_player(), current_side(), current_side_index_, current_turn_, data, db_id_, DBG_GAME, simple_wml::string_span::empty(), end_turn(), ERR_GAME, 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_, 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(), 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().

◆ process_whiteboard()

void wesnothd::game::process_whiteboard ( simple_wml::document data,
player_iterator  user 
)

Handles incoming [whiteboard] data.

Parameters
dataThe whiteboard data.
userThe user sending the whiteboard data.

Definition at line 1250 of file game.cpp.

References data, is_player(), LOG_GAME, wfl::msg(), send_and_record_server_message(), send_data_sides(), sides_, and started_.

◆ record_data()

void wesnothd::game::record_data ( std::unique_ptr< simple_wml::document data)

Records a WML document in the game's history.

Parameters
dataThe WML document to record.

Definition at line 1850 of file game.cpp.

References data, and history_.

Referenced by change_controller(), handle_controller_choice(), handle_random_choice(), process_turn(), and send_and_record_server_message().

◆ remove_player()

bool wesnothd::game::remove_player ( player_iterator  player,
const bool  disconnect = false,
const bool  destruct = false 
)

◆ reset_last_synced_context_id()

void wesnothd::game::reset_last_synced_context_id ( )
inline

Reset the internal counter for choice requests made by clients to the server.

Definition at line 571 of file game.hpp.

References last_choice_request_id_.

◆ reset_sides()

void wesnothd::game::reset_sides ( )
private

calculates the initial value for sides_, side_controllerds_, nsides_

Definition at line 388 of file game.cpp.

References get_sides_list(), nsides_, side_controllers_, and sides_.

Referenced by update_side_data().

◆ save_replay()

void wesnothd::game::save_replay ( )

◆ send_and_record_server_message() [1/2]

void wesnothd::game::send_and_record_server_message ( const char *  message,
utils::optional< player_iterator exclude = {} 
)

Send data to all players in this game except 'exclude'.

Also record this data for the replay.

Parameters
messageThe message to send.
excludeThe players to not send the message to.

Definition at line 1943 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(), start_game(), transfer_side_control(), unban_user(), and unmute_observer().

◆ send_and_record_server_message() [2/2]

void wesnothd::game::send_and_record_server_message ( const std::string &  message,
utils::optional< player_iterator exclude = {} 
)
inline

send_and_record_server_message

Definition at line 415 of file game.hpp.

◆ send_chat_history()

void wesnothd::game::send_chat_history ( player_iterator  sock) const
private

Definition at line 1753 of file game.cpp.

References chat_history_, h, and wesnothd::server::send_to_player().

Referenced by add_player().

◆ send_data()

void wesnothd::game::send_data ( simple_wml::document data,
utils::optional< player_iterator exclude = {} 
)

Send data to all players and observers except those excluded.

Parameters
dataThe data to send.
excludeThe players/observers to not send the data to.

Definition at line 1645 of file game.cpp.

References all_game_users(), data, and send_to_players().

Referenced by add_player(), change_controller_type(), handle_controller_choice(), 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().

◆ send_data_sides()

void wesnothd::game::send_data_sides ( simple_wml::document data,
const simple_wml::string_span sides,
utils::optional< player_iterator exclude = {} 
)
private

Sends a document to the provided list of sides.

Parameters
dataThe data to be sent to the provided sides.
sidesA comma sperated list of side numbers to which the document should be sent.
excludePlayers to not send the data to.

Definition at line 1650 of file game.cpp.

References data, DBG_GAME, players_, and send_to_players().

Referenced by process_turn(), and process_whiteboard().

◆ send_history()

void wesnothd::game::send_history ( player_iterator  sock) const
private

◆ send_leave_game()

void wesnothd::game::send_leave_game ( player_iterator  user) const
private

Tells a player to leave the game.

Parameters
userThe player leaving the game.

Definition at line 767 of file game.cpp.

References simple_wml::INIT_COMPRESSED, and wesnothd::server::send_to_player().

Referenced by ban_user(), and kick_member().

◆ send_muted_observers()

void wesnothd::game::send_muted_observers ( player_iterator  user) const
private

Sends a message either stating that all observers are muted or listing the observers that are muted.

Parameters
userThe player to send the message to.

Definition at line 682 of file game.cpp.

References all_observers_muted_, list_users(), muted_observers_, and send_server_message().

Referenced by mute_observer().

◆ send_observerjoins()

void wesnothd::game::send_observerjoins ( utils::optional< player_iterator player = {})
private

Send a document per observer in the game.

If player is blank, send these documents to everyone, else send them to just the observer who joined.

Parameters
playerThe observer who joined.

Definition at line 1694 of file game.cpp.

References simple_wml::node::add_child(), observers_, simple_wml::document::root(), send_data(), wesnothd::server::send_to_player(), and simple_wml::node::set_attr_dup().

Referenced by add_player(), load_next_scenario(), and start_game().

◆ send_observerquit()

void wesnothd::game::send_observerquit ( player_iterator  observer)
private

◆ send_server_message() [1/2]

void wesnothd::game::send_server_message ( const char *  message,
utils::optional< player_iterator player = {},
simple_wml::document doc = nullptr 
) const

Send a server message to the specified player.

Parameters
messageThe message to send.
playerThe player to send the message to. If empty then the message is not sent.
docThe document to create the message in. If nullptr then a new document is created.

Definition at line 1961 of file game.cpp.

References simple_wml::node::add_child(), wfl::msg(), simple_wml::document::root(), wesnothd::server::send_to_player(), chrono::serialize_timestamp(), simple_wml::node::set_attr(), and started_.

Referenced by add_player(), ban_user(), kick_member(), mute_observer(), process_turn(), send_and_record_server_message(), send_muted_observers(), send_server_message_to_all(), transfer_side_control(), unban_user(), and unmute_observer().

◆ send_server_message() [2/2]

void wesnothd::game::send_server_message ( const std::string &  message,
utils::optional< player_iterator player = {},
simple_wml::document doc = nullptr 
) const
inline

send_server_message

Definition at line 398 of file game.hpp.

◆ send_server_message_to_all() [1/2]

void wesnothd::game::send_server_message_to_all ( const char *  message,
utils::optional< player_iterator exclude = {} 
)

Sends a message to all players in this game that aren't excluded.

Parameters
messageThe message to send.
excludeThe players to not send the message to.

Definition at line 1954 of file game.cpp.

References send_data(), and send_server_message().

Referenced by load_next_scenario(), and remove_player().

◆ send_server_message_to_all() [2/2]

void wesnothd::game::send_server_message_to_all ( const std::string &  message,
utils::optional< player_iterator exclude = {} 
)
inline

send_server_message_to_all

Definition at line 381 of file game.hpp.

◆ send_taken_side()

bool wesnothd::game::send_taken_side ( simple_wml::document cfg,
const simple_wml::node side 
) const
private

Tell the host who owns a side.

Parameters
cfgThe document to send to the host.
sideThe side information to send.
Returns
True if the document was sent, false otherwise.

Definition at line 326 of file game.cpp.

References owner_, simple_wml::document::root(), wesnothd::server::send_to_player(), simple_wml::node::set_attr_dup(), and sides_.

Referenced by take_side().

◆ send_to_players()

template<typename Container >
void wesnothd::game::send_to_players ( simple_wml::document data,
const Container &  players,
utils::optional< player_iterator exclude = {} 
)

Send data to all players except those excluded.

For example, to send a message to all players except the player who typed the original message.

Parameters
dataThe data to send.
playersThe players to send the data to.
excludeThe player from players to not send the data to.

Definition at line 1636 of file game.cpp.

References data, and wesnothd::server::send_to_player().

Referenced by process_turn(), send_data(), and send_data_sides().

◆ send_user_list()

void wesnothd::game::send_user_list ( utils::optional< player_iterator exclude = {})
private

Function to send a list of users to all clients.

Only sends data if the game is initialized but not yet started.

Parameters
excludeThe players to not send the list of users to.

Definition at line 1548 of file game.cpp.

References simple_wml::node::add_child(), all_game_users(), is_observer(), is_owner(), simple_wml::document::root(), send_data(), simple_wml::node::set_attr(), simple_wml::node::set_attr_dup(), and started_.

Referenced by add_player(), and remove_player().

◆ set_description()

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

Set the game's description.

Also set the game as requiring a password if a password is set.

Parameters
descThe node containing the game's description.

Definition at line 1866 of file game.cpp.

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

◆ set_name_bans()

void wesnothd::game::set_name_bans ( const std::vector< std::string >  name_bans)
inline

Set a list of usernames that should all be banned from joining the game.

Parameters
name_bansThe list of usernames.

Definition at line 500 of file game.hpp.

References name_bans_.

◆ set_password()

void wesnothd::game::set_password ( const std::string &  passwd)
inline

Sets the password required to access the game.

Parameters
passwdThe password to set.

Definition at line 490 of file game.hpp.

References password_.

◆ set_termination_reason()

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

Sets the termination reason for this game.

Parameters
reasonThe termination reason.

Definition at line 1874 of file game.cpp.

References termination_.

◆ start_game()

void wesnothd::game::start_game ( player_iterator  starter)

◆ started()

bool wesnothd::game::started ( ) const
inline
Returns
Whether this game has started yet.

Definition at line 187 of file game.hpp.

References started_.

◆ starting_pos() [1/2]

static const simple_wml::node* wesnothd::game::starting_pos ( const simple_wml::node data)
inlinestatic

The const version.

Parameters
dataThe data describing the level for a game.
Returns
The [scenario] child node if it exists, else the [snapshot] child if it exists, else data.

Definition at line 165 of file game.hpp.

References data.

◆ starting_pos() [2/2]

static simple_wml::node* wesnothd::game::starting_pos ( simple_wml::node data)
inlinestatic

The non-const version.

Parameters
dataThe data describing the level for a game.
Returns
The [scenario] child node if it exists, else the [snapshot] child if it exists, else data.

Definition at line 148 of file game.hpp.

References data.

Referenced by get_replay_filename(), get_sides_list(), wesnothd::server::handle_player_in_game(), and start_game().

◆ take_side()

bool wesnothd::game::take_side ( player_iterator  user)
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=human or reserved side.

Parameters
userThe player taking a side.
Returns
True if the side was taken, false otherwise.

Definition at line 347 of file game.cpp.

References DBG_GAME, get_sides_list(), simple_wml::document::root(), send_taken_side(), simple_wml::node::set_attr_dup(), and started_.

Referenced by add_player().

◆ termination_reason()

const std::string& wesnothd::game::termination_reason ( ) const
inline

Provides the reason the game was ended.

Returns
Either that the game was aborted (after starting), not started, or has some other reason set.

Definition at line 527 of file game.hpp.

References started_, and termination_.

Referenced by wesnothd::server::cleanup_game(), and remove_player().

◆ transfer_side_control()

void wesnothd::game::transfer_side_control ( player_iterator  player,
const simple_wml::node cfg 
)

◆ unban_user()

void wesnothd::game::unban_user ( const simple_wml::node unban,
player_iterator  unbanner 
)

Unban a user by name.

The user does not need to be in this game but logged in.

Parameters
unbanThe user to unban.
unbannerThe player doing the unbanning.

Definition at line 847 of file game.cpp.

References bans_, db_id_, utils::erase(), find_user(), id_, LOG_GAME, name_, name_bans_, owner_, player_is_banned(), send_and_record_server_message(), send_server_message(), and username().

◆ unmute_observer()

void wesnothd::game::unmute_observer ( const simple_wml::node unmute,
player_iterator  unmuter 
)

Unmute an observer or unmute all currently muted observers if no name is given.

Parameters
unmuteThe observer to unmute. Empty if unmuting all observers.
unmuterThe player doing the unmuting.

Definition at line 735 of file game.cpp.

References db_id_, utils::erase(), find_user(), id_, is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, send_and_record_server_message(), send_server_message(), and username().

◆ update_side_data()

void wesnothd::game::update_side_data ( )

◆ update_turn_data()

void wesnothd::game::update_turn_data ( )
private

Set or update the current and max turn values in the game's description.

Definition at line 1338 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(), and start_game().

◆ username()

std::string wesnothd::game::username ( player_iterator  pl) const
private
Parameters
plThe player.
Returns
The player's username.

Definition at line 174 of file game.cpp.

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().

Member Data Documentation

◆ all_observers_muted_

bool wesnothd::game::all_observers_muted_
private

Whether all observers should be treated as muted.

Definition at line 879 of file game.hpp.

Referenced by all_observers_muted(), is_muted_observer(), mute_all_observers(), and send_muted_observers().

◆ bans_

std::vector<std::string> wesnothd::game::bans_
private

List of banned IPs.

Definition at line 882 of file game.hpp.

Referenced by ban_user(), player_is_banned(), and unban_user().

◆ chat_history_

std::vector<std::unique_ptr<simple_wml::document> > wesnothd::game::chat_history_
mutableprivate

Replay chat history data.

Definition at line 867 of file game.hpp.

Referenced by clear_chat_history(), process_message(), and send_chat_history().

◆ current_side_index_

int wesnothd::game::current_side_index_
private

The index of the current side.

The side number is current_side_index_+1.

Definition at line 875 of file game.hpp.

Referenced by current_side(), end_turn(), process_turn(), and start_game().

◆ current_turn_

int wesnothd::game::current_turn_
private

The game's current turn.

Definition at line 873 of file game.hpp.

Referenced by current_turn(), end_turn(), process_change_turns_wml(), process_turn(), and start_game().

◆ db_id_

int wesnothd::game::db_id_
private

Used for unique identification of games played in the database.

Necessary since for MP campaigns multiple scenarios can be played within the same game instance and we need a unique ID per scenario played, not per game instance.

Definition at line 815 of file game.hpp.

Referenced by add_player(), ban_user(), db_id(), debug_player_info(), debug_sides_info(), get_replay_filename(), kick_member(), mute_observer(), next_db_id(), perform_controller_tweaks(), process_turn(), remove_player(), start_game(), unban_user(), and unmute_observer().

◆ db_id_num

int wesnothd::game::db_id_num = 1
staticprivate

Incremented to retrieve a unique ID per wesnothd instance for game instances within the database.

Definition at line 809 of file game.hpp.

Referenced by next_db_id().

◆ description_

simple_wml::node* wesnothd::game::description_
private

Pointer to the game's description in the games_and_users_list_.

Definition at line 870 of file game.hpp.

Referenced by describe_slots(), description(), end_turn(), process_change_turns_wml(), set_description(), and update_turn_data().

◆ history_

std::vector<std::unique_ptr<simple_wml::document> > wesnothd::game::history_
mutableprivate

Replay data.

Definition at line 865 of file game.hpp.

Referenced by clear_history(), record_data(), save_replay(), and send_history().

◆ id_

int wesnothd::game::id_
private

◆ id_num

int wesnothd::game::id_num = 1
staticprivate

Incremented to retrieve a unique ID for game instances within wesnothd.

Definition at line 802 of file game.hpp.

◆ last_choice_request_id_

int wesnothd::game::last_choice_request_id_
private

The ID of the last request received from a client.

New requests should never have a lower value than this.

Definition at line 907 of file game.hpp.

Referenced by handle_choice(), handle_controller_choice(), handle_random_choice(), and reset_last_synced_context_id().

◆ level_

simple_wml::document wesnothd::game::level_
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 862 of file game.hpp.

Referenced by add_player(), allow_observers(), get_replay_filename(), get_sides_list(), is_reload(), level(), level_init(), load_next_scenario(), save_replay(), and start_game().

◆ muted_observers_

user_vector wesnothd::game::muted_observers_
private

A vector of muted observers.

Definition at line 831 of file game.hpp.

Referenced by is_muted_observer(), mute_observer(), send_muted_observers(), and unmute_observer().

◆ name_

std::string wesnothd::game::name_
private

◆ name_bans_

std::vector<std::string> wesnothd::game::name_bans_
private

List of banned usernames.

Definition at line 884 of file game.hpp.

Referenced by ban_user(), player_is_banned(), set_name_bans(), and unban_user().

◆ nsides_

int wesnothd::game::nsides_
private

Number of sides in the current scenario.

Definition at line 840 of file game.hpp.

Referenced by current_side(), end_turn(), handle_add_side_wml(), process_turn(), reset_sides(), and start_game().

◆ num_turns_

int wesnothd::game::num_turns_
private

The maximum number of turns before the game ends.

Definition at line 877 of file game.hpp.

Referenced by process_change_turns_wml(), start_game(), and update_turn_data().

◆ observers_

user_vector wesnothd::game::observers_
private

◆ owner_

player_iterator wesnothd::game::owner_
private

◆ password_

std::string wesnothd::game::password_
private

The password needed to join the game.

Definition at line 820 of file game.hpp.

Referenced by has_password(), password_matches(), set_description(), and set_password().

◆ player_connections_

player_connections& wesnothd::game::player_connections_
private

Definition at line 797 of file game.hpp.

Referenced by find_user(), and remove_player().

◆ players_

user_vector wesnothd::game::players_
private

◆ players_not_advanced_

std::set<const player_record*> wesnothd::game::players_not_advanced_
private

in multiplayer campaigns it can happen that some players are still in the previous scenario keep track of those players because processing certain input from those side wil lead to error (oos)

Definition at line 891 of file game.hpp.

Referenced by handle_choice(), load_next_scenario(), new_scenario(), and remove_player().

◆ replay_save_path_

std::string wesnothd::game::replay_save_path_
private

Where to save the replay of this game.

Definition at line 899 of file game.hpp.

Referenced by save_replay().

◆ rng_

randomness::mt_rng wesnothd::game::rng_
private

A wrapper for mersenne twister rng which generates randomness for this game.

Definition at line 902 of file game.hpp.

Referenced by handle_random_choice().

◆ save_replays_

bool wesnothd::game::save_replays_
private

Whether to save a replay of this game.

Definition at line 897 of file game.hpp.

Referenced by save_replay().

◆ server

wesnothd::server& wesnothd::game::server
private

The wesnothd server instance this game exists on.

Definition at line 796 of file game.hpp.

◆ side_controllers_

std::vector<side_controller::type> wesnothd::game::side_controllers_
private

◆ sides_

side_vector wesnothd::game::sides_
private

◆ started_

bool wesnothd::game::started_
private

◆ termination_

std::string wesnothd::game::termination_
private

The reason the game ended.

Definition at line 894 of file game.hpp.

Referenced by set_termination_reason(), and termination_reason().


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