| 606 | static void process_constraints(color_ostream &out); |
| 607 | |
| 608 | DFhackCExport 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 * |
nothing calls this directly
no test coverage detected