MCPcopy Create free account
hub / github.com/DFHack/dfhack / command_result plugin_onupdate

Function command_result plugin_onupdate

plugins/workflow.cpp:608–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606static void process_constraints(color_ostream &out);
607
608DFhackCExport command_result plugin_onupdate(color_ostream &out)
609{
610 // Every 5 frames check the jobs for disappearance
611 static unsigned cnt = 0;
612 if ((++cnt % 5) != 0)
613 return CR_OK;
614
615 check_lost_jobs(out, world->frame_counter - last_tick_frame_count);
616 last_tick_frame_count = world->frame_counter;
617
618 // Proceed every in-game half-day, or when jobs to recover changed
619 static unsigned last_rlen = 0;
620 bool check_time = (world->frame_counter - last_frame_count) >= DAY_TICKS/2;
621
622 if (pending_recover.size() != last_rlen || check_time)
623 {
624 recover_jobs(out);
625 last_rlen = pending_recover.size();
626
627 // If the half-day passed, proceed to update
628 if (check_time)
629 {
630 last_frame_count = world->frame_counter;
631
632 update_job_data(out);
633 process_constraints(out);
634
635 for (size_t i = 0; i < constraints.size(); i++)
636 constraints[i]->updateHistory();
637 }
638 }
639
640 return CR_OK;
641}
642
643/******************************
644 * ITEM COUNT CONSTRAINT *

Callers

nothing calls this directly

Calls 6

check_lost_jobsFunction · 0.85
recover_jobsFunction · 0.85
update_job_dataFunction · 0.85
process_constraintsFunction · 0.85
updateHistoryMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected