The Battle for Wesnoth  1.17.23+dev
lobby_data.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2023
3  by Tomasz Sniatowski <kailoran@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <ctime>
19 #include <set>
20 #include <deque>
21 #include <functional>
22 #include <vector>
23 #include <string>
24 
25 class config;
26 
27 namespace mp {
28 
29 /**
30  * This class represents the information a client has about another player
31  */
32 struct user_info
33 {
34  explicit user_info(const config& c);
35 
36  enum class user_relation {
37  ME,
38  FRIEND,
39  NEUTRAL,
40  IGNORED
41  };
42 
43  enum class user_state {
44  LOBBY,
45  GAME,
46  SEL_GAME
47  };
48 
49  bool operator<(const user_info& b) const;
50 
51  user_state get_state(int selected_game_id) const;
53 
54  std::string name;
55  int forum_id;
56  int game_id;
57  bool registered;
58  bool observing;
59  bool moderator;
60 };
61 
62 /**
63  * This class represents the info a client has about a game on the server
64  */
65 struct game_info
66 {
67  game_info(const config& c, const std::vector<std::string>& installed_addons);
68 
69  bool can_join() const;
70  bool can_observe() const;
71 
72  int id;
73  std::string map_data;
74  std::string name;
75  std::string scenario;
76  std::string type_marker;
78  std::string map_info;
79  std::string map_size_info;
80  std::string era;
81 
82  /** List of modification names and whether they're installed or not. */
83  std::vector<std::pair<std::string, bool>> mod_info;
84 
85  std::string gold;
86  std::string support;
87  std::string xp;
88  std::string vision;
89  std::string status; // vacant slots or turn info
90  std::string time_limit;
91  std::size_t vacant_slots;
92 
93  unsigned int current_turn;
94  bool reloaded;
95  bool started;
96  bool fog;
97  bool shroud;
98  bool observers;
102  bool verified;
104  bool have_era;
106 
110 
111  enum class disp_status {
112  CLEAN,
113  NEW,
114  UPDATED,
115  DELETED
116  };
117 
119 
121 
122  struct required_addon {
123  std::string addon_id;
125  std::string message;
126  };
127 
128  std::vector<required_addon> required_addons;
130 
131  addon_req check_addon_version_compatibility(const config& local_item, const config& game);
132 
133  const char* display_status_string() const;
134 
135  bool match_string_filter(const std::string& filter) const;
136 };
137 
138 }
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
Definition: manager.cpp:191
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
This class represents the info a client has about a game on the server.
Definition: lobby_data.hpp:66
bool shuffle_sides
Definition: lobby_data.hpp:99
std::string name
Definition: lobby_data.hpp:74
std::string type_marker
Definition: lobby_data.hpp:76
bool can_join() const
Definition: lobby_data.cpp:475
std::vector< required_addon > required_addons
Definition: lobby_data.hpp:128
std::string scenario
Definition: lobby_data.hpp:75
std::string era
Definition: lobby_data.hpp:80
std::string map_size_info
Definition: lobby_data.hpp:79
addon_req check_addon_version_compatibility(const config &local_item, const config &game)
Definition: lobby_data.cpp:409
unsigned int current_turn
Definition: lobby_data.hpp:93
bool remote_scenario
Definition: lobby_data.hpp:77
std::string xp
Definition: lobby_data.hpp:87
std::string map_info
Definition: lobby_data.hpp:78
std::string status
Definition: lobby_data.hpp:89
addon_req addons_outcome
Definition: lobby_data.hpp:129
std::size_t vacant_slots
Definition: lobby_data.hpp:91
bool password_required
Definition: lobby_data.hpp:103
game_info(const config &c, const std::vector< std::string > &installed_addons)
Definition: lobby_data.cpp:114
std::string gold
Definition: lobby_data.hpp:85
disp_status display_status
Definition: lobby_data.hpp:118
bool can_observe() const
Definition: lobby_data.cpp:480
bool use_map_settings
Definition: lobby_data.hpp:100
std::string support
Definition: lobby_data.hpp:86
std::string vision
Definition: lobby_data.hpp:88
std::string time_limit
Definition: lobby_data.hpp:90
const char * display_status_string() const
Definition: lobby_data.cpp:485
std::vector< std::pair< std::string, bool > > mod_info
List of modification names and whether they're installed or not.
Definition: lobby_data.hpp:83
bool match_string_filter(const std::string &filter) const
Definition: lobby_data.cpp:502
std::string map_data
Definition: lobby_data.hpp:73
This class represents the information a client has about another player.
Definition: lobby_data.hpp:33
user_state get_state(int selected_game_id) const
Definition: lobby_data.cpp:64
user_relation get_relation() const
Definition: lobby_data.cpp:75
std::string name
Definition: lobby_data.hpp:54
bool operator<(const user_info &b) const
Definition: lobby_data.cpp:88
user_info(const config &c)
Definition: lobby_data.cpp:54
mock_char c
#define b