MCPcopy Create free account
hub / github.com/DFHack/dfhack / executePaintJob

Function executePaintJob

plugins/tiletypes.cpp:1125–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1123}
1124
1125command_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);

Callers 3

processCommandFunction · 0.85
df_tiletypes_hereFunction · 0.85
df_tiletypes_here_pointFunction · 0.85

Calls 11

isValidTilePosFunction · 0.85
paintAreaFunction · 0.85
paintTileFunction · 0.85
WriteAllMethod · 0.80
emptyMethod · 0.45
isValidMethod · 0.45
printMethod · 0.45
pointsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected