31 #define ERR_GAME LOG_STREAM(err, log_server) 32 #define WRN_GAME LOG_STREAM(warn, log_server) 33 #define LOG_GAME LOG_STREAM(info, log_server) 34 #define DBG_GAME LOG_STREAM(debug, log_server) 37 #define WRN_CONFIG LOG_STREAM(warn, log_config) 44 res.push_back(span.
to_int());
48 template<
typename TResult,
typename TConvert>
51 std::vector<TResult> res;
56 while(i2 != val.
end()) {
79 const std::string& name,
81 const std::string& replay_save_path)
83 , player_connections_(player_connections)
98 , description_(nullptr)
100 , current_side_index_(0)
102 , all_observers_muted_(false)
105 , players_not_advanced_()
107 , save_replays_(save_replays)
108 , replay_save_path_(replay_save_path)
110 , last_choice_request_id_(-1)
139 ERR_GAME <<
"no [multiplayer] found. Returning root\n";
174 return iter->info().name();
181 for(
auto user : users) {
186 list += user->info().name();
196 DBG_GAME <<
"****\n Performing controller tweaks. sides = " << std::endl;
202 for(
unsigned side_index = 0; side_index < sides.size(); ++side_index) {
205 if(side[
"controller"] !=
"null") {
208 std::stringstream
msg;
209 msg <<
"Side " << side_index + 1
210 <<
" had no controller during controller tweaks! The host was assigned control.";
235 std::stringstream
msg;
236 msg <<
"Side " << side_index + 1 <<
" had no controller AFTER controller tweaks! Ruh Roh!";
254 DBG_GAME <<
"****\n Starting game. sides = " << std::endl;
264 const bool save = multiplayer[
"savegame"].to_bool();
266 << starter->client_ip() <<
"\t" << starter->name() <<
"\t" 267 << (advance ?
"advanced" :
"started") << (save ?
" reloaded" :
"") <<
" game:\t\"" <<
name_ <<
"\" (" <<
id_ 269 <<
". Settings: map: " << multiplayer[
"mp_scenario"]
270 <<
"\tera: " << multiplayer[
"mp_era"]
271 <<
"\tXP: " << multiplayer[
"experience_modifier"]
272 <<
"\tGPV: " << multiplayer[
"mp_village_gold"]
273 <<
"\tfog: " << multiplayer[
"mp_fog"]
274 <<
"\tshroud: " << multiplayer[
"mp_shroud"]
275 <<
"\tobservers: " << multiplayer[
"observer"]
276 <<
"\tshuffle: " << multiplayer[
"shuffle_sides"]
277 <<
"\ttimer: " << multiplayer[
"mp_countdown"]
278 << (multiplayer[
"mp_countdown"].to_bool()
279 ?
"\treservoir time: " + multiplayer[
"mp_countdown_reservoir_time"].to_string()
280 +
"\tinit time: " + multiplayer[
"mp_countdown_init_time"].to_string()
281 +
"\taction bonus: " + multiplayer[
"mp_countdown_action_bonus"].to_string()
282 +
"\tturn bonus: " + multiplayer[
"mp_countdown_turn_bonus"].to_string()
287 for(
unsigned side_index = 0; side_index < sides.size(); ++side_index) {
290 if(side[
"controller"] !=
"null") {
291 if(side_index >=
sides_.size()) {
296 std::stringstream
msg;
297 msg <<
"Side " << side_index + 1
298 <<
" has no controller but should! The host needs to assign control for the game to proceed past " 313 turn = lexical_cast_default<int>((*snapshot)[
"turn_at"], 1);
314 side = lexical_cast_default<int>((*snapshot)[
"playing_team"], 0);
315 LOG_GAME <<
"Reload from turn: " << turn <<
". Current side is: " << side + 1 <<
".\n";
338 const std::size_t side_index = (*side)[
"side"].to_int() - 1;
341 if(side_index >=
sides_.size()) {
374 if(((*side)[
"controller"] ==
"human" || (*side)[
"controller"] ==
"reserved")
375 && (*side)[
"current_player"] == user->name().c_str()) {
385 if((*side)[
"controller"] ==
"human") {
392 DBG_GAME <<
"take_side: there are no more sides available\n";
419 DBG_GAME <<
"update_side_data...\n";
435 for(
auto iter : users) {
437 bool side_found =
false;
438 for(
unsigned side_index = 0; side_index < level_sides.size(); ++side_index) {
448 if(player_id == iter->info().name().c_str()) {
450 if(controller !=
"human" && controller !=
"ai") {
455 sides_[side_index] = iter;
457 }
else if(iter ==
owner_ && (controller ==
"null")) {
478 DBG_GAME <<
"transfer_side_control...\n";
486 const unsigned int side_num = cfg[
"side"].to_int();
487 if(side_num < 1 || side_num >
sides_.size()) {
488 std::ostringstream
msg;
489 msg <<
"The side number has to be between 1 and " <<
sides_.size() <<
".";
500 auto old_player =
sides_[side_num - 1];
501 const std::string& controller_type = cfg[
"to"].to_string();
503 const std::string old_player_name = old_player ?
username(*old_player) :
"null";
506 if(newplayer_name.
empty()) {
507 std::stringstream
msg;
508 msg <<
"Received invalid [change_controller] with no player= attribute specified";
515 if(!(player == old_player || player ==
owner_)) {
516 std::stringstream
msg;
517 msg <<
"You can't give away side " << side_num <<
". It's controlled by '" << old_player_name <<
"' not you.";
524 auto newplayer {
find_user(newplayer_name) };
527 if(!newplayer || !
is_member(*newplayer)) {
532 if(newplayer == old_player) {
535 if(CONTROLLER::string_to_enum(controller_type) ==
side_controllers_[side_num - 1]) {
536 std::stringstream
msg;
537 msg <<
"Side " << side_num <<
" is already controlled by " << newplayer_name <<
".";
547 sides_[side_num - 1].reset();
578 const std::size_t side_index,
player_iterator player,
const std::string& player_name,
const bool player_left)
582 const std::string& side = lexical_cast_default<std::string, std::size_t>(side_index + 1);
583 sides_[side_index] = player;
604 response->root().child(
"change_controller")->set_attr(
"is_local",
"yes");
611 const std::string& side = std::to_string(side_index + 1);
623 return response.
clone();
632 std::string message = owner_name +
" has been chosen as the new host.";
643 int available_slots = 0;
648 if(((*side)[
"allow_player"].to_bool(
true) ==
false) || (*side)[
"controller"] ==
"null") {
670 auto ban = std::find(
bans_.begin(),
bans_.end(), player->client_ip());
706 if(username.
empty()) {
734 << (*user)->client_ip() <<
")\tin game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")\n";
748 if(username.
empty()) {
766 << (*user)->client_ip() <<
")\tin game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")\n";
791 }
else if(user == kicker) {
794 }
else if((*user)->info().is_moderator()) {
800 << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")\n";
823 }
else if(user == banner) {
829 }
else if((*user)->info().is_moderator()) {
835 << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")\n";
837 bans_.push_back((*user)->client_ip());
873 << unbanner->client_ip() <<
"\t" << unbanner->info().name()
874 <<
"\tunbanned: " << username <<
" (" << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" (" 886 message->
set_attr_dup(
"sender", user->info().name().c_str());
897 const bool is_host = user ==
owner_;
901 const std::size_t from_side_index = command[
"from_side"].to_int() - 1;
904 if(command[
"from_side"] ==
"server") {
908 if(from_side_index >=
sides_.size() ||
sides_[from_side_index] != user) {
925 if(command.
child(
"speak")) {
928 if(command.
child(
"surrender")) {
943 if(is_player && command.
has_attr(
"dependent") && command.
has_attr(
"from_side")) {
947 if((is_player || is_host) && (
948 command.
child(
"label") ||
949 command.
child(
"clear_labels") ||
950 command.
child(
"rename") ||
951 command.
child(
"countdown_update")
967 bool turn_ended =
false;
972 bool repackage =
false;
974 std::vector<int> marked;
979 DBG_GAME <<
"game " <<
id_ <<
", " <<
db_id_ <<
" received [" << (*command).first_child() <<
"] from player '" <<
username(user)
985 std::stringstream
msg;
986 msg <<
"Removing illegal command '" << (*command).first_child().to_string() <<
"' from: " <<
username(user)
992 marked.push_back(index - marked.size());
993 }
else if((*command).child(
"speak")) {
996 DBG_GAME <<
"repackaging..." << std::endl;
1009 const std::size_t side_index = speak[
"side"].to_int() - 1;
1011 if(side_index >=
sides_.size() ||
sides_[side_index] != user) {
1015 const auto s = std::find(
sides_.begin(),
sides_.end(), user);
1016 speak.
set_attr_dup(
"side", lexical_cast_default<std::string>(
s -
sides_.begin() + 1).c_str());
1020 }
else if (command->child(
"surrender")) {
1021 std::size_t side_index = 0;
1030 if(side_index < sides_.size()) {
1032 std::string playername;
1037 playername =
username(*sides_[(side_index + 1) % sides_.size()]);
1048 turn_ended =
end_turn(endturn[
"next_player_number"].to_int());
1054 for(
const int j : marked) {
1070 if(speak ==
nullptr) {
1071 auto mdata = std::make_unique<simple_wml::document>();
1073 (*command).
copy_into(mturn.add_child(
"command"));
1087 auto message = std::make_unique<simple_wml::document>();
1090 message_turn_command.
set_attr(
"undo",
"no");
1093 if(to_sides.
empty()) {
1094 send_data(*message, user,
"game message");
1111 std::stringstream stream;
1112 stream << std::setfill(
'0') << std::setw(
sizeof(uint32_t) * 2) << std::hex << seed;
1114 auto mdata = std::make_unique<simple_wml::document>();
1119 random_seed.
set_attr_dup(
"new_seed", stream.str().c_str());
1121 command.
set_attr(
"from_side",
"server");
1122 command.
set_attr(
"dependent",
"yes");
1137 const std::size_t side_index = req[
"side"].to_int() - 1;
1138 CONTROLLER new_controller;
1139 CONTROLLER old_controller;
1141 if(!new_controller.parse(req[
"new_controller"])) {
1143 "Could not handle [request_choice] [change_controller] with invalid controller '" + req[
"new_controller"].to_string() +
"'");
1147 if(!old_controller.parse(req[
"old_controller"])) {
1149 "Could not handle [request_choice] [change_controller] with invalid controller '" + req[
"old_controller"].to_string() +
"'");
1155 "Found unexpected old_controller= '" + old_controller.to_string() +
"' in [request_choice] [change_controller]");
1158 if(side_index >=
sides_.size()) {
1160 "Could not handle [request_choice] [change_controller] with invalid side '" + req[
"side"].to_string() +
"'");
1165 const bool becomes_null = new_controller == CONTROLLER::EMPTY;
1168 assert(!
sides_[side_index]);
1173 sides_[side_index].reset();
1178 auto mdata = std::make_unique<simple_wml::document>();
1183 change_controller_wml.
set_attr_dup(
"controller", new_controller.to_cstring());
1184 change_controller_wml.
set_attr(
"is_local",
"yes");
1186 command.
set_attr(
"from_side",
"server");
1187 command.
set_attr(
"dependent",
"yes");
1193 change_controller_wml.
set_attr(
"is_local",
"no");
1222 int request_id = lexical_cast_default<int>(data[
"request_id"], -10);
1228 DBG_GAME <<
"answering seed request " << request_id <<
" by player " 1229 << user->info().name() <<
"(" << user->socket() <<
")" << std::endl;
1253 std::size_t
const side_index = wb_node[
"side"].to_int() - 1;
1255 if(side_index >=
sides_.size() ||
sides_[side_index] != user) {
1256 std::ostringstream
msg;
1257 msg <<
"Ignoring illegal whiteboard data, sent from user '" << user->info().name()
1258 <<
"' which had an invalid side '" << side_index + 1 <<
"' specified" << std::endl;
1260 const std::string& msg_str = msg.str();
1278 const int num_turns = ctw_node[
"max"].to_int();
1279 if(num_turns > 10000 || current_turn > 10000) {
1287 assert(static_cast<int>(this->
current_turn()) == current_turn);
1354 ERR_GAME <<
"ERROR: Player is already in this game. (socket: " << player->socket() <<
")\n";
1362 bool became_observer =
false;
1374 became_observer =
true;
1378 DBG_GAME <<
"adding observer...\n";
1382 user->info().name() +
" is now observing the game.", player);
1386 observer_join.
root()
1395 << player->client_ip() <<
"\t" << user->info().name() <<
"\tjoined game:\t\"" 1396 <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")" << (observer ?
" as an observer" :
"") <<
". (socket: " << player->socket()
1399 user->info().mark_available(
id_,
name_);
1422 if(!clones.empty()) {
1424 user->info().name() +
" has the same IP as: " + clones);
1427 if(became_observer) {
1438 ERR_GAME <<
"ERROR: User is not in this game. (socket: " << player->socket() <<
")\n";
1443 DBG_GAME <<
"removing player...\n";
1445 const bool host = (player ==
owner_);
1457 << user->client_ip()
1458 <<
"\t" << user->info().name()
1459 << ((game_ended && !(observer && destruct)) ? (
started_ ?
"\tended" :
"\taborted") :
"\thas left")
1460 <<
" game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")" 1461 << (game_ended &&
started_ && !(observer && destruct)
1462 ?
" at turn: " + lexical_cast_default<std::string, std::size_t>(
current_turn())
1465 << (observer ?
" as an observer" :
"") << (disconnect ?
" and disconnected" :
"") <<
". (socket: " << user->socket()
1468 if(game_ended &&
started_ && !(observer && destruct)) {
1472 if(game_ended || destruct) {
1479 user->info().mark_available();
1486 + (disconnect ?
" has disconnected." :
" has left the game."), player);
1495 bool ai_transfer =
false;
1499 for(
unsigned side_index = 0; side_index <
sides_.size(); ++side_index) {
1500 auto side =
sides_[side_index];
1502 if(side != player) {
1514 DBG_GAME <<
"making the owner a player...\n";
1522 const std::string side_drop = lexical_cast_default<std::string, std::size_t>(side_index + 1);
1527 node_side_drop.
set_attr_dup(
"side_num", side_drop.c_str());
1530 DBG_GAME <<
"*** sending side drop: \n" << drop.output() << std::endl;
1570 assert(sender ==
owner_);
1573 if(user_ptr != sender) {
1589 DBG_GAME <<
"****\n loading next scenario for a client. sides info = " << std::endl;
1615 for(
const auto& side_user :
sides_) {
1617 cfg_controller.
set_attr(
"is_local", side_user == user ?
"yes" :
"no");
1632 template<
typename Container>
1635 for(
const auto&
player : players) {
1649 std::optional<player_iterator> exclude)
1651 std::vector<int> sides_vec = ::split<int>(sides, ::split_conv_impl);
1655 decltype(
players_) filtered_players;
1657 std::copy_if(
players_.begin(),
players_.end(), std::back_inserter(filtered_players),
1665 for(
int side : sides) {
1666 std::size_t side_index = side - 1;
1668 if(side_index <
sides_.size() &&
sides_[side_index] == player) {
1679 const std::string ip = user->client_ip();
1682 for(
auto u : users) {
1683 if(ip == u->client_ip() && user != u) {
1684 clones += (clones.empty() ?
"" :
", ") + u->info().name();
1716 observer_quit.
root()
1718 .
set_attr_dup(
"name", observer->info().name().c_str());
1744 history_.push_back(std::move(doc));
1752 return !(isalnum(c) ||
1772 std::stringstream
name;
1774 std::string filename(name.str());
1775 std::replace(filename.begin(), filename.end(),
' ',
'_');
1786 std::string replay_commands;
1797 std::stringstream replay_data;
1804 const bool has_old_replay =
level_.
child(
"replay") !=
nullptr;
1816 << (has_old_replay ?
"" :
"\t[command]\n\t\t[start]\n\t\t[/start]\n\t[/command]\n")
1817 << replay_commands <<
"[/replay]\n";
1819 std::string replay_data_str = replay_data.str();
1823 DBG_GAME <<
"saving replay: " << filename << std::endl;
1826 (*os) <<
replay.output_compressed(
true);
1829 ERR_GAME <<
"Could not save replay! (" << filename <<
")" << std::endl;
1839 history_.push_back(std::move(data));
1881 std::stringstream result;
1882 result <<
"game id: " <<
id_ <<
", " <<
db_id_ <<
"\n";
1886 result <<
"player: " << user->info().name().c_str() <<
"\n";
1891 result <<
"observer: " << user->info().name().c_str() <<
"\n";
1898 return result.str();
1903 std::stringstream result;
1904 result <<
"game id: " <<
id_ <<
", " <<
db_id_ <<
"\n";
1907 result <<
"\t\t level, server\n";
1911 <<
"side " << (*s)[
"side"].to_int()
1912 <<
" :\t" << (*s)[
"controller"].to_string()
1914 <<
"\t( " << (*
sides_[(*s)[
"side"].to_int() - 1])->socket()
1915 <<
",\t" << (*s)[
"current_player"].to_string() <<
" )\n";
1918 return result.str();
1933 auto doc = std::make_unique<simple_wml::document>();
1952 if(docptr ==
nullptr) {
1981 return multiplayer.
has_attr(
"savegame") && multiplayer[
"savegame"].to_bool();
node & add_child(const char *name)
const char * const_iterator
void remove()
Removes a tip.
const string_span & attr(const char *key) const
bool is_muted_observer(player_iterator player) const
void handle_choice(const simple_wml::node &data, player_iterator user)
std::set< const player_record * > players_not_advanced_
in multiplayer campaigns it can happen that some players are still in the previous scenario keep trac...
void send_and_record_server_message(const char *message, std::optional< player_iterator > exclude={})
Send data to all players in this game except 'exclude'.
void set_current_turn(int turn)
std::string to_string() const
void send_observerquit(player_iterator observer)
const std::string & name() const
player_connections & player_connections_
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...
std::optional< player_iterator > ban_user(const simple_wml::node &ban, player_iterator banner)
Ban and kick a user by name.
void send_to_players(simple_wml::document &data, const Container &players, std::optional< player_iterator > exclude={})
bool has_attr(const char *key) const
void process_change_turns_wml(simple_wml::document &data, player_iterator user)
Handles incoming [change_turns_wml] data.
bool is_player(player_iterator player) const
std::vector< std::unique_ptr< simple_wml::document > > history_
Replay data.
void handle_random_choice(const simple_wml::node &data)
const simple_wml::node::child_list & get_sides_list() const
bool is_current_player(player_iterator player) const
New lexcical_cast header.
user_vector muted_observers_
void update_side_data()
Resets the side configuration according to the scenario data.
bool player_is_banned(player_iterator player, const std::string &name) const
Checks whether the connection's ip address or username is banned.
std::string username(player_iterator pl) const
Returns the name of the user or "(unfound)".
node & set_attr_int(const char *key, int value)
uint32_t get_next_random()
Get a new random number.
node & set_attr(const char *key, const char *value)
std::optional< player_iterator > find_user(const simple_wml::string_span &name)
Shortcut to a convenience function for finding a user by name.
std::size_t current_side() const
int nsides_
Number of sides in the current scenario.
user_vector observers_
A vector of observers (members not owning a side).
void send_leave_game(player_iterator user) const
bool is_observer(player_iterator player) const
bool all_observers_muted_
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
bool is_member(player_iterator player) const
void new_scenario(player_iterator player)
when the host sends the new scenario of a mp campaign
randomness::mt_rng rng_
A wrapper for mersenne twister rng which generates randomness for this game.
node & set_attr_dup(const char *key, const char *value)
const child_list & children(const char *name) const
player_iterator owner_
The game host or later owner (if the host left).
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...
player_connections::const_iterator player_iterator
std::vector< std::string > bans_
bool is_legal_command(const simple_wml::node &command, player_iterator user)
std::unique_ptr< document > clone()
node * child(const char *name)
node * child(const char *name)
const char * begin() const
int last_choice_request_id_
void truncate_message(const simple_wml::string_span &str, simple_wml::node &message)
Function to ensure a text message is within the allowed length.
bool end_turn(int new_side)
Function which should be called every time a player ends their turn (i.e.
static lg::log_domain log_config("config")
void reset_sides()
calculates the initial value for sides_, side_controllerds_, nsides_
std::vector< CONTROLLER > side_controllers_
void process_whiteboard(simple_wml::document &data, player_iterator user)
Handles incoming [whiteboard] data.
void send_history(player_iterator sock) const
bool allow_observers() const
void handle_controller_choice(const simple_wml::node &data)
bool describe_slots()
Set the description to the number of available slots.
void transfer_side_control(player_iterator player, const simple_wml::node &cfg)
Let's a player owning a side give it to another player or observer.
static bool is_invalid_filename_char(char c)
std::unique_ptr< simple_wml::document > change_controller_type(const std::size_t side_num, player_iterator player, const std::string &player_name)
static lg::log_domain log_server("server")
void process_message(simple_wml::document &data, player_iterator)
std::string get_replay_filename()
std::optional< player_iterator > current_player() const
void start_game(player_iterator starter)
const user_vector all_game_users() const
Adds players and observers into one vector and returns that.
bool controls_side(const std::vector< int > &sides, player_iterator player) const
Function which returns true iff 'player' controls any of the sides spcified in 'sides'.
void perform_controller_tweaks()
bool remove_player(player_iterator player, const bool disconnect=false, const bool destruct=false)
Removes a user from the game.
std::optional< player_iterator > kick_member(const simple_wml::node &kick, player_iterator kicker)
Kick a member by name.
void load_next_scenario(player_iterator user)
A user (player only?) asks for the next scenario to advance to.
bool is_owner(player_iterator player) const
std::unique_ptr< std::ostream > scoped_ostream
static simple_wml::node * starting_pos(simple_wml::node &data)
void send_server_message(const char *message, std::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
std::vector< std::string > name_bans_
void record_data(std::unique_ptr< simple_wml::document > data)
node & set_attr_dup(const char *key, const char *value)
void send_observerjoins(std::optional< player_iterator > player={})
Send [observer] tags of all the observers in the game to the user or everyone if none given...
static map_location::DIRECTION s
void remove_child(const char *name, std::size_t index)
std::vector< node * > child_list
bool add_player(player_iterator player, bool observer=false)
Add a user to the game.
void async_send_doc_queued(socket_ptr socket, simple_wml::document &doc)
High level wrapper for sending a WML document.
std::size_t current_turn() const
Declarations for File-IO.
side_vector sides_
A vector of side owners.
void notify_new_host()
In case of a host transfer, notify the new host about its status.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
static void save(LexState *ls, int c)
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...
std::string has_same_ip(player_iterator user) const
Checks whether a user has the same IP as any other members of this game.
void change_controller(const std::size_t side_num, player_iterator 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 (hu...
void send_data_sides(simple_wml::document &data, const simple_wml::string_span &sides, std::optional< player_iterator > exclude={})
static const simple_wml::node & get_multiplayer(const simple_wml::node &root)
returns const so that operator [] won't create empty keys if not existent
void handle_add_side_wml(const simple_wml::node &req)
std::string list_users(user_vector users) const
Returns a comma separated list of user names.
simple_wml::node * description_
Pointer to the game's description in the games_and_users_list_.
std::string name_
The name of the game.
void unban_user(const simple_wml::node &unban, player_iterator unbanner)
std::string debug_sides_info() const
Helps debugging controller tweaks.
std::vector< std::string > split(const config_attribute_value &val)
std::vector< player_iterator > user_vector
bmi::multi_index_container< player_record, bmi::indexed_by< bmi::ordered_unique< bmi::tag< socket_t >, bmi::const_mem_fun< player_record, const socket_ptr, &player_record::socket > >, bmi::hashed_unique< bmi::tag< name_t >, bmi::const_mem_fun< player_record, const std::string &, &player_record::name > >, bmi::ordered_non_unique< bmi::tag< game_t >, bmi::const_mem_fun< player_record, int, &player_record::game_id > > > > player_connections
void send_user_list(std::optional< player_iterator > exclude={})
Function to send a list of users to all clients.
const std::string & termination_reason() const
std::string replay_save_path_
Standard logging facilities (interface).
user_vector players_
A vector of players (members owning a side).
void send_server_message_to_all(const char *message, std::optional< player_iterator > exclude={})
void send_muted_observers(player_iterator user) const
bool send_taken_side(simple_wml::document &cfg, const simple_wml::node *side) const
void copy_into(node &n) const
std::string debug_player_info() const
Helps debugging player and observer lists.
void unmute_observer(const simple_wml::node &unmute, player_iterator unmuter)
simple_wml::document level_
The current scenario data.
void mute_all_observers()
bool take_side(player_iterator user)
Figures out which side to take and tells that side to the game owner.
void set_termination_reason(const std::string &reason)
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="")
std::string node_to_string(const node &n)
void send_data(simple_wml::document &data, std::optional< player_iterator > exclude={}, std::string packet_type="")
const std::string observer_team_name
observer team name used for observer team chat
filesystem::scoped_ostream ostream_file(const std::string &fname, bool create_directory)