Fix sidebar's display of attacks with damage_type specials

When a [damage_type] affected an attack, the old code assumed that it would have an alternative_type.
If that assumption failed, it would add ("type_" + an empty string), causing "UNTLB type_" to be shown
in the sidebar.

UNTLB is itself a shorthand for "untranslatable", see language.cpp for an explanation.
This commit is contained in:
newfrenchy83 2024-06-01 18:23:14 +02:00 committed by Steve Cotton
parent f4e8635723
commit 84c62456a3

View file

@ -1261,14 +1261,16 @@ std::pair<std::string, std::string> attack_type::damage_type() const
std::set<std::string> attack_type::alternative_damage_types() const
{
unit_ability_list damage_alternative_type_list = get_specials_and_abilities("damage_type");
if(damage_alternative_type_list.empty()){
unit_ability_list damage_type_list = get_specials_and_abilities("damage_type");
if(damage_type_list.empty()){
return {};
}
std::set<std::string> damage_types;
for(auto& i : damage_alternative_type_list) {
for(auto& i : damage_type_list) {
const config& c = *i.ability_cfg;
damage_types.insert(c["alternative_type"].str());
if(c.has_attribute("alternative_type")){
damage_types.insert(c["alternative_type"].str());
}
}
return damage_types;