The Battle for Wesnoth  1.19.6+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...
 
std::function< void()> begin_state_sync ()
 Updates the game pointer list and returns a second stage cleanup function to be called after any actions have been done using the pointer list. 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...
 
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

bool process_gamelist_diff_impl (const config &data)
 
void process_userlist ()
 
void make_games_vector ()
 Generates a new vector of game pointers from the ID/game map. More...
 

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

Definition at line 34 of file lobby_info.cpp.

References refresh_installed_addons_cache().

Referenced by mp::get_lobby_info().

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 65 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 336 of file lobby_info.cpp.

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

Referenced by begin_state_sync(), and gui2::dialogs::mp_lobby::update_gamelist_filter().

◆ begin_state_sync()

std::function< void()> mp::lobby_info::begin_state_sync ( )

Updates the game pointer list and returns a second stage cleanup function to be called after any actions have been done using the pointer list.

Definition at line 255 of file lobby_info.cpp.

References apply_game_filter(), mp::game_info::CLEAN, DBG_LB, mp::game_info::DELETED, games_by_id_, i, and make_games_vector().

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

◆ clear_game_filters()

void mp::lobby_info::clear_game_filters ( )
inline

Clears all game filter functions.

Definition at line 71 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 57 of file lobby_info.hpp.

References gamelist_.

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

◆ gamelist_initialized()

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

Definition at line 117 of file lobby_info.hpp.

References gamelist_initialized_.

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

Definition at line 102 of file lobby_info.hpp.

References games_visibility_.

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

◆ 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 287 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(), and process_userlist().

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

References users_.

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

References game_filter_invert_, and game_filters_.

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

◆ make_games_vector()

void mp::lobby_info::make_games_vector ( )
private

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

References games_, games_by_id_, and games_visibility_.

Referenced by begin_state_sync().

◆ process_gamelist()

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

Process a full game list.

Current info is discarded.

Definition at line 114 of file lobby_info.cpp.

References c, config::child_range(), data, DBG_LB, gamelist_, gamelist_initialized_, games_by_id_, installed_addons_, config::mandatory_child(), 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 134 of file lobby_info.cpp.

References data, 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)
private

◆ process_userlist()

void mp::lobby_info::process_userlist ( )
private

◆ refresh_installed_addons_cache()

void mp::lobby_info::refresh_installed_addons_cache ( )

Definition at line 48 of file lobby_info.cpp.

References installed_addons(), and installed_addons_.

Referenced by 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 77 of file lobby_info.hpp.

References game_filter_invert_.

◆ users() [1/2]

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

Definition at line 112 of file lobby_info.hpp.

References users_.

◆ users() [2/2]

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

Member Data Documentation

◆ game_filter_invert_

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

Definition at line 149 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 147 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 143 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 151 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 145 of file lobby_info.hpp.

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


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