Merge pull request #398 from cbeck88/require_scenario
add "require_scenario" for single scenarios. track addon metadata.
This commit is contained in:
commit
7a4f025fab
3 changed files with 23 additions and 2 deletions
|
@ -400,8 +400,8 @@ void game_config_manager::load_addons_cfg()
|
|||
config umc_cfg;
|
||||
cache_.get_config(addon.main_cfg, umc_cfg);
|
||||
|
||||
// Annotate "era" and "modification" tags with addon_id info
|
||||
const char * tags_with_addon_id [] = { "era", "modification", NULL };
|
||||
// Annotate "era", "modification", and scenario tags with addon_id info
|
||||
const char * tags_with_addon_id [] = { "era", "modification", "multiplayer", "scenario", NULL };
|
||||
|
||||
for (const char ** type = tags_with_addon_id; *type; type++)
|
||||
{
|
||||
|
|
|
@ -457,6 +457,8 @@ void gamebrowser::handle_event(const SDL_Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
static mp::ADDON_REQ check_addon_version_compatibility (const config & local_item, const config & game, std::vector<required_addon> & req_list);
|
||||
|
||||
// Determine if this is a campaign or scenario and add info string to this game item.
|
||||
void gamebrowser::populate_game_item_campaign_or_scenario_info(gamebrowser::game_item & item, const config & game, const config & game_config, bool & verified)
|
||||
{
|
||||
|
@ -496,16 +498,30 @@ void gamebrowser::populate_game_item_campaign_or_scenario_info(gamebrowser::game
|
|||
verified = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*level_cfg)["require_scenario"].to_bool(false)) {
|
||||
mp::ADDON_REQ result = check_addon_version_compatibility((*level_cfg), game, item.addons);
|
||||
item.addons_outcome = std::max(item.addons_outcome, result); //elevate to most severe error level encountered so far
|
||||
}
|
||||
|
||||
} else {
|
||||
utils::string_map symbols;
|
||||
symbols["scenario_id"] = game["mp_scenario"];
|
||||
item.map_info =
|
||||
vgettext("Unknown scenario: $scenario_id", symbols);
|
||||
verified = false;
|
||||
|
||||
if (game["require_scenario"].to_bool(false)) {
|
||||
item.have_scenario = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.map_info = _("Unknown scenario");
|
||||
verified = false;
|
||||
|
||||
if (game["require_scenario"].to_bool(false)) {
|
||||
item.have_scenario = false;
|
||||
}
|
||||
}
|
||||
} else { // Is a campaign
|
||||
const config* level_cfg = &game_config.find_child("campaign", "id",
|
||||
|
|
|
@ -193,6 +193,11 @@ void saved_game::expand_scenario()
|
|||
// A hash has to be generated using an unmodified scenario data.
|
||||
mp_settings_.hash = scenario.hash();
|
||||
|
||||
// Add addon_id information if it exists.
|
||||
if (!scenario["addon_id"].empty() && scenario["require_scenario"].to_bool(false)) {
|
||||
mp_settings_.update_addon_requirements(config_of("id",scenario["addon_id"])("version", scenario["addon_version"])("min_version", scenario["addon_min_version"]));
|
||||
}
|
||||
|
||||
update_label();
|
||||
set_defaults();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue