28 #define ERR_GAME LOG_STREAM(err, log_server)
29 #define WRN_GAME LOG_STREAM(warn, log_server)
30 #define LOG_GAME LOG_STREAM(info, log_server)
31 #define DBG_GAME LOG_STREAM(debug, log_server)
34 #define WRN_CONFIG LOG_STREAM(warn, log_config)
41 res.push_back(span.
to_int());
45 template<
typename TResult,
typename TConvert>
48 std::vector<TResult> res;
53 while(i2 != val.
end()) {
76 const std::string& name,
78 const std::string& replay_save_path)
96 , description_(nullptr)
98 , current_side_index_(0)
100 , all_observers_muted_(false)
103 , players_not_advanced_()
106 , replay_save_path_(replay_save_path)
108 , last_choice_request_id_(-1)
127 }
catch(
const boost::coroutines::detail::forced_unwind&) {
128 ERR_GAME <<
"Caught forced_unwind in game destructor!";
140 ERR_GAME <<
"no [multiplayer] found. Returning root";
175 return iter->info().name();
182 for(
auto user : users) {
187 list += user->info().name();
197 DBG_GAME <<
"****\n Performing controller tweaks. sides = ";
203 for(
unsigned side_index = 0; side_index < sides.size(); ++side_index) {
206 if(side[
"controller"] != side_controller::none) {
209 std::stringstream
msg;
210 msg <<
"Side " << side_index + 1
211 <<
" had no controller during controller tweaks! The host was assigned control.";
232 std::stringstream
msg;
233 msg <<
"Side " << side_index + 1 <<
" had no controller AFTER controller tweaks! Ruh Roh!";
251 DBG_GAME <<
"****\n Starting game. sides = ";
261 const bool save = multiplayer[
"savegame"].to_bool();
263 << starter->client_ip() <<
"\t" << starter->name() <<
"\t"
264 << (advance ?
"advanced" :
"started") << (save ?
" reloaded" :
"") <<
" game:\t\"" <<
name_ <<
"\" (" <<
id_
266 <<
". Settings: map: " << multiplayer[
"mp_scenario"]
267 <<
"\tera: " << multiplayer[
"mp_era"]
268 <<
"\tXP: " << multiplayer[
"experience_modifier"]
269 <<
"\tGPV: " << multiplayer[
"mp_village_gold"]
270 <<
"\tfog: " << multiplayer[
"mp_fog"]
271 <<
"\tshroud: " << multiplayer[
"mp_shroud"]
272 <<
"\tobservers: " << multiplayer[
"observer"]
273 <<
"\tshuffle: " << multiplayer[
"shuffle_sides"]
274 <<
"\ttimer: " << multiplayer[
"mp_countdown"]
275 << (multiplayer[
"mp_countdown"].to_bool()
276 ?
"\treservoir time: " + multiplayer[
"mp_countdown_reservoir_time"].to_string()
277 +
"\tinit time: " + multiplayer[
"mp_countdown_init_time"].to_string()
278 +
"\taction bonus: " + multiplayer[
"mp_countdown_action_bonus"].to_string()
279 +
"\tturn bonus: " + multiplayer[
"mp_countdown_turn_bonus"].to_string()
283 for(
unsigned side_index = 0; side_index < sides.size(); ++side_index) {
286 if(side[
"controller"] != side_controller::none) {
287 if(side_index >=
sides_.size()) {
292 std::stringstream
msg;
293 msg <<
"Side " << side_index + 1
294 <<
" has no controller but should! The host needs to assign control for the game to proceed past "
309 turn = lexical_cast_default<int>((*snapshot)[
"turn_at"], 1);
310 side = lexical_cast_default<int>((*snapshot)[
"playing_team"], 0);
311 LOG_GAME <<
"Reload from turn: " << turn <<
". Current side is: " << side + 1 <<
".";
327 const std::size_t side_index = (*side)[
"side"].to_int() - 1;
330 if(side_index >=
sides_.size()) {
363 if(((*side)[
"controller"] == side_controller::human || (*side)[
"controller"] == side_controller::reserved)
364 && (*side)[
"current_player"] == user->name().c_str()) {
374 if((*side)[
"controller"] == side_controller::human) {
381 DBG_GAME <<
"take_side: there are no more sides available";
424 for(
auto iter : users) {
426 bool side_found =
false;
427 for(
unsigned side_index = 0; side_index < level_sides.size(); ++side_index) {
438 if(player_id == iter->info().name().c_str()) {
447 sides_[side_index] = iter;
472 DBG_GAME <<
"transfer_side_control...";
480 const unsigned int side_num = cfg[
"side"].to_int();
481 if(side_num < 1 || side_num >
sides_.size()) {
482 std::ostringstream
msg;
483 msg <<
"The side number has to be between 1 and " <<
sides_.size() <<
".";
494 auto old_player =
sides_[side_num - 1];
495 const std::string& controller_type = cfg[
"to"].to_string();
497 const std::string old_player_name = old_player ?
username(*old_player) :
"null";
500 if(newplayer_name.
empty()) {
501 std::stringstream
msg;
502 msg <<
"Received invalid [change_controller] with no player= attribute specified";
510 std::stringstream
msg;
511 msg <<
"You can't give away side " << side_num <<
". It's controlled by '" << old_player_name <<
"' not you.";
518 auto newplayer {
find_user(newplayer_name) };
521 if(!newplayer || !
is_member(*newplayer)) {
526 if(newplayer == old_player) {
532 std::stringstream
msg;
533 msg <<
"Side " << side_num <<
" is already controlled by " << newplayer_name <<
".";
543 sides_[side_num - 1].reset();
574 const std::size_t side_index,
player_iterator player,
const std::string& player_name,
const bool player_left)
578 const std::string& side = lexical_cast_default<std::string, std::size_t>(side_index + 1);
600 response->root().child(
"change_controller")->set_attr(
"is_local",
"yes");
607 const std::string& side = std::to_string(side_index + 1);
618 return response.
clone();
627 std::string message = owner_name +
" has been chosen as the new host.";
638 int available_slots = 0;
643 if(((*side)[
"allow_player"].to_bool(
true) ==
false) || (*side)[
"controller"] == side_controller::none) {
728 << (*user)->client_ip() <<
")\tin game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")";
760 << (*user)->client_ip() <<
")\tin game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")";
785 }
else if(user == kicker) {
788 }
else if((*user)->info().is_moderator()) {
794 << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")";
817 }
else if(user == banner) {
823 }
else if((*user)->info().is_moderator()) {
829 << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")";
831 bans_.push_back((*user)->client_ip());
867 << unbanner->client_ip() <<
"\t" << unbanner->info().name()
868 <<
"\tunbanned: " <<
username <<
" (" << (*user)->client_ip() <<
")\tfrom game:\t\"" <<
name_ <<
"\" ("
880 message->set_attr_dup(
"sender", user->info().name().c_str());
891 const bool is_host = user ==
owner_;
895 const std::size_t from_side_index = command[
"from_side"].to_int() - 1;
898 if(command[
"from_side"] ==
"server") {
902 if(from_side_index >=
sides_.size() ||
sides_[from_side_index] != user) {
919 if(command.
child(
"speak")) {
922 if(command.
child(
"surrender")) {
942 command.
child(
"label") ||
943 command.
child(
"clear_labels") ||
944 command.
child(
"rename") ||
945 command.
child(
"countdown_update")
961 bool turn_ended =
false;
966 bool repackage =
false;
968 std::vector<int> marked;
973 DBG_GAME <<
"game " <<
id_ <<
", " <<
db_id_ <<
" received [" << (*command).first_child() <<
"] from player '" <<
username(user)
979 std::stringstream
msg;
980 msg <<
"Removing illegal command '" << (*command).first_child().to_string() <<
"' from: " <<
username(user)
986 marked.push_back(
index - marked.size());
987 }
else if((*command).child(
"speak")) {
1003 const std::size_t side_index = speak[
"side"].to_int() - 1;
1005 if(side_index >=
sides_.size() ||
sides_[side_index] != user) {
1009 const auto s = std::find(
sides_.begin(),
sides_.end(), user);
1010 speak.
set_attr_dup(
"side", lexical_cast_default<std::string>(
s -
sides_.begin() + 1).c_str());
1014 }
else if (command->child(
"surrender")) {
1015 std::size_t side_index = 0;
1024 if(side_index <
sides_.size()) {
1026 std::string playername;
1031 auto new_side_index = (side_index + 1) %
sides_.size();
1032 auto new_owner =
sides_[new_side_index];
1034 new_side_index = (new_side_index + 1) %
sides_.size();
1035 if(new_side_index == side_index) {
1036 ERR_GAME <<
"Ran out of sides to surrender to.";
1039 new_owner =
sides_[new_side_index];
1052 turn_ended =
end_turn(endturn[
"next_player_number"].to_int());
1058 for(
const int j : marked) {
1074 if(speak ==
nullptr) {
1075 auto mdata = std::make_unique<simple_wml::document>();
1091 auto message = std::make_unique<simple_wml::document>();
1094 message_turn_command.
set_attr(
"undo",
"no");
1097 if(to_sides.
empty()) {
1115 std::stringstream stream;
1116 stream << std::setfill(
'0') << std::setw(
sizeof(uint32_t) * 2) << std::hex << seed;
1118 auto mdata = std::make_unique<simple_wml::document>();
1123 random_seed.
set_attr_dup(
"new_seed", stream.str().c_str());
1126 command.
set_attr(
"from_side",
"server");
1127 command.
set_attr(
"dependent",
"yes");
1142 const std::size_t side_index = req[
"side"].to_int() - 1;
1146 if(!new_controller) {
1148 "Could not handle [request_choice] [change_controller] with invalid controller '" + req[
"new_controller"].to_string() +
"'");
1152 if(!old_controller) {
1154 "Could not handle [request_choice] [change_controller] with invalid controller '" + req[
"old_controller"].to_string() +
"'");
1160 "Found unexpected old_controller= '" +
side_controller::get_string(*old_controller) +
"' in [request_choice] [change_controller]");
1163 if(side_index >=
sides_.size()) {
1165 "Could not handle [request_choice] [change_controller] with invalid side '" + req[
"side"].to_string() +
"'");
1169 const bool was_null = this->
side_controllers_[side_index] == side_controller::type::none;
1170 const bool becomes_null = new_controller == side_controller::type::none;
1173 assert(!
sides_[side_index]);
1178 sides_[side_index].reset();
1183 auto mdata = std::make_unique<simple_wml::document>();
1189 change_controller_wml.
set_attr(
"is_local",
"yes");
1192 command.
set_attr(
"from_side",
"server");
1193 command.
set_attr(
"dependent",
"yes");
1199 change_controller_wml.
set_attr(
"is_local",
"no");
1228 int request_id = lexical_cast_default<int>(
data[
"request_id"], -10);
1234 DBG_GAME <<
"answering choice request " << request_id <<
" by player "
1235 << user->info().name();
1238 if(
data.child(
"random_seed")) {
1242 }
else if(
data.child(
"add_side_wml")) {
1259 std::size_t
const side_index = wb_node[
"side"].to_int() - 1;
1261 if(side_index >=
sides_.size() ||
sides_[side_index] != user) {
1262 std::ostringstream
msg;
1263 msg <<
"Ignoring illegal whiteboard data, sent from user '" << user->info().name()
1264 <<
"' which had an invalid side '" << side_index + 1 <<
"' specified" << std::endl;
1266 const std::string& msg_str =
msg.str();
1284 const int num_turns = ctw_node[
"max"].to_int();
1293 assert(
static_cast<int>(this->
current_turn()) == current_turn);
1355 ERR_GAME <<
"ERROR: Player is already in this game.";
1363 bool became_observer =
false;
1375 became_observer =
true;
1383 user->info().name() +
" is now observing the game.",
player);
1387 observer_join.
root()
1396 <<
player->client_ip() <<
"\t" << user->info().
name() <<
"\tjoined game:\t\""
1399 user->info().mark_available(
id_,
name_);
1424 if(!clones.empty()) {
1426 user->info().name() +
" has the same IP as: " + clones);
1429 if(became_observer) {
1440 ERR_GAME <<
"ERROR: User is not in this game.";
1459 << user->client_ip()
1460 <<
"\t" << user->info().name()
1461 << ((game_ended && !(
observer && destruct)) ? (
started_ ?
"\tended" :
"\taborted") :
"\thas left")
1462 <<
" game:\t\"" <<
name_ <<
"\" (" <<
id_ <<
", " <<
db_id_ <<
")"
1464 ?
" at turn: " + lexical_cast_default<std::string, std::size_t>(
current_turn())
1467 << (
observer ?
" as an observer" :
"") << (disconnect ?
" and disconnected" :
"") <<
".";
1473 if(game_ended || destruct) {
1481 user->info().mark_available();
1488 + (disconnect ?
" has disconnected." :
" has left the game."),
player);
1497 bool ai_transfer =
false;
1501 for(
unsigned side_index = 0; side_index <
sides_.size(); ++side_index) {
1502 auto side =
sides_[side_index];
1516 DBG_GAME <<
"making the owner a player...";
1524 const std::string side_drop = lexical_cast_default<std::string, std::size_t>(side_index + 1);
1529 node_side_drop.
set_attr_dup(
"side_num", side_drop.c_str());
1572 assert(sender ==
owner_);
1575 if(user_ptr != sender) {
1591 DBG_GAME <<
"****\n loading next scenario for a client. sides info = ";
1617 for(
const auto& side_user :
sides_) {
1619 cfg_controller.
set_attr(
"is_local", side_user == user ?
"yes" :
"no");
1634 template<
typename Container>
1637 for(
const auto&
player : players) {
1651 std::optional<player_iterator> exclude)
1653 std::vector<int> sides_vec = ::split<int>(sides, ::split_conv_impl);
1657 decltype(
players_) filtered_players;
1659 std::copy_if(
players_.begin(),
players_.end(), std::back_inserter(filtered_players),
1660 [
this, &sides_vec](
player_iterator user) { return controls_side(sides_vec, user); });
1667 for(
int side : sides) {
1668 std::size_t side_index = side - 1;
1681 const std::string ip = user->client_ip();
1684 for(
auto u : users) {
1685 if(ip == u->client_ip() && user != u) {
1686 clones += (clones.empty() ?
"" :
", ") + u->info().name();
1718 observer_quit.
root()
1746 history_.push_back(std::move(doc));
1748 WRN_CONFIG << __func__ <<
": simple_wml error: " <<
e.message;
1765 return !(isalnum(
c) ||
1785 std::stringstream
name;
1787 std::string filename(
name.str());
1788 std::replace(filename.begin(), filename.end(),
' ',
'_');
1799 std::string replay_commands;
1810 std::stringstream replay_data;
1817 const bool has_old_replay =
level_.
child(
"replay") !=
nullptr;
1829 << (has_old_replay ?
"" :
"\t[command]\n\t\t[start]\n\t\t[/start]\n\t[/command]\n")
1830 << replay_commands <<
"[/replay]\n";
1832 std::string replay_data_str = replay_data.str();
1836 DBG_GAME <<
"saving replay: " << filename;
1839 (*os) <<
replay.output_compressed(
true);
1842 ERR_GAME <<
"Could not save replay! (" << filename <<
")";
1845 WRN_CONFIG << __func__ <<
": simple_wml error: " <<
e.message;
1899 std::stringstream result;
1900 result <<
"game id: " <<
id_ <<
", " <<
db_id_ <<
"\n";
1903 result <<
"player: " << user->info().name().c_str() <<
"\n";
1907 result <<
"observer: " << user->info().name().c_str() <<
"\n";
1910 return result.str();
1915 std::stringstream result;
1916 result <<
"game id: " <<
id_ <<
", " <<
db_id_ <<
"\n";
1919 result <<
"\t\t level, server\n";
1923 <<
"side " << (*s)[
"side"].to_int()
1924 <<
" :\t" << (*s)[
"controller"].to_string()
1926 <<
"\t( " << (*s)[
"current_player"].to_string() <<
" )\n";
1929 return result.str();
1944 auto doc = std::make_unique<simple_wml::document>();
1963 if(docptr ==
nullptr) {
1975 msg.set_attr(
"id",
"server");
1976 msg.set_attr_dup(
"message", message);
1977 std::stringstream ss;
1978 ss << ::std::time(
nullptr);
1979 msg.set_attr_dup(
"time", ss.str().c_str());
1983 msg.set_attr(
"sender",
"server");
1984 msg.set_attr_dup(
"message", message);
1995 return multiplayer.
has_attr(
"savegame") && multiplayer[
"savegame"].to_bool();
uint32_t get_next_random()
Get a new random number.
node & set_attr_dup(const char *key, const char *value)
std::unique_ptr< document > clone()
node * child(const char *name)
const string_span & attr(const char *key) const
void remove_child(const char *name, std::size_t index)
const child_list & children(const char *name) const
bool has_attr(const char *key) const
node & set_attr_int(const char *key, int value)
node * child(const char *name)
std::vector< node * > child_list
node & add_child(const char *name)
node & set_attr(const char *key, const char *value)
void copy_into(node &n) const
node & set_attr_dup(const char *key, const char *value)
std::string to_string() const
const char * begin() const
const char * const_iterator
std::optional< player_iterator > ban_user(const simple_wml::node &ban, player_iterator banner)
Ban a user by name.
void handle_controller_choice(const simple_wml::node &data)
Handle a request to change a side's controller.
std::string debug_player_info() const
Helps debugging player and observer lists.
void mute_all_observers()
Toggles whether all observers are muted or not.
int current_side_index_
The index of the current side.
std::vector< std::unique_ptr< simple_wml::document > > history_
Replay data.
bool is_legal_command(const simple_wml::node &command, player_iterator user)
void clear_chat_history()
Clears the history of recorded chat WML documents.
void send_and_record_server_message(const char *message, std::optional< player_iterator > exclude={})
Send data to all players in this game except 'exclude'.
std::vector< std::string > bans_
List of banned IPs.
bool is_owner(player_iterator player) const
void send_history(player_iterator sock) const
std::optional< player_iterator > current_player() const
void process_change_turns_wml(simple_wml::document &data, player_iterator user)
Handles incoming [change_turns_wml] data.
bool is_current_player(player_iterator player) const
randomness::mt_rng rng_
A wrapper for mersenne twister rng which generates randomness for this game.
std::string has_same_ip(player_iterator user) const
Checks whether a user has the same IP as any other members of this game.
std::string name_
The name of the game.
void notify_new_host()
In case of a host transfer, notify the new host about its status.
void send_data_sides(simple_wml::document &data, const simple_wml::string_span &sides, std::optional< player_iterator > exclude={})
Sends a document to the provided list of sides.
void send_chat_history(player_iterator sock) const
void update_side_data()
Resets the side configuration according to the scenario data.
std::string replay_save_path_
Where to save the replay of this game.
void send_leave_game(player_iterator user) const
Tells a player to leave the game.
void handle_random_choice()
Send a randomly generated number to the requestor.
void set_termination_reason(const std::string &reason)
Sets the termination reason for this game.
void unban_user(const simple_wml::node &unban, player_iterator unbanner)
Unban a user by name.
std::optional< player_iterator > find_user(const simple_wml::string_span &name)
Shortcut to a convenience function for finding a user by name.
std::vector< std::unique_ptr< simple_wml::document > > chat_history_
Replay chat history data.
void perform_controller_tweaks()
This is performed just before starting and before the [start_game] signal.
void record_data(std::unique_ptr< simple_wml::document > data)
Records a WML document in the game's history.
std::vector< side_controller::type > side_controllers_
A vector containiner the controller type for each side.
void handle_add_side_wml()
Adds a new, empty side owned by no one.
void clear_history()
Clears the history of recorded WML documents.
void send_to_players(simple_wml::document &data, const Container &players, std::optional< player_iterator > exclude={})
Send data to all players except those excluded.
int current_turn_
The game's current turn.
bool save_replays_
Whether to save a replay of this game.
void send_muted_observers(player_iterator user) const
Sends a message either stating that all observers are muted or listing the observers that are muted.
void load_next_scenario(player_iterator user)
A user asks for the next scenario to advance to.
bool add_player(player_iterator player, bool observer=false)
Add a user to the game.
void new_scenario(player_iterator sender)
When the host sends the new scenario of a mp campaign.
void send_server_message_to_all(const char *message, std::optional< player_iterator > exclude={})
Sends a message to all players in this game that aren't excluded.
const user_vector all_game_users() const
void start_game(player_iterator starter)
Starts the game (if a new game) or starts the next scenario of an MP campaign.
static simple_wml::node * starting_pos(simple_wml::node &data)
The non-const version.
std::vector< std::string > name_bans_
List of banned usernames.
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="")
bool remove_player(player_iterator player, const bool disconnect=false, const bool destruct=false)
Removes a user from the game.
int id_
This game's ID within wesnothd.
std::size_t current_side() const
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.
std::size_t current_turn() const
std::string username(player_iterator pl) const
void process_whiteboard(simple_wml::document &data, player_iterator user)
Handles incoming [whiteboard] data.
player_connections & player_connections_
bool is_member(player_iterator player) const
int db_id_
Used for unique identification of games played in the database.
void reset_sides()
calculates the initial value for sides_, side_controllerds_, nsides_
std::optional< player_iterator > kick_member(const simple_wml::node &kick, player_iterator kicker)
Kick a user from this game by name.
void handle_choice(const simple_wml::node &data, player_iterator user)
Handle a choice requested by a client, such as changing a side's controller, if initiated by WML/lua.
std::string list_users(user_vector users) const
user_vector muted_observers_
A vector of muted observers.
bool is_muted_observer(player_iterator player) const
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 save_replay()
Move the level information and recorded history into a replay file and save it.
void transfer_side_control(player_iterator player, const simple_wml::node &cfg)
Lets a player owning a side give it to another player or observer.
void unmute_observer(const simple_wml::node &unmute, player_iterator unmuter)
Unmute an observer or unmute all currently muted observers if no name is given.
bool started_
Whether the game has been started or not.
std::string debug_sides_info() const
Helps debugging controller tweaks.
std::string termination_
The reason the game ended.
const std::string & name() const
void send_server_message(const char *message, std::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
Send a server message to the specified player.
void send_observerjoins(std::optional< player_iterator > player={})
Send a document per observer in the game.
const simple_wml::node::child_list & get_sides_list() const
simple_wml::node * description_
Pointer to the game's description in the games_and_users_list_.
user_vector observers_
A vector of observers (members not owning a side).
static int db_id_num
Incremented to retrieve a unique ID per wesnothd instance for game instances within the database.
void set_description(simple_wml::node *desc)
Set the game's description.
int num_turns_
The maximum number of turns before the game ends.
bool all_observers_muted_
Whether all observers should be treated as muted.
side_vector sides_
A vector of side owners.
int nsides_
Number of sides in the current scenario.
void send_data(simple_wml::document &data, std::optional< player_iterator > exclude={})
Send data to all players and observers except those excluded.
simple_wml::document level_
The current scenario data.
bool take_side(player_iterator user)
Figures out which side to take and tells that side to the game owner.
void change_controller(const std::size_t side_index, player_iterator player, const std::string &player_name, const bool player_left=true)
Send [change_controller] message to tell all clients the new controller's name or controller type (hu...
bool allow_observers() const
user_vector players_
A vector of players (members owning a side).
void send_observerquit(player_iterator observer)
bool send_taken_side(simple_wml::document &cfg, const simple_wml::node *side) const
Tell the host who owns a side.
std::string password_
The password needed to join the game.
bool is_observer(player_iterator player) const
bool describe_slots()
Set the description to the number of available slots.
bool is_player(player_iterator player) const
int last_choice_request_id_
The ID of the last request received from a client.
const std::string & termination_reason() const
Provides the reason the game was ended.
bool controls_side(const std::vector< int > &sides, player_iterator player) const
Function which returns true if 'player' controls any of the sides specified in 'sides'.
void send_user_list(std::optional< player_iterator > exclude={})
Function to send a list of users to all clients.
static int id_num
Incremented to retrieve a unique ID for game instances within wesnothd.
bool player_is_banned(player_iterator player, const std::string &name) const
std::string get_replay_filename()
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::unique_ptr< simple_wml::document > change_controller_type(const std::size_t side_index, player_iterator player, const std::string &player_name)
Tell everyone else but the source player that the controller type changed.
void update_turn_data()
Set or update the current and max turn values in the game's description.
bool end_turn(int new_side)
Function which should be called every time a player ends their turn (i.e.
player_iterator owner_
The game host or later owner (if the host left).
void process_message(simple_wml::document &data, player_iterator user)
Sends an ingame message to all other players.
const std::string & name() const
void send_to_player(player_iterator player, simple_wml::document &data)
Declarations for File-IO.
New lexcical_cast header.
Standard logging facilities (interface).
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
std::unique_ptr< std::ostream > scoped_ostream
const std::string observer_team_name
observer team name used for observer team chat
void remove()
Removes a tip.
std::string node_to_string(const node &n)
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.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
std::vector< std::string > split(const config_attribute_value &val)
void truncate_message(const simple_wml::string_span &str, simple_wml::node &message)
Function to ensure a text message is within the allowed length.
static bool is_invalid_filename_char(char c)
std::vector< player_iterator > user_vector
player_connections::const_iterator player_iterator
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
bmi::multi_index_container< player_record, bmi::indexed_by< bmi::ordered_unique< bmi::tag< socket_t >, bmi::const_mem_fun< player_record, const any_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
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
static lg::log_domain log_server("server")
static lg::log_domain log_config("config")
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
static map_location::DIRECTION s