zone overlay -- tolerate corrupt animal-to-pasture links #5581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a mitigation for #5580 "DFhack assign function on Pen/Pastures not working". There is further discussion in that issue.
Based on the stacktrace, the issue was apparently caused by an animal with a corrupt link to a pasture zone or to a pit/pond zone.
The animal apparently had a general reference of type
BUILDING_CIVZONE_ASSIGNED
which had abuilding_id
field pointing to a building that either did not exist or was not a civzone.This patch tests for those conditions. When detected, the animal is assigned a status of
NONE
, which causes the animal to be entirely hidden from the assign-to-pasture and assign-to-cage interfaces.The changes made by this patch are minimal; they load and run; they mitigate the two ways I found to trigger the issue; but they are not well-tested.
I would like to have a code review with a focus on whether there are any other ways that line 992 could have triggered an error().
As I understand it: this is purely a bug workaround, so it doesn't need a changelog entry. There's no visible change except for corrupt animal -> pasture links, which now don't abort the overlay.