The Battle for Wesnoth  1.19.13+dev
lobby_data.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2025
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 <vector>
19 #include <string>
20 
21 class config;
22 
23 namespace mp {
24 
25 /**
26  * This class represents the information a client has about another player
27  */
28 struct user_info
29 {
30  explicit user_info(const config& c);
31 
32  enum class user_relation {
33  ME,
34  FRIEND,
35  NEUTRAL,
36  IGNORED
37  };
38 
39  enum class user_state {
40  LOBBY,
41  GAME,
42  SEL_GAME
43  };
44 
45  bool operator<(const user_info& b) const;
46 
47  user_state get_state(int selected_game_id) const;
49 
50  std::string name;
51  int forum_id;
52  int game_id;
53  bool registered;
54  bool observing;
55  bool moderator;
56 };
57 
58 /**
59  * This class represents the info a client has about a game on the server
60  */
61 struct game_info
62 {
63  game_info(const config& c, const std::vector<std::string>& installed_addons);
64 
65  bool can_join() const;
66  bool can_observe() const;
67 
68  int id;
69  std::string map_data;
70  std::string name;
71  std::string scenario;
72  std::string scenario_id;
73  std::string type_marker;
75  std::string map_info;
76  std::string map_size_info;
77  std::string era;
78 
79  /** List of modification names and whether they're installed or not. */
80  std::vector<std::pair<std::string, bool>> mod_info;
81 
82  std::string gold;
83  std::string support;
84  std::string xp;
85  std::string vision;
86  std::string status; // vacant slots or turn info
87  std::string time_limit;
88  std::size_t vacant_slots;
89 
90  unsigned int current_turn;
91  bool reloaded;
92  bool started;
93  bool fog;
94  bool shroud;
95  bool observers;
99  // TODO: what does it do? it doesn't seem to be used.
100  bool verified;
102  bool have_era;
104 
109 
110  enum class disp_status {
111  CLEAN,
112  NEW,
113  UPDATED,
114  DELETED
115  };
116 
118 
120 
121  struct required_addon {
122  std::string addon_id;
124  std::string message;
125  };
126 
127  std::vector<required_addon> required_addons;
129 
130  addon_req check_addon_version_compatibility(const config& local_item, const config& game);
131 
132  const char* display_status_string() const;
133 
134  bool match_string_filter(const std::string& filter) const;
135 };
136 
137 }
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
Definition: manager.cpp:186
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:49
constexpr auto filter
Definition: ranges.hpp:38
This class represents the info a client has about a game on the server.
Definition: lobby_data.hpp:62
bool shuffle_sides
Definition: lobby_data.hpp:96
std::string name
Definition: lobby_data.hpp:70
std::string scenario_id
Definition: lobby_data.hpp:72
std::string type_marker
Definition: lobby_data.hpp:73
bool can_join() const
Definition: lobby_data.cpp:473
std::vector< required_addon > required_addons
Definition: lobby_data.hpp:127
std::string scenario
Definition: lobby_data.hpp:71
std::string era
Definition: lobby_data.hpp:77
std::string map_size_info
Definition: lobby_data.hpp:76
addon_req check_addon_version_compatibility(const config &local_item, const config &game)
Definition: lobby_data.cpp:407
unsigned int current_turn
Definition: lobby_data.hpp:90
bool remote_scenario
Definition: lobby_data.hpp:74
std::string xp
Definition: lobby_data.hpp:84
std::string map_info
Definition: lobby_data.hpp:75
std::string status
Definition: lobby_data.hpp:86
addon_req addons_outcome
Definition: lobby_data.hpp:128
std::size_t vacant_slots
Definition: lobby_data.hpp:88
bool password_required
Definition: lobby_data.hpp:101
game_info(const config &c, const std::vector< std::string > &installed_addons)
Definition: lobby_data.cpp:111
std::string gold
Definition: lobby_data.hpp:82
disp_status display_status
Definition: lobby_data.hpp:117
bool can_observe() const
Definition: lobby_data.cpp:478
bool use_map_settings
Definition: lobby_data.hpp:97
std::string support
Definition: lobby_data.hpp:83
std::string vision
Definition: lobby_data.hpp:85
std::string time_limit
Definition: lobby_data.hpp:87
bool private_replay
Definition: lobby_data.hpp:98
const char * display_status_string() const
Definition: lobby_data.cpp:483
std::vector< std::pair< std::string, bool > > mod_info
List of modification names and whether they're installed or not.
Definition: lobby_data.hpp:80
bool match_string_filter(const std::string &filter) const
Definition: lobby_data.cpp:500
std::string map_data
Definition: lobby_data.hpp:69
This class represents the information a client has about another player.
Definition: lobby_data.hpp:29
user_state get_state(int selected_game_id) const
Definition: lobby_data.cpp:61
user_relation get_relation() const
Definition: lobby_data.cpp:72
std::string name
Definition: lobby_data.hpp:50
bool operator<(const user_info &b) const
Definition: lobby_data.cpp:85
user_info(const config &c)
Definition: lobby_data.cpp:51
mock_char c
#define b