| 1424 | } |
| 1425 | |
| 1426 | command_result digv (color_ostream &out, vector <string> & parameters) |
| 1427 | { |
| 1428 | uint32_t x_max,y_max,z_max; |
| 1429 | bool updown = false; |
| 1430 | int32_t priority = parse_priority(out, parameters); |
| 1431 | |
| 1432 | for(size_t i = 0; i < parameters.size();i++) |
| 1433 | { |
| 1434 | if(parameters.size() && parameters[0]=="x") |
| 1435 | updown = true; |
| 1436 | else |
| 1437 | return CR_WRONG_USAGE; |
| 1438 | } |
| 1439 | |
| 1440 | auto &con = out; |
| 1441 | |
| 1442 | if (!Maps::IsValid()) |
| 1443 | { |
| 1444 | out.printerr("Map is not available!\n"); |
| 1445 | return CR_FAILURE; |
| 1446 | } |
| 1447 | |
| 1448 | int32_t cx, cy, cz; |
| 1449 | Maps::getSize(x_max,y_max,z_max); |
| 1450 | uint32_t tx_max = x_max * 16; |
| 1451 | uint32_t ty_max = y_max * 16; |
| 1452 | Gui::getCursorCoords(cx,cy,cz); |
| 1453 | while(cx == -30000) |
| 1454 | { |
| 1455 | con.printerr("Cursor is not active. Point the cursor at a vein.\n"); |
| 1456 | return CR_FAILURE; |
| 1457 | } |
| 1458 | DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); |
| 1459 | if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1) |
| 1460 | { |
| 1461 | con.printerr("I won't dig the borders. That would be cheating!\n"); |
| 1462 | return CR_FAILURE; |
| 1463 | } |
| 1464 | std::unique_ptr<MapExtras::MapCache> MCache = std::make_unique<MapExtras::MapCache>(); |
| 1465 | df::tile_designation des = MCache->designationAt(xy); |
| 1466 | df::tiletype tt = MCache->tiletypeAt(xy); |
| 1467 | int16_t veinmat = MCache->veinMaterialAt(xy); |
| 1468 | if( veinmat == -1 ) |
| 1469 | { |
| 1470 | con.printerr("This tile is not a vein.\n"); |
| 1471 | return CR_FAILURE; |
| 1472 | } |
| 1473 | con.print("{} tiletype: {}, veinmat: {}, designation: 0x{:x} ... DIGGING!\n", xy, ENUM_AS_STR(tt), veinmat, des.whole); |
| 1474 | stack <DFHack::DFCoord> flood; |
| 1475 | flood.push(xy); |
| 1476 | |
| 1477 | while( !flood.empty() ) |
| 1478 | { |
| 1479 | DFHack::DFCoord current = flood.top(); |
| 1480 | flood.pop(); |
| 1481 | if (MCache->tagAt(current)) |
| 1482 | continue; |
| 1483 | int16_t vmat2 = MCache->veinMaterialAt(current); |
no test coverage detected