-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed broken suspend script / remove --onlyblocking option (fixes #4717)
- Loading branch information
Showing
3 changed files
with
21 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |