mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 16:22:08 +00:00
Use unit_type::race() instead of getting the race id...
...then searching for a matching unit_race.
This commit is contained in:
parent
76285dd388
commit
83958a10fb
@ -971,10 +971,8 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
|
||||
det.level = t->level();
|
||||
det.alignment = unit_type::alignment_description(t->alignment(), t->genders().front());
|
||||
|
||||
if (const unit_race *r = unit_types.find_race(t->race_id())) {
|
||||
assert(!t->genders().empty());
|
||||
det.race = r->name(t->genders().front());
|
||||
}
|
||||
det.race = t->race()->name(t->genders().front());
|
||||
|
||||
//FIXME: This probably must be move into a unit_type function
|
||||
BOOST_FOREACH(const config &tr, t->possible_traits())
|
||||
|
@ -117,18 +117,12 @@ void tunit_create::pre_show(CVideo& /*video*/, twindow& window)
|
||||
// And so we map an unit_type id to a list subscript. Ugh.
|
||||
type_ids_.push_back(i.first);
|
||||
|
||||
std::string race_label;
|
||||
|
||||
if (const unit_race *r = unit_types.find_race(i.second.race_id())) {
|
||||
race_label = r->plural_name();
|
||||
}
|
||||
|
||||
std::map< std::string, string_map > row_data;
|
||||
string_map column;
|
||||
|
||||
column["label"] = i.second.type_name();
|
||||
row_data.insert(std::make_pair("unit_type", column));
|
||||
column["label"] = race_label;
|
||||
column["label"] = i.second.race()->plural_name();
|
||||
row_data.insert(std::make_pair("race", column));
|
||||
|
||||
list.add_row(row_data);
|
||||
|
@ -1442,10 +1442,8 @@ public:
|
||||
// Print the race of the unit, cross-reference it to the
|
||||
// respective topic.
|
||||
const std::string race_id = type_.race_id();
|
||||
std::string race_name;
|
||||
if (const unit_race *r = unit_types.find_race(race_id)) {
|
||||
race_name = r->plural_name();
|
||||
} else {
|
||||
std::string race_name = type_.race()->plural_name();
|
||||
if ( race_name.empty() ) {
|
||||
race_name = _ ("race^Miscellaneous");
|
||||
}
|
||||
ss << _("Race: ");
|
||||
|
@ -1303,11 +1303,7 @@ void menu_handler::create_unit(mouse_handler& mousehandler)
|
||||
|
||||
unit_types.find(i.first, unit_type::HELP_INDEX);
|
||||
|
||||
std::string race;
|
||||
if (const unit_race *r = unit_types.find_race(i.second.race_id())) {
|
||||
race = r->plural_name();
|
||||
}
|
||||
row << race << COLUMN_SEPARATOR;
|
||||
row << i.second.race()->plural_name() << COLUMN_SEPARATOR;
|
||||
row << i.second.type_name() << COLUMN_SEPARATOR;
|
||||
|
||||
options.push_back(row.str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user