Skip to content

Commit a063c0c

Browse files
committed
only recheck orders that have conditions
1 parent ab386a0 commit a063c0c

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Template for new versions:
6363

6464
## Misc Improvements
6565
- `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates
66+
- `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked
6667

6768
## Documentation
6869

docs/plugins/orders.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ Usage
1818
``orders clear``
1919
Deletes all manager orders in the current embark.
2020
``orders recheck [this]``
21-
Sets the status to ``Checking`` (from ``Active``) for all work orders. if the
22-
"this" option is passed, only sets the status for the workorder whose condition
23-
details page is open. This makes the manager reevaluate its conditions.
24-
This is especially useful for an order that had its conditions met when it
25-
was started, but the requisite items have since disappeared and the workorder
26-
is now generating job cancellation spam.
21+
Sets the status to ``Checking`` (from ``Active``) for all work orders that
22+
have conditions that can be re-checked. If the "this" option is passed,
23+
only sets the status for the workorder whose condition details page is
24+
open. This makes the manager reevaluate its conditions. This is especially
25+
useful for an order that had its conditions met when it was started, but
26+
the requisite items have since disappeared and the workorder is now
27+
generating job cancellation spam.
2728
``orders sort``
2829
Sorts current manager orders by repeat frequency so repeating orders don't
2930
prevent one-time orders from ever being completed. The sorting order is:

plugins/lua/orders.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ OrdersOverlay.ATTRS{
7171
default_pos={x=53,y=-6},
7272
default_enabled=true,
7373
viewscreens='dwarfmode/Info/WORK_ORDERS/Default',
74-
frame={w=46, h=4},
74+
frame={w=43, h=4},
7575
}
7676

7777
function OrdersOverlay:init()
@@ -99,7 +99,7 @@ function OrdersOverlay:init()
9999
},
100100
widgets.HotkeyLabel{
101101
frame={t=0, l=15},
102-
label='recheck',
102+
label='recheck conditions',
103103
key='CUSTOM_CTRL_K',
104104
auto_width=true,
105105
on_activate=do_recheck,
@@ -112,7 +112,7 @@ function OrdersOverlay:init()
112112
on_activate=do_sort,
113113
},
114114
widgets.HotkeyLabel{
115-
frame={t=0, l=31},
115+
frame={t=1, l=28},
116116
label='clear',
117117
key='CUSTOM_CTRL_C',
118118
auto_width=true,
@@ -179,10 +179,10 @@ local function set_current_inactive()
179179
end
180180
end
181181

182-
local function is_current_active()
182+
local function can_recheck()
183183
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
184184
local order = scrConditions.wq
185-
return order.status.active
185+
return order.status.active and #order.item_conditions > 0
186186
end
187187

188188
-- -------------------
@@ -197,7 +197,7 @@ RecheckOverlay.ATTRS{
197197
default_enabled=true,
198198
viewscreens=focusString,
199199
-- width is the sum of lengths of `[` + `Ctrl+A` + `: ` + button.label + `]`
200-
frame={w=1 + 6 + 2 + 16 + 1, h=3},
200+
frame={w=1 + 6 + 2 + 19 + 1, h=3},
201201
}
202202

203203
local function areTabsInTwoRows()
@@ -226,10 +226,10 @@ function RecheckOverlay:init()
226226
widgets.TextButton{
227227
view_id = 'button',
228228
-- frame={t=0, l=0, r=0, h=1}, -- is set in `updateTextButtonFrame()`
229-
label='request re-check',
229+
label='re-check conditions',
230230
key='CUSTOM_CTRL_A',
231231
on_activate=set_current_inactive,
232-
enabled=is_current_active,
232+
enabled=can_recheck,
233233
},
234234
}
235235

plugins/orders.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,15 @@ static command_result orders_sort_command(color_ostream & out)
10361036

10371037
static command_result orders_recheck_command(color_ostream & out)
10381038
{
1039-
for (auto it : world->manager_orders)
1040-
{
1041-
it->status.bits.active = false;
1042-
it->status.bits.validated = false;
1039+
size_t count = 0;
1040+
for (auto it : world->manager_orders) {
1041+
if (it->item_conditions.size() && it->status.bits.active) {
1042+
++count;
1043+
it->status.bits.active = false;
1044+
it->status.bits.validated = false;
1045+
}
10431046
}
1047+
out << "Re-checking conditions for " << count << " manager orders." << std::endl;
10441048
return CR_OK;
10451049
}
10461050

0 commit comments

Comments
 (0)