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