| 343 | } |
| 344 | |
| 345 | int regrass_tile(color_ostream &out, const regrass_options &options, df::map_block *block, int tx, int ty) |
| 346 | { // Regrass single tile. Return 1 if tile success, else 0. |
| 347 | CHECK_NULL_POINTER(block); |
| 348 | if (!is_valid_tile_coord(df::coord2d(tx, ty))) { |
| 349 | out.printerr("({}, {}) not in range 0-15!\n", tx, ty); |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | DEBUG(log, out).print("Regrass tile ({}, {}, {})\n", |
| 354 | block->map_pos.x + tx, block->map_pos.y + ty, block->map_pos.z); |
| 355 | if (!regrass_events(out, options, block, tx, ty)) |
| 356 | return 0; |
| 357 | |
| 358 | auto tt = block->tiletype[tx][ty]; |
| 359 | auto mat = tileMaterial(tt); |
| 360 | auto shape = tileShape(tt); |
| 361 | |
| 362 | if (mat == tiletype_material::GRASS_LIGHT || |
| 363 | mat == tiletype_material::GRASS_DARK || |
| 364 | mat == tiletype_material::PLANT || |
| 365 | mat == tiletype_material::TREE) |
| 366 | { // Already appropriate tile. |
| 367 | TRACE(log, out).print("Tiletype no change.\n"); |
| 368 | return 1; |
| 369 | } |
| 370 | |
| 371 | if (shape == tiletype_shape::FLOOR) |
| 372 | { // Floor (including ashes). |
| 373 | DEBUG(log, out).print("Tiletype to random grass floor.\n"); |
| 374 | block->tiletype[tx][ty] = findRandomVariant((rand() & 1) ? tiletype::GrassLightFloor1 : tiletype::GrassDarkFloor1); |
| 375 | } |
| 376 | else |
| 377 | { // Ramp or stairs. |
| 378 | auto new_mat = (rand() & 1) ? tiletype_material::GRASS_LIGHT : tiletype_material::GRASS_DARK; |
| 379 | auto new_tt = findTileType(shape, new_mat, tiletype_variant::NONE, tiletype_special::NONE, nullptr); |
| 380 | DEBUG(log, out).print("Tiletype to {}.\n", ENUM_KEY_STR(tiletype, new_tt)); |
| 381 | block->tiletype[tx][ty] = new_tt; |
| 382 | } |
| 383 | return 1; |
| 384 | } |
| 385 | |
| 386 | int regrass_cuboid(color_ostream &out, const regrass_options &options, const cuboid &bounds) |
| 387 | { // Regrass all tiles in the defined cuboid. |
no test coverage detected