Skip to content

Commit

Permalink
Merge pull request #865 from myk002/myk_no_prioritize_dig
Browse files Browse the repository at this point in the history
[prioritize] refuse to automatically prioritize dig jobs
  • Loading branch information
myk002 authored Oct 15, 2023
2 parents 7444de2 + 2c86c21 commit 7450359
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit 7450359

Please sign in to comment.