returns whether blueprint generation was successful. populates files with the names of the files that were generated
| 1658 | // returns whether blueprint generation was successful. populates files with the |
| 1659 | // names of the files that were generated |
| 1660 | static command_result do_blueprint(color_ostream &out, |
| 1661 | const vector<string> ¶meters, |
| 1662 | vector<string> &files) { |
| 1663 | if (parameters.size() >= 1 && parameters[0] == "gui") { |
| 1664 | ostringstream command; |
| 1665 | command << "gui/blueprint"; |
| 1666 | for (size_t i = 1; i < parameters.size(); ++i) { |
| 1667 | command << " " << parameters[i]; |
| 1668 | } |
| 1669 | string command_str = command.str(); |
| 1670 | out.print("launching {}\n", command_str); |
| 1671 | |
| 1672 | Core::getInstance().getHotkeyManager()->setHotkeyCommand(command_str); |
| 1673 | return CR_OK; |
| 1674 | } |
| 1675 | |
| 1676 | blueprint_options options; |
| 1677 | if (!Lua::CallLuaModuleFunction(out, "plugins.blueprint", "parse_commandline", std::make_tuple(&options, parameters)) |
| 1678 | || options.help) |
| 1679 | { |
| 1680 | return CR_WRONG_USAGE; |
| 1681 | } |
| 1682 | |
| 1683 | if (!Maps::IsValid()) { |
| 1684 | out.printerr("Map is not available!\n"); |
| 1685 | return CR_FAILURE; |
| 1686 | } |
| 1687 | |
| 1688 | // start coordinates can come from either the commandline or the map cursor |
| 1689 | df::coord start(options.start); |
| 1690 | if (!start.isValid()) { |
| 1691 | if (!Gui::getCursorCoords(start)) { |
| 1692 | out.printerr("Can't get cursor coords! Make sure you specify the" |
| 1693 | " --cursor parameter or have an active cursor in DF.\n"); |
| 1694 | return CR_FAILURE; |
| 1695 | } |
| 1696 | } |
| 1697 | if (!Maps::isValidTilePos(start)) { |
| 1698 | out.printerr("Invalid start position: {},{},{},\n", |
| 1699 | start.x, start.y, start.z); |
| 1700 | return CR_FAILURE; |
| 1701 | } |
| 1702 | |
| 1703 | // end coords are one beyond the last processed coordinate. note that |
| 1704 | // options.depth can be negative. |
| 1705 | df::coord end(start.x + options.width, start.y + options.height, |
| 1706 | start.z + options.depth); |
| 1707 | |
| 1708 | // crop end coordinate to map bounds. we've already verified that start is |
| 1709 | // a valid coordinate, and width, height, and depth are non-zero, so our |
| 1710 | // final area is always going to be at least 1x1x1. |
| 1711 | df::world::T_map &map = df::global::world->map; |
| 1712 | if (end.x > map.x_count) |
| 1713 | end.x = map.x_count; |
| 1714 | if (end.y > map.y_count) |
| 1715 | end.y = map.y_count; |
| 1716 | if (end.z > map.z_count) |
| 1717 | end.z = map.z_count; |
no test coverage detected