| 472 | } |
| 473 | |
| 474 | static void manageJobInitiatedEvent(color_ostream& out) { |
| 475 | if (!df::global::world) |
| 476 | return; |
| 477 | if (!df::global::job_next_id) |
| 478 | return; |
| 479 | if ( lastJobId == -1 ) { |
| 480 | lastJobId = *df::global::job_next_id - 1; |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | if ( lastJobId+1 == *df::global::job_next_id ) { |
| 485 | return; //no new jobs |
| 486 | } |
| 487 | multimap<Plugin*,EventHandler> copy(handlers[EventType::JOB_INITIATED].begin(), handlers[EventType::JOB_INITIATED].end()); |
| 488 | |
| 489 | for ( df::job_list_link* link = &df::global::world->jobs.list; link != nullptr; link = link->next ) { |
| 490 | if ( link->item == nullptr ) |
| 491 | continue; |
| 492 | if ( link->item->id <= lastJobId ) |
| 493 | continue; |
| 494 | for (auto &[_,handle] : copy) { |
| 495 | DEBUG(log,out).print("calling handler for job initiated event\n"); |
| 496 | run_handler(out, EventType::JOB_INITIATED, handle, (void*)link->item); |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | lastJobId = *df::global::job_next_id - 1; |
| 501 | } |
| 502 | |
| 503 | static void manageJobStartedEvent(color_ostream& out) { |
| 504 | if (!df::global::world) |
nothing calls this directly
no test coverage detected