Skip to content

Commit

Permalink
don't convert [scenario] to [multiplayer]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gfgtdf committed Jul 21, 2015
1 parent 1cbde8d commit 7df9c04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/game_classification.cpp
Expand Up @@ -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();
Expand Down
29 changes: 7 additions & 22 deletions src/game_config_manager.cpp
Expand Up @@ -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<config> 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<std::string>(game_classification::CAMPAIGN_TYPE::MULTIPLAYER), cfg);
scenario["force_lock_settings"] = scenario["force_lock_settings"].to_bool(true);
}
}
}
Expand Down

0 comments on commit 7df9c04

Please sign in to comment.