The Battle for Wesnoth  1.15.1+dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
mp::lobby_info Class Reference

This class represents the collective information the client has about the players and games on the server. More...

#include <lobby_info.hpp>

Public Types

typedef std::map< int, game_infogame_info_map
 
using game_filter_func = std::function< bool(const game_info &)>
 

Public Member Functions

 lobby_info (const std::vector< std::string > &installed_addons)
 
void process_gamelist (const config &data)
 Process a full game list. More...
 
bool process_gamelist_diff (const config &data)
 Process a gamelist diff. More...
 
bool process_gamelist_diff_impl (const config &data)
 
void sync_games_display_status ()
 
void make_games_vector ()
 Generates a new vector of game pointers from the ID/game map. More...
 
const configgamelist () const
 Returns the raw game list config data. More...
 
void add_game_filter (game_filter_func func)
 Adds a new filter function to be considered when apply_game_filter is called. More...
 
void clear_game_filter ()
 Clears all game filter functions. More...
 
void set_game_filter_invert (bool value)
 Sets whether the result of each game filter should be inverted. More...
 
void apply_game_filter ()
 Generates a new list of games that match the current filter functions and inversion setting. More...
 
game_infoget_game_by_id (int id)
 Returns info on a game with the given game ID. More...
 
const game_infoget_game_by_id (int id) const
 Const overload of get_game_by_id. More...
 
void open_room (const std::string &name)
 Open a new chat room with the given name. More...
 
void close_room (const std::string &name)
 Close the chat room with the given name. More...
 
bool has_room (const std::string &name) const
 Returns whether a room with the given name has been opened. More...
 
room_infoget_room (const std::string &name)
 Returns info on room with the given name, or nullptr if it doesn't exist. More...
 
const room_infoget_room (const std::string &name) const
 Const overload of get_room. More...
 
user_infoget_user (const std::string &name)
 Returns info on the user with the given name, or nullptr if they don't eixst. More...
 
chat_sessionget_whisper_log (const std::string &name)
 
void update_user_statuses (int game_id, const room_info *room)
 
const std::vector< room_info > & rooms () const
 
const std::vector< game_info * > & games () const
 
const boost::dynamic_bitsetgames_visibility () const
 
const std::vector< user_info > & users () const
 
std::vector< user_info > & users ()
 
bool gamelist_initialized () const
 

Private Member Functions

void process_userlist ()
 

Private Attributes

const std::vector< std::string > & installed_addons_
 
config gamelist_
 
bool gamelist_initialized_
 
std::vector< room_inforooms_
 
game_info_map games_by_id_
 
std::vector< game_info * > games_
 
std::vector< user_infousers_
 
std::map< std::string, chat_sessionwhispers_
 
std::vector< game_filter_funcgame_filters_
 
bool game_filter_invert_
 
boost::dynamic_bitset games_visibility_
 

Detailed Description

This class represents the collective information the client has about the players and games on the server.

Definition at line 30 of file lobby_info.hpp.

Member Typedef Documentation

◆ game_filter_func

using mp::lobby_info::game_filter_func = std::function<bool(const game_info&)>

Definition at line 66 of file lobby_info.hpp.

◆ game_info_map

typedef std::map<int, game_info> mp::lobby_info::game_info_map

Definition at line 35 of file lobby_info.hpp.

Constructor & Destructor Documentation

◆ lobby_info()

mp::lobby_info::lobby_info ( const std::vector< std::string > &  installed_addons)
explicit

Definition at line 38 of file lobby_info.cpp.

Member Function Documentation

◆ add_game_filter()

void mp::lobby_info::add_game_filter ( game_filter_func  func)
inline

Adds a new filter function to be considered when apply_game_filter is called.

Definition at line 69 of file lobby_info.hpp.

References game_filters_.

Referenced by gui2::dialogs::mp_lobby::game_filter_reload().

◆ apply_game_filter()

void mp::lobby_info::apply_game_filter ( )

Generates a new list of games that match the current filter functions and inversion setting.

Definition at line 353 of file lobby_info.cpp.

References game_filter_invert_, game_filters_, games_, games_visibility_, i, and gui2::dialogs::tip::show().

Referenced by set_game_filter_invert(), gui2::dialogs::mp_lobby::update_gamelist(), gui2::dialogs::mp_lobby::update_gamelist_diff(), and gui2::dialogs::mp_lobby::update_gamelist_filter().

◆ clear_game_filter()

void mp::lobby_info::clear_game_filter ( )
inline

Clears all game filter functions.

Definition at line 75 of file lobby_info.hpp.

References game_filters_.

Referenced by gui2::dialogs::mp_lobby::game_filter_reload().

◆ close_room()

void mp::lobby_info::close_room ( const std::string &  name)

Close the chat room with the given name.

Definition at line 329 of file lobby_info.cpp.

References DBG_LB, get_room(), and rooms_.

Referenced by gui2::chatbox::close_window(), and set_game_filter_invert().

◆ gamelist()

const config& mp::lobby_info::gamelist ( ) const
inline

Returns the raw game list config data.

Definition at line 61 of file lobby_info.hpp.

References gamelist_.

Referenced by mp::do_notify(), and gui2::dialogs::mp_lobby::pre_show().

◆ gamelist_initialized()

bool mp::lobby_info::gamelist_initialized ( ) const
inline

Definition at line 145 of file lobby_info.hpp.

References gamelist_initialized_, and process_userlist().

Referenced by gui2::dialogs::mp_lobby::network_handler().

◆ games()

const std::vector<game_info*>& mp::lobby_info::games ( ) const
inline

◆ games_visibility()

const boost::dynamic_bitset& mp::lobby_info::games_visibility ( ) const
inline

◆ get_game_by_id() [1/2]

game_info * mp::lobby_info::get_game_by_id ( int  id)

Returns info on a game with the given game ID.

Definition at line 272 of file lobby_info.cpp.

References games_by_id_, and i.

Referenced by gui2::dialogs::mp_lobby::enter_game_by_id(), gui2::dialogs::lobby_player_info::pre_show(), process_userlist(), and set_game_filter_invert().

◆ get_game_by_id() [2/2]

const game_info * mp::lobby_info::get_game_by_id ( int  id) const

Const overload of get_game_by_id.

Definition at line 278 of file lobby_info.cpp.

References games_by_id_, and i.

◆ get_room() [1/2]

room_info * mp::lobby_info::get_room ( const std::string &  name)

◆ get_room() [2/2]

const room_info * mp::lobby_info::get_room ( const std::string &  name) const

Const overload of get_room.

Definition at line 295 of file lobby_info.cpp.

References name(), and rooms_.

◆ get_user()

user_info * mp::lobby_info::get_user ( const std::string &  name)

Returns info on the user with the given name, or nullptr if they don't eixst.

Definition at line 311 of file lobby_info.cpp.

References users_.

Referenced by set_game_filter_invert().

◆ get_whisper_log()

chat_session& mp::lobby_info::get_whisper_log ( const std::string &  name)
inline

◆ has_room()

bool mp::lobby_info::has_room ( const std::string &  name) const

Returns whether a room with the given name has been opened.

Definition at line 306 of file lobby_info.cpp.

References get_room().

Referenced by open_room(), and set_game_filter_invert().

◆ make_games_vector()

void mp::lobby_info::make_games_vector ( )

Generates a new vector of game pointers from the ID/game map.

The games will be referenced in ascending order by ID.

Definition at line 338 of file lobby_info.cpp.

References games_, games_by_id_, and games_visibility_.

Referenced by sync_games_display_status(), gui2::dialogs::mp_lobby::update_gamelist(), and gui2::dialogs::mp_lobby::update_gamelist_diff().

◆ open_room()

void mp::lobby_info::open_room ( const std::string &  name)

Open a new chat room with the given name.

Definition at line 322 of file lobby_info.cpp.

References has_room(), and rooms_.

Referenced by gui2::chatbox::find_or_create_window(), gui2::chatbox::process_room_join(), and set_game_filter_invert().

◆ process_gamelist()

void mp::lobby_info::process_gamelist ( const config data)

Process a full game list.

Current info is discarded.

Definition at line 108 of file lobby_info.cpp.

References c, config::child(), config::child_range(), DBG_LB, gamelist_, gamelist_initialized_, games_by_id_, mp::game_info::id, installed_addons_, process_userlist(), and SCOPE_LB.

Referenced by gui2::dialogs::mp_lobby::process_gamelist().

◆ process_gamelist_diff()

bool mp::lobby_info::process_gamelist_diff ( const config data)

Process a gamelist diff.

Parameters
dataRaw game list data, usually received from the MP server.
Returns
True on success, false on failure (e.g. when the diff did not apply correctly).

Definition at line 128 of file lobby_info.cpp.

References gamelist_initialized_, and process_gamelist_diff_impl().

Referenced by gui2::dialogs::mp_lobby::process_gamelist_diff().

◆ process_gamelist_diff_impl()

bool mp::lobby_info::process_gamelist_diff_impl ( const config data)

◆ process_userlist()

void mp::lobby_info::process_userlist ( )
private

◆ rooms()

const std::vector<room_info>& mp::lobby_info::rooms ( ) const
inline

Definition at line 120 of file lobby_info.hpp.

References rooms_.

◆ set_game_filter_invert()

void mp::lobby_info::set_game_filter_invert ( bool  value)
inline

Sets whether the result of each game filter should be inverted.

Definition at line 81 of file lobby_info.hpp.

References apply_game_filter(), close_room(), game_filter_invert_, get_game_by_id(), get_room(), get_user(), has_room(), name(), and open_room().

Referenced by gui2::dialogs::mp_lobby::game_filter_reload().

◆ sync_games_display_status()

void mp::lobby_info::sync_games_display_status ( )

◆ update_user_statuses()

void mp::lobby_info::update_user_statuses ( int  game_id,
const room_info room 
)

Definition at line 378 of file lobby_info.cpp.

References users_.

Referenced by get_whisper_log(), and gui2::dialogs::mp_lobby::update_playerlist().

◆ users() [1/2]

const std::vector<user_info>& mp::lobby_info::users ( ) const
inline

◆ users() [2/2]

std::vector<user_info>& mp::lobby_info::users ( )
inline

Definition at line 140 of file lobby_info.hpp.

References users_.

Member Data Documentation

◆ game_filter_invert_

bool mp::lobby_info::game_filter_invert_
private

Definition at line 170 of file lobby_info.hpp.

Referenced by apply_game_filter(), and set_game_filter_invert().

◆ game_filters_

std::vector<game_filter_func> mp::lobby_info::game_filters_
private

Definition at line 168 of file lobby_info.hpp.

Referenced by add_game_filter(), apply_game_filter(), and clear_game_filter().

◆ gamelist_

config mp::lobby_info::gamelist_
private

◆ gamelist_initialized_

bool mp::lobby_info::gamelist_initialized_
private

◆ games_

std::vector<game_info*> mp::lobby_info::games_
private

Definition at line 162 of file lobby_info.hpp.

Referenced by apply_game_filter(), games(), and make_games_vector().

◆ games_by_id_

game_info_map mp::lobby_info::games_by_id_
private

◆ games_visibility_

boost::dynamic_bitset mp::lobby_info::games_visibility_
private

Definition at line 172 of file lobby_info.hpp.

Referenced by apply_game_filter(), games_visibility(), and make_games_vector().

◆ installed_addons_

const std::vector<std::string>& mp::lobby_info::installed_addons_
private

Definition at line 152 of file lobby_info.hpp.

Referenced by process_gamelist(), and process_gamelist_diff_impl().

◆ rooms_

std::vector<room_info> mp::lobby_info::rooms_
private

Definition at line 158 of file lobby_info.hpp.

Referenced by close_room(), get_room(), open_room(), and rooms().

◆ users_

std::vector<user_info> mp::lobby_info::users_
private

Definition at line 164 of file lobby_info.hpp.

Referenced by get_user(), process_userlist(), update_user_statuses(), and users().

◆ whispers_

std::map<std::string, chat_session> mp::lobby_info::whispers_
private

Definition at line 166 of file lobby_info.hpp.

Referenced by get_whisper_log().


The documentation for this class was generated from the following files: