| 246 | } |
| 247 | |
| 248 | static df::building * popInvalidTasks(color_ostream &out, Bucket &task_queue, |
| 249 | unordered_map<int32_t, PlannedBuilding> &planned_buildings) { |
| 250 | while (!task_queue.empty()) { |
| 251 | auto & task = task_queue.front(); |
| 252 | auto id = task.first; |
| 253 | if (planned_buildings.count(id) > 0) { |
| 254 | auto bld = planned_buildings.at(id).getBuildingIfValidOrRemoveIfNot(out); |
| 255 | if (bld && bld->jobs[0]->job_items.elements[task.second]->quantity) |
| 256 | return bld; |
| 257 | } |
| 258 | DEBUG(cycle,out).print("discarding invalid task: bld={}, job_item_idx={}\n", id, task.second); |
| 259 | task_queue.pop_front(); |
| 260 | } |
| 261 | return NULL; |
| 262 | } |
| 263 | |
| 264 | |
| 265 | static int distance(df::coord pos1, df::coord pos2) { |
no test coverage detected