Skip to content

Commit 7fb40a7

Browse files
authored
Merge pull request #5567 from chdoc/job-helpers
two minor fixes for #5535
2 parents d49b28b + a2a768c commit 7fb40a7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

docs/dev/Lua API.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,11 +1908,12 @@ Units module
19081908

19091909
Unit has an uninterruptible social activity (e.g. a purple "Socialize!").
19101910

1911-
* ``dfhack.units.isJobAvailable(unit [, interrupt_social])``
1911+
* ``dfhack.units.isJobAvailable(unit [, preserve_social])``
19121912

19131913
Check whether a unit can be assigned to (i.e. is looking for) a job. Will
19141914
return ``true`` if the unit is engaged in "green" social activities, unless
1915-
the boolean ``interrupt_social`` is true.
1915+
the boolean ``preserve_social`` is true. Will never interrupt uninterruptible
1916+
social activities (e.g. a purple "Socialize!").
19161917

19171918
* ``dfhack.units.getFocusPenalty(unit, need_type [, need_type, ...])``
19181919

library/include/modules/Units.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ DFHACK_EXPORT int32_t getFocusPenalty(df::unit* unit, df::need_type need_type);
350350
// unit has an unbailable social activity (e.g. "Socialize!")
351351
DFHACK_EXPORT bool hasUnbailableSocialActivity(df::unit *unit);
352352
// unit can be assigned a job
353-
DFHACK_EXPORT bool isJobAvailable(df::unit *unit, bool interrupt_social);
353+
DFHACK_EXPORT bool isJobAvailable(df::unit *unit, bool preserve_social);
354354

355355
// Stress categories. 0 is highest stress, 6 is lowest.
356356
DFHACK_EXPORT extern const std::vector<int32_t> stress_cutoffs;

library/modules/Units.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,8 @@ bool Units::isJobAvailable(df::unit *unit, bool preserve_social = false){
20902090
return false;
20912091
if (unit->flags1.bits.caged || unit->flags1.bits.chained)
20922092
return false;
2093+
if (Units::getSpecificRef(unit, df::specific_ref_type::ACTIVITY))
2094+
return false;
20932095
if (unit->individual_drills.size() > 0) {
20942096
if (unit->individual_drills.size() > 1)
20952097
return false; // this is even possible

0 commit comments

Comments
 (0)