From 7df9c043d09f0656d99330d1db92cbe4848646ba Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Tue, 21 Jul 2015 13:07:57 +0200 Subject: [PATCH] don't convert [scenario] to [multiplayer] This should fix the :cl list which previously did not show all scenarios. Also it speeds up config reloading becasue previously the contents of every [scenario] were copied multiple times when reloading the game config. I don't know why the [scenario]s were converted to [multiplayer] in the first place. --- src/game_classification.cpp | 4 ++-- src/game_config_manager.cpp | 29 +++++++---------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/game_classification.cpp b/src/game_classification.cpp index fd4fbe064f58..aa23da29ec2b 100644 --- a/src/game_classification.cpp +++ b/src/game_classification.cpp @@ -114,8 +114,8 @@ config game_classification::to_config() const std::string game_classification::get_tagname() const { - if(this->campaign_type == CAMPAIGN_TYPE::SCENARIO) { - return "multiplayer"; + if(this->campaign_type == CAMPAIGN_TYPE::MULTIPLAYER) { + return this->campaign.empty() ? "multiplayer" : "scenario"; } else { return this->campaign_type.to_string(); diff --git a/src/game_config_manager.cpp b/src/game_config_manager.cpp index 3c12c5cb5860..605f7dbb1dea 100644 --- a/src/game_config_manager.cpp +++ b/src/game_config_manager.cpp @@ -263,29 +263,14 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload, // become [multiplayer] tags and campaign's id should be added to them // to allow to recognize which scenarios belongs to a loaded campaign. if (classification != NULL) { - if ((classification->campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER || - classification->campaign_type == game_classification::CAMPAIGN_TYPE::SCENARIO) && - !classification->campaign_define.empty()) { - - const config& campaign = game_config().find_child("campaign", - "define", classification->campaign_define); - // FIXME: check whether campaign is valid - const std::string& campaign_id = campaign["id"]; - const bool require_campaign = - campaign["require_campaign"].to_bool(true); - - const config::const_child_itors &ci = - game_config().child_range("scenario"); - std::vector scenarios(ci.first, ci.second); - - game_config_.clear_children("scenario"); - - BOOST_FOREACH(config& cfg, scenarios) { - cfg["campaign_id"] = campaign_id; - cfg["require_scenario"] = require_campaign; + if (const config& campaign = game_config().find_child("campaign", "id", classification->campaign)) + { + const bool require_campaign = campaign["require_campaign"].to_bool(true); + BOOST_FOREACH(config& scenario, game_config_.child_range("scenario")) + { + scenario["require_scenario"] = require_campaign; // make force_lock_settings default to true for [scenario] - cfg["force_lock_settings"] = cfg["force_lock_settings"].to_bool(true); - game_config_.add_child(lexical_cast(game_classification::CAMPAIGN_TYPE::MULTIPLAYER), cfg); + scenario["force_lock_settings"] = scenario["force_lock_settings"].to_bool(true); } } }