Skip to content

Commit

Permalink
[animate_unit]: backported fix for death and victory animations from …
Browse files Browse the repository at this point in the history
…master
  • Loading branch information
Elvish-Hunter committed Nov 7, 2014
1 parent 0559131 commit 40f73c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
3 changes: 3 additions & 0 deletions changelog
Expand Up @@ -16,6 +16,9 @@ Version 1.11.18+dev:
* Upgraded Lua to version 5.2.3.
* Miscellaneous and bug fixes:
* Micro AIs: only display on-screen error messages when in debug mode
* WML engine:
* Fixed a bug that prevented [animate_unit] from displaying death or victory
animations for those units that filter them based on weapon (eg. Wose)

Version 1.11.18:
* Add-ons server:
Expand Down
46 changes: 33 additions & 13 deletions src/unit_display.cpp
Expand Up @@ -803,22 +803,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;
}
}
}
}
Expand Down

0 comments on commit 40f73c8

Please sign in to comment.