Fixes objectives showing despite being set to silent...
...and adds a recursive search for config childs. This was needed, because the position of [objectives] is not fixed, not even in the WML hierarchy.
This commit is contained in:
parent
77c94414ec
commit
b0be5d5fb2
4 changed files with 28 additions and 2 deletions
|
@ -8,6 +8,8 @@ Version 1.7.5+svn:
|
|||
* Added a couple of missing frames for the Inferno Drake
|
||||
* Language and i18n:
|
||||
* Updated translations: Spanish.
|
||||
* WML engine:
|
||||
* Fix silent=yes for objectives
|
||||
* Miscellaneous and bugfixes:
|
||||
* Fix broken "Skip Ai moves" option.
|
||||
* Changed upload log format and defaulted the new uploader.
|
||||
|
|
|
@ -478,6 +478,23 @@ const config &config::find_child(const std::string& key,
|
|||
return const_cast<config *>(this)->find_child(key, name, value);
|
||||
}
|
||||
|
||||
const config& config::find_child_recursive(const std::string& key,
|
||||
const std::string& name,
|
||||
const t_string& value) const
|
||||
{
|
||||
const config& res = this->find_child(key, name, value);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
foreach (const any_child &child, all_children_range()) {
|
||||
const config& res2 = child.cfg.find_child_recursive(key, name, value);
|
||||
|
||||
if (res2)
|
||||
return res2;
|
||||
}
|
||||
|
||||
return invalid;
|
||||
}
|
||||
namespace {
|
||||
/**
|
||||
* Helper struct for iterative config clearing.
|
||||
|
|
|
@ -227,6 +227,8 @@ public:
|
|||
const t_string& value);
|
||||
const config &find_child(const std::string& key, const std::string& name,
|
||||
const t_string& value) const;
|
||||
const config &find_child_recursive(const std::string& key, const std::string& name,
|
||||
const t_string& value) const;
|
||||
|
||||
void clear_children(const std::string& key);
|
||||
void remove_child(const std::string& key, size_t index);
|
||||
|
|
|
@ -680,8 +680,13 @@ void game_state::build_team(const config& side_cfg,
|
|||
|
||||
// If this team has no objectives, set its objectives
|
||||
// to the level-global "objectives"
|
||||
if(teams.back().objectives().empty())
|
||||
teams.back().set_objectives(level["objectives"]);
|
||||
if(teams.back().objectives().empty()){
|
||||
const config& child = level.find_child_recursive("objectives", "side", side_cfg["side"]);
|
||||
bool silent = false;
|
||||
if (child && child.has_attribute("silent"))
|
||||
silent = utils::string_bool(child["silent"]);
|
||||
teams.back().set_objectives(level["objectives"], silent);
|
||||
}
|
||||
|
||||
// If this side tag describes the leader of the side
|
||||
if(!utils::string_bool(side_cfg["no_leader"]) && side_cfg["controller"] != "null") {
|
||||
|
|
Loading…
Add table
Reference in a new issue