use generic baby/child names when race doesn't have something specific

develop
Myk Taylor 2023-10-14 04:22:43 -07:00
parent cac17bd8fa
commit 87af3281fb
No known key found for this signature in database
2 changed files with 17 additions and 5 deletions

@ -64,6 +64,7 @@ Template for new versions:
- `sort`: new search widgets for artifacts on the world/raid screen - `sort`: new search widgets for artifacts on the world/raid screen
## Fixes ## Fixes
- `zone`: races without specific child or baby names will now get generic child/baby names instead of an empty string
- `zone`: don't show animal assignment link for cages and restraints linked to dungeon zones (which aren't normally assignable) - `zone`: don't show animal assignment link for cages and restraints linked to dungeon zones (which aren't normally assignable)
## Misc Improvements ## Misc Improvements

@ -1225,8 +1225,12 @@ string Units::getRaceBabyNameById(int32_t id)
if (id >= 0 && (size_t)id < world->raws.creatures.all.size()) if (id >= 0 && (size_t)id < world->raws.creatures.all.size())
{ {
df::creature_raw* raw = world->raws.creatures.all[id]; df::creature_raw* raw = world->raws.creatures.all[id];
if (raw) if (raw) {
return raw->general_baby_name[0]; string & baby_name = raw->general_baby_name[0];
if (!baby_name.empty())
return baby_name;
return getRaceReadableNameById(id) + " baby";
}
} }
return ""; return "";
} }
@ -1242,8 +1246,12 @@ string Units::getRaceChildNameById(int32_t id)
if (id >= 0 && (size_t)id < world->raws.creatures.all.size()) if (id >= 0 && (size_t)id < world->raws.creatures.all.size())
{ {
df::creature_raw* raw = world->raws.creatures.all[id]; df::creature_raw* raw = world->raws.creatures.all[id];
if (raw) if (raw) {
return raw->general_child_name[0]; string & child_name = raw->general_child_name[0];
if (!child_name.empty())
return child_name;
return getRaceReadableNameById(id) + " child";
}
} }
return ""; return "";
} }
@ -1266,7 +1274,10 @@ static string get_caste_name(df::unit* unit) {
} }
string Units::getReadableName(df::unit* unit) { string Units::getReadableName(df::unit* unit) {
string race_name = isChild(unit) ? getRaceChildName(unit) : get_caste_name(unit); string race_name = isBaby(unit) ? getRaceBabyName(unit) :
(isChild(unit) ? getRaceChildName(unit) : get_caste_name(unit));
if (race_name.empty())
race_name = getRaceReadableName(unit);
if (isHunter(unit)) if (isHunter(unit))
race_name = "hunter " + race_name; race_name = "hunter " + race_name;
if (isWar(unit)) if (isWar(unit))