@@ -67,8 +67,6 @@ static command_result orders_export_command(color_ostream & out, const std::stri
6767static command_result orders_import_command (color_ostream & out, const std::string & name);
6868static command_result orders_clear_command (color_ostream & out);
6969static command_result orders_sort_command (color_ostream & out);
70- static command_result orders_sort_type_command (color_ostream & out);
71- static command_result orders_sort_material_command (color_ostream & out);
7270static command_result orders_recheck_command (color_ostream & out);
7371static command_result orders_recheck_current_command (color_ostream & out);
7472
@@ -118,16 +116,6 @@ static command_result orders_command(color_ostream & out, std::vector<std::strin
118116 return orders_sort_command (out);
119117 }
120118
121- if (parameters[0 ] == " sort_type" && parameters.size () == 1 )
122- {
123- return orders_sort_type_command (out);
124- }
125-
126- if (parameters[0 ] == " sort_material" && parameters.size () == 1 )
127- {
128- return orders_sort_material_command (out);
129- }
130-
131119 if (parameters[0 ] == " recheck" && parameters.size () == 1 )
132120 {
133121 return orders_recheck_command (out);
@@ -1046,144 +1034,6 @@ static command_result orders_sort_command(color_ostream & out)
10461034 return CR_OK;
10471035}
10481036
1049- static bool compare_type (df::manager_order *a, df::manager_order *b)
1050- {
1051- // Goal: Sort orders to easily find them in the list and to see dupclicated orders.
1052- // Sorting by job types
1053-
1054- // Divide orders by frequency first
1055- if (a->frequency != b->frequency )
1056- {
1057- return compare_freq (a, b);
1058- }
1059-
1060- // Determine if only one order has reaction_name
1061- bool a_has_reaction_name = !a->reaction_name .empty ();
1062- bool b_has_reaction_name = !b->reaction_name .empty ();
1063-
1064- if (a_has_reaction_name != b_has_reaction_name)
1065- {
1066- return a_has_reaction_name;
1067- }
1068- else if (a_has_reaction_name && b_has_reaction_name)
1069- {
1070- if (a->reaction_name != b->reaction_name )
1071- {
1072- return a->reaction_name < b->reaction_name ;
1073- }
1074- }
1075-
1076- // Compare job_type
1077- if (enum_item_key (a->job_type ) != enum_item_key (b->job_type ))
1078- {
1079- return enum_item_key (a->job_type ) < enum_item_key (b->job_type );
1080- }
1081-
1082- // Compare item subtype
1083- bool a_has_item_subtype = (a->item_subtype != -1 );
1084- bool b_has_item_subtype = (b->item_subtype != -1 );
1085-
1086- if (a_has_item_subtype != b_has_item_subtype)
1087- {
1088- return a_has_item_subtype;
1089- }
1090- else if (a_has_item_subtype && b_has_item_subtype)
1091- {
1092- if (a->item_subtype != b->item_subtype )
1093- {
1094- return a->item_subtype < b->item_subtype ;
1095- }
1096- }
1097-
1098- // By default orders are the same
1099- return false ;
1100- }
1101-
1102- static command_result orders_sort_type_command (color_ostream & out)
1103- {
1104- CoreSuspender suspend;
1105- if (!std::is_sorted (world->manager_orders .begin (),
1106- world->manager_orders .end (),
1107- compare_type))
1108- {
1109- std::stable_sort (world->manager_orders .begin (),
1110- world->manager_orders .end (),
1111- compare_type);
1112- out << " Manager orders are sorted by job type." << std::endl;
1113- }
1114-
1115- return CR_OK;
1116- }
1117-
1118- static bool compare_material (df::manager_order *a, df::manager_order *b)
1119- {
1120- // Goal: Sort orders to easily find them in the list and to see dupclicated orders.
1121- // Sorting by materials
1122-
1123- // Divide orders by frequency first
1124- if (a->frequency != b->frequency )
1125- {
1126- return compare_freq (a, b);
1127- }
1128-
1129- // Determine if only one of the orders has mat_type
1130- bool a_has_material = (a->mat_type != -1 || a->mat_index != -1 );
1131- bool b_has_material = (b->mat_type != -1 || b->mat_index != -1 );
1132-
1133- if (a_has_material != b_has_material)
1134- {
1135- return a_has_material;
1136- }
1137- else if (a_has_material && b_has_material)
1138- {
1139- // Compare mat_type using MaterialInfo
1140- if (MaterialInfo (a).getToken () != MaterialInfo (b).getToken ())
1141- {
1142- return MaterialInfo (a).getToken () < MaterialInfo (b).getToken ();
1143- }
1144- }
1145-
1146- // Determine if only one order has material_category
1147- bool a_has_material_category = (a->material_category .whole != 0 );
1148- bool b_has_material_category = (b->material_category .whole != 0 );
1149-
1150- if (a_has_material_category != b_has_material_category)
1151- {
1152- return a_has_material_category;
1153- }
1154- else if (a_has_material_category && b_has_material_category)
1155- {
1156- std::vector<std::string> a_mats, b_mats;
1157- bitfield_to_string (&a_mats, a->material_category );
1158- bitfield_to_string (&b_mats, b->material_category );
1159-
1160- // Checking that mats are not empty just in case
1161- if (!a_mats.empty () && !b_mats.empty () && a_mats[0 ] != b_mats[0 ])
1162- {
1163- return a_mats[0 ] < b_mats[0 ];
1164- }
1165- }
1166-
1167- // Fall back to material sort
1168- return compare_type (a, b);
1169- }
1170-
1171- static command_result orders_sort_material_command (color_ostream & out)
1172- {
1173- CoreSuspender suspend;
1174- if (!std::is_sorted (world->manager_orders .begin (),
1175- world->manager_orders .end (),
1176- compare_material))
1177- {
1178- std::stable_sort (world->manager_orders .begin (),
1179- world->manager_orders .end (),
1180- compare_material);
1181- out << " Manager orders are sorted by material." << std::endl;
1182- }
1183-
1184- return CR_OK;
1185- }
1186-
11871037static command_result orders_recheck_command (color_ostream & out)
11881038{
11891039 for (auto it : world->manager_orders )
0 commit comments