Skip to content

Commit 5a4cdcf

Browse files
authored
Sync
1 parent 8f8c95e commit 5a4cdcf

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/changelog.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Template for new versions:
5959
- `plant`: can now ``remove`` shrubs and saplings; ``list`` all valid shrub/sapling raw IDs; ``grow`` can make mature trees older; many new command options
6060

6161
## Fixes
62-
- `suspendmanager`: stop suspending single tile stair constructions
6362
- ``Gui::makeAnnouncement``, ``Gui::autoDFAnnouncement``: fix skipping index 0 when iterating reports vector
6463
- `regrass`: don't remove mud on regrass, consistent with vanilla behavior
6564
- `seedwatch`: display a limit of ``-`` instead of ``0`` for a seed that is present in inventory but not being watched
@@ -96,7 +95,8 @@ Template for new versions:
9695
- ``Maps::setAreaAquifer``: make all tiles in a cuboid into aquifers, with the option to provide a filter
9796
- ``Maps::removeTileAquifer``: remove aquifer from tile
9897
- ``Maps::removeAreaAquifer``: remove aquifers from all tiles in a cuboid, with the option to provide a filter
99-
- ``Units::makeown``: API to use bay12-provided entry point for "makeown" operation
98+
- ``Units::create``, ``Units::makeown``: new APIs to use bay12-provided entry points for low-level operations
99+
- ``format_number``: format numbers according to the current system locale
100100

101101
## Lua
102102
- ``dfhack.gui.getSelectedJob``: can now return the job with a destination under the keyboard cursor (e.g. digging/carving/engraving jobs)
@@ -113,12 +113,19 @@ Template for new versions:
113113
- ``dfhack.maps.removeTileAquifer``: remove aquifer from tile
114114
- ``plugins.tiletypes.tiletypes_setTile``: can now accept a table for access to previously unavailable options
115115
- ``dialogs.showYesNoPrompt``: extend options so the standard dialog can be used for `gui/confirm`-style confirmation prompts
116+
- ``dfhack.units.create``, ``dfhack.units.makeown``: Lua access to new module API
117+
- ``dfhack.formatInt``, ``dfhack.formatFloat``: formats numbers according to the current system locale
116118

117119
## Removed
118120
- `plants`: renamed to `plant`
119121
- ``gui.FramedScreen``: this class is now deprecated; please use ``gui.ZScreen`` and ``widgets.Window`` instead
120122
- ``dfhack.HIDE_CONSOLE_ON_STARTUP`` and ``dfhack.HIDE_ARMOK_TOOLS`` are no longer directly accessible. Please use `control-panel` or `gui/control-panel` to interact wtih those settings.
121123

124+
# 50.13-r2.1
125+
126+
## Fixes
127+
- `suspendmanager`: stop suspending single tile stair constructions
128+
122129
# 50.13-r2
123130

124131
## New Tools

docs/dev/Lua API.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,18 @@ can be omitted.
994994
This function does not downcase characters. Use ``dfhack.lowerCp437``
995995
first, if desired.
996996

997+
* ``dfhack.formatInt(num)``
998+
999+
Formats an integer value as a string according to the current system locale.
1000+
E.g. for American English, it would transform like: ``12345`` ->
1001+
``'12,345'``
1002+
1003+
* ``dfhack.formatFloat(num)``
1004+
1005+
Formats a floating point value as a string according to the current system
1006+
locale. E.g. for American English, it would transform like: ``-12345.6789``
1007+
-> ``'-12,345.678711'`` (because float imprecision).
1008+
9971009
* ``dfhack.run_command(command[, ...])``
9981010

9991011
Run an arbitrary DFHack command, with the core suspended, and send output to
@@ -1629,11 +1641,20 @@ Units module
16291641

16301642
Returns the nemesis record of the unit if it has one, or *nil*.
16311643

1632-
``dfhack.units.makeown(unit)``
1644+
* ``dfhack.units.makeown(unit)``
16331645

16341646
Makes the selected unit a member of the current fortress and site.
16351647
Note that this operation may silently fail for any of several reasons, so it may be prudent to check if the operation has succeeded by using ``dfhack.units.isOwnCiv`` or another appropriate predicate on the unit in question.
16361648

1649+
* ``dfhack.units.create(race, caste)``
1650+
1651+
Creates a new unit from scratch. The unit will be added to the
1652+
``world.units.all`` vector, but not to the ``world.units.active`` vector. The
1653+
unit will not have an associated historical figure, nemesis record, map
1654+
position, labors, or any group associations. The unit *will* have a race,
1655+
caste, name, soul, and initialized body and mind (including personality). The
1656+
unit must be configured further as needed and put into play by the client.
1657+
16371658
* ``dfhack.units.getPhysicalAttrValue(unit, attr_type)``
16381659
* ``dfhack.units.getMentalAttrValue(unit, attr_type)``
16391660

library/modules/Units.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,14 @@ void Units::makeown(df::unit* unit)
11431143
(*f)(unit);
11441144
}
11451145

1146+
df::unit * Units::create(int16_t race, int16_t caste) {
1147+
auto fp = df::global::unitst_more_convenient_create;
1148+
CHECK_NULL_POINTER(fp);
1149+
1150+
using FT = std::function<df::unit * (int16_t, int16_t)>;
1151+
auto f = reinterpret_cast<FT*>(fp);
1152+
return (*f)(race, caste);
1153+
}
11461154

11471155
int Units::getPhysicalAttrValue(df::unit *unit, df::physical_attribute_type attr)
11481156
{

0 commit comments

Comments
 (0)