Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Template for new versions:

## API
- ``Units::isUnitInBox``, ``Units::getUnitsInBox``: add versions accepting pos arguments
- ``Units::getVisibleName``: when acting on a unit without an impersonated identity, returns the unit's name structure instead of the associated histfig's name structure

## Lua
- ``dfhack.units.isUnitInBox``, ``dfhack.units.getUnitsInBox``: add versions accepting pos arguments
Expand Down
8 changes: 6 additions & 2 deletions library/modules/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,12 @@ df::language_name *Units::getVisibleName(df::historical_figure *hf) {

df::language_name *Units::getVisibleName(df::unit *unit) {
CHECK_NULL_POINTER(unit);
auto hf = df::historical_figure::find(unit->hist_figure_id);
return hf ? getVisibleName(hf) : &unit->name;
if (auto identity = getIdentity(unit))
{
auto imp_hf = df::historical_figure::find(identity->impersonated_hf);
return (imp_hf && imp_hf->name.has_name) ? &imp_hf->name : &identity->name;
}
return &unit->name;
}

bool Units::assignTrainer(df::unit *unit, int32_t trainer_id) {
Expand Down
Loading