From 3fc289cefadcde4ebca15d08991d3ff1cef27a1c Mon Sep 17 00:00:00 2001 From: Mikhail Panov Date: Fri, 22 Sep 2023 16:26:23 +0300 Subject: [PATCH] Added single order recheck option to orders recheck. Sorting by material and job type consider frequency as a higher priority. --- plugins/orders.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/plugins/orders.cpp b/plugins/orders.cpp index 4b93cff2d..0bb89a0bc 100644 --- a/plugins/orders.cpp +++ b/plugins/orders.cpp @@ -67,6 +67,7 @@ static command_result orders_sort_command(color_ostream & out); static command_result orders_sort_type_command(color_ostream & out); static command_result orders_sort_material_command(color_ostream & out); static command_result orders_recheck_command(color_ostream & out); +static command_result orders_recheck_current_command(color_ostream & out); static command_result orders_command(color_ostream & out, std::vector & parameters) { @@ -129,6 +130,14 @@ static command_result orders_command(color_ostream & out, std::vectorfrequency != b->frequency) + { + return compare_freq(a, b); + } + // Determine if only one order has reaction_name bool a_has_reaction_name = !a->reaction_name.empty(); bool b_has_reaction_name = !b->reaction_name.empty(); @@ -1077,8 +1092,8 @@ static bool compare_type(df::manager_order *a, df::manager_order *b) } } - // Fall back to freq sort - return compare_freq(a, b); + // By default orders are the same + return false; } static command_result orders_sort_type_command(color_ostream & out) @@ -1102,6 +1117,12 @@ static bool compare_material(df::manager_order *a, df::manager_order *b) // Goal: Sort orders to easily find them in the list and to see dupclicated orders. // Sorting by materials + // Divide orders by frequency first + if (a->frequency != b->frequency) + { + return compare_freq(a, b); + } + // Determine if only one of the orders has mat_type bool a_has_material = (a->mat_type != -1 || a->mat_index != -1); bool b_has_material = (b->mat_type != -1 || b->mat_index != -1); @@ -1169,3 +1190,17 @@ static command_result orders_recheck_command(color_ostream & out) } return CR_OK; } + +static command_result orders_recheck_current_command(color_ostream & out) +{ + if (game->main_interface.info.work_orders.conditions.open) + { + game->main_interface.info.work_orders.conditions.wq.status.active = false; + } + else + { + out << COLOR_LIGHTRED << "Order conditions is not open" << std::endl; + return CR_FAILURE; + } + return CR_OK; +}