Skip to content

Commit 924a7ba

Browse files
committed
fixed broken suspend script / remove --onlyblocking option (fixes #4717)
1 parent 32bf2af commit 924a7ba

File tree

3 files changed

+21
-38
lines changed

3 files changed

+21
-38
lines changed

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Template for new versions:
5353
- `control-panel`: restore non-default values of per-save enabled/disabled settings for repeat-based commands
5454
- `confirm`: fix confirmation prompt for overwriting a hotkey zoom location
5555
- `quickfort`: allow farm plots to be built on muddy stone
56+
- `suspend`: remove broken ``--onlyblocking`` option; restore functionality to suspend all construction jobs
5657

5758
## Misc Improvements
5859
- `gui/launcher`: "space space to toggle pause" behavior is skipped if the game was paused when `gui/launcher` came up to prevent accidental unpausing

docs/suspend.rst

+4-22
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,15 @@ suspend
33

44
.. dfhack-tool::
55
:summary: Suspends building construction jobs.
6-
:tags: fort productivity jobs
6+
:tags: fort jobs
77

8-
This tool will suspend jobs. It can either suspend all the current jobs, or only
9-
construction jobs that are likely to block other jobs. When building walls, it's
10-
common that wall corners get stuck because dwarves build the two adjacent walls
11-
before the corner. The ``--onlyblocking`` option will only suspend jobs that can
12-
potentially lead to this situation.
13-
14-
See `suspendmanager` in `gui/control-panel` to automatically suspend and
15-
unsuspend jobs.
8+
This tool will suspend jobs all construction jobs. This is mainly useful as an
9+
emergency measure. Consider using `suspendmanager` from `gui/control-panel` to
10+
automatically suspend and unsuspend jobs.
1611

1712
Usage
1813
-----
1914

2015
::
2116

2217
suspend
23-
24-
Options
25-
-------
26-
27-
``-b``, ``--onlyblocking``
28-
Only suspend jobs that are likely to block other jobs.
29-
30-
.. note::
31-
32-
``--onlyblocking`` does not check pathing (which would be very expensive); it only
33-
looks at immediate neighbours. As such, it is possible that this tool will miss
34-
suspending some jobs that prevent access to other farther away jobs, for example
35-
when building a large rectangle of solid walls.

suspend.lua

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
-- Suspend jobs
2-
3-
-- It can either suspend all jobs, or just jobs that risk blocking others.
1+
-- Suspend all construction jobs
42

3+
local utils = require('utils')
54
local argparse = require('argparse')
6-
local suspendmanager = reqscript('suspendmanager')
75

8-
local help, onlyblocking = false, false
6+
local help = false
97
argparse.processArgsGetopt({...}, {
108
{'h', 'help', handler=function() help = true end},
11-
{'b', 'onlyblocking', handler=function() onlyblocking = true end},
129
})
1310

11+
---cancel job and remove worker
12+
---@param job df.job
13+
local function suspend(job)
14+
job.flags.suspend = true
15+
job.flags.working = false
16+
dfhack.job.removeWorker(job, 0);
17+
end
18+
19+
1420
if help then
1521
print(dfhack.script_help())
1622
return
1723
end
1824

19-
-- Only initialize suspendmanager if we want to suspend blocking jobs
20-
manager = onlyblocking and suspendmanager.SuspendManager{preventBlocking=true} or nil
21-
if manager then
22-
manager:refresh()
23-
end
24-
25-
suspendmanager.foreach_construction_job(function (job)
26-
if not manager or manager:shouldBeSuspended(job) then
27-
suspendmanager.suspend(job)
25+
for _,job in utils.listpairs(df.global.world.jobs.list) do
26+
if job.job_type == df.job_type.ConstructBuilding then
27+
suspend(job)
2828
end
29-
end)
29+
end

0 commit comments

Comments
 (0)