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

#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_listget_sides_list () const
 
bool started () const
 
std::size_t nplayers () const
 
std::size_t nobservers () const
 
std::size_t current_turn () const
 
void set_current_turn (int turn)
 
void mute_all_observers ()
 
void mute_observer (const simple_wml::node &mute, const socket_ptr &muter)
 Mute an observer or give a message of all currently muted observers if no name is given. More...
 
void unmute_observer (const simple_wml::node &unmute, const socket_ptr &unmuter)
 
socket_ptr kick_member (const simple_wml::node &kick, const socket_ptr &kicker)
 Kick a member by name. More...
 
socket_ptr ban_user (const simple_wml::node &ban, const socket_ptr &banner)
 Ban and kick a user by name. More...
 
void unban_user (const simple_wml::node &unban, const socket_ptr &unbanner)
 
bool add_player (const socket_ptr &player, bool observer=false)
 Add a user to the game. More...
 
bool remove_player (const socket_ptr &player, const bool disconnect=false, const bool destruct=false)
 Removes a user from the game. More...
 
const user_vector all_game_users () const
 Adds players and observers into one vector and returns that. More...
 
void start_game (const socket_ptr &starter)
 
void perform_controller_tweaks ()
 
void update_game ()
 
void load_next_scenario (const socket_ptr &user)
 A user (player only?) asks for the next scenario to advance to. More...
 
void update_side_data ()
 Resets the side configuration according to the scenario data. More...
 
void transfer_side_control (const socket_ptr &sock, const simple_wml::node &cfg)
 Let's a player owning a side give it to another player or observer. More...
 
void process_message (simple_wml::document &data, const socket_ptr &user)
 
bool process_turn (simple_wml::document &data, const socket_ptr &user)
 Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data. More...
 
void process_whiteboard (simple_wml::document &data, const socket_ptr &user)
 Handles incoming [whiteboard] data. More...
 
void process_change_turns_wml (simple_wml::document &data, const socket_ptr &user)
 Handles incoming [change_turns_wml] data. More...
 
bool describe_slots ()
 Set the description to the number of available slots. More...
 
void send_server_message_to_all (const char *message, const socket_ptr &exclude=socket_ptr()) const
 
void send_server_message_to_all (const std::string &message, const socket_ptr &exclude=socket_ptr()) const
 
void send_server_message (const char *message, const socket_ptr &sock=socket_ptr(), simple_wml::document *doc=nullptr) const
 
void send_server_message (const std::string &message, const socket_ptr &sock=socket_ptr(), simple_wml::document *doc=nullptr) const
 
void send_and_record_server_message (const char *message, const socket_ptr &exclude=socket_ptr())
 Send data to all players in this game except 'exclude'. More...
 
void send_and_record_server_message (const std::string &message, const socket_ptr &exclude=socket_ptr())
 
void send_data (simple_wml::document &data, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const
 
void clear_history ()
 
void record_data (simple_wml::document *data)
 
void save_replay ()
 
simple_wml::documentlevel ()
 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::nodedescription () 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::nodestarting_pos (simple_wml::node &data)
 
static const simple_wml::nodestarting_pos (const simple_wml::node &data)
 

Public Attributes

const socket_ptrhost
 
const socket_ptr const std::string & name = ""
 
const socket_ptr const std::string bool save_replays = false
 
const socket_ptr const std::string bool const std::string & replay_save_path = "")
 

Private Types

typedef boost::ptr_vector< simple_wml::documenthistory
 Replay data. More...
 

Private Member Functions

 game (const game &)
 
void operator= (const game &)
 
std::size_t current_side () const
 
const socket_ptr current_player () const
 
bool is_current_player (const socket_ptr &player) const
 
bool is_muted_observer (const socket_ptr &player) const
 
bool all_observers_muted () const
 
void send_muted_observers (const socket_ptr &user) const
 
bool send_taken_side (simple_wml::document &cfg, const simple_wml::node *side) const
 
bool take_side (const socket_ptr &user)
 Figures out which side to take and tells that side to the game owner. More...
 
void change_controller (const std::size_t side_num, const socket_ptr &sock, const std::string &player_name, const bool player_left=true)
 Send [change_controller] message to tell all clients the new controller's name or controller type (human or ai). More...
 
void transfer_ai_sides (const socket_ptr &player)
 
void send_leave_game (const socket_ptr &user) const
 
void send_data_sides (simple_wml::document &data, const simple_wml::string_span &sides, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const
 
void send_data_observers (simple_wml::document &data, const socket_ptr &exclude=socket_ptr(), std::string packet_type="") const
 
void send_observerjoins (const socket_ptr &sock=socket_ptr()) const
 Send [observer] tags of all the observers in the game to the user or everyone if none given. More...
 
void send_observerquit (const socket_ptr &observer) const
 
void send_history (const socket_ptr &sock) const
 
void notify_new_host ()
 In case of a host transfer, notify the new host about its status. More...
 
socket_ptr find_user (const simple_wml::string_span &name)
 Shortcut to a convenience function for finding a user by name. More...
 
bool observers_can_label () const
 
bool observers_can_chat () const
 
bool is_legal_command (const simple_wml::node &command, const socket_ptr &user)
 
std::string has_same_ip (const socket_ptr &user, bool observer) const
 Checks whether a user has the same IP as members of this game. More...
 
bool end_turn (int new_side)
 Function which should be called every time a player ends their turn (i.e. More...
 
void update_turn_data ()
 
void send_user_list (const socket_ptr &exclude=socket_ptr()) const
 Function to send a list of users to all clients. More...
 
std::string username (const socket_ptr &pl) const
 Returns the name of the user or "(unfound)". More...
 
std::string list_users (user_vector users, const std::string &func) const
 Returns a comma separated list of user names. More...
 
void missing_user (socket_ptr socket, const std::string &func) const
 Function to log when we don't find a connection in player_info_. More...
 
void reset_sides ()
 calculates the initial value for sides_, side_controllerds_, nsides_ More...
 
std::string debug_player_info () const
 Helps debugging player and observer lists. More...
 
std::string debug_sides_info () const
 Helps debugging controller tweaks. More...
 

Private Attributes

player_connectionsplayer_connections_
 
int id_
 
std::string name_
 The name of the game. More...
 
std::string password_
 
socket_ptr owner_
 The game host or later owner (if the host left). More...
 
user_vector players_
 A vector of players (members owning a side). More...
 
user_vector observers_
 A vector of observers (members not owning a side). More...
 
user_vector muted_observers_
 
side_vector sides_
 A vector of side owners. More...
 
std::vector< CONTROLLER > side_controllers_
 
int nsides_
 Number of sides in the current scenario. More...
 
bool started_
 
simple_wml::document level_
 The current scenario data. More...
 
history history_
 
simple_wml::nodedescription_
 Pointer to the game's description in the games_and_users_list_. More...
 
int current_turn_
 
int current_side_index_
 
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_
 
randomness::mt_rng rng_
 A wrapper for mersenne twister rng which generates randomness for this game. More...
 
int last_choice_request_id_
 

Static Private Attributes

static int id_num = 1
 

Detailed Description

Definition at line 35 of file game.hpp.

Member Typedef Documentation

◆ history

typedef boost::ptr_vector<simple_wml::document> wesnothd::game::history
private

Replay data.

Definition at line 490 of file game.hpp.

Constructor & Destructor Documentation

◆ ~game()

wesnothd::game::~game ( )

Definition at line 140 of file game.cpp.

References all_game_users(), clear_history(), remove_player(), and save_replay().

◆ game()

wesnothd::game::game ( const game )
private

Member Function Documentation

◆ add_player()

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

◆ all_game_users()

const user_vector wesnothd::game::all_game_users ( ) const

Adds players and observers into one vector and returns that.

Definition at line 1893 of file game.cpp.

References observers_, and players_.

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

◆ all_observers_muted()

bool wesnothd::game::all_observers_muted ( ) const
inlineprivate

◆ allow_observers()

bool wesnothd::game::allow_observers ( ) const

Definition at line 165 of file game.cpp.

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

Referenced by add_player(), and is_member().

◆ ban_user()

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.

Returns
The network handle of the banned player if he was in this game, null pointer otherwise.

Definition at line 844 of file game.cpp.

References bans_, 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(), and set_current_turn().

◆ change_controller()

void wesnothd::game::change_controller ( const std::size_t  side_num,
const socket_ptr sock,
const std::string &  player_name,
const bool  player_left = true 
)
private

◆ clear_history()

void wesnothd::game::clear_history ( )

Definition at line 1866 of file game.cpp.

References history_.

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

◆ controls_side()

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

Function which returns true iff 'player' controls any of the sides spcified in 'sides'.

Definition at line 1684 of file game.cpp.

References sides_.

Referenced by reset_last_synced_context_id().

◆ current_player()

const socket_ptr wesnothd::game::current_player ( ) const
inlineprivate

Definition at line 323 of file game.hpp.

References current_side(), nsides_, and sides_.

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

◆ current_side()

std::size_t wesnothd::game::current_side ( ) const
inlineprivate

Definition at line 318 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

Definition at line 127 of file game.hpp.

References current_turn_.

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

◆ debug_player_info()

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

Helps debugging player and observer lists.

Definition at line 1903 of file game.cpp.

References id_, observers_, p, player_connections_, and players_.

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

◆ debug_sides_info()

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

Helps debugging controller tweaks.

Definition at line 1937 of file game.cpp.

References get_sides_list(), id_, s, side_controllers_, and sides_.

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

◆ describe_slots()

bool wesnothd::game::describe_slots ( )

Set the description to the number of available slots.

Returns
True iff the number of slots has changed.

Definition at line 673 of file game.cpp.

References simple_wml::node::add_child(), simple_wml::node::child(), description_, get_sides_list(), i, simple_wml::node::set_attr_int(), sides_, and started_.

Referenced by wesnothd::server::handle_player_in_game(), set_current_turn(), and update_game().

◆ description()

simple_wml::node* wesnothd::game::description ( ) const
inline

◆ 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. Will return true iff there has been a change.

Definition at line 1318 of file game.cpp.

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

Referenced by observers_can_chat(), and process_turn().

◆ find_user()

socket_ptr wesnothd::game::find_user ( const simple_wml::string_span name)
private

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

Definition at line 1957 of file game.cpp.

References player_connections_, and simple_wml::string_span::to_string().

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

◆ get_sides_list()

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

◆ handle_choice()

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

◆ handle_controller_choice()

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

◆ handle_random_choice()

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

◆ has_same_ip()

std::string wesnothd::game::has_same_ip ( const socket_ptr user,
bool  observer 
) const
private

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

If observer is true it only checks against players.

Returns
A comma separated string of members with matching IPs.

Definition at line 1697 of file game.cpp.

References all_game_users(), client_address(), player_connections_, and players_.

Referenced by add_player(), and observers_can_chat().

◆ id()

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

Definition at line 52 of file game.hpp.

References id_.

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

◆ is_current_player()

bool wesnothd::game::is_current_player ( const socket_ptr player) const
inlineprivate

Definition at line 328 of file game.hpp.

References current_player(), and is_muted_observer().

Referenced by is_legal_command(), and process_turn().

◆ is_legal_command()

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

◆ is_member()

bool wesnothd::game::is_member ( const socket_ptr player) const
inline

◆ is_muted_observer()

bool wesnothd::game::is_muted_observer ( const socket_ptr player) const
private

◆ is_observer()

bool wesnothd::game::is_observer ( const socket_ptr player) const

◆ is_owner()

bool wesnothd::game::is_owner ( const socket_ptr player) const
inline

Definition at line 62 of file game.hpp.

References owner_.

Referenced by wesnothd::server::handle_player_in_game(), and send_user_list().

◆ is_player()

bool wesnothd::game::is_player ( const socket_ptr player) const

◆ kick_member()

socket_ptr wesnothd::game::kick_member ( const simple_wml::node kick,
const socket_ptr kicker 
)

Kick a member by name.

Returns
The network handle of the removed member if successful, null pointer otherwise.

Definition at line 812 of file game.cpp.

References client_address(), find_user(), id_, is_member(), LOG_GAME, name_, owner_, player_connections_, remove_player(), send_and_record_server_message(), send_leave_game(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().

◆ level()

simple_wml::document& wesnothd::game::level ( )
inline

The full scenario data.

Definition at line 261 of file game.hpp.

References level_, and set_description().

Referenced by wesnothd::server::create_game(), and wesnothd::server::handle_player_in_game().

◆ level_init()

bool wesnothd::game::level_init ( ) const
inline

Definition at line 80 of file game.hpp.

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

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

◆ list_users()

std::string wesnothd::game::list_users ( user_vector  users,
const std::string &  func 
) const
private

Returns a comma separated list of user names.

Definition at line 208 of file game.cpp.

References missing_user(), and player_connections_.

Referenced by observers_can_chat(), send_muted_observers(), and start_game().

◆ load_next_scenario()

void wesnothd::game::load_next_scenario ( const socket_ptr user)

◆ MAKE_ENUM()

wesnothd::game::MAKE_ENUM ( CONTROLLER  ,
(HUMAN, "human")(AI, "ai")(EMPTY, "null")   
) &

◆ missing_user()

void wesnothd::game::missing_user ( socket_ptr  socket,
const std::string &  func 
) const
private

Function to log when we don't find a connection in player_info_.

Definition at line 88 of file game.cpp.

References WRN_GAME.

Referenced by game(), list_users(), observers_can_chat(), perform_controller_tweaks(), transfer_side_control(), and update_side_data().

◆ mute_all_observers()

void wesnothd::game::mute_all_observers ( )

◆ mute_observer()

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.

Todo:
FIXME: Maybe rather save muted nicks as a set of strings and also allow muting of usernames not in the game.

Definition at line 732 of file game.cpp.

References client_address(), simple_wml::string_span::empty(), find_user(), id_, is_muted_observer(), is_observer(), LOG_GAME, muted_observers_, name_, owner_, send_and_record_server_message(), send_muted_observers(), send_server_message(), simple_wml::string_span::to_string(), and username().

Referenced by wesnothd::server::handle_player_in_game(), and set_current_turn().

◆ name()

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

Definition at line 57 of file game.hpp.

References name_.

Referenced by all_observers_muted(), and save_replay().

◆ nobservers()

std::size_t wesnothd::game::nobservers ( ) const
inline

Definition at line 122 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 662 of file game.cpp.

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

Referenced by all_observers_muted(), and remove_player().

◆ nplayers()

std::size_t wesnothd::game::nplayers ( ) const
inline

Definition at line 117 of file game.hpp.

References players_.

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

◆ observers_can_chat()

bool wesnothd::game::observers_can_chat ( ) const
inlineprivate

◆ observers_can_label()

bool wesnothd::game::observers_can_label ( ) const
inlineprivate

Definition at line 390 of file game.hpp.

◆ operator=()

void wesnothd::game::operator= ( const game )
private

◆ password_matches()

bool wesnothd::game::password_matches ( const std::string &  passwd) const
inline

Definition at line 282 of file game.hpp.

References password_.

◆ perform_controller_tweaks()

void wesnothd::game::perform_controller_tweaks ( )

◆ player_is_banned()

bool wesnothd::game::player_is_banned ( const socket_ptr player) const

Checks whether the connection's ip address is banned.

Definition at line 704 of file game.cpp.

References bans_, and client_address().

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

◆ process_change_turns_wml()

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

◆ process_message()

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

◆ process_turn()

bool wesnothd::game::process_turn ( simple_wml::document data,
const socket_ptr user 
)

◆ process_whiteboard()

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

◆ record_data()

void wesnothd::game::record_data ( simple_wml::document data)

◆ registered_users_only()

bool wesnothd::game::registered_users_only ( ) const

Definition at line 170 of file game.cpp.

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

Referenced by is_member().

◆ remove_player()

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

◆ reset_last_synced_context_id()

void wesnothd::game::reset_last_synced_context_id ( )
inline

◆ reset_sides()

void wesnothd::game::reset_sides ( )
private

calculates the initial value for sides_, side_controllerds_, nsides_

Definition at line 441 of file game.cpp.

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

Referenced by observers_can_chat(), and 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,
const socket_ptr exclude = socket_ptr() 
)

◆ send_and_record_server_message() [2/2]

void wesnothd::game::send_and_record_server_message ( const std::string &  message,
const socket_ptr exclude = socket_ptr() 
)
inline

◆ send_data()

void wesnothd::game::send_data ( simple_wml::document data,
const socket_ptr exclude = socket_ptr(),
std::string  packet_type = "" 
) const

◆ send_data_observers()

void wesnothd::game::send_data_observers ( simple_wml::document data,
const socket_ptr exclude = socket_ptr(),
std::string  packet_type = "" 
) const
private

Referenced by all_observers_muted().

◆ send_data_sides()

void wesnothd::game::send_data_sides ( simple_wml::document data,
const simple_wml::string_span sides,
const socket_ptr exclude = socket_ptr(),
std::string  packet_type = "" 
) const
private
Parameters
sidesa comma sperated list of side numbers to which the package should be sent,

Definition at line 1667 of file game.cpp.

References DBG_GAME, players_, and wesnothd::send_to_players().

Referenced by all_observers_muted(), process_turn(), and process_whiteboard().

◆ send_history()

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

◆ send_leave_game()

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

Definition at line 806 of file game.cpp.

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

Referenced by all_observers_muted(), ban_user(), and kick_member().

◆ send_muted_observers()

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

◆ send_observerjoins()

void wesnothd::game::send_observerjoins ( const socket_ptr sock = socket_ptr()) const
private

Send [observer] tags of all the observers in the game to the user or everyone if none given.

Definition at line 1716 of file game.cpp.

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

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

◆ send_observerquit()

void wesnothd::game::send_observerquit ( const socket_ptr observer) const
private

◆ send_server_message() [1/2]

void wesnothd::game::send_server_message ( const char *  message,
const socket_ptr sock = socket_ptr(),
simple_wml::document doc = nullptr 
) const

◆ send_server_message() [2/2]

void wesnothd::game::send_server_message ( const std::string &  message,
const socket_ptr sock = socket_ptr(),
simple_wml::document doc = nullptr 
) const
inline

Definition at line 240 of file game.hpp.

References send_and_record_server_message(), and send_server_message().

◆ send_server_message_to_all() [1/2]

void wesnothd::game::send_server_message_to_all ( const char *  message,
const socket_ptr exclude = socket_ptr() 
) const

◆ send_server_message_to_all() [2/2]

void wesnothd::game::send_server_message_to_all ( const std::string &  message,
const socket_ptr exclude = socket_ptr() 
) const
inline

Definition at line 233 of file game.hpp.

References send_server_message(), and send_server_message_to_all().

◆ send_taken_side()

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

◆ send_user_list()

void wesnothd::game::send_user_list ( const socket_ptr exclude = socket_ptr()) const
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 1565 of file game.cpp.

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

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

◆ set_current_turn()

void wesnothd::game::set_current_turn ( int  turn)
inline

◆ set_description()

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 1871 of file game.cpp.

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

Referenced by wesnothd::server::handle_player_in_game(), and level().

◆ set_password()

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

Definition at line 277 of file game.hpp.

References password_.

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

◆ set_termination_reason()

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

Definition at line 1879 of file game.cpp.

References termination_.

Referenced by wesnothd::server::handle_player_in_game(), and termination_reason().

◆ start_game()

void wesnothd::game::start_game ( const socket_ptr starter)

◆ started()

bool wesnothd::game::started ( ) const
inline

Definition at line 112 of file game.hpp.

References started_.

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

◆ starting_pos() [1/2]

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

◆ starting_pos() [2/2]

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

Definition at line 96 of file game.hpp.

References simple_wml::node::child().

◆ take_side()

bool wesnothd::game::take_side ( const socket_ptr 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="network" side.

Definition at line 400 of file game.cpp.

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

Referenced by add_player(), and all_observers_muted().

◆ termination_reason()

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

◆ transfer_ai_sides()

void wesnothd::game::transfer_ai_sides ( const socket_ptr player)
private

Referenced by all_observers_muted().

◆ transfer_side_control()

void wesnothd::game::transfer_side_control ( const socket_ptr sock,
const simple_wml::node cfg 
)

◆ unban_user()

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

◆ unmute_observer()

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

◆ update_game()

void wesnothd::game::update_game ( )

◆ update_side_data()

void wesnothd::game::update_side_data ( )

◆ update_turn_data()

void wesnothd::game::update_turn_data ( )
private

◆ username()

std::string wesnothd::game::username ( const socket_ptr pl) const
private

Member Data Documentation

◆ all_observers_muted_

bool wesnothd::game::all_observers_muted_
private

◆ bans_

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

Definition at line 502 of file game.hpp.

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

◆ current_side_index_

int wesnothd::game::current_side_index_
private

Definition at line 497 of file game.hpp.

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

◆ current_turn_

int wesnothd::game::current_turn_
private

Definition at line 496 of file game.hpp.

Referenced by current_turn(), end_turn(), set_current_turn(), and start_game().

◆ description_

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

Pointer to the game's description in the games_and_users_list_.

Definition at line 494 of file game.hpp.

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

◆ end_turn_

int wesnothd::game::end_turn_
private

Definition at line 498 of file game.hpp.

Referenced by process_turn().

◆ history_

history wesnothd::game::history_
mutableprivate

Definition at line 491 of file game.hpp.

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

◆ host

const socket_ptr& wesnothd::game::host

Definition at line 45 of file game.hpp.

Referenced by remove_player().

◆ id_

int wesnothd::game::id_
private

◆ id_num

int wesnothd::game::id_num = 1
staticprivate

Definition at line 445 of file game.hpp.

◆ last_choice_request_id_

int wesnothd::game::last_choice_request_id_
private

Definition at line 511 of file game.hpp.

Referenced by handle_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 487 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().

◆ muted_observers_

user_vector wesnothd::game::muted_observers_
private

Definition at line 460 of file game.hpp.

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

◆ name

const socket_ptr const std::string& wesnothd::game::name = ""

Definition at line 46 of file game.hpp.

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

◆ name_

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

◆ nsides_

int wesnothd::game::nsides_
private

Number of sides in the current scenario.

Definition at line 468 of file game.hpp.

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

◆ num_turns_

int wesnothd::game::num_turns_
private

Definition at line 499 of file game.hpp.

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

◆ observers_

user_vector wesnothd::game::observers_
private

A vector of observers (members not owning a side).

Definition at line 459 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().

◆ owner_

socket_ptr wesnothd::game::owner_
private

◆ password_

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

Definition at line 450 of file game.hpp.

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

◆ player_connections_

player_connections& wesnothd::game::player_connections_
private

◆ players_

user_vector wesnothd::game::players_
private

◆ replay_save_path

const socket_ptr const std::string bool const std::string& wesnothd::game::replay_save_path = "")

Definition at line 48 of file game.hpp.

◆ replay_save_path_

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

Definition at line 507 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 510 of file game.hpp.

Referenced by handle_random_choice().

◆ save_replays

const socket_ptr const std::string bool wesnothd::game::save_replays = false

Definition at line 47 of file game.hpp.

◆ save_replays_

bool wesnothd::game::save_replays_
private

Definition at line 506 of file game.hpp.

Referenced by save_replay().

◆ side_controllers_

std::vector<CONTROLLER> 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

Definition at line 504 of file game.hpp.

Referenced by set_termination_reason(), and termination_reason().


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