MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / tilesBorderedByRegion

Method tilesBorderedByRegion

source/gamemap/TileContainer.cpp:609–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609std::vector<Tile*> TileContainer::tilesBorderedByRegion(const std::vector<Tile*> &region)
610{
611 std::vector<Tile*> returnList;
612
613 std::vector<std::vector<bool>> tilesToRefresh(getMapSizeX(), std::vector<bool>(getMapSizeY(), false));
614 for (Tile* t1 : region)
615 {
616 if(!tilesToRefresh[t1->getX()][t1->getY()])
617 {
618 tilesToRefresh[t1->getX()][t1->getY()] = true;
619 returnList.push_back(t1);
620 }
621
622 // Get the tiles bordering the current tile and loop over them.
623 for (Tile* t2 : t1->getAllNeighbors())
624 {
625 if(tilesToRefresh[t2->getX()][t2->getY()])
626 continue;
627
628 tilesToRefresh[t2->getX()][t2->getY()] = true;
629 returnList.push_back(t2);
630 }
631 }
632
633 return returnList;
634}
635
636const std::vector<Tile*>& TileContainer::neighborTiles(int x, int y) const
637{

Callers 1

Calls 2

getXMethod · 0.45
getYMethod · 0.45

Tested by

no test coverage detected