Get the scenario_id from the addon content list sent by the server if it's not otherwise available.

Fixes #6285
This commit is contained in:
Pentarctagon 2021-12-18 12:08:02 -06:00 committed by Pentarctagon
parent c21dfcaeb4
commit 7ffe2f84ee
4 changed files with 18 additions and 7 deletions

View file

@ -146,7 +146,7 @@ bool map_includes(const preproc_map& general, const preproc_map& special)
} // end anonymous namespace
void game_config_manager::load_game_config_with_loadscreen(
FORCE_RELOAD_CONFIG force_reload, game_classification const*, std::optional<std::set<std::string>> active_addons)
FORCE_RELOAD_CONFIG force_reload, std::optional<std::set<std::string>> active_addons)
{
if(!lg::info().dont_log(log_config)) {
auto out = formatter();
@ -703,7 +703,7 @@ void game_config_manager::load_game_config_for_game(
}
try {
load_game_config_with_loadscreen(NO_FORCE_RELOAD, &classification, classification.active_addons(scenario_id));
load_game_config_with_loadscreen(NO_FORCE_RELOAD, classification.active_addons(scenario_id));
} catch(const game::error&) {
cache_.clear_defines();

View file

@ -62,8 +62,7 @@ private:
void load_game_config(bool reload_everything);
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload,
game_classification const* classification = nullptr, std::optional<std::set<std::string>> active_addons = {});
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, std::optional<std::set<std::string>> active_addons = {});
// load_game_config() helper functions.
void load_addons_cfg();

View file

@ -134,7 +134,19 @@ bool mp_join_game::fetch_game_config()
state_.classification() = game_classification(level_);
// Make sure that we have the same config as host, if possible.
game_config_manager::get()->load_game_config_for_game(state_.classification(), state_.get_scenario_id());
std::string scenario_id = state_.get_scenario_id();
// since add-ons are now only enabled when used, the scenario ID may still not be known
// so check in the MP info sent from the server for the scenario ID if that's the case
if(scenario_id == "") {
for(const auto& addon : level_.child("multiplayer").child_range("addon")) {
for(const auto& content : addon.child_range("content")) {
if(content["type"] == "scenario") {
scenario_id = content["id"].str();
}
}
}
}
game_config_manager::get()->load_game_config_for_game(state_.classification(), scenario_id);
}
game_config::add_color_info(game_config_view::wrap(get_scenario()));

View file

@ -1760,9 +1760,9 @@ void server::handle_player_in_game(player_iterator p, simple_wml::document& data
g.level().root().apply_diff(*scenario_diff);
const simple_wml::node* cfg_change = scenario_diff->child("change_child");
// it is very likeley that the diff changes a side so this check isn't that important.
// it is very likely that the diff changes a side so this check isn't that important.
// Note that [side] is not at toplevel but inside [scenario] or [snapshot]
if(cfg_change /** && cfg_change->child("side") */) {
if(cfg_change) {
g.update_side_data();
}