| 738 | item_coords_t; |
| 739 | |
| 740 | static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords, |
| 741 | item_coords_t &item_coords, const dig_now_options &options) { |
| 742 | MapExtras::MapCache map; |
| 743 | Random::MersenneRNG rng; |
| 744 | DesignationJobs jobs; |
| 745 | |
| 746 | DEBUG(general).print("do_dig(): starting..\n"); |
| 747 | jobs.load(map); |
| 748 | rng.init(); |
| 749 | |
| 750 | DEBUG(general).print("do_dig(): reading map..\n"); |
| 751 | std::unordered_set<designation> buffer; |
| 752 | // go down levels instead of up so stacked ramps behave as expected |
| 753 | for (int16_t z = options.end.z; z >= options.start.z; --z) { |
| 754 | for (int16_t y = options.start.y; y <= options.end.y; ++y) { |
| 755 | for (int16_t x = options.start.x; x <= options.end.x; ++x) { |
| 756 | // this will return NULL if the map block hasn't been allocated |
| 757 | // yet, but that means there aren't any designations anyway. |
| 758 | if (!Maps::getTileBlock(x, y, z)) |
| 759 | continue; |
| 760 | |
| 761 | DFCoord pos(x, y, z); |
| 762 | df::tile_designation td = map.designationAt(pos); |
| 763 | df::tile_occupancy to = map.occupancyAt(pos); |
| 764 | if (jobs.count(pos)) { |
| 765 | buffer.emplace(jobs.get(pos)); |
| 766 | jobs.remove(pos); |
| 767 | // if it does get removed, then we're gonna buffer the jobs info then remove the job |
| 768 | } else if ((td.bits.dig != df::tile_dig_designation::No && !to.bits.dig_marked) |
| 769 | || td.bits.smooth == 1 |
| 770 | || to.bits.carve_track_north == 1 |
| 771 | || to.bits.carve_track_east == 1 |
| 772 | || to.bits.carve_track_south == 1 |
| 773 | || to.bits.carve_track_west == 1) { |
| 774 | |
| 775 | // we're only buffering designations, so that processing doesn't affect what we're buffering |
| 776 | buffer.emplace(pos, td, to); |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | DEBUG(general).print("do_dig(): processing designations..\n"); |
| 783 | // process designations |
| 784 | for(auto &d : buffer) { |
| 785 | auto pos = d.pos; |
| 786 | auto td = d.type; |
| 787 | auto to = d.occupancy; |
| 788 | |
| 789 | if (td.bits.dig != df::tile_dig_designation::No && !to.bits.dig_marked) { |
| 790 | std::vector<dug_tile_info> dug_tiles; |
| 791 | |
| 792 | if (dig_tile(out, map, pos, td.bits.dig, dug_tiles)) { |
| 793 | for (auto info: dug_tiles) { |
| 794 | td = map.designationAt(info.pos); |
| 795 | td.bits.dig = df::tile_dig_designation::No; |
| 796 | map.setDesignationAt(info.pos, td); |
| 797 |
no test coverage detected