| 1144 | } |
| 1145 | |
| 1146 | static int getQueuePosition(color_ostream &out, df::building *bld, int index) { |
| 1147 | TRACE(control,out).print("entering getQueuePosition\n"); |
| 1148 | if (!validate_pb(out, bld, index)) |
| 1149 | return 0; |
| 1150 | |
| 1151 | PlannedBuilding &pb = planned_buildings.at(bld->id); |
| 1152 | auto & jitems = bld->jobs[0]->job_items.elements; |
| 1153 | const size_t num_job_items = jitems.size(); |
| 1154 | int rev_index = num_job_items - (index + 1); |
| 1155 | auto &job_item = jitems[rev_index]; |
| 1156 | |
| 1157 | if (job_item->quantity <= 0) |
| 1158 | return 0; |
| 1159 | |
| 1160 | int min_pos = -1; |
| 1161 | for (auto &vec_id : pb.vector_ids[index]) { |
| 1162 | if (!tasks.count(vec_id)) |
| 1163 | continue; |
| 1164 | auto &buckets = tasks.at(vec_id); |
| 1165 | string bucket_id = getBucket(*job_item, pb, index); |
| 1166 | if (!buckets.count(bucket_id)) |
| 1167 | continue; |
| 1168 | int bucket_pos = -1; |
| 1169 | for (auto &task : buckets.at(bucket_id)) { |
| 1170 | ++bucket_pos; |
| 1171 | if (bld->id == task.first && rev_index == task.second) |
| 1172 | break; |
| 1173 | } |
| 1174 | if (bucket_pos++ >= 0) |
| 1175 | min_pos = min_pos < 0 ? bucket_pos : std::min(min_pos, bucket_pos); |
| 1176 | } |
| 1177 | |
| 1178 | return min_pos < 0 ? 0 : min_pos; |
| 1179 | } |
| 1180 | |
| 1181 | static void makeTopPriority(color_ostream &out, df::building *bld) { |
| 1182 | DEBUG(control,out).print("entering makeTopPriority\n"); |
nothing calls this directly
no test coverage detected