Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prioritize] refuse to automatically prioritize dig jobs #865

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Template for new versions:
- `hide-tutorials`: fix the embark tutorial prompt sometimes not being skipped

## Misc Improvements
- `prioritize`: refuse to automatically prioritize dig and smooth/carve job types since it can break the DF job scheduler; instead, print a suggestion that the player use specialized units and vanilla designation priorities

## Removed

Expand Down
26 changes: 26 additions & 0 deletions prioritize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local argparse = require('argparse')
local json = require('json')
local eventful = require('plugins.eventful')
local persist = require('persist-table')
local utils = require('utils')

local GLOBAL_KEY = 'prioritize' -- used for state change hooks and persistence

Expand Down Expand Up @@ -269,6 +270,27 @@ local function boost_and_watch_special(job_type, job_matcher,
end
end

local JOB_TYPES_DENYLIST = utils.invert{
df.job_type.CarveFortification,
df.job_type.SmoothWall,
df.job_type.SmoothFloor,
df.job_type.DetailWall,
df.job_type.DetailFloor,
df.job_type.Dig,
df.job_type.CarveUpwardStaircase,
df.job_type.CarveDownwardStaircase,
df.job_type.CarveUpDownStaircase,
df.job_type.CarveRamp,
df.job_type.DigChannel,
}

local DIG_SMOOTH_WARNING = {
'Priortizing current pending jobs, but skipping automatic boosting of dig and',
'smooth/engrave job types. Automatic priority boosting of these types of jobs',
'will overwhelm the DF job scheduler. Instead, consider specializing units for',
'mining and related work details, and using vanilla designation priorities.',
}

local function boost_and_watch(job_matchers, opts)
local quiet = opts.quiet
boost(job_matchers, opts)
Expand All @@ -284,6 +306,10 @@ local function boost_and_watch(job_matchers, opts)
function(jm) return jm.reaction_matchers end,
function(jm) jm.reaction_matchers = nil end,
get_annotation_str, quiet)
elseif JOB_TYPES_DENYLIST[job_type] then
for _,msg in ipairs(DIG_SMOOTH_WARNING) do
dfhack.printerr(msg)
end
elseif watched_job_matchers[job_type] then
if not quiet then
print_skip_add_message(job_type)
Expand Down