| 52 | } |
| 53 | |
| 54 | command_result tubefill(color_ostream &out, std::vector<std::string> & params) |
| 55 | { |
| 56 | uint64_t count = 0; |
| 57 | bool hollow = false; |
| 58 | |
| 59 | for(size_t i = 0; i < params.size();i++) |
| 60 | { |
| 61 | if(params[i] == "help" || params[i] == "?") |
| 62 | return CR_WRONG_USAGE; |
| 63 | if (params[i] == "hollow") |
| 64 | hollow = true; |
| 65 | } |
| 66 | |
| 67 | if (!Maps::IsValid()) |
| 68 | { |
| 69 | out.printerr("Map is not available!\n"); |
| 70 | return CR_FAILURE; |
| 71 | } |
| 72 | |
| 73 | // walk the map |
| 74 | for (size_t i = 0; i < world->map.map_blocks.size(); i++) |
| 75 | { |
| 76 | df::map_block *block = world->map.map_blocks[i]; |
| 77 | df::map_block *above = Maps::getTileBlock(block->map_pos + df::coord(0,0,1)); |
| 78 | DFHack::t_feature feature; |
| 79 | if (!Maps::ReadFeatures(block, &feature, NULL)) |
| 80 | continue; |
| 81 | if (feature.type != feature_type::deep_special_tube) |
| 82 | continue; |
| 83 | for (uint32_t x = 0; x < 16; x++) |
| 84 | { |
| 85 | for (uint32_t y = 0; y < 16; y++) |
| 86 | { |
| 87 | if (!block->designation[x][y].bits.feature_local) |
| 88 | continue; |
| 89 | |
| 90 | if (!hollow && isDesignatedHollow(block->map_pos + df::coord(x,y,0))) |
| 91 | continue; |
| 92 | |
| 93 | // Is the tile already a wall? |
| 94 | if (tileShape(block->tiletype[x][y]) == tiletype_shape::WALL) |
| 95 | continue; |
| 96 | |
| 97 | // Does the tile contain liquid? |
| 98 | if (block->designation[x][y].bits.flow_size) |
| 99 | continue; |
| 100 | |
| 101 | // Check the tile above this one, in case we need to add a floor |
| 102 | if (above) |
| 103 | { |
| 104 | if ((tileShape(above->tiletype[x][y]) == tiletype_shape::EMPTY) || (tileShape(above->tiletype[x][y]) == tiletype_shape::RAMP_TOP)) |
| 105 | { |
| 106 | // if this tile isn't a local feature, it's likely the tile underneath was originally just a floor |
| 107 | // it's also possible there was just solid non-feature stone above, but we don't care enough to check |
| 108 | if (!above->designation[x][y].bits.feature_local) |
| 109 | continue; |
| 110 | above->tiletype[x][y] = findRandomVariant(tiletype::FeatureFloor1); |
| 111 | } |
nothing calls this directly
no test coverage detected