[animate_unit]: fixed a bug that prevented displaying the Wose's death animation

This commit is contained in:
Elvish_Hunter 2014-10-16 20:10:10 +02:00
parent da93b36571
commit 5a0109fb9a
2 changed files with 35 additions and 13 deletions

View file

@ -157,6 +157,8 @@ Version 1.13.0-dev:
traits instead of hardcoding the id of those traits in c++.
* added support for a shuffle key in the [music] music to allow selecting
between random and non-random music play (bug #19653)
* Fixed a bug that prevented [animate_unit] from displaying death or victory
animations for those units that filter them based on weapon (eg. Wose)
* Miscellaneous and bug fixes:
* replace 'fight_on_without_leader'=yes/no with defeat_condition=no_leader/
no_units/always/never which allows the wml developer to decide when a side

View file

@ -792,22 +792,42 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m
std::vector<attack_type> attacks = u->attacks();
std::vector<attack_type>::iterator itor;
filter = cfg.child("primary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_parsed_config())) {
primary = &*itor;
break;
}
// death and victory animations are handled here because usually
// the code iterates through all the unit's attacks
// but in these two specific cases we need to create dummy attacks
// to fire correctly certain animations
// this is especially evident with the Wose's death animations
if (cfg["flag"] == "death" || cfg["flag"] == "victory") {
filter = cfg.child("primary_attack");
if(!filter.null()) {
attack_type dummy_primary = static_cast<attack_type>(filter.get_config());
primary = &dummy_primary;
}
filter = cfg.child("secondary_attack");
if(!filter.null()) {
attack_type dummy_secondary = static_cast<attack_type>(filter.get_config());
secondary = &dummy_secondary;
}
}
filter = cfg.child("secondary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_parsed_config())) {
secondary = &*itor;
break;
else {
filter = cfg.child("primary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_parsed_config())) {
primary = &*itor;
break;
}
}
}
filter = cfg.child("secondary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_parsed_config())) {
secondary = &*itor;
break;
}
}
}
}