diff --git a/changelog.txt b/changelog.txt index 80cb86fad8..4a64f7ee03 100644 --- a/changelog.txt +++ b/changelog.txt @@ -53,6 +53,7 @@ Template for new versions: - `control-panel`: restore non-default values of per-save enabled/disabled settings for repeat-based commands - `confirm`: fix confirmation prompt for overwriting a hotkey zoom location - `quickfort`: allow farm plots to be built on muddy stone +- `suspend`: remove broken ``--onlyblocking`` option; restore functionality to suspend all construction jobs ## Misc Improvements - `gui/launcher`: "space space to toggle pause" behavior is skipped if the game was paused when `gui/launcher` came up to prevent accidental unpausing diff --git a/docs/suspend.rst b/docs/suspend.rst index 6c50ab0f37..568e60b161 100644 --- a/docs/suspend.rst +++ b/docs/suspend.rst @@ -3,16 +3,11 @@ suspend .. dfhack-tool:: :summary: Suspends building construction jobs. - :tags: fort productivity jobs + :tags: fort jobs -This tool will suspend jobs. It can either suspend all the current jobs, or only -construction jobs that are likely to block other jobs. When building walls, it's -common that wall corners get stuck because dwarves build the two adjacent walls -before the corner. The ``--onlyblocking`` option will only suspend jobs that can -potentially lead to this situation. - -See `suspendmanager` in `gui/control-panel` to automatically suspend and -unsuspend jobs. +This tool will suspend jobs all construction jobs. This is mainly useful as an +emergency measure. Consider using `suspendmanager` from `gui/control-panel` to +automatically suspend and unsuspend jobs. Usage ----- @@ -20,16 +15,3 @@ Usage :: suspend - -Options -------- - -``-b``, ``--onlyblocking`` - Only suspend jobs that are likely to block other jobs. - -.. note:: - - ``--onlyblocking`` does not check pathing (which would be very expensive); it only - looks at immediate neighbours. As such, it is possible that this tool will miss - suspending some jobs that prevent access to other farther away jobs, for example - when building a large rectangle of solid walls. diff --git a/suspend.lua b/suspend.lua index bbbe4e4293..8d250e0675 100644 --- a/suspend.lua +++ b/suspend.lua @@ -1,29 +1,29 @@ --- Suspend jobs - --- It can either suspend all jobs, or just jobs that risk blocking others. +-- Suspend all construction jobs +local utils = require('utils') local argparse = require('argparse') -local suspendmanager = reqscript('suspendmanager') -local help, onlyblocking = false, false +local help = false argparse.processArgsGetopt({...}, { {'h', 'help', handler=function() help = true end}, - {'b', 'onlyblocking', handler=function() onlyblocking = true end}, }) +---cancel job and remove worker +---@param job df.job +local function suspend(job) + job.flags.suspend = true + job.flags.working = false + dfhack.job.removeWorker(job, 0); +end + + if help then print(dfhack.script_help()) return end --- Only initialize suspendmanager if we want to suspend blocking jobs -manager = onlyblocking and suspendmanager.SuspendManager{preventBlocking=true} or nil -if manager then - manager:refresh() -end - -suspendmanager.foreach_construction_job(function (job) - if not manager or manager:shouldBeSuspended(job) then - suspendmanager.suspend(job) +for _,job in utils.listpairs(df.global.world.jobs.list) do + if job.job_type == df.job_type.ConstructBuilding then + suspend(job) end -end) +end