| 122 | } |
| 123 | |
| 124 | command_result df_createplant(color_ostream &out, const df::coord &pos, const plant_options &options) |
| 125 | { |
| 126 | auto col = Maps::getBlockColumn((pos.x / 48)*3, (pos.y / 48)*3); |
| 127 | auto tt = Maps::getTileType(pos); |
| 128 | if (!tt || !col) |
| 129 | { |
| 130 | out.printerr("No map block at pos!\n"); |
| 131 | return CR_FAILURE; |
| 132 | } |
| 133 | |
| 134 | if (tileShape(*tt) != tiletype_shape::FLOOR) |
| 135 | { |
| 136 | out.printerr("Can't create plant: Not floor!\n"); |
| 137 | return CR_FAILURE; |
| 138 | } |
| 139 | |
| 140 | auto occ = Maps::getTileOccupancy(pos); |
| 141 | CHECK_NULL_POINTER(occ); |
| 142 | if (occ->bits.building > tile_building_occ::None) |
| 143 | { |
| 144 | out.printerr("Can't create plant: Building present!\n"); |
| 145 | return CR_FAILURE; |
| 146 | } |
| 147 | else if (!options.force && occ->bits.no_grow) |
| 148 | { |
| 149 | out.printerr("Can't create plant: Tile flagged no_grow and not --force!\n"); |
| 150 | return CR_FAILURE; |
| 151 | } |
| 152 | |
| 153 | auto des = Maps::getTileDesignation(pos); |
| 154 | CHECK_NULL_POINTER(des); |
| 155 | if (des->bits.flow_size > (des->bits.liquid_type == tile_liquid::Magma ? 0U : 3U)) |
| 156 | { |
| 157 | out.printerr("Can't create plant: Too much liquid!\n"); |
| 158 | return CR_FAILURE; |
| 159 | } |
| 160 | |
| 161 | auto spec = tileSpecial(*tt); |
| 162 | auto mat = tileMaterial(*tt); |
| 163 | switch (mat) |
| 164 | { |
| 165 | case tiletype_material::SOIL: |
| 166 | case tiletype_material::GRASS_LIGHT: |
| 167 | case tiletype_material::GRASS_DARK: |
| 168 | case tiletype_material::ASHES: |
| 169 | break; |
| 170 | case tiletype_material::STONE: |
| 171 | case tiletype_material::LAVA_STONE: |
| 172 | case tiletype_material::MINERAL: |
| 173 | if (spec == tiletype_special::SMOOTH || spec == tiletype_special::TRACK) |
| 174 | { |
| 175 | out.printerr("Can't create plant: Smooth stone!\n"); |
| 176 | return CR_FAILURE; |
| 177 | } |
| 178 | else if (!tile_muddy(pos)) |
| 179 | { |
| 180 | out.printerr("Can't create plant: Non-muddy stone!\n"); |
| 181 | return CR_FAILURE; |
no test coverage detected