| 607 | } |
| 608 | |
| 609 | std::vector<Tile*> TileContainer::tilesBorderedByRegion(const std::vector<Tile*> ®ion) |
| 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 | |
| 636 | const std::vector<Tile*>& TileContainer::neighborTiles(int x, int y) const |
| 637 | { |
no test coverage detected