File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ Template for new versions:
7878## API
7979
8080- ``DFHack::Units``: new function ``setPathGoal``
81+ - ``Units::setAutomaticProfessions``: bay12-provided entry point to assign labors based on work details
8182
8283## Lua
8384
Original file line number Diff line number Diff line change @@ -239,6 +239,10 @@ DFHACK_EXPORT bool unassignTrainer(df::unit *unit);
239239// / to determine if the makeown operation was successful.
240240DFHACK_EXPORT void makeown (df::unit *unit);
241241
242+ // / set appropriate labors on a unit based on current work detail settings
243+ // / (uses Bay12-provided algorithm)
244+ DFHACK_EXPORT void setAutomaticProfessions (df::unit* unit);
245+
242246// Set the units target location and goal, clearing any existing goal or path
243247DFHACK_EXPORT void setPathGoal (df::unit *unit, df::coord pos, df::unit_path_goal goal);
244248
Original file line number Diff line number Diff line change @@ -934,6 +934,17 @@ void Units::makeown(df::unit *unit) {
934934 (*f)(unit);
935935}
936936
937+ void Units::setAutomaticProfessions (df::unit* unit) {
938+ CHECK_NULL_POINTER (unit);
939+ auto fp = df::global::unitst_set_automatic_professions;
940+ CHECK_NULL_POINTER (fp);
941+
942+ using FT = std::function<void (df::unit*)>;
943+ auto f = reinterpret_cast <FT*>(fp);
944+ (*f)(unit);
945+ }
946+
947+
937948// functionality reverse-engineered from DF's unitst::set_goal
938949void Units::setPathGoal (df::unit *unit, df::coord pos, df::unit_path_goal goal)
939950{
You can’t perform that action at this time.
0 commit comments