fix bug #13193: Weapon special filter should use id instead of tag name

This commit is contained in:
Patrick Parker 2009-03-18 03:48:06 +00:00
parent a348e55646
commit c8f798cc60
2 changed files with 23 additions and 5 deletions

View file

@ -12,6 +12,7 @@ Version 1.5.14+svn:
* Increase the map size limit to 1000 by 1000
* Added an 'always_display' key to [advancement] to make it possible to show
the advance dialog even with just one option.
* weapon filters now recognize the id= attribute of specials (bug #13193)
* Miscellaneous and bug fixes:
* Fixed bug #13204: NR: Death event doesn't re-spawn Malifor as expected
* Fixed bug #13198: Corrupt replay in MP

View file

@ -539,15 +539,31 @@ std::pair<int,map_location> unit_ability_list::lowest(const std::string& key, in
*
*/
namespace {
bool get_special_children(std::vector<const config*>& result, const config& parent,
const std::string& id, bool just_peeking=false) {
config::all_children_iterator it, it_end = parent.ordered_end();
for(it = parent.ordered_begin(); it != it_end; ++it) {
if(it.get_key() == id || it.get_child()["id"] == id) {
if(just_peeking) {
return true; // peek succeeded, abort
} else {
result.push_back(it->second);
}
}
}
return false;
}
}
bool attack_type::get_special_bool(const std::string& special,bool force) const
{
// log_scope("get_special_bool");
const config* specials = cfg_.child("specials");
if(specials) {
const config::child_list& list = specials->get_children(special);
if (!list.empty() && force) return true;
for (config::child_list::const_iterator i = list.begin(),
std::vector<const config*> list;
if (get_special_children(list, *specials, special, force)) return true;
for (std::vector<const config*>::iterator i = list.begin(),
i_end = list.end(); i != i_end; ++i) {
if (special_active(**i, true))
return true;
@ -556,8 +572,9 @@ bool attack_type::get_special_bool(const std::string& special,bool force) const
if (force || !other_attack_) return false;
specials = other_attack_->cfg_.child("specials");
if (specials) {
const config::child_list& list = specials->get_children(special);
for (config::child_list::const_iterator i = list.begin(),
std::vector<const config*> list;
get_special_children(list, *specials, special);
for (std::vector<const config*>::iterator i = list.begin(),
i_end = list.end(); i != i_end; ++i) {
if (other_attack_->special_active(**i, false))
return true;