Make the GUI2 lobby respect the require_modification attribute.

Fixes bug #22877.
This commit is contained in:
Boldizsár Lipka 2014-11-01 12:51:08 +01:00
parent 408a12a288
commit 824f142231
2 changed files with 18 additions and 2 deletions

View file

@ -190,6 +190,7 @@ game_info::game_info(const config& game, const config& game_config)
, verified(true)
, password_required(game["password"].to_bool())
, have_era(true)
, have_all_mods(true)
, has_friends(false)
, has_ignored(false)
, display_status(NEW)
@ -219,6 +220,19 @@ game_info::game_info(const config& game, const config& game_config)
}
map_info = era;
if(!game.child_or_empty("modification").empty()) {
BOOST_FOREACH(const config &cfg, game.child_range("modification")) {
if (cfg["require_modification"].to_bool(false)) {
const config &mod = game_config.find_child("modification", "id",
cfg["id"]);
if (!mod) {
have_all_mods = false;
break;
}
}
}
}
if(map_data.empty()) {
map_data = filesystem::read_map(game["mp_scenario"]);
}
@ -342,12 +356,13 @@ game_info::game_info(const config& game, const config& game_config)
bool game_info::can_join() const
{
return have_era && !started && vacant_slots > 0;
return have_era && have_all_mods && !started && vacant_slots > 0;
}
bool game_info::can_observe() const
{
return (have_era && observers) || preferences::is_authenticated();
return (have_era && have_all_mods && observers)
|| preferences::is_authenticated();
}
const char* game_info::display_status_string() const

View file

@ -170,6 +170,7 @@ struct game_info
bool verified;
bool password_required;
bool have_era;
bool have_all_mods;
bool has_friends;
bool has_ignored;