Fixes JOB_STARTED event

develop
Josh Cooper 2022-11-08 12:43:23 -08:00
parent 22eb9ca8b3
commit 92645ccb5b
2 changed files with 8 additions and 5 deletions

@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `tiletypes`: no longer resets dig priority to the default when updating other properties of a tile
- `automaterial`: fix rendering errors with box boundary markers
- Core: fix the segmentation fault with the REPORT event in EventManager
- Core: fix the new JOB_STARTED event only sending each event once, to the first handler listed
## Misc Improvements
- `blueprint`: new ``--smooth`` option for recording all smoothed floors and walls instead of just the ones that require smoothing for later carving

@ -444,12 +444,14 @@ static void manageJobStartedEvent(color_ostream& out) {
// iterate event handler callbacks
multimap<Plugin*, EventHandler> copy(handlers[EventType::JOB_STARTED].begin(), handlers[EventType::JOB_STARTED].end());
for (auto &key_value : copy) {
auto &handler = key_value.second;
for (df::job_list_link* link = df::global::world->jobs.list.next; link != nullptr; link = link->next) {
df::job* job = link->item;
for (df::job_list_link* link = df::global::world->jobs.list.next; link != nullptr; link = link->next) {
df::job* job = link->item;
bool send = false;
for (auto &key_value : copy) {
auto &handler = key_value.second;
// the jobs must have a worker to start
if (job && Job::getWorker(job) && !startedJobs.count(job->id)) {
if (send || (job && Job::getWorker(job) && !startedJobs.count(job->id))) {
send = true;
startedJobs.emplace(job->id);
handler.eventHandler(out, job);
}