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

Method count_tools

plugins/autolabor/labormanager.cpp:829–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827 }
828
829 void count_tools()
830 {
831 for (int e = TOOL_NONE; e < TOOLS_MAX; e++)
832 {
833 tool_count[e] = 0;
834 tool_in_use[e] = 0;
835 }
836
837 priority_food = 0;
838
839 df::item_flags bad_flags;
840 bad_flags.whole = 0;
841
842#define F(x) bad_flags.bits.x = true;
843 F(dump); F(forbid); F(garbage_collect);
844 F(hostile); F(on_fire); F(rotten); F(trader);
845 F(in_building); F(construction);
846#undef F
847
848 for (auto item : world->items.other.IN_PLAY) {
849 if (item->flags.bits.dump && !labor_infos[df::unit_labor::HAUL_REFUSE].is_unmanaged())
850 labor_needed[df::unit_labor::HAUL_REFUSE]++;
851
852 if (item->flags.whole & bad_flags.whole)
853 continue;
854
855 df::item_type t = item->getType();
856
857 if (item->materialRots() && t != df::item_type::CORPSEPIECE && t != df::item_type::CORPSE && item->getRotTimer() > 1)
858 priority_food++;
859
860 if (!item->isWeapon())
861 continue;
862
863 df::itemdef_weaponst* weapondef = ((df::item_weaponst*)item)->subtype;
864 df::job_skill weaponsk = (df::job_skill) weapondef->skill_melee;
865 df::job_skill weaponsk2 = (df::job_skill) weapondef->skill_ranged;
866 if (weaponsk == df::job_skill::AXE)
867 tool_count[TOOL_AXE]++;
868 else if (weaponsk == df::job_skill::MINING)
869 tool_count[TOOL_PICK]++;
870 else if (weaponsk2 == df::job_skill::CROSSBOW)
871 tool_count[TOOL_CROSSBOW]++;
872 }
873
874 }
875
876 void collect_job_list()
877 {

Callers

nothing calls this directly

Calls 2

is_unmanagedMethod · 0.80
getTypeMethod · 0.80

Tested by

no test coverage detected