engine/maps/source/MapUtils.cpp
// Generate a list of map components.
// FIXME: Unit tests
Generate a list of map components.
FIXME: Unit tests
Generate a list of map components . FIXME : Unit tests
MapComponents MapUtils::get_map_components(MapPtr map, const set<TileType>& exclusion_tiles)
{
  MapComponents result;
  set<TileType>::const_iterator c_it;
  Dimensions dimensions = map->size();
  int height = dimensions.get_y();
  int width = dimensions.get_x();
  for (int y = 0; y < height; y++)
  {
    for (int x = 0; x < width; x++)
    {
      Coordinate current_tile_pair = make_pair(y, x);
      TilePtr current_tile = map->at(y, x);
      c_it = exclusion_tiles.find(current_tile->get_tile_type());
      if (c_it == exclusion_tiles.end())
      {
        if (!is_tile_contained_in_an_existing_component(current_tile_pair, result))
        {
          Component component;
          add_connected_tiles_to_component(map, current_tile_pair, dimensions, exclusion_tiles, &component);
          result.push_back(component);
        }
      }
    }
  }
  return result;
}
MapComponents MapUtils :: get_map_components ( MapPtr map , const set < TileType > & exclusion_tiles ) { MapComponents result ; set < TileType > :: const_iterator c_it ; Dimensions dimensions = map -> size ( ) ; int height = dimensions . get_y ( ) ; int width = dimensions . get_x ( ) ; for ( int y = 0 ; y < height ; y ++ ) { for ( int x = 0 ; x < width ; x ++ ) { Coordinate current_tile_pair = make_pair ( y , x ) ; TilePtr current_tile = map -> at ( y , x ) ; c_it = exclusion_tiles . find ( current_tile -> get_tile_type ( ) ) ; if ( c_it == exclusion_tiles . end ( ) ) { if ( ! is_tile_contained_in_an_existing_component ( current_tile_pair , result ) ) { Component component ; add_connected_tiles_to_component ( map , current_tile_pair , dimensions , exclusion_tiles , & component ) ; result . push_back ( component ) ; } } } } return result ; }
Generate a list of map components.
Generate a list of map components .
// Is it a rock tile?  If so, ignore, and check in // existing sets.