| 734 | } |
| 735 | |
| 736 | DFhackCExport command_result plugin_onupdate ( color_ostream &out ) |
| 737 | { |
| 738 | if(!world || !world->map.block_index || !enable_autolabor) |
| 739 | { |
| 740 | return CR_OK; |
| 741 | } |
| 742 | |
| 743 | if (world->frame_counter - cycle_timestamp <= CYCLE_TICKS) |
| 744 | return CR_OK; |
| 745 | |
| 746 | cycle_timestamp = world->frame_counter; |
| 747 | |
| 748 | std::vector<df::unit *> dwarfs; |
| 749 | |
| 750 | bool has_butchers = false; |
| 751 | bool has_fishery = false; |
| 752 | bool trader_requested = false; |
| 753 | |
| 754 | for (auto& build : world->buildings.all) |
| 755 | { |
| 756 | auto type = build->getType(); |
| 757 | if (building_type::Workshop == type) |
| 758 | { |
| 759 | df::workshop_type subType = (df::workshop_type)build->getSubtype(); |
| 760 | if (workshop_type::Butchers == subType) |
| 761 | has_butchers = true; |
| 762 | if (workshop_type::Fishery == subType) |
| 763 | has_fishery = true; |
| 764 | } |
| 765 | else if (building_type::TradeDepot == type) |
| 766 | { |
| 767 | df::building_tradedepotst* depot = (df::building_tradedepotst*) build; |
| 768 | trader_requested = trader_requested || depot->trade_flags.bits.trader_requested; |
| 769 | TRACE(cycle,out).print("{}", trader_requested |
| 770 | ? "Trade depot found and trader requested, trader will be excluded from all labors.\n" |
| 771 | : "Trade depot found but trader is not requested.\n" |
| 772 | ); |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | for (auto& cre : world->units.active) |
| 777 | { |
| 778 | if (Units::isCitizen(cre)) |
| 779 | { |
| 780 | if (cre->burrows.size() > 0) |
| 781 | continue; // dwarfs assigned to active burrows are skipped entirely |
| 782 | dwarfs.push_back(cre); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | int n_dwarfs = dwarfs.size(); |
| 787 | |
| 788 | if (n_dwarfs == 0) |
| 789 | return CR_OK; |
| 790 | |
| 791 | std::vector<dwarf_info_t> dwarf_info(n_dwarfs); |
| 792 | |
| 793 | // Find total skill and highest skill for each dwarf. More skilled dwarves shouldn't be used for minor tasks. |
nothing calls this directly
no test coverage detected