The Battle for Wesnoth  1.17.0-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 ()
 
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_filters ()
 Clears all game filter functions. More...
 
void set_game_filter_invert (std::function< bool(bool)> value)
 Sets whether the result of each game filter should be inverted. More...
 
bool is_game_visible (const game_info &)
 Returns whether the game would be visible after the game filters are applied. 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...
 
user_infoget_user (const std::string &name)
 Returns info on the user with the given name, or nullptr if they don't eixst. More...
 
void update_user_statuses (int game_id)
 
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
 
void refresh_installed_addons_cache ()
 

Private Member Functions

void process_userlist ()
 

Private Attributes

std::vector< std::string > installed_addons_
 
config gamelist_
 
bool gamelist_initialized_
 
game_info_map games_by_id_
 
std::vector< game_info * > games_
 
std::vector< user_infousers_
 
std::vector< game_filter_funcgame_filters_
 
std::function< bool(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 31 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 67 of file lobby_info.hpp.

◆ game_info_map

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

Definition at line 36 of file lobby_info.hpp.

Constructor & Destructor Documentation

◆ lobby_info()

mp::lobby_info::lobby_info ( )

Definition at line 40 of file lobby_info.cpp.

References refresh_installed_addons_cache().

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 70 of file lobby_info.hpp.

References game_filters_.

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

◆ 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 366 of file lobby_info.cpp.

References games_, games_visibility_, i, and is_game_visible().

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_filters()

void mp::lobby_info::clear_game_filters ( )
inline

Clears all game filter functions.

Definition at line 76 of file lobby_info.hpp.

References game_filters_.

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

◆ gamelist()

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

Returns the raw game list config data.

Definition at line 62 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

◆ 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 282 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 288 of file lobby_info.cpp.

References games_by_id_, and i.

◆ 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 317 of file lobby_info.cpp.

References users_.

Referenced by set_game_filter_invert().

◆ is_game_visible()

bool mp::lobby_info::is_game_visible ( const game_info game)

Returns whether the game would be visible after the game filters are applied.

Definition at line 355 of file lobby_info.cpp.

References game_filter_invert_, and game_filters_.

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

◆ 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 340 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().

◆ process_gamelist()

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

Process a full game list.

Current info is discarded.

Definition at line 120 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 140 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

◆ refresh_installed_addons_cache()

void mp::lobby_info::refresh_installed_addons_cache ( )

Definition at line 54 of file lobby_info.cpp.

References installed_addons(), and installed_addons_.

Referenced by gamelist_initialized(), and lobby_info().

◆ set_game_filter_invert()

void mp::lobby_info::set_game_filter_invert ( std::function< bool(bool)>  value)
inline

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

Definition at line 82 of file lobby_info.hpp.

References apply_game_filter(), game_filter_invert_, get_game_by_id(), get_user(), is_game_visible(), and update_user_statuses().

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

◆ 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)

Definition at line 377 of file lobby_info.cpp.

References users_.

Referenced by set_game_filter_invert(), 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 119 of file lobby_info.hpp.

References users_.

Member Data Documentation

◆ game_filter_invert_

std::function<bool(bool)> mp::lobby_info::game_filter_invert_
private

Definition at line 148 of file lobby_info.hpp.

Referenced by is_game_visible(), and set_game_filter_invert().

◆ game_filters_

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

Definition at line 146 of file lobby_info.hpp.

Referenced by add_game_filter(), clear_game_filters(), and is_game_visible().

◆ 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 142 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 150 of file lobby_info.hpp.

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

◆ installed_addons_

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

◆ users_

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

Definition at line 144 of file lobby_info.hpp.

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


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