Skip to content

Conversation

SilasD
Copy link
Contributor

@SilasD SilasD commented Sep 11, 2025

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 a building_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.

While the overlay is processing all animals to see where they're
assigned, if it encounters an animal assigned to a nonexistent
civzone or to a building that isn't a civzone, it errors out.
This patch makes the overlay more robust in these cases.
Note that the overlay will not display the relevant animal, nor
will it attempt to repair the invalid assignment.
@ab9rf
Copy link
Member

ab9rf commented Sep 11, 2025

This does require a changelog, something akin to "tolerate corrupt animal-to-pasture links" would be fine. Changelogs are used to build our release notes, and as this is a visible change to end users it's worth logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants