Skip to content

Commit 3674ba1

Browse files
authored
Merge pull request #5799 from chdoc/fix-getFocusPenalty
Handle units without current soul in `Units::getFocusPenalty`
2 parents 57fb192 + b9c1c91 commit 3674ba1

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Template for new versions:
6666

6767
## API
6868
- add flexible casting to ``enum_field`` to enable explicit casting to more types
69+
- Handle units without current soul in ``Units::getFocusPenalty``
6970

7071
## Lua
7172

library/modules/Units.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,9 @@ int32_t Units::getFocusPenalty(df::unit* unit, need_type_set need_types) {
20272027
CHECK_NULL_POINTER(unit);
20282028

20292029
int max_penalty = INT_MAX;
2030+
if (!unit->status.current_soul) {
2031+
return max_penalty;
2032+
}
20302033
auto& needs = unit->status.current_soul->personality.needs;
20312034
for (auto const need : needs) {
20322035
if (need_types.test(need->id)) {

0 commit comments

Comments
 (0)