Skip to content

Commit

Permalink
[suspendmanager] fix suspension of dead ends without exit
Browse files Browse the repository at this point in the history
  • Loading branch information
chdoc authored and myk002 committed May 22, 2024
1 parent 7564386 commit a55bd92
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions plugins/suspendmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ class SuspendManager {
return true;
}

void suspendBuilding(df::building *building, Reason reason){
for (auto job : building->jobs)
if (job->job_type == df::job_type::ConstructBuilding)
suspensions[job->id] = reason;
}

void suspendDeadend (color_ostream &out, df::job* job) {
auto building = Job::getHolder(job);
if (!building) return;
Expand Down Expand Up @@ -561,18 +567,14 @@ class SuspendManager {
// there is no exit at all
if (isImpassable(building)) {
// suspend the current construction job to leave the entire plan suspended
suspensions[job->id] = Reason::DEADEND;
suspendBuilding(building, Reason::DEADEND);
}
// and stop here
return;
}

// exit is the single exit point of this corridor, suspend its construction job...
for (auto exit_job : exit->jobs) {
if (exit_job->job_type == df::job_type::ConstructBuilding) {
suspensions[exit_job->id] = Reason::DEADEND;
}
}
suspendBuilding(exit, Reason::DEADEND);
// ...mark the current tile of the corridor as leading to a dead-end...
leadsToDeadend.insert(building->id);

Expand All @@ -590,11 +592,7 @@ class SuspendManager {
{
auto building = Buildings::findAtTile(job->pos);
if (building) {
for (auto building_job : building->jobs) {
if (building_job->job_type == df::job_type::ConstructBuilding) {
suspensions[building_job->id] = Reason::ERASE_DESIGNATION;
}
}
suspendBuilding(building, Reason::ERASE_DESIGNATION);
}
}
}
Expand Down

0 comments on commit a55bd92

Please sign in to comment.