Merge pull request #3878 from myk002/myk_babybaby

[zone] use generic baby/child names when race doesn't have something specific
develop
Myk 2023-10-14 04:31:46 -07:00 committed by GitHub
commit 158c385f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
## 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)
- `dwarfvet`: fix invalid job id assigned to ``Rest`` job, which could cause crashes on reload

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