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

Method count_map_designations

plugins/autolabor/labormanager.cpp:782–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780 }
781
782 void count_map_designations()
783 {
784 dig_count = 0;
785 tree_count = 0;
786 plant_count = 0;
787 detail_count = 0;
788
789 for (size_t i = 0; i < world->map.map_blocks.size(); ++i)
790 {
791 df::map_block* bl = world->map.map_blocks[i];
792
793 if (!bl->flags.bits.designated)
794 continue;
795
796 for (int x = 0; x < 16; x++)
797 for (int y = 0; y < 16; y++)
798 {
799 if (bl->designation[x][y].bits.hidden)
800 {
801 df::coord p = bl->map_pos;
802 if (! Maps::isTileVisible(p.x, p.y, p.z-1))
803 continue;
804 }
805
806 df::tile_dig_designation dig = bl->designation[x][y].bits.dig;
807 if (dig != df::enums::tile_dig_designation::No)
808 {
809 df::tiletype tt = bl->tiletype[x][y];
810 df::tiletype_material ttm = ENUM_ATTR(tiletype, material, tt);
811 df::tiletype_shape tts = ENUM_ATTR(tiletype, shape, tt);
812 if (ttm == df::enums::tiletype_material::TREE)
813 tree_count++;
814 else if (tts == df::enums::tiletype_shape::SHRUB)
815 plant_count++;
816 else
817 dig_count++;
818 }
819 if (bl->designation[x][y].bits.smooth != 0)
820 detail_count++;
821 }
822 }
823
824 if (print_debug)
825 out.print("Dig count = %d, Cut tree count = %d, gather plant count = %d, detail count = %d\n", dig_count, tree_count, plant_count, detail_count);
826
827 }
828
829 void count_tools()
830 {

Callers

nothing calls this directly

Calls 3

isTileVisibleFunction · 0.85
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected