Skip to content

Commit 4b0a10b

Browse files
authored
Merge pull request #5581 from SilasD/invalid-pasture
zone overlay -- tolerate corrupt animal-to-pasture links
2 parents 8df7c42 + f001362 commit 4b0a10b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Template for new versions:
5656
## New Features
5757

5858
## Fixes
59+
- `zone`: animal assignment dialog now tolerates corrupt animal-to-pasture links.
5960

6061
## Misc Improvements
6162

plugins/lua/zone.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,9 @@ local function get_zone_status(unit_or_vermin, bld_assignments)
989989
return PASTURE_STATUS.ASSIGNED_HERE.value
990990
else
991991
local civzone = df.building.find(assigned_zone_ref.building_id)
992-
if civzone.type == df.civzone_type.Pen then
992+
if not civzone or not df.building_civzonest:is_instance(civzone) then
993+
return PASTURE_STATUS.NONE.value
994+
elseif civzone.type == df.civzone_type.Pen then
993995
return PASTURE_STATUS.PASTURED.value
994996
elseif civzone.type == df.civzone_type.Pond then
995997
return PASTURE_STATUS.PITTED.value
@@ -1150,7 +1152,9 @@ local function get_cage_status(unit_or_vermin, bld_assignments)
11501152
local assigned_zone_ref = get_general_ref(unit_or_vermin, df.general_ref_type.BUILDING_CIVZONE_ASSIGNED)
11511153
if assigned_zone_ref then
11521154
local civzone = df.building.find(assigned_zone_ref.building_id)
1153-
if civzone.type == df.civzone_type.Pen then
1155+
if not civzone or not df.building_civzonest:is_instance(civzone) then
1156+
return CAGE_STATUS.NONE.value
1157+
elseif civzone.type == df.civzone_type.Pen then
11541158
return CAGE_STATUS.PASTURED.value
11551159
elseif civzone.type == df.civzone_type.Pond then
11561160
return CAGE_STATUS.PITTED.value

0 commit comments

Comments
 (0)