Adds todo comments to dig-now.cpp for issue #2720

develop
Josh Cooper 2023-01-29 13:53:50 -08:00 committed by Josh Cooper
parent d222092b30
commit 456020fb38
1 changed files with 24 additions and 14 deletions

@ -320,8 +320,10 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
std::vector<dug_tile_info> &dug_tiles) { std::vector<dug_tile_info> &dug_tiles) {
df::tiletype tt = map.tiletypeAt(pos); df::tiletype tt = map.tiletypeAt(pos);
if (!is_diggable(map, pos, tt)) if (!is_diggable(map, pos, tt)) {
out.print("dig_tile: not diggable\n");
return false; return false;
}
df::tiletype target_type = df::tiletype::Void; df::tiletype target_type = df::tiletype::Void;
switch(designation) { switch(designation) {
@ -339,19 +341,23 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
case df::tile_dig_designation::Channel: case df::tile_dig_designation::Channel:
{ {
DFCoord pos_below(pos.x, pos.y, pos.z-1); DFCoord pos_below(pos.x, pos.y, pos.z-1);
// todo: does can_dig_channel return false?
if (can_dig_channel(tt) && map.ensureBlockAt(pos_below) if (can_dig_channel(tt) && map.ensureBlockAt(pos_below)
&& is_diggable(map, pos_below, map.tiletypeAt(pos_below))) { && is_diggable(map, pos_below, map.tiletypeAt(pos_below))) {
target_type = df::tiletype::OpenSpace; target_type = df::tiletype::OpenSpace;
DFCoord pos_above(pos.x, pos.y, pos.z+1); DFCoord pos_above(pos.x, pos.y, pos.z+1);
if (map.ensureBlockAt(pos_above)) if (map.ensureBlockAt(pos_above)) {
remove_ramp_top(map, pos_above); remove_ramp_top(map, pos_above);
df::tile_dig_designation td_below = }
map.designationAt(pos_below).bits.dig; df::tile_dig_designation td_below = map.designationAt(pos_below).bits.dig;
if (dig_tile(out, map, pos_below,
df::tile_dig_designation::Ramp, dug_tiles)) { // todo: what is this chain of dig_tile(below)?
if (dig_tile(out, map, pos_below, df::tile_dig_designation::Ramp, dug_tiles)) {
clean_ramps(map, pos_below); clean_ramps(map, pos_below);
if (td_below == df::tile_dig_designation::Default) if (td_below == df::tile_dig_designation::Default) {
// todo: removing ramp?
dig_tile(out, map, pos_below, td_below, dug_tiles); dig_tile(out, map, pos_below, td_below, dug_tiles);
}
return true; return true;
} }
} }
@ -407,7 +413,7 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
if (target_type == df::tiletype::Void || target_type == tt) if (target_type == df::tiletype::Void || target_type == tt)
return false; return false;
dug_tiles.push_back(dug_tile_info(map, pos)); dug_tiles.emplace_back(map, pos);
dig_type(map, pos, target_type); dig_type(map, pos, target_type);
// let light filter down to newly exposed tiles // let light filter down to newly exposed tiles
@ -606,14 +612,17 @@ static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
if (!Maps::getTileBlock(x, y, z)) if (!Maps::getTileBlock(x, y, z))
continue; continue;
// todo: check if tile is in the job list with a dig type
DFCoord pos(x, y, z); DFCoord pos(x, y, z);
df::tile_designation td = map.designationAt(pos); df::tile_designation td = map.designationAt(pos);
df::tile_occupancy to = map.occupancyAt(pos); df::tile_occupancy to = map.occupancyAt(pos);
if (td.bits.dig != df::tile_dig_designation::No && if (td.bits.dig != df::tile_dig_designation::No && !to.bits.dig_marked) {
!to.bits.dig_marked) {
std::vector<dug_tile_info> dug_tiles; std::vector<dug_tile_info> dug_tiles;
// todo: check why dig_tile doesn't dig the second layer of channels
if (dig_tile(out, map, pos, td.bits.dig, dug_tiles)) { if (dig_tile(out, map, pos, td.bits.dig, dug_tiles)) {
for (auto info : dug_tiles) { for (auto info: dug_tiles) {
td = map.designationAt(info.pos); td = map.designationAt(info.pos);
td.bits.dig = df::tile_dig_designation::No; td.bits.dig = df::tile_dig_designation::No;
map.setDesignationAt(info.pos, td); map.setDesignationAt(info.pos, td);
@ -629,6 +638,7 @@ static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
} }
} }
} }
// todo: check mark mode of smooth designations
} else if (td.bits.smooth == 1) { } else if (td.bits.smooth == 1) {
if (smooth_tile(out, map, pos)) { if (smooth_tile(out, map, pos)) {
to = map.occupancyAt(pos); to = map.occupancyAt(pos);
@ -636,9 +646,9 @@ static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
map.setDesignationAt(pos, td); map.setDesignationAt(pos, td);
} }
} else if (to.bits.carve_track_north == 1 } else if (to.bits.carve_track_north == 1
|| to.bits.carve_track_east == 1 || to.bits.carve_track_east == 1
|| to.bits.carve_track_south == 1 || to.bits.carve_track_south == 1
|| to.bits.carve_track_west == 1) { || to.bits.carve_track_west == 1) {
if (carve_tile(map, pos, to)) { if (carve_tile(map, pos, to)) {
to = map.occupancyAt(pos); to = map.occupancyAt(pos);
to.bits.carve_track_north = 0; to.bits.carve_track_north = 0;