Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/generator/height_map.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Macros | Functions | Variables
height_map.c File Reference
`#include "rand.h"`
`#include "map.h"`
`#include "mapgen_topology.h"`
`#include "mapgen_utils.h"`
`#include "height_map.h"`

Go to the source code of this file.

## Macros

#define | set_midpoints(X, Y, V)

## Functions

static float | hmap_pole_factor (struct tile *ptile)
void | normalize_hmap_poles (void)
void | renormalize_hmap_poles (void)
void | make_random_hmap (int smooth)
static void | gen5rec (int step, int xl, int yt, int xr, int yb)
void | make_pseudofractal1_hmap (int extra_div)
bool | area_is_too_flat (struct tile *ptile, int thill, int my_height)

## Variables

int * | height_map = NULL
int | hmap_shore_level = 0
int | hmap_mountain_level = 0

## Macro Definition Documentation

## ◆ set_midpoints

#define set_midpoints | ( |  | X,
|  |  | Y,
|  |  | V
| ) |  |

Value:
{ \
struct tile *ptile = native_pos_to_tile(&(wld.map), (X), (Y)); \
if (map_colatitude(ptile) <= ICE_BASE_LEVEL / 2) { \
/* possibly flatten poles, or possibly not (even at map edge) */ \
hmap(ptile) = (V) * (100 - wld.map.server.flatpoles) / 100; \
} else if (near_singularity(ptile) \
|| hmap(ptile) != 0) { \
/* do nothing */ \
} else { \
hmap(ptile) = (V); \
} \
}
wld
struct world wld
Definition game.c:58
hmap
#define hmap(_tile)
Definition height_map.h:17
native_pos_to_tile
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Definition map.c:441
map_colatitude
int map_colatitude(const struct tile *ptile)
Definition mapgen_topology.c:38
near_singularity
bool near_singularity(const struct tile *ptile)
Definition mapgen_topology.c:205
ICE_BASE_LEVEL
#define ICE_BASE_LEVEL
Definition mapgen_topology.h:49
civ_map::server
struct civ_map::@41::@43 server
civ_map::flatpoles
int flatpoles
Definition map_types.h:99
tile
Definition tile.h:49
world::map
struct civ_map map
Definition world_object.h:38

## Function Documentation

## ◆ area_is_too_flat()

bool area_is_too_flat | ( | struct tile * | ptile,
|  | int | thill,
|  | int | my_height
| ) |  |

We don't want huge areas of grass/plains, so we put in a hill here and there, where it gets too 'clean'

Return TRUE if the terrain around the given map position is "clean". This means that all the terrain for 2 squares around it is not mountain or hill.

Definition at line 269 of file height_map.c.

Referenced by make_fracture_relief(), and make_relief().

## ◆ gen5rec()

static void gen5rec | ( | int | step,
|  | int | xl,
|  | int | yt,
|  | int | xr,
|  | int | yb
| ) |  |

static

Recursive function which does the work for generator 5.

All (x0,y0) and (x1,y1) are in native coordinates.

Definition at line 119 of file height_map.c.

Referenced by gen5rec(), and make_pseudofractal1_hmap().

## ◆ hmap_pole_factor()

static float hmap_pole_factor | ( | struct tile * | ptile | ) |

static

Factor by which to lower height map near poles in normalize_hmap_poles

Definition at line 35 of file height_map.c.

Referenced by normalize_hmap_poles(), and renormalize_hmap_poles().

## ◆ make_pseudofractal1_hmap()

void make_pseudofractal1_hmap | ( | int | extra_div | ) |

Generator 5 makes earthlike worlds with one or more large continents and a scattering of smaller islands. It does so by dividing the world into blocks and on each block raising or lowering the corners, then the midpoints and middle and so on recursively. Fiddling with 'xdiv' and 'ydiv' will change the size of the initial blocks and, if the map does not wrap in at least one direction, fiddling with 'avoidedge' will change the likelihood of continents butting up to non-wrapped edges.

All X and Y values used in this function are in native coordinates.

extra_div can be increased to break the world up into more, smaller islands. This is used in conjunction with the startpos setting.

Definition at line 197 of file height_map.c.

Referenced by map_fractal_generate().

## ◆ make_random_hmap()

void make_random_hmap | ( | int | smooth | ) |

Create uncorrelated rand map and do some call to smoth to correlate it a little and create random shapes

Definition at line 100 of file height_map.c.

Referenced by map_fractal_generate().

## ◆ normalize_hmap_poles()

void normalize_hmap_poles | ( | void |  | ) |

Lower the land near the map edges and (optionally) the polar region to avoid too much land there.

See also renormalize_hmap_poles

Definition at line 64 of file height_map.c.

Referenced by make_land().

## ◆ renormalize_hmap_poles()

void renormalize_hmap_poles | ( | void |  | ) |

Invert (most of) the effects of normalize_hmap_poles so that we have accurate heights for texturing the poles.

Definition at line 80 of file height_map.c.

Referenced by make_land().

## Variable Documentation

## ◆ height_map

int* height_map = NULL

Definition at line 29 of file height_map.c.

Referenced by create_island(), initworld(), make_fracture_map(), make_pseudofractal1_hmap(), make_random_hmap(), map_fractal_generate(), mapgenerator2(), mapgenerator3(), and mapgenerator4().

## ◆ hmap_mountain_level

int hmap_mountain_level = 0

Definition at line 30 of file height_map.c.

## ◆ hmap_shore_level

int hmap_shore_level = 0

Definition at line 30 of file height_map.c.

Referenced by area_is_too_flat(), create_tmap(), make_fracture_map(), make_fracture_relief(), make_land(), and make_relief().