MCPcopy Create free account
hub / github.com/DFHack/dfhack / manageJobInitiatedEvent

Function manageJobInitiatedEvent

library/modules/EventManager.cpp:474–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472}
473
474static 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
503static void manageJobStartedEvent(color_ostream& out) {
504 if (!df::global::world)

Callers

nothing calls this directly

Calls 4

run_handlerFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected