| 1192 | } |
| 1193 | |
| 1194 | static void update_jobs_by_constraints(color_ostream &out) |
| 1195 | { |
| 1196 | for (TKnownJobs::const_iterator it = known_jobs.begin(); it != known_jobs.end(); ++it) |
| 1197 | { |
| 1198 | ProtectedJob *pj = it->second; |
| 1199 | if (!pj->isLive()) |
| 1200 | continue; |
| 1201 | |
| 1202 | if (pj->actual_job->job_type == job_type::MeltMetalObject && |
| 1203 | isOptionEnabled(CF_AUTOMELT)) |
| 1204 | { |
| 1205 | setJobResumed(out, pj, meltable_count > 0); |
| 1206 | continue; |
| 1207 | } |
| 1208 | |
| 1209 | if (pj->constraints.empty()) |
| 1210 | continue; |
| 1211 | |
| 1212 | int resume_weight = -1; |
| 1213 | int suspend_weight = -1; |
| 1214 | |
| 1215 | for (size_t i = 0; i < pj->constraints.size(); i++) |
| 1216 | { |
| 1217 | if (pj->constraints[i]->request_resume) |
| 1218 | resume_weight = std::max(resume_weight, pj->constraints[i]->weight); |
| 1219 | if (pj->constraints[i]->request_suspend) |
| 1220 | suspend_weight = std::max(suspend_weight, pj->constraints[i]->weight); |
| 1221 | } |
| 1222 | |
| 1223 | bool goal = pj->isResumed(); |
| 1224 | |
| 1225 | if (resume_weight >= 0 && resume_weight >= suspend_weight) |
| 1226 | goal = true; |
| 1227 | else if (suspend_weight >= 0 && suspend_weight >= resume_weight) |
| 1228 | goal = false; |
| 1229 | |
| 1230 | setJobResumed(out, pj, goal); |
| 1231 | } |
| 1232 | |
| 1233 | for (size_t i = 0; i < constraints.size(); i++) |
| 1234 | { |
| 1235 | ItemConstraint *ct = constraints[i]; |
| 1236 | |
| 1237 | bool is_running = false; |
| 1238 | for (size_t j = 0; j < ct->jobs.size(); j++) |
| 1239 | if (!!(is_running = ct->jobs[j]->isResumed())) |
| 1240 | break; |
| 1241 | |
| 1242 | std::string info = ct->item.toString(); |
| 1243 | |
| 1244 | if (ct->is_craft) |
| 1245 | info = "crafts"; |
| 1246 | |
| 1247 | if (ct->material.isValid()) |
| 1248 | info = ct->material.toString() + " " + info; |
| 1249 | else if (ct->mat_mask.whole) |
| 1250 | info = bitfield_to_string(ct->mat_mask) + " " + info; |
| 1251 |
no test coverage detected