dfhack
dfhack copied to clipboard
`suspendmanager`: handle deadlocks due to obstruction better
the issue: consider this scenario:
the construction in the corner needs to have the boulder cleared before it can proceed, but the game's obstruction-clearing mechanic cannot clear the boulder because none of the four available locations to clear it to are available: two are ineligible open spaces and two contain (suspended) constructions. as a result, the game will suspend the construction with "item blocking site". suspendmanager will then unsuspend the construction, leading to a cycle that generates cancellation spam
this is a deadlock. while in this scenario suspendmanager could allow one of the two adjacent constructions to proceed safely it just leads back to essentially the same scenario. allowing both to proceed would block off the unconstructed corner wall, and the game won't allow the corner wall to be built
the only way to resolve this deadlock is to remove the obstructing boulder. i don't think suspendmanager should be responsible for this; instead, what suspendmanager should do in this situation is detect the deadlock, suspend all involved constructions, notify the player of the deadlock, and wait for the player to do something about it
please note that i have no idea how to go about actually doing this, or even if it's feasible
one related workaround (which might be useful elsewhere as well) would be to add a player-initiated (not automatic) command which detects items that will cause deadlocks like this and designates them for dumping
if you add deadlock detection warnings maybe even mention the command in them (like, "deadlock detected! you may be able to fix it by running dump-blocking-items
to designate the item causing the deadlock for dumping" as an example)
i know i would certainly use this bc i tend to run into item-blocking-site spam a lot due to the way i build bedrooms
What about the following algorithm, which does not seem to be too hard to implement::
- When checking/updating the suspend status, also check if there is an item blocking the building site.
- Only if this is the case, check that there is a (non-diagonally) neighboring walkable space without a scheduled construction.
- If not, emit a warning.
If we ever implement "levels of Armokness", even the lowest level might just shift the boulder over to any neighboring suspended constructions.
I'm looking into implementing @chdoc suggestion, and dorfs can be surprisingly creative sometimes...
note that moving an item that is associated with a job will cancel that job. you might be able to modify the job to look in the new location, and maybe also have to adjust the pathing of the unit that is en route to pick it up.