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

Function dig

plugins/dig.cpp:490–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488};
489
490bool dig (MapExtras::MapCache & MCache,
491 circle_what what,
492 df::tile_dig_designation type,
493 int32_t priority,
494 int32_t x, int32_t y, int32_t z,
495 int x_max, int y_max
496 )
497{
498 DFCoord at (x,y,z);
499 auto b = MCache.BlockAt(at/16);
500 if(!b || !b->is_valid())
501 return false;
502 if(x == 0 || x == x_max * 16 - 1)
503 {
504 //out.print("not digging map border\n");
505 return false;
506 }
507 if(y == 0 || y == y_max * 16 - 1)
508 {
509 //out.print("not digging map border\n");
510 return false;
511 }
512 df::tiletype tt = MCache.tiletypeAt(at);
513 df::tile_designation des = MCache.designationAt(at);
514 // could be potentially used to locate hidden constructions?
515 if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
516 return false;
517 df::tiletype_shape ts = tileShape(tt);
518 if (ts == tiletype_shape::EMPTY && !des.bits.hidden)
519 return false;
520 if(!des.bits.hidden)
521 {
522 do
523 {
524 df::tiletype_shape_basic tsb = ENUM_ATTR(tiletype_shape, basic_shape, ts);
525 if(tsb == tiletype_shape_basic::Wall)
526 {
527 //std::cerr << "allowing tt" << (int)tt << ", is wall\n";
528 break;
529 }
530 if (tsb == tiletype_shape_basic::Floor
531 && (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel)
532 && ts != tiletype_shape::BRANCH
533 && ts != tiletype_shape::TRUNK_BRANCH
534 && ts != tiletype_shape::TWIG
535 )
536 {
537 //std::cerr << "allowing tt" << (int)tt << ", is floor\n";
538 break;
539 }
540 if (tsb == tiletype_shape_basic::Stair && type == tile_dig_designation::Channel )
541 break;
542 return false;
543 }
544 while(0);
545 }
546 switch(what)
547 {

Callers 3

lineXFunction · 0.85
lineYFunction · 0.85
digcircleFunction · 0.85

Calls 5

tileMaterialFunction · 0.85
tileShapeFunction · 0.85
BlockAtMethod · 0.80
tiletypeAtMethod · 0.80
setDesignationAtMethod · 0.80

Tested by

no test coverage detected