The Battle for Wesnoth  1.19.0-dev
lobby_data.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2024
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 <vector>
20 #include <string>
21 
22 class config;
23 
24 namespace mp {
25 
26 /**
27  * This class represents the information a client has about another player
28  */
29 struct user_info
30 {
31  explicit user_info(const config& c);
32 
33  enum class user_relation {
34  ME,
35  FRIEND,
36  NEUTRAL,
37  IGNORED
38  };
39 
40  enum class user_state {
41  LOBBY,
42  GAME,
43  SEL_GAME
44  };
45 
46  bool operator<(const user_info& b) const;
47 
48  user_state get_state(int selected_game_id) const;
50 
51  std::string name;
52  int forum_id;
53  int game_id;
54  bool registered;
55  bool observing;
56  bool moderator;
57 };
58 
59 /**
60  * This class represents the info a client has about a game on the server
61  */
62 struct game_info
63 {
64  game_info(const config& c, const std::vector<std::string>& installed_addons);
65 
66  bool can_join() const;
67  bool can_observe() const;
68 
69  int id;
70  std::string map_data;
71  std::string name;
72  std::string scenario;
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 
108 
109  enum class disp_status {
110  CLEAN,
111  NEW,
112  UPDATED,
113  DELETED
114  };
115 
117 
119 
120  struct required_addon {
121  std::string addon_id;
123  std::string message;
124  };
125 
126  std::vector<required_addon> required_addons;
128 
129  addon_req check_addon_version_compatibility(const config& local_item, const config& game);
130 
131  const char* display_status_string() const;
132 
133  bool match_string_filter(const std::string& filter) const;
134 };
135 
136 }
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:159
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:50
This class represents the info a client has about a game on the server.
Definition: lobby_data.hpp:63
bool shuffle_sides
Definition: lobby_data.hpp:96
std::string name
Definition: lobby_data.hpp:71
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:126
std::string scenario
Definition: lobby_data.hpp:72
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:127
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:112
std::string gold
Definition: lobby_data.hpp:82
disp_status display_status
Definition: lobby_data.hpp:116
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:70
This class represents the information a client has about another player.
Definition: lobby_data.hpp:30
user_state get_state(int selected_game_id) const
Definition: lobby_data.cpp:62
user_relation get_relation() const
Definition: lobby_data.cpp:73
std::string name
Definition: lobby_data.hpp:51
bool operator<(const user_info &b) const
Definition: lobby_data.cpp:86
user_info(const config &c)
Definition: lobby_data.cpp:52
mock_char c
#define b