| 683 | } |
| 684 | |
| 685 | void process_job(df::job* j) |
| 686 | { |
| 687 | if (j->flags.bits.suspend || j->flags.bits.item_lost) |
| 688 | return; |
| 689 | |
| 690 | int worker = -1; |
| 691 | int bld = -1; |
| 692 | |
| 693 | for (auto ref : j->general_refs) |
| 694 | { |
| 695 | if (ref->getType() == df::general_ref_type::UNIT_WORKER) |
| 696 | worker = ((df::general_ref_unit_workerst *)ref)->unit_id; |
| 697 | if (ref->getType() == df::general_ref_type::BUILDING_HOLDER) |
| 698 | bld = ((df::general_ref_building_holderst *)ref)->building_id; |
| 699 | } |
| 700 | |
| 701 | if (bld != -1) |
| 702 | { |
| 703 | df::building* b = binsearch_in_vector(world->buildings.all, bld); |
| 704 | |
| 705 | // check if this job is the first nonsuspended job on this building; if not, ignore it |
| 706 | // (except for farms and trade depots) |
| 707 | |
| 708 | if (b->getType() != df::building_type::FarmPlot && |
| 709 | b->getType() != df::building_type::TradeDepot) |
| 710 | { |
| 711 | int fjid = -1; |
| 712 | for (size_t jn = 0; jn < b->jobs.size(); jn++) |
| 713 | { |
| 714 | if (b->jobs[jn]->flags.bits.suspend) |
| 715 | continue; |
| 716 | fjid = b->jobs[jn]->id; |
| 717 | break; |
| 718 | } |
| 719 | if (fjid != j->id) |
| 720 | return; |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | df::unit_labor labor = labor_mapper->find_job_labor(j); |
| 725 | |
| 726 | if (labor != df::unit_labor::NONE && !labor_infos[labor].is_unmanaged()) |
| 727 | { |
| 728 | labor_needed[labor]++; |
| 729 | if (worker == -1) |
| 730 | { |
| 731 | if (j->pos.isValid()) |
| 732 | { |
| 733 | df::tile_designation* d = Maps::getTileDesignation(j->pos); |
| 734 | if (d->bits.outside) |
| 735 | labor_outside[labor] = true; |
| 736 | } |
| 737 | } |
| 738 | else { |
| 739 | labor_infos[labor].mark_assigned(); |
| 740 | labor_in_use[labor]++; |
| 741 | } |
| 742 |
nothing calls this directly
no test coverage detected