| 1551 | } |
| 1552 | |
| 1553 | static bool do_transform(color_ostream &out, |
| 1554 | const df::coord &start, const df::coord &end, |
| 1555 | blueprint_options opts, // copy so we can munge it |
| 1556 | vector<string> &filenames) { |
| 1557 | // empty map instances to pass to emplace() below |
| 1558 | static const bp_area EMPTY_AREA; |
| 1559 | static const bp_row EMPTY_ROW; |
| 1560 | |
| 1561 | init_caches(out, opts.engrave); |
| 1562 | |
| 1563 | vector<blueprint_processor> processors; |
| 1564 | |
| 1565 | get_tile_fn* smooth_get_tile_fn = get_tile_smooth_minimal; |
| 1566 | if (opts.engrave) smooth_get_tile_fn = get_tile_smooth_with_engravings; |
| 1567 | if (opts.smooth) smooth_get_tile_fn = get_tile_smooth_all; |
| 1568 | |
| 1569 | add_processor(processors, opts, "dig", "dig", opts.dig, get_tile_dig); |
| 1570 | add_processor(processors, opts, "dig", "smooth", opts.carve, |
| 1571 | smooth_get_tile_fn); |
| 1572 | add_processor(processors, opts, "dig", "carve", opts.carve, |
| 1573 | opts.engrave ? get_tile_carve : get_tile_carve_minimal); |
| 1574 | add_processor(processors, opts, "build", "construct", opts.construct, |
| 1575 | get_tile_construct, ensure_building); |
| 1576 | add_processor(processors, opts, "build", "build", opts.build, |
| 1577 | get_tile_build, ensure_building); |
| 1578 | add_processor(processors, opts, "place", "place", opts.place, |
| 1579 | get_tile_place, ensure_building); |
| 1580 | add_processor(processors, opts, "zone", "zone", opts.zone, get_tile_zone); |
| 1581 | if (processors.empty()) { |
| 1582 | out.printerr("no phases requested! nothing to do!\n"); |
| 1583 | return false; |
| 1584 | } |
| 1585 | |
| 1586 | if (!create_output_dir(out, opts)) |
| 1587 | return false; |
| 1588 | |
| 1589 | const bool pretty = opts.format != "minimal"; |
| 1590 | const int32_t z_inc = start.z < end.z ? 1 : -1; |
| 1591 | for (int32_t z = start.z; z != end.z; z += z_inc) { |
| 1592 | for (int32_t y = start.y; y < end.y; y++) { |
| 1593 | for (int32_t x = start.x; x < end.x; x++) { |
| 1594 | df::coord pos(x, y, z); |
| 1595 | tile_context ctx; |
| 1596 | ctx.pretty = pretty; |
| 1597 | for (blueprint_processor &processor : processors) { |
| 1598 | ctx.processor = &processor; |
| 1599 | if (processor.init_ctx) |
| 1600 | processor.init_ctx(pos, ctx); |
| 1601 | const char *tile_str = processor.get_tile(out, pos, ctx); |
| 1602 | if (tile_str) { |
| 1603 | // ensure our z-index is in the order we want to write |
| 1604 | auto area = processor.mapdata.emplace(abs(z - start.z), |
| 1605 | EMPTY_AREA); |
| 1606 | auto row = area.first->second.emplace(y - start.y, |
| 1607 | EMPTY_ROW); |
| 1608 | auto &tiles = row.first->second; |
| 1609 | if (row.second) |
| 1610 | tiles.resize(opts.width); |
no test coverage detected