The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lobby_data.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2017 by Tomasz Sniatowski <kailoran@gmail.com>
3  Part of the Battle for Wesnoth Project http://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 <set>
18 #include <deque>
19 #include <functional>
20 #include <vector>
21 #include <string>
22 
23 class config;
24 
25 namespace mp {
26 
27 /** This class represents a single stored chat message */
29 {
30  /** Create a chat message */
31  chat_message(const time_t& timestamp,
32  const std::string& user,
33  const std::string& message);
34 
35  time_t timestamp;
38 };
39 
40 /** this class memorizes a chat session. */
42 {
43 public:
44  chat_session();
45 
46  void add_message(const time_t& timestamp,
47  const std::string& user,
48  const std::string& message);
49 
50  void add_message(const std::string& user, const std::string& message);
51 
52  const std::deque<chat_message>& history() const
53  {
54  return history_;
55  }
56 
57  void clear();
58 
59 private:
60  std::deque<chat_message> history_;
61 };
62 
63 /**
64  * This class represents the information a client has about a room
65  */
66 class room_info
67 {
68 public:
69  explicit room_info(const std::string& name);
70 
71  const std::string& name() const
72  {
73  return name_;
74  }
75  const std::set<std::string>& members() const
76  {
77  return members_;
78  }
79  bool is_member(const std::string& user) const;
80  void add_member(const std::string& user);
81  void remove_member(const std::string& user);
82  void process_room_members(const config& data);
83 
84  const chat_session& log() const
85  {
86  return log_;
87  }
89  {
90  return log_;
91  }
92 
93 private:
95  std::set<std::string> members_;
97 };
98 
99 
100 /**
101  * This class represents the information a client has about another player
102  */
103 struct user_info
104 {
105  explicit user_info(const config& c);
106 
107  void update_state(int selected_game_id,
108  const room_info* current_room = nullptr);
109  void update_relation();
110 
113  ME,
116  };
117  enum user_state {
122  };
123 
124  bool operator>(const user_info& b) const;
125 
127  int game_id;
131  bool observing;
132 };
133 
134 /**
135  * This class represents the info a client has about a game on the server
136  */
137 struct game_info
138 {
139  game_info(const config& c, const config& game_config, const std::vector<std::string>& installed_addons);
140 
141  bool can_join() const;
142  bool can_observe() const;
143 
144  int id;
154 
159  std::string status; // vacant slots or turn info
161  size_t vacant_slots;
162 
163  unsigned int current_turn;
164  bool reloaded;
165  bool started;
166  bool fog;
167  bool shroud;
168  bool observers;
172  bool verified;
174  bool have_era;
176 
179 
185  };
187 
189 
190  struct required_addon {
194  };
195 
196  std::vector<required_addon> required_addons;
198 
199  ADDON_REQ check_addon_version_compatibility(const config& local_item, const config& game);
200 
201  const char* display_status_string() const;
202 
203  bool match_string_filter(const std::string& filter) const;
204 };
205 
206 }
std::string scenario
Definition: lobby_data.hpp:147
std::string map_size_info
Definition: lobby_data.hpp:150
ADDON_REQ addons_outcome
Definition: lobby_data.hpp:197
std::vector< char_t > string
std::string status
Definition: lobby_data.hpp:159
void add_message(const time_t &timestamp, const std::string &user, const std::string &message)
Definition: lobby_data.cpp:61
std::string mod_info
Definition: lobby_data.hpp:153
bool match_string_filter(const std::string &filter) const
Definition: lobby_data.cpp:525
unsigned int current_turn
Definition: lobby_data.hpp:163
std::deque< chat_message > history_
Definition: lobby_data.hpp:60
This class represents the info a client has about a game on the server.
Definition: lobby_data.hpp:137
user_state state
Definition: lobby_data.hpp:129
bool can_join() const
Definition: lobby_data.cpp:498
std::set< std::string > members_
Definition: lobby_data.hpp:95
std::string user
Definition: lobby_data.hpp:36
std::string map_info
Definition: lobby_data.hpp:149
size_t vacant_slots
Definition: lobby_data.hpp:161
bool remote_scenario
Definition: lobby_data.hpp:148
this class memorizes a chat session.
Definition: lobby_data.hpp:41
std::string name
Definition: lobby_data.hpp:146
std::string time_limit
Definition: lobby_data.hpp:160
#define b
Pubic entry points for the MP workflow.
Definition: lobby_data.cpp:48
bool password_required
Definition: lobby_data.hpp:173
std::string support
Definition: lobby_data.hpp:156
user_info(const config &c)
Definition: lobby_data.cpp:107
bool is_member(const std::string &user) const
Definition: lobby_data.cpp:83
const chat_session & log() const
Definition: lobby_data.hpp:84
const std::set< std::string > & members() const
Definition: lobby_data.hpp:75
chat_session log_
Definition: lobby_data.hpp:96
bool operator>(const user_info &b) const
std::string name_
Definition: lobby_data.hpp:94
std::string vision
Definition: lobby_data.hpp:158
chat_message(const time_t &timestamp, const std::string &user, const std::string &message)
Create a chat message.
Definition: lobby_data.cpp:50
std::string map_data
Definition: lobby_data.hpp:145
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
Definition: manager.cpp:148
const std::string & name() const
Definition: lobby_data.hpp:71
std::string gold
Definition: lobby_data.hpp:155
std::string era_short
Definition: lobby_data.hpp:152
bool can_observe() const
Definition: lobby_data.cpp:503
bool registered_users_only
Definition: lobby_data.hpp:171
bool use_map_settings
Definition: lobby_data.hpp:170
std::string name
Definition: lobby_data.hpp:126
const char * display_status_string() const
Definition: lobby_data.cpp:508
Game configuration data as global variables.
Definition: build_info.cpp:53
ADDON_REQ check_addon_version_compatibility(const config &local_item, const config &game)
Definition: lobby_data.cpp:441
This class represents the information a client has about a room.
Definition: lobby_data.hpp:66
const std::deque< chat_message > & history() const
Definition: lobby_data.hpp:52
std::string era
Definition: lobby_data.hpp:151
This class represents the information a client has about another player.
Definition: lobby_data.hpp:103
void update_state(int selected_game_id, const room_info *current_room=nullptr)
Definition: lobby_data.cpp:118
room_info(const std::string &name)
Definition: lobby_data.cpp:79
static bool timestamp
Definition: log.cpp:46
std::string message
Definition: lobby_data.hpp:37
void remove_member(const std::string &user)
Definition: lobby_data.cpp:93
game_display_status display_status
Definition: lobby_data.hpp:186
game_info(const config &c, const config &game_config, const std::vector< std::string > &installed_addons)
Definition: lobby_data.cpp:173
std::vector< required_addon > required_addons
Definition: lobby_data.hpp:196
void update_relation()
Definition: lobby_data.cpp:137
user_relation relation
Definition: lobby_data.hpp:128
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
mock_char c
This class represents a single stored chat message.
Definition: lobby_data.hpp:28
chat_session & log()
Definition: lobby_data.hpp:88
std::string xp
Definition: lobby_data.hpp:157
void process_room_members(const config &data)
Definition: lobby_data.cpp:98
void add_member(const std::string &user)
Definition: lobby_data.cpp:88