Skip to content

Commit

Permalink
Merge pull request DFHack#3859 from myk002/myk_readable
Browse files Browse the repository at this point in the history
[zone] label war and hunt trained animals in readable names
  • Loading branch information
myk002 authored Oct 10, 2023
2 parents 0b9103b + a7b5bf6 commit 4db6f8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Template for new versions:
- `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates
- `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked
- `sort`: added help button for squad assignment search/filter/sort
- `zone`: animals trained for war or hunting are now labeled as such in animal assignment screens

## Documentation

Expand Down
3 changes: 2 additions & 1 deletion docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,8 @@ Units module
* ``dfhack.units.getReadableName(unit)``

Returns a string that includes the language name of the unit (if any), the
race of the unit, and any syndrome-given descriptions (such as "necromancer").
race of the unit, whether it is trained for war or hunting, and any
syndrome-given descriptions (such as "necromancer").

* ``dfhack.units.getStressCategory(unit)``

Expand Down
4 changes: 4 additions & 0 deletions library/modules/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,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);
if (isHunter(unit))
race_name = "hunter " + race_name;
if (isWar(unit))
race_name = "war " + race_name;
string name = Translation::TranslateName(getVisibleName(unit));
if (name.empty()) {
name = race_name;
Expand Down

0 comments on commit 4db6f8f

Please sign in to comment.