From 2700b017659c7ffa13a3a63ef42aa2970faca6e0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 25 Nov 2015 23:35:19 -0500 Subject: [PATCH] Ensure that the correct job posting is kept (if there is one) --- plugins/workflow.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index b2a2d11c4..e35552dd3 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -436,24 +436,17 @@ static int fix_job_postings (color_ostream *out, bool dry_run) df::job *job = link->item; if (job) { - bool needs_posting = (job->posting_index >= 0); - bool found_posting = false; - for (auto it = world->job_postings.begin(); it != world->job_postings.end(); ++it) + for (size_t i = 0; i < world->job_postings.size(); ++i) { - df::world::T_job_postings *posting = *it; - if (posting->job == job && !posting->flags.bits.dead) + df::world::T_job_postings *posting = world->job_postings[i]; + if (posting->job == job && i != job->posting_index) { - if (!found_posting && needs_posting) - found_posting = true; - else - { - ++count; - if (*out) - *out << "Found extra job posting: Job " << job->id << ": " - << Job::getName(job) << endl; - if (!dry_run) - posting->flags.bits.dead = true; - } + ++count; + if (out) + *out << "Found extra job posting: Job " << job->id << ": " + << Job::getName(job) << endl; + if (!dry_run) + posting->flags.bits.dead = true; } } }