| 1093 | } |
| 1094 | |
| 1095 | command_result autolabor (color_ostream &out, std::vector <std::string> & parameters) |
| 1096 | { |
| 1097 | if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) { |
| 1098 | out.printerr("Cannot run {} without a loaded fort.\n", plugin_name); |
| 1099 | return CR_FAILURE; |
| 1100 | } |
| 1101 | |
| 1102 | if (parameters.size() == 1 && |
| 1103 | (parameters[0] == "0" || parameters[0] == "enable" || |
| 1104 | parameters[0] == "1" || parameters[0] == "disable")) |
| 1105 | { |
| 1106 | bool enable = (parameters[0] == "1" || parameters[0] == "enable"); |
| 1107 | |
| 1108 | return plugin_enable(out, enable); |
| 1109 | } |
| 1110 | else if (parameters.size() == 2 && parameters[0] == "haulpct") |
| 1111 | { |
| 1112 | if (!enable_autolabor) |
| 1113 | { |
| 1114 | out << "Error: The plugin is not enabled." << std::endl; |
| 1115 | return CR_FAILURE; |
| 1116 | } |
| 1117 | |
| 1118 | int pct = atoi (parameters[1].c_str()); |
| 1119 | hauler_pct = pct; |
| 1120 | return CR_OK; |
| 1121 | } |
| 1122 | else if (parameters.size() >= 2 && parameters.size() <= 4) |
| 1123 | { |
| 1124 | if (!enable_autolabor) |
| 1125 | { |
| 1126 | out << "Error: The plugin is not enabled." << std::endl; |
| 1127 | return CR_FAILURE; |
| 1128 | } |
| 1129 | |
| 1130 | df::unit_labor labor = unit_labor::NONE; |
| 1131 | |
| 1132 | FOR_ENUM_ITEMS(unit_labor, test_labor) |
| 1133 | { |
| 1134 | if (parameters[0] == ENUM_KEY_STR(unit_labor, test_labor)) |
| 1135 | labor = test_labor; |
| 1136 | } |
| 1137 | |
| 1138 | if (labor == unit_labor::NONE) |
| 1139 | { |
| 1140 | out.printerr("Could not find labor {}.\n", parameters[0]); |
| 1141 | return CR_WRONG_USAGE; |
| 1142 | } |
| 1143 | |
| 1144 | if (parameters[1] == "haulers") |
| 1145 | { |
| 1146 | labor_infos[labor].set_mode(HAULERS); |
| 1147 | print_labor(labor, out); |
| 1148 | return CR_OK; |
| 1149 | } |
| 1150 | if (parameters[1] == "disable") |
| 1151 | { |
| 1152 | labor_infos[labor].set_mode(DISABLE); |
nothing calls this directly
no test coverage detected