18 #include "addon/manager.hpp"
25 #define WRN_NG LOG_STREAM(warn, log_engine)
28 #define DBG_LB LOG_STREAM(debug, log_lobby)
29 #define WRN_LB LOG_STREAM(warn, log_lobby)
30 #define ERR_LB LOG_STREAM(err, log_lobby)
31 #define SCOPE_LB log_scope2(log_lobby, __func__)
38 , gamelist_initialized_(false)
43 , game_filter_invert_()
93 for(
const auto& v : games) {
94 const game_info&
game = v.second;
95 ss <<
"G" <<
game.id <<
"(" <<
game.name <<
") " <<
game.display_status_string() <<
" ";
102 std::string dump_games_config(
const config& gamelist)
104 std::stringstream ss;
129 for(
const auto& side : scenario.
child_range(
"side")) {
130 if(side[
"controller"].str() ==
"human") {
134 if(human_sides == 0) {
135 ERR_LB <<
"No human sides for scenario " <<
game[
"scenario"];
140 qgame[
"id"] = queued_id;
142 qgame[
"auto_hosted"] =
true;
144 qgame[
"name"] = scenario[
"name"];
145 qgame[
"mp_scenario"] =
game[
"scenario"];
146 qgame[
"mp_era"] =
game[
"era"];
147 qgame[
"mp_use_map_settings"] =
game[
"use_map_settings"];
148 qgame[
"mp_fog"] =
game[
"fog"];
149 qgame[
"mp_shroud"] =
game[
"shroud"];
150 qgame[
"mp_village_gold"] =
game[
"village_gold"];
151 qgame[
"experience_modifier"] =
game[
"experience_modifier"];
153 qgame[
"mp_countdown"] =
game[
"countdown"];
154 if(qgame[
"countdown"].to_bool()) {
155 qgame[
"mp_countdown_reservoir_time"] =
game[
"countdown_reservoir_time"];
156 qgame[
"mp_countdown_init_time"] =
game[
"countdown_init_time"];
157 qgame[
"mp_countdown_action_bonus"] =
game[
"countdown_action_bonus"];
158 qgame[
"mp_countdown_turn_bonus"] =
game[
"countdown_turn_bonus"];
161 qgame[
"observer"] =
game[
"observer"];
162 qgame[
"human_sides"] = human_sides;
165 qgame[
"map_data"] = scenario[
"map_data"];
172 qchild[
"vacant"] = human_sides;
173 qchild[
"max"] = human_sides;
213 ERR_LB <<
"Error while applying the gamelist diff: '" <<
e.message <<
"' Getting a new gamelist.";
223 const int game_id =
c[
"id"].to_int();
225 ERR_LB <<
"game with id 0 in gamelist config";
233 if(diff_result ==
"new" || diff_result ==
"modified") {
247 }
else if(diff_result ==
"deleted") {
249 WRN_LB <<
"Would have to delete a game that I don't have: " << game_id;
268 ERR_LB <<
"Error while applying the gamelist diff (2): '" <<
e.message <<
"' Getting a new gamelist.";
298 g->has_friends =
true;
301 g->has_ignored =
true;
319 DBG_LB <<
"lobby_info, second state sync stage";
357 for(
auto& user :
users_) {
358 if(user.name == name) {
372 games_.push_back(&v.second);
398 for(
unsigned i = 0;
i <
games_.size(); ++
i) {
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
A config object defines a single node in a WML file, with access to child nodes.
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
bool has_attribute(config_key_type key) const
static const char * diff_track_attribute
The name of the attribute used for tracking diff changes.
child_itors child_range(config_key_type key)
void apply_diff(const config &diff, bool track=false)
A function to apply a diff config onto this config object.
void clear_diff_track(const config &diff)
Clear any tracking info from a previous apply_diff call with tracking.
config & add_child(config_key_type key)
static game_config_manager * get()
const game_config_view & game_config() const
const config & mandatory_child(config_key_type key) const
const config & find_mandatory_child(config_key_type key, const std::string &name, const std::string &value) const
std::function< bool(bool)> game_filter_invert_
bool gamelist_initialized_
bool is_game_visible(const game_info &)
Returns whether the game would be visible after the game filters are applied.
bool process_gamelist_diff_impl(const config &data)
void process_gamelist(const config &data)
Process a full game list.
bool process_gamelist_diff(const config &data)
Process a gamelist diff.
void refresh_installed_addons_cache()
std::function< void()> begin_state_sync()
Updates the game pointer list and returns a second stage cleanup function to be called after any acti...
game_info * get_game_by_id(int id)
Returns info on a game with the given game ID.
game_info_map games_by_id_
void make_games_vector()
Generates a new vector of game pointers from the ID/game map.
std::vector< user_info > users_
user_info * get_user(const std::string &name)
Returns info on the user with the given name, or nullptr if they don't eixst.
std::vector< game_info * > games_
boost::dynamic_bitset games_visibility_
std::map< int, game_info > game_info_map
void apply_game_filter()
Generates a new list of games that match the current filter functions and inversion setting.
std::vector< game_filter_func > game_filters_
std::vector< std::string > installed_addons_
static lg::log_domain log_engine("engine")
static lg::log_domain log_lobby("lobby")
Standard logging facilities (interface).
std::string read_map(const std::string &name)
Game configuration data as global variables.
void public_message(bool is_lobby, const std::string &sender, const std::string &message)
void game_created(const std::string &scenario, const std::string &name)
void private_message(bool is_lobby, const std::string &sender, const std::string &message)
void player_joins(bool is_lobby)
void friend_message(bool is_lobby, const std::string &sender, const std::string &message)
void server_message(bool is_lobby, const std::string &sender, const std::string &message)
void player_leaves(bool is_lobby)
Main entry points of multiplayer mode.
void do_notify(notify_mode mode, const std::string &sender, const std::string &message)
This class represents the info a client has about a game on the server.
This class represents the information a client has about another player.
user_relation get_relation() const