| 1179 | } |
| 1180 | |
| 1181 | static void makeTopPriority(color_ostream &out, df::building *bld) { |
| 1182 | DEBUG(control,out).print("entering makeTopPriority\n"); |
| 1183 | if (!validate_pb(out, bld, 0)) |
| 1184 | return; |
| 1185 | |
| 1186 | PlannedBuilding &pb = planned_buildings.at(bld->id); |
| 1187 | auto &job_items = bld->jobs[0]->job_items.elements; |
| 1188 | const int num_job_items = (int)job_items.size(); |
| 1189 | |
| 1190 | for (int index = 0; index < num_job_items; ++index) { |
| 1191 | int rev_index = num_job_items - (index + 1); |
| 1192 | for (auto &vec_id : pb.vector_ids[index]) { |
| 1193 | if (!tasks.count(vec_id)) |
| 1194 | continue; |
| 1195 | auto &buckets = tasks.at(vec_id); |
| 1196 | string bucket_id = getBucket(*job_items[rev_index], pb, index); |
| 1197 | if (!buckets.count(bucket_id)) |
| 1198 | continue; |
| 1199 | auto &bucket = buckets.at(bucket_id); |
| 1200 | for (auto taskit = bucket.begin(); taskit != bucket.end(); ++taskit) { |
| 1201 | if (bld->id == taskit->first && rev_index == taskit->second) { |
| 1202 | auto task_bld_id = taskit->first; |
| 1203 | auto task_job_item_idx = taskit->second; |
| 1204 | bucket.erase(taskit); |
| 1205 | bucket.emplace_front(task_bld_id, task_job_item_idx); |
| 1206 | break; |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | DFHACK_PLUGIN_LUA_FUNCTIONS { |
| 1214 | DFHACK_LUA_FUNCTION(printStatus), |