gui2/unit_attack: Only display active specials on the weapons list

This fixes issues reported on the forums where the weapons list now
includes weapon specials even when they aren't active, a regression from
1.12.x.

Closes #3033.
This commit is contained in:
Iris Morelle 2018-05-06 00:33:52 -03:00
parent ebf3866132
commit d727cf2c99
2 changed files with 28 additions and 6 deletions

View file

@ -73,6 +73,8 @@
* Custom MP game names are now capped at 50 characters.
* Restored Era info to main MP game display.
* Improved the resolution selection criteria for the MP Lobby.
* Fixed inactive weapon specials being displayed in the Unit Attack dialog
unlike in 1.12 (issue #3033).
### WML engine
* Support formula= key in [variable] ConditionalWML
* Support to_location in [move_unit], taking a location ID

View file

@ -120,7 +120,7 @@ void unit_attack::pre_show(window& window)
const attack_type& defender_weapon = defender.weapon ?
*defender.weapon : *no_weapon;
// Don't show if the atacker's weapon has at least one active "disable" special.
// Don't show if the attacker's weapon has at least one active "disable" special.
if(attacker.disable) {
continue;
}
@ -136,17 +136,37 @@ void unit_attack::pre_show(window& window)
range = string_table["range_" + range];
}
const std::string& attw_apecials =
!attacker_weapon.weapon_specials().empty() ? " " + attacker_weapon.weapon_specials() : "";
const std::string& defw_specials =
!defender_weapon.weapon_specials().empty() ? " " + defender_weapon.weapon_specials() : "";
auto a_ctx = attacker_weapon.specials_context(
attacker_itor_.get_shared_ptr(),
defender_itor_.get_shared_ptr(),
attacker_itor_->get_location(),
defender_itor_->get_location(), true, defender.weapon
);
auto d_ctx = defender_weapon.specials_context(
defender_itor_.get_shared_ptr(),
attacker_itor_.get_shared_ptr(),
defender_itor_->get_location(),
attacker_itor_->get_location(), false, attacker.weapon
);
std::string attw_specials = attacker_weapon.weapon_specials(true, attacker.backstab_pos);
std::string defw_specials = defender_weapon.weapon_specials(true);
if(!attw_specials.empty()) {
attw_specials = " " + attw_specials;
}
if(!defw_specials.empty()) {
defw_specials = " " + defw_specials;
}
std::stringstream attacker_stats, defender_stats;
// Use attacker/defender.num_blows instead of attacker/defender_weapon.num_attacks() because the latter does not consider the swarm weapon special
attacker_stats << "<b>" << attw_name << "</b>" << "\n"
<< attacker.damage << font::weapon_numbers_sep << attacker.num_blows
<< attw_apecials << "\n"
<< attw_specials << "\n"
<< font::span_color(a_cth_color) << attacker.chance_to_hit << "%</span>";
defender_stats << "<b>" << defw_name << "</b>" << "\n"