From 40f73c8c57d013f46dd8a5d7c83579cded861a4a Mon Sep 17 00:00:00 2001 From: Elvish_Hunter Date: Mon, 3 Nov 2014 00:18:53 +0100 Subject: [PATCH] [animate_unit]: backported fix for death and victory animations from master --- changelog | 3 +++ src/unit_display.cpp | 46 +++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/changelog b/changelog index 0f8da679cf33..dec9794f2a70 100644 --- a/changelog +++ b/changelog @@ -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: diff --git a/src/unit_display.cpp b/src/unit_display.cpp index 48747a68998a..7f0c5f584048 100644 --- a/src/unit_display.cpp +++ b/src/unit_display.cpp @@ -803,22 +803,42 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m std::vector attacks = u->attacks(); std::vector::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(filter.get_config()); + primary = &dummy_primary; + } + filter = cfg.child("secondary_attack"); + if(!filter.null()) { + attack_type dummy_secondary = static_cast(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; + } } } }