engine/generators/fortresses/source/MotteBaileyCastleGeneratorStrategy.cpp
// Generate a land bridge over the moat.
Generate a land bridge over the moat.
Generate a land bridge over the moat .
void MotteBaileyCastleGeneratorStrategy::generate_bridge(MapPtr castle_map, const int start_y, const int start_x, const int end_y, const int end_x)
{
  Coordinate a = make_pair(start_y, start_x);
  Coordinate b = make_pair(end_y, end_x);
  map<CardinalDirection, Coordinate> bridge_coords = CoordUtils::get_midway_coordinates(a, b);
  auto b_it = bridge_coords.begin();
  std::advance(b_it, RNG::range(0, bridge_coords.size() - 1));
  Coordinate c = b_it->second;
  TilePtr bridge_tile = castle_map->at(c);
  TileGenerator tg;
  if (bridge_tile != nullptr)
  {
    bridge_tile = tg.generate(TileType::TILE_TYPE_ROAD);
    castle_map->insert(c.first, c.second, bridge_tile);
  }
}
void MotteBaileyCastleGeneratorStrategy :: generate_bridge ( MapPtr castle_map , const int start_y , const int start_x , const int end_y , const int end_x ) { Coordinate a = make_pair ( start_y , start_x ) ; Coordinate b = make_pair ( end_y , end_x ) ; map < CardinalDirection , Coordinate > bridge_coords = CoordUtils :: get_midway_coordinates ( a , b ) ; auto b_it = bridge_coords . begin ( ) ; std :: advance ( b_it , RNG :: range ( 0 , bridge_coords . size ( ) - 1 ) ) ; Coordinate c = b_it -> second ; TilePtr bridge_tile = castle_map -> at ( c ) ; TileGenerator tg ; if ( bridge_tile != nullptr ) { bridge_tile = tg . generate ( TileType :: TILE_TYPE_ROAD ) ; castle_map -> insert ( c . first , c . second , bridge_tile ) ; } }
Generate a land bridge over the moat.
Generate a land bridge over the moat .