The Battle for Wesnoth  1.15.12+dev
game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "mt_rng.hpp"
21 #include "utils/make_enum.hpp"
22 
23 #include <map>
24 #include <optional>
25 #include <vector>
26 
27 // class player;
28 
29 namespace wesnothd
30 {
31 typedef std::vector<player_iterator> user_vector;
32 typedef std::vector<std::optional<player_iterator>> side_vector;
33 class server;
34 
35 class game
36 {
37 public:
38  MAKE_ENUM(CONTROLLER,
39  (HUMAN, "human")
40  (AI, "ai")
41  (EMPTY, "null")
42  );
43 
45  player_iterator host,
46  const std::string& name = "",
47  bool save_replays = false,
48  const std::string& replay_save_path = "");
49 
50  ~game();
51 
52  int id() const
53  {
54  return id_;
55  }
56 
57  int db_id() const
58  {
59  return db_id_;
60  }
61 
62  void next_db_id()
63  {
64  db_id_ = db_id_num++;
65  }
66 
67  const std::string& name() const
68  {
69  return name_;
70  }
71 
73  {
74  return (player == owner_);
75  }
76 
78  {
79  return is_player(player) || is_observer(player);
80  }
81 
82  bool allow_observers() const;
84  bool is_player(player_iterator player) const;
85 
86  /** Checks whether the connection's ip address or username is banned. */
87  bool player_is_banned(player_iterator player, const std::string& name) const;
88 
89  /** when the host sends the new scenario of a mp campaign */
90  void new_scenario(player_iterator player);
91 
92  bool level_init() const
93  {
94  return level_.child("snapshot") || level_.child("scenario");
95  }
96 
98  {
99  if(simple_wml::node* scenario = data.child("scenario")) {
100  return scenario;
101  } else if(simple_wml::node* snapshot = data.child("snapshot")) {
102  return snapshot;
103  }
104 
105  return &data;
106  }
107 
108  static const simple_wml::node* starting_pos(const simple_wml::node& data)
109  {
110  if(const simple_wml::node* scenario = data.child("scenario")) {
111  return scenario;
112  } else if(const simple_wml::node* snapshot = data.child("snapshot")) {
113  return snapshot;
114  }
115 
116  return &data;
117  }
118 
120  {
121  return starting_pos(level_.root())->children("side");
122  }
123 
124  bool started() const
125  {
126  return started_;
127  }
128 
129  std::size_t nplayers() const
130  {
131  return players_.size();
132  }
133 
134  std::size_t nobservers() const
135  {
136  return observers_.size();
137  }
138 
139  std::size_t current_turn() const
140  {
141  return current_turn_;
142  }
143 
144  void set_current_turn(int turn)
145  {
146  current_turn_ = turn;
147  }
148 
149  std::string get_replay_filename();
150 
151  void mute_all_observers();
152 
153  /**
154  * Mute an observer or give a message of all currently muted observers if no
155  * name is given.
156  */
157  void mute_observer(const simple_wml::node& mute, player_iterator muter);
158 
159  void unmute_observer(const simple_wml::node& unmute, player_iterator unmuter);
160 
161  /**
162  * Kick a member by name.
163  *
164  * @return The iterator to the removed member if
165  * successful, empty optional otherwise.
166  */
167  std::optional<player_iterator> kick_member(const simple_wml::node& kick, player_iterator kicker);
168 
169  /**
170  * Ban and kick a user by name.
171  *
172  * The user does not need to be in this game but logged in.
173  *
174  * @return The iterator to the banned player if he
175  * was in this game, empty optional otherwise.
176  */
177  std::optional<player_iterator> ban_user(const simple_wml::node& ban, player_iterator banner);
178 
179  void unban_user(const simple_wml::node& unban, player_iterator unbanner);
180 
181  /**
182  * Add a user to the game.
183  *
184  * @return True iff the user successfully joined the game.
185  */
186  bool add_player(player_iterator player, bool observer = false);
187 
188  /**
189  * Removes a user from the game.
190  *
191  * @return True iff the game ends. That is, if there are
192  * no more players or the host left on a not yet
193  * started game.
194  */
195  bool remove_player(player_iterator player, const bool disconnect = false, const bool destruct = false);
196 
197  /** Adds players and observers into one vector and returns that. */
198  const user_vector all_game_users() const;
199 
200  void start_game(player_iterator starter);
201 
202  // this is performed just before starting and before [start_game] signal
203  // send scenario_diff's specific to each client so that they locally
204  // control their human sides
206 
207  void update_game();
208 
209  /** A user (player only?) asks for the next scenario to advance to. */
210  void load_next_scenario(player_iterator user); // const
211 
212  // iceiceice: I unmarked this const because I want to send and record server messages when I fail to tweak sides
213  // properly
214 
215  /** Resets the side configuration according to the scenario data. */
216  void update_side_data();
217 
218  /** Let's a player owning a side give it to another player or observer. */
219  void transfer_side_control(player_iterator player, const simple_wml::node& cfg);
220 
222 
223  /**
224  * Handles [end_turn], repackages [commands] with private [speak]s in them
225  * and sends the data.
226  * Also filters commands from all but the current player.
227  * Currently removes all commands but [speak] for observers and all but
228  * [speak], [label] and [rename] for players.
229  *
230  * @returns True if the turn ended.
231  */
233 
234  /** Handles incoming [whiteboard] data. */
236  /** Handles incoming [change_turns_wml] data. */
238 
239  /**
240  * Set the description to the number of available slots.
241  *
242  * @returns True iff the number of slots has changed.
243  */
244  bool describe_slots();
245 
246  void send_server_message_to_all(const char* message, std::optional<player_iterator> exclude = {});
247  void send_server_message_to_all(const std::string& message, std::optional<player_iterator> exclude = {})
248  {
249  send_server_message_to_all(message.c_str(), exclude);
250  }
251 
252  void send_server_message(
253  const char* message, std::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const;
255  const std::string& message, std::optional<player_iterator> player = {}, simple_wml::document* doc = nullptr) const
256  {
257  send_server_message(message.c_str(), player, doc);
258  }
259 
260  /** Send data to all players in this game except 'exclude'. */
261  void send_and_record_server_message(const char* message, std::optional<player_iterator> exclude = {});
262  void send_and_record_server_message(const std::string& message, std::optional<player_iterator> exclude = {})
263  {
264  send_and_record_server_message(message.c_str(), exclude);
265  }
266 
267  template<typename Container>
268  void send_to_players(simple_wml::document& data, const Container& players, std::optional<player_iterator> exclude = {});
269  void send_data(simple_wml::document& data, std::optional<player_iterator> exclude = {}, std::string packet_type = "");
270 
271  void clear_history();
272  void record_data(std::unique_ptr<simple_wml::document> data);
273  void save_replay();
274 
275  /** The full scenario data. */
277  {
278  return level_;
279  }
280 
281  /**
282  * Functions to set/get the address of the game's summary description as
283  * sent to players in the lobby.
284  */
285  void set_description(simple_wml::node* desc);
286 
288  {
289  return description_;
290  }
291 
292  void set_password(const std::string& passwd)
293  {
294  password_ = passwd;
295  }
296 
297  void set_name_bans(const std::vector<std::string> name_bans)
298  {
299  name_bans_ = name_bans;
300  }
301 
302  bool password_matches(const std::string& passwd) const
303  {
304  return password_.empty() || passwd == password_;
305  }
306 
307  bool has_password() const
308  {
309  return !password_.empty();
310  }
311 
312  const std::string& termination_reason() const
313  {
314  static const std::string aborted = "aborted";
315  static const std::string not_started = "not started";
316 
317  return started_ ? (termination_.empty() ? aborted : termination_) : not_started;
318  }
319 
320  void set_termination_reason(const std::string& reason);
321 
322  void handle_choice(const simple_wml::node& data, player_iterator user);
323 
324  void handle_random_choice(const simple_wml::node& data);
325 
326  void handle_controller_choice(const simple_wml::node& data);
327 
328  void handle_add_side_wml(const simple_wml::node& req);
329 
331  {
333  }
334 
335  /**
336  * Function which returns true iff 'player' controls any of the sides spcified in 'sides'.
337  */
338  bool controls_side(const std::vector<int>& sides, player_iterator player) const;
339 
340  bool is_reload() const;
341 
342 private:
343  // forbidden operations
344  game(const game&) = delete;
345  game& operator=(const game&) = delete;
346 
347  std::size_t current_side() const
348  {
349  return nsides_ ? (current_side_index_ % nsides_) : 0;
350  }
351 
352  std::optional<player_iterator> current_player() const
353  {
354  return sides_[current_side()];
355  }
356 
358  {
359  return (current_player() == player);
360  }
361 
362  bool is_muted_observer(player_iterator player) const;
363  bool all_observers_muted() const
364  {
365  return all_observers_muted_;
366  }
367 
368  void send_muted_observers(player_iterator user) const;
369 
370  bool send_taken_side(simple_wml::document& cfg, const simple_wml::node* side) const;
371 
372  /**
373  * Figures out which side to take and tells that side to the game owner.
374  *
375  * The owner then should send a [scenario_diff] that implements the side
376  * change and a subsequent update_side_data() call makes it actually
377  * happen.
378  * First we look for a side where save_id= or current_player= matches the
379  * new user's name then we search for the first controller="network" side.
380  */
381  bool take_side(player_iterator user);
382 
383  /**
384  * Send [change_controller] message to tell all clients the new controller's name
385  * or controller type (human or ai).
386  */
387  void change_controller(const std::size_t side_num,
388  player_iterator sock,
389  const std::string& player_name,
390  const bool player_left = true);
391  std::unique_ptr<simple_wml::document> change_controller_type(const std::size_t side_num,
392  player_iterator player,
393  const std::string& player_name);
394  void transfer_ai_sides(player_iterator player);
395  void send_leave_game(player_iterator user) const;
396 
397  /**
398  * @param data the data to be sent to the sides.
399  * @param sides a comma sperated list of side numbers to which the package should be sent.
400  * @param exclude sides to not send the data to.
401  */
403  const simple_wml::string_span& sides,
404  std::optional<player_iterator> exclude = {});
405 
406  void send_data_observers(
407  simple_wml::document& data, std::optional<player_iterator> exclude = {}, std::string packet_type = "") const;
408 
409  /**
410  * Send [observer] tags of all the observers in the game to the user or
411  * everyone if none given.
412  */
413  void send_observerjoins(std::optional<player_iterator> player = {});
415  void send_history(player_iterator sock) const;
416 
417  /** In case of a host transfer, notify the new host about its status. */
418  void notify_new_host();
419 
420  /** Shortcut to a convenience function for finding a user by name. */
421  std::optional<player_iterator> find_user(const simple_wml::string_span& name);
422 
423  bool observers_can_label() const
424  {
425  return false;
426  }
427 
428  bool observers_can_chat() const
429  {
430  return true;
431  }
432 
433  bool is_legal_command(const simple_wml::node& command, player_iterator user);
434 
435  /**
436  * Checks whether a user has the same IP as any other members of this game.
437  * @return A comma separated string of members with matching IPs.
438  */
439  std::string has_same_ip(player_iterator user) const;
440 
441  /**
442  * Function which should be called every time a player ends their turn
443  * (i.e. [end_turn] received). This will update the 'turn' attribute for
444  * the game's description when appropriate. Will return true iff there has
445  * been a change.
446  */
447  bool end_turn(int new_side);
448 
449  void update_turn_data();
450  /**
451  * Function to send a list of users to all clients.
452  *
453  * Only sends data if the game is initialized but not yet started.
454  */
455  void send_user_list(std::optional<player_iterator> exclude = {});
456 
457  /** Returns the name of the user or "(unfound)". */
458  std::string username(player_iterator pl) const;
459 
460  /** Returns a comma separated list of user names. */
461  std::string list_users(user_vector users) const;
462 
463  /** calculates the initial value for sides_, side_controllerds_, nsides_*/
464  void reset_sides();
465 
466  /** Helps debugging player and observer lists. */
467  std::string debug_player_info() const;
468 
469  /** Helps debugging controller tweaks. */
470  std::string debug_sides_info() const;
471 
473  player_connections& player_connections_;
474 
475  // used for unique identification of game instances within wesnothd
476  static int id_num;
477  int id_;
478 
479  // used for unique identification of games played in the database
480  // necessary since for MP campaigns multiple scenarios can be played within the same game instance
481  // and we need a unique ID per scenario played, not per game instance
482  static int db_id_num;
483  int db_id_;
484 
485  /** The name of the game. */
486  std::string name_;
487  std::string password_;
488 
489  /** The game host or later owner (if the host left). */
491 
492  /** A vector of players (members owning a side). */
493  user_vector players_;
494 
495  /** A vector of observers (members not owning a side). */
496  user_vector observers_;
497  user_vector muted_observers_;
498 
499  /** A vector of side owners. */
500  side_vector sides_;
501 
502  std::vector<CONTROLLER> side_controllers_;
503 
504  /** Number of sides in the current scenario. */
505  int nsides_;
506  bool started_;
507 
508  /**
509  The current scenario data.ยด
510  WRONG! This contains the initial state or the state from which
511  the game was loaded from.
512  Using this to make assumptions about the current gamestate is
513  extremely dangerous and should especially not be done for anything
514  that can be nodified by wml (especially by [modify_side]),
515  like team_name, controller ... in [side].
516  FIXME: move every code here that uses this object to query those
517  information to the clients. But note that there are some checks
518  (like controller == null) that are definitely needed by the server and
519  in this case we should try to modify the client to inform the server if
520  a change of those properties occur. Ofc we shouldn't update level_
521  then, but rather store that information in a separate object
522  (like in side_controllers_).
523  */
525 
526  /** Replay data. */
527  mutable std::vector<std::unique_ptr<simple_wml::document>> history_;
528 
529  /** Pointer to the game's description in the games_and_users_list_. */
531 
536 
537  // IP ban list and name ban list
538  std::vector<std::string> bans_;
539  std::vector<std::string> name_bans_;
540  /**
541  * in multiplayer campaigns it can happen that some players are still in the previous scenario
542  * keep track of those players because processing certain
543  * input from those side wil lead to error (oos)
544  */
545  std::set<const player_record*> players_not_advanced_;
546 
547  std::string termination_;
548 
550  std::string replay_save_path_;
551 
552  /** A wrapper for mersenne twister rng which generates randomness for this game */
555 };
556 
557 } // namespace wesnothd
bool save_replays_
Definition: game.hpp:549
bool started() const
Definition: game.hpp:124
bool is_muted_observer(player_iterator player) const
Definition: game.cpp:154
void handle_choice(const simple_wml::node &data, player_iterator user)
Definition: game.cpp:1199
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...
Definition: game.hpp:545
void send_and_record_server_message(const char *message, std::optional< player_iterator > exclude={})
Send data to all players in this game except &#39;exclude&#39;.
Definition: game.cpp:1931
void set_current_turn(int turn)
Definition: game.hpp:144
void update_game()
Definition: game.cpp:328
void send_observerquit(player_iterator observer)
Definition: game.cpp:1711
const std::string & name() const
Definition: game.hpp:67
void send_server_message_to_all(const std::string &message, std::optional< player_iterator > exclude={})
Definition: game.hpp:247
bool observers_can_label() const
Definition: game.hpp:423
void save_replay()
Definition: game.cpp:1780
player_connections & player_connections_
Definition: game.hpp:473
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...
Definition: game.cpp:698
std::optional< player_iterator > ban_user(const simple_wml::node &ban, player_iterator banner)
Ban and kick a user by name.
Definition: game.cpp:810
void send_to_players(simple_wml::document &data, const Container &players, std::optional< player_iterator > exclude={})
Definition: game.cpp:1633
void process_change_turns_wml(simple_wml::document &data, player_iterator user)
Handles incoming [change_turns_wml] data.
Definition: game.cpp:1270
bool is_player(player_iterator player) const
Definition: game.cpp:167
std::vector< std::unique_ptr< simple_wml::document > > history_
Replay data.
Definition: game.hpp:527
void handle_random_choice(const simple_wml::node &data)
Definition: game.cpp:1107
const simple_wml::node::child_list & get_sides_list() const
Definition: game.hpp:119
bool is_current_player(player_iterator player) const
Definition: game.hpp:357
user_vector muted_observers_
Definition: game.hpp:497
void update_side_data()
Resets the side configuration according to the scenario data.
Definition: game.cpp:409
bool player_is_banned(player_iterator player, const std::string &name) const
Checks whether the connection&#39;s ip address or username is banned.
Definition: game.cpp:668
std::string username(player_iterator pl) const
Returns the name of the user or "(unfound)".
Definition: game.cpp:172
void transfer_ai_sides(player_iterator player)
bool level_init() const
Definition: game.hpp:92
std::optional< player_iterator > find_user(const simple_wml::string_span &name)
Shortcut to a convenience function for finding a user by name.
Definition: game.cpp:1921
std::size_t current_side() const
Definition: game.hpp:347
int nsides_
Number of sides in the current scenario.
Definition: game.hpp:505
user_vector observers_
A vector of observers (members not owning a side).
Definition: game.hpp:496
void send_leave_game(player_iterator user) const
Definition: game.cpp:772
bool is_observer(player_iterator player) const
Definition: game.cpp:149
bool all_observers_muted_
Definition: game.hpp:535
bool is_member(player_iterator player) const
Definition: game.hpp:77
std::string termination_
Definition: game.hpp:547
game & operator=(const game &)=delete
void send_data_observers(simple_wml::document &data, std::optional< player_iterator > exclude={}, std::string packet_type="") const
void new_scenario(player_iterator player)
when the host sends the new scenario of a mp campaign
Definition: game.cpp:1568
randomness::mt_rng rng_
A wrapper for mersenne twister rng which generates randomness for this game.
Definition: game.hpp:553
int db_id() const
Definition: game.hpp:57
player_iterator owner_
The game host or later owner (if the host left).
Definition: game.hpp:490
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...
Definition: game.cpp:959
player_connections::const_iterator player_iterator
void send_and_record_server_message(const std::string &message, std::optional< player_iterator > exclude={})
Definition: game.hpp:262
std::vector< std::string > bans_
Definition: game.hpp:538
void next_db_id()
Definition: game.hpp:62
wesnothd::server & server
Definition: game.hpp:472
bool is_legal_command(const simple_wml::node &command, player_iterator user)
Definition: game.cpp:894
node * child(const char *name)
Definition: simple_wml.hpp:261
node * child(const char *name)
Definition: simple_wml.cpp:606
int last_choice_request_id_
Definition: game.hpp:554
bool password_matches(const std::string &passwd) const
Definition: game.hpp:302
bool end_turn(int new_side)
Function which should be called every time a player ends their turn (i.e.
Definition: game.cpp:1299
void reset_sides()
calculates the initial value for sides_, side_controllerds_, nsides_
Definition: game.cpp:398
std::vector< CONTROLLER > side_controllers_
Definition: game.hpp:502
bool has_password() const
Definition: game.hpp:307
void process_whiteboard(simple_wml::document &data, player_iterator user)
Handles incoming [whiteboard] data.
Definition: game.cpp:1243
int num_turns_
Definition: game.hpp:534
void send_history(player_iterator sock) const
Definition: game.cpp:1723
void update_turn_data()
Definition: game.cpp:1331
bool allow_observers() const
Definition: game.cpp:144
void handle_controller_choice(const simple_wml::node &data)
Definition: game.cpp:1135
bool describe_slots()
Set the description to the number of available slots.
Definition: game.cpp:637
void transfer_side_control(player_iterator player, const simple_wml::node &cfg)
Let&#39;s a player owning a side give it to another player or observer.
Definition: game.cpp:476
std::unique_ptr< simple_wml::document > change_controller_type(const std::size_t side_num, player_iterator player, const std::string &player_name)
Definition: game.cpp:609
void process_message(simple_wml::document &data, player_iterator)
Definition: game.cpp:882
static int db_id_num
Definition: game.hpp:482
std::string get_replay_filename()
Definition: game.cpp:1770
std::optional< player_iterator > current_player() const
Definition: game.hpp:352
std::size_t nobservers() const
Definition: game.hpp:134
void start_game(player_iterator starter)
Definition: game.cpp:251
const user_vector all_game_users() const
Adds players and observers into one vector and returns that.
Definition: game.cpp:1869
bool controls_side(const std::vector< int > &sides, player_iterator player) const
Function which returns true iff &#39;player&#39; controls any of the sides spcified in &#39;sides&#39;.
Definition: game.cpp:1663
void perform_controller_tweaks()
Definition: game.cpp:192
bool remove_player(player_iterator player, const bool disconnect=false, const bool destruct=false)
Removes a user from the game.
Definition: game.cpp:1435
bool all_observers_muted() const
Definition: game.hpp:363
std::optional< player_iterator > kick_member(const simple_wml::node &kick, player_iterator kicker)
Kick a member by name.
Definition: game.cpp:778
void load_next_scenario(player_iterator user)
A user (player only?) asks for the next scenario to advance to.
Definition: game.cpp:1580
bool is_owner(player_iterator player) const
Definition: game.hpp:72
bool observers_can_chat() const
Definition: game.hpp:428
static simple_wml::node * starting_pos(simple_wml::node &data)
Definition: game.hpp:97
void send_server_message(const char *message, std::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
Definition: game.cpp:1949
static const simple_wml::node * starting_pos(const simple_wml::node &data)
Definition: game.hpp:108
std::vector< std::string > name_bans_
Definition: game.hpp:539
void record_data(std::unique_ptr< simple_wml::document > data)
Definition: game.cpp:1836
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...
Definition: game.cpp:1691
std::vector< std::optional< player_iterator > > side_vector
Definition: game.hpp:32
std::vector< node * > child_list
Definition: simple_wml.hpp:125
bool add_player(player_iterator player, bool observer=false)
Add a user to the game.
Definition: game.cpp:1351
std::size_t current_turn() const
Definition: game.hpp:139
void reset_last_synced_context_id()
Definition: game.hpp:330
int current_side_index_
Definition: game.hpp:533
side_vector sides_
A vector of side owners.
Definition: game.hpp:500
void notify_new_host()
In case of a host transfer, notify the new host about its status.
Definition: game.cpp:626
void set_description(simple_wml::node *desc)
Functions to set/get the address of the game&#39;s summary description as sent to players in the lobby...
Definition: game.cpp:1847
std::string has_same_ip(player_iterator user) const
Checks whether a user has the same IP as any other members of this game.
Definition: game.cpp:1676
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&#39;s name or controller type (hu...
Definition: game.cpp:577
void set_password(const std::string &passwd)
Definition: game.hpp:292
void send_data_sides(simple_wml::document &data, const simple_wml::string_span &sides, std::optional< player_iterator > exclude={})
Definition: game.cpp:1647
std::string observer
std::size_t nplayers() const
Definition: game.hpp:129
void handle_add_side_wml(const simple_wml::node &req)
Definition: game.cpp:1128
std::string list_users(user_vector users) const
Returns a comma separated list of user names.
Definition: game.cpp:177
simple_wml::node * description_
Pointer to the game&#39;s description in the games_and_users_list_.
Definition: game.hpp:530
std::string name_
The name of the game.
Definition: game.hpp:486
void unban_user(const simple_wml::node &unban, player_iterator unbanner)
Definition: game.cpp:852
std::string debug_sides_info() const
Helps debugging controller tweaks.
Definition: game.cpp:1901
static int id_num
Definition: game.hpp:476
MAKE_ENUM(CONTROLLER,(HUMAN, "human")(AI, "ai")(EMPTY, "null"))
std::vector< player_iterator > user_vector
Definition: game.hpp:31
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
bool is_reload() const
Definition: game.cpp:1978
Definition: ban.cpp:28
void send_user_list(std::optional< player_iterator > exclude={})
Function to send a list of users to all clients.
Definition: game.cpp:1545
const std::string & termination_reason() const
Definition: game.hpp:312
std::string replay_save_path_
Definition: game.hpp:550
int current_turn_
Definition: game.hpp:532
user_vector players_
A vector of players (members owning a side).
Definition: game.hpp:493
void send_server_message_to_all(const char *message, std::optional< player_iterator > exclude={})
Definition: game.cpp:1942
std::string password_
Definition: game.hpp:487
void send_muted_observers(player_iterator user) const
Definition: game.cpp:686
bool started_
Definition: game.hpp:506
bool send_taken_side(simple_wml::document &cfg, const simple_wml::node *side) const
Definition: game.cpp:336
std::string debug_player_info() const
Helps debugging player and observer lists.
Definition: game.cpp:1879
void set_name_bans(const std::vector< std::string > name_bans)
Definition: game.hpp:297
void send_server_message(const std::string &message, std::optional< player_iterator > player={}, simple_wml::document *doc=nullptr) const
Definition: game.hpp:254
void unmute_observer(const simple_wml::node &unmute, player_iterator unmuter)
Definition: game.cpp:740
Defines the MAKE_ENUM macro.
simple_wml::document level_
The current scenario data.
Definition: game.hpp:524
void clear_history()
Definition: game.cpp:1842
void mute_all_observers()
Definition: game.cpp:676
bool take_side(player_iterator user)
Figures out which side to take and tells that side to the game owner.
Definition: game.cpp:357
void set_termination_reason(const std::string &reason)
Definition: game.cpp:1855
game(wesnothd::server &server, player_connections &player_connections, player_iterator host, const std::string &name="", bool save_replays=false, const std::string &replay_save_path="")
Definition: game.cpp:77
void send_data(simple_wml::document &data, std::optional< player_iterator > exclude={}, std::string packet_type="")
Definition: game.cpp:1642
simple_wml::document & level()
The full scenario data.
Definition: game.hpp:276
simple_wml::node * description() const
Definition: game.hpp:287
bool save_replays()
Definition: game.cpp:764
int id() const
Definition: game.hpp:52