| 1123 | } |
| 1124 | |
| 1125 | command_result executePaintJob(color_ostream &out, |
| 1126 | const tiletypes_options &opts) |
| 1127 | { |
| 1128 | if (paint.empty()) |
| 1129 | { |
| 1130 | out.printerr("Set the paint first.\n"); |
| 1131 | return CR_OK; |
| 1132 | } |
| 1133 | |
| 1134 | if (!Maps::IsValid()) |
| 1135 | { |
| 1136 | out.printerr("Map is not available!\n"); |
| 1137 | return CR_FAILURE; |
| 1138 | } |
| 1139 | |
| 1140 | uint32_t x_max = 0, y_max = 0, z_max = 0; |
| 1141 | Maps::getSize(x_max, y_max, z_max); |
| 1142 | |
| 1143 | df::coord cursor; |
| 1144 | if (Maps::isValidTilePos(opts.cursor)) |
| 1145 | { |
| 1146 | cursor = opts.cursor; |
| 1147 | } |
| 1148 | else |
| 1149 | { |
| 1150 | cursor = Gui::getCursorPos(); |
| 1151 | if (!cursor.isValid()) |
| 1152 | { |
| 1153 | out.printerr("Can't get cursor coords! Make sure you have a cursor active in DF or specify the --cursor option.\n"); |
| 1154 | return CR_FAILURE; |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | if (!opts.quiet) |
| 1159 | out.print("Cursor coords: ({}, {}, {})\n", |
| 1160 | cursor.x, cursor.y, cursor.z); |
| 1161 | |
| 1162 | MapExtras::MapCache map; |
| 1163 | coord_vec all_tiles = brush->points(map, cursor); |
| 1164 | if (!opts.quiet) |
| 1165 | out.print("working...\n"); |
| 1166 | |
| 1167 | int failures = 0; |
| 1168 | std::vector<PaintResult> paintResults = std::vector<PaintResult>(); |
| 1169 | |
| 1170 | if (all_tiles.size() > 0) { |
| 1171 | if (dynamic_cast<RectangleBrush*>(brush) != nullptr || dynamic_cast<BlockBrush*>(brush) != nullptr || dynamic_cast<ColumnBrush*>(brush) != nullptr) { |
| 1172 | df::coord minPos = all_tiles[0]; |
| 1173 | df::coord maxPos = all_tiles[0]; |
| 1174 | for (df::coord& tile : all_tiles) { |
| 1175 | minPos.x = std::min(minPos.x, tile.x); |
| 1176 | minPos.y = std::min(minPos.y, tile.y); |
| 1177 | minPos.z = std::min(minPos.z, tile.z); |
| 1178 | maxPos.x = std::max(maxPos.x, tile.x); |
| 1179 | maxPos.y = std::max(maxPos.y, tile.y); |
| 1180 | maxPos.z = std::max(maxPos.z, tile.z); |
| 1181 | } |
| 1182 | PaintResult result = paintArea(map, minPos, maxPos, paint, filter); |
no test coverage detected