Defines | Typedefs | Functions | Variables

mapgen.cpp File Reference

Map-generator, with standalone testprogram. More...

#include "global.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "language.hpp"
#include "log.hpp"
#include "map.hpp"
#include "mapgen.hpp"
#include "pathfind/pathfind.hpp"
#include "pathutils.hpp"
#include "race.hpp"
#include "util.hpp"
#include "wml_exception.hpp"
#include "formula_string_utils.hpp"
#include "SDL.h"
Include dependency graph for mapgen.cpp:

Go to the source code of this file.

Defines

#define ERR_NG   LOG_STREAM(err, log_engine)
#define LOG_NG   LOG_STREAM(info, log_engine)

Typedefs

typedef std::vector
< std::vector< int > > 
height_map
typedef t_translation::t_map terrain_map
typedef map_location location
typedef std::map
< t_translation::t_terrain,
t_translation::t_list
tcode_list_cache

Functions

static height_map generate_height_map (size_t width, size_t height, size_t iterations, size_t hill_size, size_t island_size, size_t island_off_center)
 Generate a height-map.
static bool generate_lake (terrain_map &terrain, int x, int y, int lake_fall_off, std::set< location > &locs_touched)
 Generate a lake.
static bool generate_river_internal (const height_map &heights, terrain_map &terrain, int x, int y, std::vector< location > &river, std::set< location > &seen_locations, int river_uphill)
 River generation.
static std::vector< locationgenerate_river (const height_map &heights, terrain_map &terrain, int x, int y, int river_uphill)
static location random_point_at_side (size_t width, size_t height)
 Returns a random tile at one of the borders of a map that is of the given dimensions.
static std::string output_map (const terrain_map &terrain, std::map< int, t_translation::coordinate > starting_positions)
 Function which, given the map will output it in a valid format.
static int rank_castle_location (int x, int y, const is_valid_terrain &valid_terrain, int min_x, int max_x, int min_y, int max_y, size_t min_distance, const std::vector< map_location > &other_castles, int highest_ranking)
static map_location place_village (const t_translation::t_map &map, const size_t x, const size_t y, const size_t radius, const config &cfg, tcode_list_cache &adj_liked_cache)
static std::string generate_name (const unit_race &name_generator, const std::string &id, std::string *base_name=NULL, utils::string_map *additional_symbols=NULL)
static void flood_name (const map_location &start, const std::string &name, std::map< map_location, std::string > &tile_names, const t_translation::t_match &tile_types, const terrain_map &terrain, unsigned width, unsigned height, size_t label_count, std::map< map_location, std::string > *labels, const std::string &full_name)
std::string default_generate_map (size_t width, size_t height, size_t island_size, size_t island_off_center, size_t iterations, size_t hill_size, size_t max_lakes, size_t nvillages, size_t castle_size, size_t nplayers, bool roads_between_castles, std::map< map_location, std::string > *labels, const config &cfg)
 Generate the map.

Variables

static lg::log_domain log_engine ("engine")

Detailed Description

Map-generator, with standalone testprogram.

Definition in file mapgen.cpp.


Define Documentation

#define ERR_NG   LOG_STREAM(err, log_engine)

Definition at line 39 of file mapgen.cpp.

Referenced by default_generate_map().

#define LOG_NG   LOG_STREAM(info, log_engine)

Typedef Documentation

typedef std::vector<std::vector<int> > height_map

Definition at line 49 of file mapgen.cpp.

Definition at line 52 of file mapgen.cpp.

Definition at line 531 of file mapgen.cpp.

Definition at line 50 of file mapgen.cpp.


Function Documentation

std::string default_generate_map ( size_t  width,
size_t  height,
size_t  island_size,
size_t  island_off_center,
size_t  iterations,
size_t  hill_size,
size_t  max_lakes,
size_t  nvillages,
size_t  castle_size,
size_t  nplayers,
bool  roads_between_castles,
std::map< map_location, std::string > *  labels,
const config cfg 
)
static void flood_name ( const map_location start,
const std::string &  name,
std::map< map_location, std::string > &  tile_names,
const t_translation::t_match tile_types,
const terrain_map terrain,
unsigned  width,
unsigned  height,
size_t  label_count,
std::map< map_location, std::string > *  labels,
const std::string &  full_name 
) [static]

Definition at line 619 of file mapgen.cpp.

References get_adjacent_tiles(), t_translation::terrain_matches(), and map_location::x.

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static height_map generate_height_map ( size_t  width,
size_t  height,
size_t  iterations,
size_t  hill_size,
size_t  island_size,
size_t  island_off_center 
) [static]

Generate a height-map.

Basically we generate a lot of hills, each hill being centered at a certain point, with a certain radius - being a half sphere. Hills are combined additively to form a bumpy surface. The size of each hill varies randomly from 1-hill_size. We generate 'iterations' hills in total. The range of heights is normalized to 0-1000. 'island_size' controls whether or not the map should tend toward an island shape, and if so, how large the island should be. Hills with centers that are more than 'island_size' away from the center of the map will be inverted (i.e. be valleys). 'island_size' as 0 indicates no island.

Definition at line 67 of file mapgen.cpp.

References LOG_NG.

Referenced by default_generate_map().

Here is the caller graph for this function:

static bool generate_lake ( terrain_map terrain,
int  x,
int  y,
int  lake_fall_off,
std::set< location > &  locs_touched 
) [static]

Generate a lake.

It will create water at (x,y), and then have 'lake_fall_off' % chance to make another water tile in each of the directions n,s,e,w. In each of the directions it does make another water tile, it will have 'lake_fall_off'/2 % chance to make another water tile in each of the directions. This will continue recursively.

Definition at line 193 of file mapgen.cpp.

References t_translation::SHALLOW_WATER.

Referenced by default_generate_map().

Here is the caller graph for this function:

static std::string generate_name ( const unit_race name_generator,
const std::string &  id,
std::string *  base_name = NULL,
utils::string_map additional_symbols = NULL 
) [static]

Definition at line 588 of file mapgen.cpp.

References unit_race::generate_name(), utils::interpolate_variables_into_string(), LOG_NG, unit_race::MALE, utils::split(), and string_table.

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static std::vector<location> generate_river ( const height_map heights,
terrain_map terrain,
int  x,
int  y,
int  river_uphill 
) [static]

Definition at line 294 of file mapgen.cpp.

References generate_river_internal().

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static bool generate_river_internal ( const height_map heights,
terrain_map terrain,
int  x,
int  y,
std::vector< location > &  river,
std::set< location > &  seen_locations,
int  river_uphill 
) [static]

River generation.

Rivers have a source, and then keep on flowing until they meet another body of water, which they flow into, or until they reach the edge of the map. Rivers will always flow downhill, except that they can flow a maximum of 'river_uphill' uphill. This is to represent the water eroding the higher ground lower.

Every possible path for a river will be attempted, in random order, and the first river path that can be found that makes the river flow into another body of water or off the map will be used.

If no path can be found, then the river's generation will be aborted, and false will be returned. true is returned if the river is generated successfully.

Definition at line 238 of file mapgen.cpp.

References t_translation::DEEP_WATER, get_adjacent_tiles(), LOG_NG, t_translation::SHALLOW_WATER, map_location::x, and map_location::y.

Referenced by generate_river().

Here is the call graph for this function:

Here is the caller graph for this function:

static std::string output_map ( const terrain_map terrain,
std::map< int, t_translation::coordinate starting_positions 
) [static]

Function which, given the map will output it in a valid format.

Definition at line 325 of file mapgen.cpp.

References gamemap::default_border, and t_translation::write_game_map().

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static map_location place_village ( const t_translation::t_map map,
const size_t  x,
const size_t  y,
const size_t  radius,
const config cfg,
tcode_list_cache adj_liked_cache 
) [static]

Definition at line 533 of file mapgen.cpp.

References preferences::editor::TransitionUpdateMode::count, config::find_child(), get_adjacent_tiles(), get_tiles_radius(), t_translation::read_list(), t_translation::write_terrain_code(), map_location::x, and map_location::y.

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static location random_point_at_side ( size_t  width,
size_t  height 
) [static]

Returns a random tile at one of the borders of a map that is of the given dimensions.

Definition at line 310 of file mapgen.cpp.

Referenced by default_generate_map().

Here is the caller graph for this function:

static int rank_castle_location ( int  x,
int  y,
const is_valid_terrain &  valid_terrain,
int  min_x,
int  max_x,
int  min_y,
int  max_y,
size_t  min_distance,
const std::vector< map_location > &  other_castles,
int  highest_ranking 
) [static]

Definition at line 466 of file mapgen.cpp.

References gui2::distance(), and distance_between().

Referenced by default_generate_map().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

lg::log_domain log_engine("engine") [static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:08:31 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs