engine/maps/source/MapUtils.cpp
// Add the tile and its connected tiles to the Component.
Add the tile and its connected tiles to the Component.
Add the tile and its connected tiles to the Component .
void MapUtils::add_connected_tiles_to_component(MapPtr map, const Coordinate& coord, const Dimensions& dim, const set<TileType>& exclusion_tiles, Component* component)
{
  int row = coord.first;
  int col = coord.second;
  TilePtr tile2 = map->at(row, col);
  if (exclusion_tiles.find(tile2->get_tile_type()) == exclusion_tiles.end())
  {
    component->insert(coord);
    vector<Coordinate> adjacent_coordinates = CoordUtils::get_adjacent_map_coordinates(dim, row, col);
    for (vector<Coordinate>::const_iterator c_it = adjacent_coordinates.begin(); c_it != adjacent_coordinates.end(); c_it++)
    {
      Coordinate adjacent_coord = *c_it;
      if (component->find(adjacent_coord) == component->end())
      {
        TilePtr tile = map->at(row, col);
        if (exclusion_tiles.find(tile->get_tile_type()) == exclusion_tiles.end())
        {
          add_connected_tiles_to_component(map, adjacent_coord, dim, exclusion_tiles, component);
        }
      }
    }
  }
}
void MapUtils :: add_connected_tiles_to_component ( MapPtr map , const Coordinate & coord , const Dimensions & dim , const set < TileType > & exclusion_tiles , Component * component ) { int row = coord . first ; int col = coord . second ; TilePtr tile2 = map -> at ( row , col ) ; if ( exclusion_tiles . find ( tile2 -> get_tile_type ( ) ) == exclusion_tiles . end ( ) ) { component -> insert ( coord ) ; vector < Coordinate > adjacent_coordinates = CoordUtils :: get_adjacent_map_coordinates ( dim , row , col ) ; for ( vector < Coordinate > :: const_iterator c_it = adjacent_coordinates . begin ( ) ; c_it != adjacent_coordinates . end ( ) ; c_it ++ ) { Coordinate adjacent_coord = * c_it ; if ( component -> find ( adjacent_coord ) == component -> end ( ) ) { TilePtr tile = map -> at ( row , col ) ; if ( exclusion_tiles . find ( tile -> get_tile_type ( ) ) == exclusion_tiles . end ( ) ) { add_connected_tiles_to_component ( map , adjacent_coord , dim , exclusion_tiles , component ) ; } } } } }
Add the tile and its connected tiles to the Component.
Add the tile and its connected tiles to the Component .
// If the adjacent coordinate is not in the component, add it.