28 #define WRN_NG LOG_STREAM(warn, log_engine) 31 #define DBG_LB LOG_STREAM(debug, log_lobby) 32 #define WRN_LB LOG_STREAM(warn, log_lobby) 33 #define ERR_LB LOG_STREAM(err, log_lobby) 34 #define SCOPE_LB log_scope2(log_lobby, __func__) 39 : installed_addons_(installed_addons)
41 , gamelist_initialized_(false)
46 , game_filter_invert_(false)
87 for(
const auto& v : games) {
152 ERR_LB <<
"Error while applying the gamelist diff: '" << e.
message <<
"' Getting a new gamelist.\n";
162 const int game_id = c[
"id"];
164 ERR_LB <<
"game with id 0 in gamelist config" << std::endl;
172 if(diff_result ==
"new" || diff_result ==
"modified") {
186 }
else if(diff_result ==
"deleted") {
188 WRN_LB <<
"Would have to delete a game that I don't have: " << game_id << std::endl;
207 ERR_LB <<
"Error while applying the gamelist diff (2): '" << e.
message <<
"' Getting a new gamelist.\n";
229 if(ui.game_id == 0) {
235 WRN_NG <<
"User " << ui.name <<
" has unknown game_id: " << ui.game_id << std::endl;
239 switch(ui.relation) {
254 DBG_LB <<
"lobby_info::sync_games_display_status";
288 return &rooms_.at(name);
289 }
catch(
const std::out_of_range&) {
297 return &rooms_.at(name);
298 }
catch(
const std::out_of_range&) {
305 return get_room(name) !=
nullptr;
310 for(
auto& user :
users_) {
311 if(user.name == name) {
327 DBG_LB <<
"lobby info: closing room " << name << std::endl;
337 games_.push_back(&v.second);
352 for(
unsigned i = 0;
i <
games_.size(); ++
i) {
356 show = filter_func(*
games_[
i]);
373 for(
auto& user :
users_) {
374 user.update_state(game_id, room);
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
const config & gamelist() const
Returns the raw game list config data.
user_info * get_user(const std::string &name)
Returns info on the user with the given name, or nullptr if they don't eixst.
static lg::log_domain log_engine("engine")
This class represents the info a client has about a game on the server.
child_itors child_range(config_key_type key)
std::map< int, game_info > game_info_map
void update_user_statuses(int game_id, const room_info *room)
void clear_diff_track(const config &diff)
Clear any tracking info from a previous apply_diff call with tracking.
std::vector< game_filter_func > game_filters_
void process_gamelist(const config &data)
Process a full game list.
void apply_game_filter()
Generates a new list of games that match the current filter functions and inversion setting...
std::vector< std::string > installed_addons_
game_info * get_game_by_id(int id)
Returns info on a game with the given game ID.
void make_games_vector()
Generates a new vector of game pointers from the ID/game map.
Main entry points of multiplayer mode.
void friend_message(bool is_lobby, const std::string &sender, const std::string &message)
void do_notify(notify_mode mode, const std::string &sender, const std::string &message)
void private_message(bool is_lobby, const std::string &sender, const std::string &message)
boost::dynamic_bitset games_visibility_
void sync_games_display_status()
static lg::log_domain log_lobby("lobby")
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
game_info_map games_by_id_
bool has_room(const std::string &name) const
Returns whether a room with the given name has been opened.
room_info * get_room(const std::string &name)
Returns info on room with the given name, or nullptr if it doesn't exist.
void apply_diff(const config &diff, bool track=false)
A function to apply a diff config onto this config object.
bool gamelist_initialized_
const char * display_status_string() const
const std::vector< game_info * > & games() const
void public_message(bool is_lobby, const std::string &sender, const std::string &message)
This class represents the information a client has about a room.
void server_message(bool is_lobby, const std::string &sender, const std::string &message)
bool process_gamelist_diff(const config &data)
Process a gamelist diff.
lobby_info(const std::vector< std::string > &installed_addons)
void player_leaves(bool is_lobby)
This class represents the information a client has about another player.
static const char * diff_track_attribute
The name of the attribute used for tracking diff changes.
void game_created(const std::string &scenario, const std::string &name)
void player_joins(bool is_lobby)
Standard logging facilities (interface).
void close_room(const std::string &name)
Close the chat room with the given name.
A config object defines a single node in a WML file, with access to child nodes.
std::vector< user_info > users_
std::vector< game_info * > games_
void open_room(const std::string &name)
Open a new chat room with the given name.
bool process_gamelist_diff_impl(const config &data)
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.