Skip to content

Commit 0d8e540

Browse files
committed
don't include already prioritized jobs in output of -j
and print number of already-prioritized jobs when prioritizing all jobs of a specified type
1 parent cc421f0 commit 0d8e540

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Template for new versions:
4545
- `gui/confirm`: in the delete manager order confirmation dialog, show a description of which order you have selected to delete
4646
- `position`: display both adventurer and site pos simultaneously. Display map block pos+offset of selected tile.
4747
- `gui/sitemap`: shift click to start following the selected unit or artifact
48+
- `prioritize`: when prioritizing jobs of a specified type, also output how many of those jobs were already prioritized before you ran the command
49+
- `prioritize`: don't include already-prioritized jobs in the output of ``prioritize -j``
4850

4951
## Removed
5052

docs/prioritize.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prioritize
77

88
This tool encourages specified types of jobs to get assigned and completed as
99
soon as possible. Finally, you can be sure your food will be hauled before
10-
rotting, your hides will be tanned before going bad, and the corpses of your
10+
it rots, your hides will be tanned before they go bad, and the corpses of your
1111
enemies will be cleared expediently from your entranceway.
1212

1313
You can prioritize a bunch of active jobs that you need done *right now*, or you
@@ -40,7 +40,8 @@ Examples
4040
Watch for and prioritize the default set of job types that the community has
4141
suggested and playtested (see below for details).
4242
``prioritize -j``
43-
Print out the list of active jobs that you can prioritize right now.
43+
Print out the list of not-yet prioritized jobs that you can prioritize
44+
right now.
4445
``prioritize ConstructBuilding DestroyBuilding``
4546
Prioritize all current building construction and destruction jobs.
4647
``prioritize -a --haul-labor=Food,Body StoreItemInStockpile``
@@ -56,8 +57,7 @@ Options
5657
``-d``, ``--delete``
5758
Stop automatically prioritizing new jobs of the specified job types.
5859
``-j``, ``--jobs``
59-
Print out how many current jobs of each type there are. This is useful for
60-
discovering the types of the jobs that you can prioritize right now. If any
60+
Print out how many current unprioritized jobs of each type there are. If any
6161
job types are specified, only jobs of those types are listed.
6262
``-l``, ``--haul-labor <labor>[,<labor>...]``
6363
For StoreItemInStockpile jobs, match only the specified hauling labor(s).
@@ -97,7 +97,7 @@ staring at the screen in annoyance for too long.
9797
You may be tempted to automatically prioritize ``ConstructBuilding`` jobs, but
9898
beware that if you engage in megaprojects where many constructions must be
9999
built, these jobs can consume your entire fortress if prioritized. It is often
100-
better to run ``prioritize ConstructBuilding`` by itself (i.e. without the
100+
better to run ``prioritize ConstructBuilding`` by itself (that is, without the
101101
``-a`` parameter) as needed to just prioritize the construction jobs that you
102102
have ready at the time if you need to "clear the queue".
103103

prioritize.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,23 @@ local function for_all_jobs(cb)
192192
end
193193

194194
local function boost(job_matchers, opts)
195-
local count = 0
195+
local count, already_prioritized = 0, 0
196196
for_all_jobs(
197197
function(job)
198-
if not job.flags.do_now and boost_job_if_matches(job, job_matchers) then
199-
count = count + 1
198+
local was_prioritized = job.flags.do_now
199+
if boost_job_if_matches(job, job_matchers) then
200+
if was_prioritized then
201+
already_prioritized = already_prioritized + 1
202+
else
203+
count = count + 1
204+
end
200205
end
201206
end)
202207
if not opts.quiet then
203208
print(('Prioritized %d job%s.'):format(count, count == 1 and '' or 's'))
209+
if already_prioritized > 0 then
210+
print(('%d job%s already prioritized.'):format(already_prioritized, already_prioritized == 1 and '' or 's'))
211+
end
204212
end
205213
end
206214

@@ -440,6 +448,7 @@ local function print_current_jobs(job_matchers, opts)
440448
local filtered = next(job_matchers)
441449
local function count_job(jobs, job)
442450
if filtered and not job_matchers[job.job_type] then return end
451+
if job.flags.do_now then return end
443452
local job_type = get_job_type_str(job)
444453
jobs[job_type] = (jobs[job_type] or 0) + 1
445454
end

0 commit comments

Comments
 (0)