The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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::stringname () const
 
bool is_owner (const socket_ptr player) const
 
bool is_member (const socket_ptr player) const
 
bool allow_observers () const
 
bool registered_users_only () const
 
bool is_observer (const socket_ptr player) const
 
bool is_player (const socket_ptr player) const
 
bool player_is_banned (const socket_ptr player) const
 Checks whether the connection's ip address is banned. More...
 
bool level_init () const
 
const
simple_wml::node::child_list
get_sides_list () const
 
bool started () const
 
size_t nplayers () const
 
size_t nobservers () const
 
size_t current_turn () const
 
void set_current_turn (int turn)
 
void mute_all_observers ()
 
void mute_observer (const simple_wml::node &mute, const socket_ptr muter)
 Mute an observer or give a message of all currently muted observers if no name is given. More...
 
void unmute_observer (const simple_wml::node &unmute, const socket_ptr unmuter)
 
socket_ptr kick_member (const simple_wml::node &kick, const socket_ptr kicker)
 Kick a member by name. More...
 
socket_ptr ban_user (const simple_wml::node &ban, const socket_ptr banner)
 Ban and kick a user by name. More...
 
void unban_user (const simple_wml::node &unban, const socket_ptr unbanner)
 
bool add_player (const socket_ptr player, bool observer=false)
 Add a user to the game. More...
 
bool remove_player (const socket_ptr player, const bool disconnect=false, const bool destruct=false)
 Removes a user from the game. More...
 
const user_vector all_game_users () const
 Adds players and observers into one vector and returns that. More...
 
void start_game (const socket_ptr starter)
 
void perform_controller_tweaks ()
 
void update_game ()
 
void load_next_scenario (const socket_ptr user)
 A user (player only?) asks for the next scenario to advance to. More...
 
void update_side_data ()
 Resets the side configuration according to the scenario data. More...
 
void transfer_side_control (const socket_ptr sock, const simple_wml::node &cfg)
 Let's a player owning a side give it to another player or observer. More...
 
void process_message (simple_wml::document &data, const socket_ptr user)
 
bool process_turn (simple_wml::document &data, const socket_ptr user)
 Handles [end_turn], repackages [commands] with private [speak]s in them and sends the data. More...
 
void process_whiteboard (simple_wml::document &data, const socket_ptr user)
 Handles incoming [whiteboard] data. More...
 
void process_change_turns_wml (simple_wml::document &data, const socket_ptr user)
 Handles incoming [change_turns_wml] data. More...
 
bool describe_slots ()
 Set the description to the number of available slots. More...
 
void send_server_message_to_all (const char *message, socket_ptr exclude=socket_ptr()) const
 
void send_server_message_to_all (const std::string &message, socket_ptr exclude=socket_ptr()) const
 
void send_server_message (const char *message, socket_ptr sock=socket_ptr(), simple_wml::document *doc=nullptr) const
 
void send_server_message (const std::string &message, socket_ptr sock=socket_ptr(), simple_wml::document *doc=nullptr) const
 
void send_and_record_server_message (const char *message, const socket_ptr exclude=socket_ptr())
 Send data to all players in this game except 'exclude'. More...
 
void send_and_record_server_message (const std::string &message, const socket_ptr exclude=socket_ptr())
 
void send_data (simple_wml::document &data, const socket_ptr exclude=socket_ptr(), std::string packet_type="") const
 
void clear_history ()
 
void record_data (simple_wml::document *data)
 
void save_replay ()
 
simple_wml::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::stringtermination_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

socket_ptr host
 
socket_ptr const std::stringname =""
 
socket_ptr const std::string bool save_replays =false
 
socket_ptr const std::string
bool const std::string
replay_save_path ="")
 

Private Types

typedef boost::ptr_vector
< simple_wml::document
t_history
 Replay data. More...
 

Private Member Functions

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

Private Attributes

player_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...
 
t_history history_
 
simple_wml::nodedescription_
 Pointer to the game's description in the games_and_users_list_. More...
 
int end_turn_
 
int num_turns_
 
bool all_observers_muted_
 
std::vector< std::stringbans_
 
std::string termination_
 
bool save_replays_
 
std::string replay_save_path_
 
rand_rng::mt_rng rng_
 A wrapper for mersenne twister rng which generates randomness for this game. More...
 
int last_choice_request_id_
 

Static Private Attributes

static int id_num = 1
 

Detailed Description

Definition at line 37 of file game.hpp.

Member Typedef Documentation

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

Replay data.

Definition at line 395 of file game.hpp.

Constructor & Destructor Documentation

wesnothd::game::~game ( )

Definition at line 120 of file game.cpp.

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

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

Definition at line 80 of file game.cpp.

References id_, missing_user(), name_, owner_, player_connections_, players_, and wesnothd::player::PLAYING.

Member Function Documentation

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

Adds players and observers into one vector and returns that.

Definition at line 1586 of file game.cpp.

References observers_, and players_.

Referenced by wesnothd::room_manager::enter_lobby(), has_same_ip(), send_data(), send_user_list(), update_side_data(), and ~game().

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

Definition at line 260 of file game.hpp.

References all_observers_muted_.

bool wesnothd::game::allow_observers ( ) const

Definition at line 145 of file game.cpp.

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

Referenced by add_player().

socket_ptr wesnothd::game::ban_user ( const simple_wml::node ban,
const socket_ptr  banner 
)

Ban and kick a user by name.

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

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

Definition at line 767 of file game.cpp.

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

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

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

Definition at line 1563 of file game.cpp.

References history_.

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

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

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

Definition at line 1420 of file game.cpp.

References sides_.

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

Definition at line 255 of file game.hpp.

References current_side(), nsides_, and sides_.

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

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

Definition at line 254 of file game.hpp.

References end_turn_, and nsides_.

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

size_t wesnothd::game::current_turn ( ) const
inline

Definition at line 91 of file game.hpp.

References end_turn_, and nsides_.

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

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

Helps debugging player and observer lists.

Definition at line 1595 of file game.cpp.

References id_, observers_, player_connections_, and players_.

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

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

Helps debugging controller tweaks.

Definition at line 1626 of file game.cpp.

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

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

bool wesnothd::game::describe_slots ( )

Set the description to the number of available slots.

Returns
True iff the number of slots has changed.

Definition at line 604 of file game.cpp.

References description_, get_sides_list(), i, simple_wml::node::set_attr_dup(), sides_, and started_.

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

simple_wml::node* wesnothd::game::description ( ) const
inline
bool wesnothd::game::end_turn ( )
private

Function which should be called every time a player ends their turn (i.e.

[end_turn] received). This will update the 'turn' attribute for the game's description when appropriate. Will return true iff there has been a change.

Definition at line 1138 of file game.cpp.

References current_side(), current_turn(), description_, end_turn_, i, nsides_, num_turns_, simple_wml::node::set_attr_dup(), and side_controllers_.

Referenced by process_turn(), and start_game().

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

References gui2::event::find(), player_connections_, and simple_wml::string_span::to_string().

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

const simple_wml::node::child_list& wesnothd::game::get_sides_list ( ) const
inline
void wesnothd::game::handle_choice ( const simple_wml::node data,
const socket_ptr  user 
)
void wesnothd::game::handle_controller_choice ( const simple_wml::node data)
void wesnothd::game::handle_random_choice ( const simple_wml::node data)
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 1432 of file game.cpp.

References all_game_users(), wesnothd::client_address(), i, player_connections_, and players_.

Referenced by add_player().

int wesnothd::game::id ( ) const
inline
bool wesnothd::game::is_current_player ( const socket_ptr  player) const
inlineprivate

Definition at line 257 of file game.hpp.

References current_player().

Referenced by is_legal_command(), and process_turn().

bool wesnothd::game::is_legal_command ( const simple_wml::node command,
const socket_ptr  user 
)
private
bool wesnothd::game::is_member ( const socket_ptr  player) const
inline
bool wesnothd::game::is_muted_observer ( const socket_ptr  player) const
private
bool wesnothd::game::is_observer ( const socket_ptr  player) const
bool wesnothd::game::is_owner ( const socket_ptr  player) const
inline

Definition at line 54 of file game.hpp.

References owner_.

Referenced by wesnothd::server::handle_player_in_game(), and wesnothd::game_is_member::operator()().

bool wesnothd::game::is_player ( const socket_ptr  player) const
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 736 of file game.cpp.

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

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

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

The full scenario data.

Definition at line 216 of file game.hpp.

References level_.

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

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

Definition at line 64 of file game.hpp.

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

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

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

References missing_user(), and player_connections_.

Referenced by send_muted_observers(), and start_game().

void wesnothd::game::load_next_scenario ( const socket_ptr  user)
wesnothd::game::MAKE_ENUM ( CONTROLLER  ,
(HUMAN,"human")(AI,"ai")(EMPTY,"null")   
)
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 74 of file game.cpp.

References id_, name_, and WRN_GAME.

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

void wesnothd::game::mute_all_observers ( )
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 656 of file game.cpp.

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

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

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

Definition at line 52 of file game.hpp.

References name_.

Referenced by save_replay().

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

Definition at line 90 of file game.hpp.

References observers_.

void wesnothd::game::notify_new_host ( )
private

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

Definition at line 594 of file game.cpp.

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

Referenced by remove_player().

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

Definition at line 89 of file game.hpp.

References players_.

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

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

Definition at line 307 of file game.hpp.

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

Definition at line 306 of file game.hpp.

void wesnothd::game::operator= ( const game )
private
bool wesnothd::game::password_matches ( const std::string passwd) const
inline

Definition at line 226 of file game.hpp.

References password_.

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

Checks whether the connection's ip address is banned.

Definition at line 630 of file game.cpp.

References bans_, wesnothd::client_address(), and gui2::event::find().

Referenced by ban_user(), and unban_user().

void wesnothd::game::process_change_turns_wml ( simple_wml::document data,
const socket_ptr  user 
)
void wesnothd::game::process_message ( simple_wml::document data,
const socket_ptr  user 
)
bool wesnothd::game::process_turn ( simple_wml::document data,
const socket_ptr  user 
)
void wesnothd::game::process_whiteboard ( simple_wml::document data,
const socket_ptr  user 
)
void wesnothd::game::record_data ( simple_wml::document data)
bool wesnothd::game::registered_users_only ( ) const

Definition at line 149 of file game.cpp.

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

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

Definition at line 244 of file game.hpp.

References last_choice_request_id_.

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

void wesnothd::game::reset_sides ( )
private

calculates the initial value for sides_, side_controllerds_, nsides_

Definition at line 391 of file game.cpp.

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

Referenced by update_side_data().

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

Definition at line 204 of file game.hpp.

References send_and_record_server_message().

void wesnothd::game::send_data ( simple_wml::document data,
const socket_ptr  exclude = socket_ptr(),
std::string  packet_type = "" 
) const
void wesnothd::game::send_data_observers ( simple_wml::document data,
const socket_ptr  exclude = socket_ptr(),
std::string  packet_type = "" 
) const
private
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 1408 of file game.cpp.

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

Referenced by process_turn(), and process_whiteboard().

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

Definition at line 730 of file game.cpp.

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

Referenced by ban_user(), and kick_member().

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

Definition at line 645 of file game.cpp.

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

Referenced by mute_observer().

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

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

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

void wesnothd::game::send_observerquit ( const socket_ptr  observer) const
private
void wesnothd::game::send_server_message ( const char *  message,
socket_ptr  sock = socket_ptr(),
simple_wml::document doc = nullptr 
) const
void wesnothd::game::send_server_message ( const std::string message,
socket_ptr  sock = socket_ptr(),
simple_wml::document doc = nullptr 
) const
inline

Definition at line 197 of file game.hpp.

References send_server_message().

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

Definition at line 191 of file game.hpp.

References send_server_message_to_all().

bool wesnothd::game::send_taken_side ( simple_wml::document cfg,
const simple_wml::node::child_list::const_iterator  side 
) const
private
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.

Todo:
Should be renamed to userlist.

Definition at line 1319 of file game.cpp.

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

Referenced by add_player(), and remove_player().

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

Definition at line 92 of file game.hpp.

References current_side(), end_turn_, and nsides_.

Referenced by process_change_turns_wml().

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

Functions to set/get the address of the game's summary description as sent to players in the lobby.

Definition at line 1568 of file game.cpp.

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

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

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

Definition at line 225 of file game.hpp.

References password_.

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

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

Definition at line 1575 of file game.cpp.

References termination_.

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

void wesnothd::game::start_game ( const socket_ptr  starter)
bool wesnothd::game::started ( ) const
inline

Definition at line 87 of file game.hpp.

References started_.

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

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

Definition at line 74 of file game.hpp.

References simple_wml::node::child().

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

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

Referenced by add_player().

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

Definition at line 230 of file game.hpp.

References started_, and termination_.

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

void wesnothd::game::transfer_ai_sides ( const socket_ptr  player)
private
void wesnothd::game::transfer_side_control ( const socket_ptr  sock,
const simple_wml::node cfg 
)
void wesnothd::game::unban_user ( const simple_wml::node unban,
const socket_ptr  unbanner 
)
void wesnothd::game::unmute_observer ( const simple_wml::node unmute,
const socket_ptr  unmuter 
)
void wesnothd::game::update_game ( )
void wesnothd::game::update_side_data ( )
std::string wesnothd::game::username ( const socket_ptr  pl) const
private

Member Data Documentation

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

Definition at line 405 of file game.hpp.

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

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

Pointer to the game's description in the games_and_users_list_.

Definition at line 399 of file game.hpp.

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

int wesnothd::game::end_turn_
private
t_history wesnothd::game::history_
mutableprivate

Definition at line 396 of file game.hpp.

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

socket_ptr wesnothd::game::host

Definition at line 46 of file game.hpp.

Referenced by remove_player().

int wesnothd::game::id_
private
int wesnothd::game::id_num = 1
staticprivate

Definition at line 350 of file game.hpp.

int wesnothd::game::last_choice_request_id_
private

Definition at line 414 of file game.hpp.

Referenced by handle_choice(), and reset_last_synced_context_id().

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 seperate object (like in side_controllers_).

Definition at line 392 of file game.hpp.

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

user_vector wesnothd::game::muted_observers_
private

Definition at line 365 of file game.hpp.

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

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

Definition at line 47 of file game.hpp.

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

std::string wesnothd::game::name_
private
int wesnothd::game::nsides_
private

Number of sides in the current scenario.

Definition at line 373 of file game.hpp.

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

int wesnothd::game::num_turns_
private

Definition at line 402 of file game.hpp.

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

user_vector wesnothd::game::observers_
private

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

Definition at line 364 of file game.hpp.

Referenced by add_player(), all_game_users(), debug_player_info(), is_observer(), nobservers(), process_turn(), remove_player(), send_observerjoins(), transfer_side_control(), and update_side_data().

socket_ptr wesnothd::game::owner_
private
std::string wesnothd::game::password_
private

Definition at line 355 of file game.hpp.

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

player_connections& wesnothd::game::player_connections_
private
user_vector wesnothd::game::players_
private
socket_ptr const std::string bool const std::string& wesnothd::game::replay_save_path ="")

Definition at line 48 of file game.hpp.

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

Definition at line 410 of file game.hpp.

Referenced by save_replay().

rand_rng::mt_rng wesnothd::game::rng_
private

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

Definition at line 413 of file game.hpp.

Referenced by handle_random_choice().

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

Definition at line 47 of file game.hpp.

bool wesnothd::game::save_replays_
private

Definition at line 409 of file game.hpp.

Referenced by save_replay().

std::vector<CONTROLLER> wesnothd::game::side_controllers_
private
side_vector wesnothd::game::sides_
private
bool wesnothd::game::started_
private
std::string wesnothd::game::termination_
private

Definition at line 407 of file game.hpp.

Referenced by set_termination_reason(), and termination_reason().


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