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

Function getEdgeSet

plugins/diggingInvaders/edgeCost.cpp:456–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454*/
455
456vector<Edge>* getEdgeSet(color_ostream &out, df::coord point, MapExtras::MapCache& cache, int32_t xMax, int32_t yMax, int32_t zMax, DigAbilities& abilities) {
457 //vector<Edge>* result = new vector<Edge>(26);
458 vector<Edge>* result = new vector<Edge>();
459 result->reserve(26);
460
461 //size_t count = 0;
462 for ( int32_t dx = -1; dx <= 1; dx++ ) {
463 for ( int32_t dy = -1; dy <= 1; dy++ ) {
464 for ( int32_t dz = -1; dz <= 1; dz++ ) {
465 df::coord neighbor(point.x+dx, point.y+dy, point.z+dz);
466 if ( !Maps::isValidTilePos(neighbor) )
467 continue;
468 if ( dz != 0 && /*(point.x == 0 || point.y == 0 || point.z == 0 || point.x == xMax-1 || point.y == yMax-1 || point.z == zMax-1) ||*/ (neighbor.x == 0 || neighbor.y == 0 || neighbor.z == 0 || neighbor.x == xMax-1 || neighbor.y == yMax-1 || neighbor.z == zMax-1) )
469 continue;
470 if ( dx == 0 && dy == 0 && dz == 0 )
471 continue;
472 cost_t cost = getEdgeCost(out, point, neighbor, abilities);
473 if ( cost == -1 )
474 continue;
475 Edge edge(point, neighbor, cost);
476 //(*result)[count] = edge;
477 result->push_back(edge);
478 //count++;
479 }
480 }
481 }
482
483 return result;
484}

Callers 1

findAndAssignInvasionJobFunction · 0.85

Calls 3

isValidTilePosFunction · 0.85
getEdgeCostFunction · 0.85
reserveMethod · 0.80

Tested by

no test coverage detected