return true if this job is at risk of blocking another one
| 469 | |
| 470 | // return true if this job is at risk of blocking another one |
| 471 | static bool riskBlocking(color_ostream &out, df::job* job) { |
| 472 | if (job->job_type != job_type::ConstructBuilding) |
| 473 | return false; |
| 474 | TRACE(cycle,out).print("risk blocking: check construction job {}\n", job->id); |
| 475 | |
| 476 | auto building = Job::getHolder(job); |
| 477 | if (!building || !isImpassable(building)) |
| 478 | return false; // not building a blocking construction, no risk |
| 479 | |
| 480 | coord pos(building->centerx,building->centery,building->z); |
| 481 | if (!isPotentialSuitableAccess(pos)) |
| 482 | // construction is on a tile that is not usable to build, and will not |
| 483 | // become one, can't block |
| 484 | return false; |
| 485 | |
| 486 | auto risk = riskOfStuckConstructionAt(pos); |
| 487 | TRACE(cycle,out).print(" risk is {}\n", risk); |
| 488 | |
| 489 | // TOTHINK: on a large grid, this will compute the same risk up to 5 times |
| 490 | for (auto npos : neighbors | transform(around(pos))) { |
| 491 | if (plannedImpassibleAt(npos) && riskOfStuckConstructionAt(npos) > risk) |
| 492 | return true; // neighbour job is at greater risk of getting stuck |
| 493 | } |
| 494 | |
| 495 | return false; |
| 496 | } |
| 497 | |
| 498 | static bool constructionIsUnsupported(color_ostream &out, df::job* job) |
| 499 | { |