Freeciv-3.1
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
mapgen.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "maphand.h"
#include "mem.h"
#include "rand.h"
#include "shared.h"
#include "game.h"
#include "map.h"
#include "road.h"
#include "fracture_map.h"
#include "height_map.h"
#include "mapgen_topology.h"
#include "mapgen_utils.h"
#include "startpos.h"
#include "temperature_map.h"
#include "mapgen.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

struct  gen234_state
 
struct  terrain_select
 
struct  river_map
 
struct  DataFilter
 
struct  test_func
 
struct  fair_tile
 
struct  fair_geometry_data
 

Macros

#define SPECLIST_TAG   terrain_select
 
#define terrain_select_list_iterate(tersel_list, ptersel)    TYPED_LIST_ITERATE(struct terrain_select, tersel_list, ptersel)
 
#define terrain_select_list_iterate_end    LIST_ITERATE_END
 
#define RIVERS_MAXTRIES   32767
 
#define HAS_POLES   (wld.map.server.temperature < 70 && !wld.map.server.alltemperate)
 
#define map_pos_is_dry(ptile)
 
#define ini_hmap_low_level()
 
#define map_pos_is_low(ptile)   ((hmap((ptile)) < hmap_low_level))
 
#define PLACE_ONE_TYPE(count, alternate, ter, wc, tc, mc, weight)
 
#define NUM_TEST_FUNCTIONS   9
 
#define DMSIS   10
 
#define fair_do_iso_hex_symmetry2   fair_do_rotation
 

Typedefs

typedef void(* fair_geometry_func) (int *x, int *y)
 

Enumerations

enum  wetness_c { WC_ALL = 200 , WC_DRY , WC_NDRY }
 
enum  miscellaneous_c { MC_NONE , MC_LOW , MC_NLOW }
 
enum  fair_tile_flag {
  FTF_NONE = 0 , FTF_ASSIGNED = 1 << 0 , FTF_OCEAN = 1 << 1 , FTF_STARTPOS = 1 << 2 ,
  FTF_NO_RESOURCE = 1 << 3 , FTF_HAS_HUT = 1 << 4 , FTF_NO_HUT = 1 << 5
}
 

Functions

static void make_huts (int number)
 
static void add_resources (int prob)
 
static void mapgenerator2 (void)
 
static void mapgenerator3 (void)
 
static void mapgenerator4 (void)
 
static bool map_generate_fair_islands (void)
 
static void adjust_terrain_param (void)
 
static struct terrain_selecttersel_new (int weight, enum mapgen_terrain_property target, enum mapgen_terrain_property prefer, enum mapgen_terrain_property avoid, int temp_condition, int wet_condition)
 
static void tersel_free (struct terrain_select *ptersel)
 
static void island_terrain_init (void)
 
static void island_terrain_free (void)
 
static void fill_island (int coast, long int *bucket, const struct terrain_select_list *tersel_list, const struct gen234_state *const pstate)
 
static bool make_island (int islemass, int starters, struct gen234_state *pstate, int min_specific_island_size)
 
static int river_test_blocked (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_rivergrid (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_highlands (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_adjacent_ocean (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_adjacent_river (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_adjacent_highlands (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_swamp (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_adjacent_swamp (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static int river_test_height_map (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static void river_blockmark (struct river_map *privermap, struct tile *ptile)
 
static bool make_river (struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
 
static void make_rivers (void)
 
static void river_types_init (void)
 
static bool test_wetness (const struct tile *ptile, wetness_c c)
 
static bool test_miscellaneous (const struct tile *ptile, miscellaneous_c c)
 
static bool condition_filter (const struct tile *ptile, const void *data)
 
static struct tilerand_map_pos_characteristic (wetness_c wc, temperature_type tc, miscellaneous_c mc)
 
static bool terrain_is_too_high (struct tile *ptile, int thill, int my_height)
 
static void make_relief (void)
 
static void make_polar (void)
 
static bool ok_for_separate_poles (struct tile *ptile)
 
static void make_polar_land (void)
 
static void place_terrain (struct tile *ptile, int diff, struct terrain *pterrain, int *to_be_placed, wetness_c wc, temperature_type tc, miscellaneous_c mc)
 
static void make_plain (struct tile *ptile, int *to_be_placed)
 
static void make_plains (void)
 
static void make_terrains (void)
 
static void make_land (void)
 
static bool is_tiny_island (struct tile *ptile)
 
static void remove_tiny_islands (void)
 
static void print_mapgen_map (void)
 
bool map_fractal_generate (bool autosize, struct unit_type *initial_unit)
 
static bool near_safe_tiles (struct tile *ptile)
 
static bool is_resource_close (const struct tile *ptile)
 
static struct tileget_random_map_position_from_state (const struct gen234_state *const pstate)
 
static bool island_river_mouth_suitability (const struct tile *ptile, const struct extra_type *priver)
 
static bool island_river_suitability (const struct tile *ptile, const struct extra_type *priver)
 
static void fill_island_rivers (int coast, long int *bucket, const struct gen234_state *const pstate)
 
static bool is_near_land (struct tile *ptile)
 
static bool place_island (struct gen234_state *pstate)
 
static int count_card_adjc_elevated_tiles (struct tile *ptile)
 
static bool create_island (int islemass, struct gen234_state *pstate)
 
static void initworld (struct gen234_state *pstate)
 
static struct fair_tilefair_map_new (void)
 
static void fair_map_destroy (struct fair_tile *pmap)
 
static void fair_map_tile_pos (struct fair_tile *pmap, struct fair_tile *ptile, int *x, int *y)
 
static struct fair_tilefair_map_pos_tile (struct fair_tile *pmap, int x, int y)
 
static struct fair_tilefair_map_tile_step (struct fair_tile *pmap, struct fair_tile *ptile, enum direction8 dir)
 
static bool fair_map_tile_border (struct fair_tile *pmap, struct fair_tile *ptile, int dist)
 
static int fair_team_placement_closest (const void *a, const void *b)
 
static int fair_team_placement_horizontal (const void *a, const void *b)
 
static int fair_team_placement_vertical (const void *a, const void *b)
 
static void fair_do_symmetry1 (int *x, int *y)
 
static void fair_do_symmetry2 (int *x, int *y)
 
static void fair_do_hex_symmetry1 (int *x, int *y)
 
static void fair_do_hex_symmetry2 (int *x, int *y)
 
static void fair_do_iso_hex_symmetry1 (int *x, int *y)
 
static void fair_do_rotation (int *x, int *y)
 
static void fair_do_hex_rotation (int *x, int *y)
 
static void fair_do_iso_hex_rotation (int *x, int *y)
 
static void fair_do_geometry (const struct fair_geometry_data *data, int *x, int *y)
 
static void fair_geometry_rand (struct fair_geometry_data *data)
 
static bool fair_map_copy (struct fair_tile *ptarget, int tx, int ty, struct fair_tile *psource, const struct fair_geometry_data *data, int startpos_team_id)
 
static bool fair_map_place_island_rand (struct fair_tile *ptarget, struct fair_tile *psource)
 
static bool fair_map_place_island_team (struct fair_tile *ptarget, int tx, int ty, struct fair_tile *psource, const struct iter_index *outwards_indices, int startpos_team_id)
 
static void fair_map_make_resources (struct fair_tile *pmap)
 
static void fair_map_make_huts (struct fair_tile *pmap)
 
static struct fair_tilefair_map_island_new (int size, int startpos_num)
 

Variables

static struct extra_typeriver_types [MAX_EXTRA_TYPES]
 
static int river_type_count = 0
 
struct { 
 
   bool   init 
 
   struct terrain_select_list *   forest 
 
   struct terrain_select_list *   desert 
 
   struct terrain_select_list *   mountain 
 
   struct terrain_select_list *   swamp 
 
island_terrain = { .init = FALSE
 
static int forest_pct = 0
 
static int desert_pct = 0
 
static int swamp_pct = 0
 
static int mountain_pct = 0
 
static int jungle_pct = 0
 
static int river_pct = 0
 
static int hmap_low_level = 0
 
static struct test_func test_funcs [NUM_TEST_FUNCTIONS]
 
static long int checkmass
 

Macro Definition Documentation

◆ DMSIS

#define DMSIS   10

Definition at line 2236 of file mapgen.c.

◆ fair_do_iso_hex_symmetry2

#define fair_do_iso_hex_symmetry2   fair_do_rotation

Definition at line 2718 of file mapgen.c.

◆ HAS_POLES

#define HAS_POLES   (wld.map.server.temperature < 70 && !wld.map.server.alltemperate)

Definition at line 155 of file mapgen.c.

◆ ini_hmap_low_level

#define ini_hmap_low_level ( )
Value:
{ \
}
int hmap_shore_level
Definition height_map.c:30
#define hmap_max_level
Definition height_map.h:33
static int hmap_low_level
Definition mapgen.c:182
static int swamp_pct
Definition mapgen.c:161

Definition at line 183 of file mapgen.c.

◆ map_pos_is_dry

#define map_pos_is_dry (   ptile)
Value:
&& map_colatitude((ptile)) > DRY_MIN_LEVEL \
FALSE, TRUE, TC_OCEAN) <= 35)
struct world wld
Definition game.c:58
int map_colatitude(const struct tile *ptile)
#define DRY_MIN_LEVEL
#define DRY_MAX_LEVEL
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
int count_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
Definition terrain.c:621

Conditions used mainly in rand_map_pos_characteristic()

Definition at line 172 of file mapgen.c.

◆ map_pos_is_low

#define map_pos_is_low (   ptile)    ((hmap((ptile)) < hmap_low_level))

Definition at line 189 of file mapgen.c.

◆ NUM_TEST_FUNCTIONS

#define NUM_TEST_FUNCTIONS   9

Definition at line 684 of file mapgen.c.

◆ PLACE_ONE_TYPE

#define PLACE_ONE_TYPE (   count,
  alternate,
  ter,
  wc,
  tc,
  mc,
  weight 
)
Value:
if ((count) > 0) { \
struct tile *ptile; \
/* Place some terrains */ \
if ((ptile = rand_map_pos_characteristic((wc), (tc), (mc)))) { \
place_terrain(ptile, (weight), (ter), &(count), (wc),(tc), (mc)); \
} else { \
/* If rand_map_pos_temperature returns FALSE we may as well stop */ \
/* looking for this time and go to alternate type. */ \
(alternate) += (count); \
(count) = 0; \
} \
}
static struct tile * rand_map_pos_characteristic(wetness_c wc, temperature_type tc, miscellaneous_c mc)
Definition mapgen.c:259
Definition tile.h:49

This place randomly a cluster of terrains with some characteristics

Definition at line 465 of file mapgen.c.

◆ RIVERS_MAXTRIES

#define RIVERS_MAXTRIES   32767

Definition at line 110 of file mapgen.c.

◆ SPECLIST_TAG

#define SPECLIST_TAG   terrain_select

Definition at line 75 of file mapgen.c.

◆ terrain_select_list_iterate

#define terrain_select_list_iterate (   tersel_list,
  ptersel 
)     TYPED_LIST_ITERATE(struct terrain_select, tersel_list, ptersel)

Definition at line 78 of file mapgen.c.

◆ terrain_select_list_iterate_end

#define terrain_select_list_iterate_end    LIST_ITERATE_END

Definition at line 80 of file mapgen.c.

Typedef Documentation

◆ fair_geometry_func

typedef void(* fair_geometry_func) (int *x, int *y)

Definition at line 2535 of file mapgen.c.

Enumeration Type Documentation

◆ fair_tile_flag

Enumerator
FTF_NONE 
FTF_ASSIGNED 
FTF_OCEAN 
FTF_STARTPOS 
FTF_NO_RESOURCE 
FTF_HAS_HUT 
FTF_NO_HUT 

Definition at line 2517 of file mapgen.c.

◆ miscellaneous_c

Enumerator
MC_NONE 
MC_LOW 
MC_NLOW 

Definition at line 191 of file mapgen.c.

◆ wetness_c

enum wetness_c
Enumerator
WC_ALL 
WC_DRY 
WC_NDRY 

Definition at line 177 of file mapgen.c.

Function Documentation

◆ add_resources()

static void add_resources ( int  prob)
static

Add specials to the map with given probability (out of 1000).

Definition at line 1569 of file mapgen.c.

Referenced by map_fractal_generate().

◆ adjust_terrain_param()

static void adjust_terrain_param ( void  )
static

Convert parameters from the server into terrains percents parameters for the generators

Definition at line 1485 of file mapgen.c.

Referenced by map_fractal_generate().

◆ condition_filter()

static bool condition_filter ( const struct tile ptile,
const void *  data 
)
static

A filter function to be passed to rand_map_pos_filtered(). See rand_map_pos_characteristic() for more explanation.

Definition at line 244 of file mapgen.c.

Referenced by rand_map_pos_characteristic().

◆ count_card_adjc_elevated_tiles()

static int count_card_adjc_elevated_tiles ( struct tile ptile)
static

Returns the number of cardinally adjacent tiles have a non-zero elevation.

Definition at line 1924 of file mapgen.c.

Referenced by create_island().

◆ create_island()

static bool create_island ( int  islemass,
struct gen234_state pstate 
)
static

finds a place and drop the island created when called with islemass != 0

Definition at line 1940 of file mapgen.c.

Referenced by make_island().

◆ fair_do_geometry()

static void fair_do_geometry ( const struct fair_geometry_data data,
int *  x,
int *  y 
)
static

Perform transformations defined into 'data' to position ('x', 'y').

Definition at line 2756 of file mapgen.c.

Referenced by fair_map_copy().

◆ fair_do_hex_rotation()

static void fair_do_hex_rotation ( int *  x,
int *  y 
)
static

Rotation matrix for hexgonal topology.

Definition at line 2734 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_hex_symmetry1()

static void fair_do_hex_symmetry1 ( int *  x,
int *  y 
)
static

Symmetry matrix for hexagonal topologies.

Definition at line 2696 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_hex_symmetry2()

static void fair_do_hex_symmetry2 ( int *  x,
int *  y 
)
static

Symmetry matrix for hexagonal topologies.

Definition at line 2704 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_iso_hex_rotation()

static void fair_do_iso_hex_rotation ( int *  x,
int *  y 
)
static

Rotation matrix for hexgonal-isometric topology.

Definition at line 2745 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_iso_hex_symmetry1()

static void fair_do_iso_hex_symmetry1 ( int *  x,
int *  y 
)
static

Symmetry matrix for hexgonal-isometric topology.

Definition at line 2713 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_rotation()

static void fair_do_rotation ( int *  x,
int *  y 
)
static

Rotation matrix, also symmetry matrix for hexagonal-isometric topology.

Definition at line 2723 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_symmetry1()

static void fair_do_symmetry1 ( int *  x,
int *  y 
)
static

Symmetry matrix.

Definition at line 2680 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_do_symmetry2()

static void fair_do_symmetry2 ( int *  x,
int *  y 
)
static

Symmetry matrix.

Definition at line 2688 of file mapgen.c.

Referenced by fair_geometry_rand().

◆ fair_geometry_rand()

static void fair_geometry_rand ( struct fair_geometry_data data)
static

Push random transformations to 'data'.

Definition at line 2769 of file mapgen.c.

Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().

◆ fair_map_copy()

static bool fair_map_copy ( struct fair_tile ptarget,
int  tx,
int  ty,
struct fair_tile psource,
const struct fair_geometry_data data,
int  startpos_team_id 
)
static

Copy 'psource' on 'ptarget' at position ('tx', 'ty'), performing transformations defined into 'data'. Assign start positions for team 'startpos_team_id'. Return TRUE if we have copied the map, FALSE if the copy was not possible.

Definition at line 2820 of file mapgen.c.

Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().

◆ fair_map_destroy()

static void fair_map_destroy ( struct fair_tile pmap)
inlinestatic

Free a map.

Definition at line 2553 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_map_island_new()

static struct fair_tile * fair_map_island_new ( int  size,
int  startpos_num 
)
static

Generate a map where an island would be placed in the center.

Definition at line 3071 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_map_make_huts()

static void fair_map_make_huts ( struct fair_tile pmap)
static

Add huts on 'pmap'.

Definition at line 3019 of file mapgen.c.

Referenced by fair_map_island_new(), and map_generate_fair_islands().

◆ fair_map_make_resources()

static void fair_map_make_resources ( struct fair_tile pmap)
static

Add resources on 'pmap'.

Definition at line 2963 of file mapgen.c.

Referenced by fair_map_island_new(), and map_generate_fair_islands().

◆ fair_map_new()

static struct fair_tile * fair_map_new ( void  )
inlinestatic

Create a map. Note that all maps have the same dimensions, to be able to call map utilities.

Definition at line 2545 of file mapgen.c.

Referenced by fair_map_island_new(), and map_generate_fair_islands().

◆ fair_map_place_island_rand()

static bool fair_map_place_island_rand ( struct fair_tile ptarget,
struct fair_tile psource 
)
static

Attempts to copy 'psource' to 'ptarget' at a random position, with random geometric effects.

Definition at line 2898 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_map_place_island_team()

static bool fair_map_place_island_team ( struct fair_tile ptarget,
int  tx,
int  ty,
struct fair_tile psource,
const struct iter_index outwards_indices,
int  startpos_team_id 
)
static

Attempts to copy 'psource' to 'ptarget' as close as possible of position 'x', 'y' for players of the team 'team_id'.

Definition at line 2933 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_map_pos_tile()

static struct fair_tile * fair_map_pos_tile ( struct fair_tile pmap,
int  x,
int  y 
)
inlinestatic

Get the tile at the position ('x', 'y').

Definition at line 2571 of file mapgen.c.

Referenced by fair_map_copy(), fair_map_island_new(), and fair_map_tile_step().

◆ fair_map_tile_border()

static bool fair_map_tile_border ( struct fair_tile pmap,
struct fair_tile ptile,
int  dist 
)
inlinestatic

Returns whether 'ptile' is at least at 'dist' tiles (in real distance) to the border. Note is also take in account map wrapping.

Definition at line 2615 of file mapgen.c.

Referenced by fair_map_island_new().

◆ fair_map_tile_pos()

static void fair_map_tile_pos ( struct fair_tile pmap,
struct fair_tile ptile,
int *  x,
int *  y 
)
inlinestatic

Get the coordinates of tile 'ptile'.

Definition at line 2561 of file mapgen.c.

Referenced by fair_map_copy(), and fair_map_tile_step().

◆ fair_map_tile_step()

static struct fair_tile * fair_map_tile_step ( struct fair_tile pmap,
struct fair_tile ptile,
enum direction8  dir 
)
inlinestatic

Get the next tile in direction 'dir'.

Definition at line 2600 of file mapgen.c.

Referenced by fair_map_island_new(), and fair_map_make_resources().

◆ fair_team_placement_closest()

static int fair_team_placement_closest ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing closest team placement.

Definition at line 2642 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_team_placement_horizontal()

static int fair_team_placement_horizontal ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing horizontal team placement.

Definition at line 2652 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fair_team_placement_vertical()

static int fair_team_placement_vertical ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing vertical team placement.

Definition at line 2666 of file mapgen.c.

Referenced by map_generate_fair_islands().

◆ fill_island()

static void fill_island ( int  coast,
long int *  bucket,
const struct terrain_select_list *  tersel_list,
const struct gen234_state *const  pstate 
)
static

Fill an island with different types of terrains; rivers have extra code.

Definition at line 1653 of file mapgen.c.

Referenced by make_island().

◆ fill_island_rivers()

static void fill_island_rivers ( int  coast,
long int *  bucket,
const struct gen234_state *const  pstate 
)
static

Fill an island with rivers.

Definition at line 1777 of file mapgen.c.

Referenced by make_island().

◆ get_random_map_position_from_state()

static struct tile * get_random_map_position_from_state ( const struct gen234_state *const  pstate)
static

Returns a random position in the rectangle denoted by the given state.

Definition at line 1602 of file mapgen.c.

Referenced by create_island(), fill_island(), and fill_island_rivers().

◆ initworld()

static void initworld ( struct gen234_state pstate)
static

fill ocean and make polar A temperature map is created in map_fractal_generate().

Definition at line 2204 of file mapgen.c.

Referenced by mapgenerator2(), mapgenerator3(), and mapgenerator4().

◆ is_near_land()

static bool is_near_land ( struct tile ptile)
static

Return TRUE if the ocean position is near land. This is used in the creation of islands, so it differs logically from near_safe_tiles().

Definition at line 1833 of file mapgen.c.

Referenced by place_island().

◆ is_resource_close()

static bool is_resource_close ( const struct tile ptile)
static

Return TRUE iff there's a resource within one tile of the given map position.

Definition at line 1555 of file mapgen.c.

Referenced by add_resources().

◆ is_tiny_island()

static bool is_tiny_island ( struct tile ptile)
static

Returns if this is a 1x1 island

Definition at line 1151 of file mapgen.c.

Referenced by remove_tiny_islands().

◆ island_river_mouth_suitability()

static bool island_river_mouth_suitability ( const struct tile ptile,
const struct extra_type priver 
)
static

Returns TRUE if ptile is suitable for a river mouth.

Definition at line 1732 of file mapgen.c.

Referenced by fill_island_rivers().

◆ island_river_suitability()

static bool island_river_suitability ( const struct tile ptile,
const struct extra_type priver 
)
static

Returns TRUE if there is a river in a cardinal direction near the tile and the tile is suitable for extending it.

Definition at line 1753 of file mapgen.c.

Referenced by fill_island_rivers().

◆ island_terrain_free()

static void island_terrain_free ( void  )
static

Free memory allocated for terrain selection lists.

Definition at line 2071 of file mapgen.c.

Referenced by map_fractal_generate().

◆ island_terrain_init()

static void island_terrain_init ( void  )
static

Initialize terrain selection lists for make_island().

Definition at line 2010 of file mapgen.c.

Referenced by map_fractal_generate().

◆ make_huts()

static void make_huts ( int  number)
static

This function spreads out huts on the map, a position can be used for a hut if there isn't another hut close and if it's not on the ocean.

Definition at line 1528 of file mapgen.c.

Referenced by map_fractal_generate().

◆ make_island()

static bool make_island ( int  islemass,
int  starters,
struct gen234_state pstate,
int  min_specific_island_size 
)
static

make an island, fill every tile type except plains note: you have to create big islands first. Return TRUE if successful. min_specific_island_size is a percent value.

Definition at line 2091 of file mapgen.c.

Referenced by initworld(), mapgenerator2(), mapgenerator3(), and mapgenerator4().

◆ make_land()

static void make_land ( void  )
static

make land simply does it all based on a generated heightmap 1) with map.server.landpercent it generates a ocean/unknown map 2) it then calls the above functions to generate the different terrains

Definition at line 1048 of file mapgen.c.

Referenced by map_fractal_generate().

◆ make_plain()

static void make_plain ( struct tile ptile,
int *  to_be_placed 
)
static

A simple function that adds plains grassland or tundra to the current location.

Definition at line 429 of file mapgen.c.

Referenced by make_plains(), and make_terrains().

◆ make_plains()

static void make_plains ( void  )
static

Make_plains converts all not yet placed terrains to plains (tundra, grass) used by generators 2-4

Definition at line 450 of file mapgen.c.

Referenced by mapgenerator2(), mapgenerator3(), and mapgenerator4().

◆ make_polar()

static void make_polar ( void  )
static

Add frozen tiles in the arctic zone. If ruleset has frozen ocean, use that, else use frozen land terrains with appropriate texturing. This is used in generators 2-4.

Definition at line 332 of file mapgen.c.

Referenced by initworld(), and map_generate_fair_islands().

◆ make_polar_land()

static void make_polar_land ( void  )
static

Place untextured land at the poles on any tile that is not already covered with TER_FROZEN terrain. This is used by generators 1 and 5.

Definition at line 372 of file mapgen.c.

Referenced by make_land().

◆ make_relief()

static void make_relief ( void  )
static

make_relief() will convert all squares that are higher than thill to mountains and hills. Note that thill will be adjusted according to the map.server.steepness value, so increasing map.mountains will result in more hills and mountains.

Definition at line 295 of file mapgen.c.

Referenced by make_land().

◆ make_river()

static bool make_river ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Makes a river starting at (x, y). Returns 1 if it succeeds. Return 0 if it fails. The river is stored in river_map.

How to make a river path look natural

Rivers always flow down. Thus rivers are best implemented on maps where every tile has an explicit height value. However, Freeciv has a flat map. But there are certain things that help the user imagine differences in height between tiles. The selection of direction for rivers should confirm and even amplify the user's image of the map's topology.

To decide which direction the river takes, the possible directions are tested in a series of test until there is only 1 direction left. Some tests are fatal. This means that they can sort away all remaining directions. If they do so, the river is aborted. Here follows a description of the test series.

Falling into itself: fatal (river_test_blocked) This is tested by looking up in the river_map array if a tile or every tile surrounding the tile is marked as blocked. A tile is marked as blocked if it belongs to the current river or has been evaluated in a previous iteration in the creation of the current river.

Possible values: 0: Is not falling into itself. 1: Is falling into itself.

Forming a 4-river-grid: optionally fatal (river_test_rivergrid) A minimal 4-river-grid is formed when an intersection in the map grid is surrounded by 4 river tiles. There can be larger river grids consisting of several overlapping minimal 4-river-grids.

Possible values: 0: Is not forming a 4-river-grid. 1: Is forming a 4-river-grid.

Highlands: (river_test_highlands) Rivers must not flow up in mountains or hills if there are alternatives.

Possible values: 0: Is not hills and not mountains. 1: Is hills. 2: Is mountains.

Adjacent ocean: (river_test_adjacent_ocean) Rivers must flow down to coastal areas when possible:

Possible values: 0-100

Adjacent river: (river_test_adjacent_river) Rivers must flow down to areas near other rivers when possible:

Possible values: 0-100

Adjacent highlands: (river_test_adjacent_highlands) Rivers must not flow towards highlands if there are alternatives.

Swamps: (river_test_swamp) Rivers must flow down in swamps when possible.

Possible values: 0: Is swamps. 1: Is not swamps.

Adjacent swamps: (river_test_adjacent_swamp) Rivers must flow towards swamps when possible.

height_map: (river_test_height_map) Rivers must flow in the direction which takes it to the tile with the lowest value on the height_map.

Possible values: n: height_map[...]

If these rules haven't decided the direction, the random number generator gets the decision. -Erik Sigra

Definition at line 787 of file mapgen.c.

Referenced by make_rivers().

◆ make_rivers()

static void make_rivers ( void  )
static

Calls make_river until there are enough river tiles on the map. It stops when it has tried to create RIVERS_MAXTRIES rivers. -Erik Sigra

Definition at line 901 of file mapgen.c.

Referenced by make_land().

◆ make_terrains()

static void make_terrains ( void  )
static

Make_terrains calls make_forest(), make_dessert(), etc with random free locations until there has been made enough. Comment: functions as make_swamp(), etc. has to have a non zero probability to place one terrains in called position. Else make_terrains() will get in a infinite loop!

Definition at line 486 of file mapgen.c.

Referenced by make_land().

◆ map_fractal_generate()

bool map_fractal_generate ( bool  autosize,
struct unit_type initial_unit 
)

See stdinhand.c for information on map generation methods.

FIXME: Some continent numbers are unused at the end of this function, fx removed completely by remove_tiny_islands. When this function is finished various data is written to "islands", indexed by continent numbers, so a simple renumbering would not work...

If "autosize" is specified then mapgen will automatically size the map based on the map.server.size server parameter and the specified topology. If not map.xsize and map.ysize will be used.

Definition at line 1262 of file mapgen.c.

Referenced by srv_ready().

◆ map_generate_fair_islands()

static bool map_generate_fair_islands ( void  )
static

Build a map using generator 'FAIR'.

Definition at line 3382 of file mapgen.c.

Referenced by map_fractal_generate().

◆ mapgenerator2()

static void mapgenerator2 ( void  )
static

island base map generators

Definition at line 2241 of file mapgen.c.

Referenced by map_fractal_generate().

◆ mapgenerator3()

static void mapgenerator3 ( void  )
static

On popular demand, this tries to mimic the generator 3 as best as possible.

PS: I'd like to mult by 3/2, but starters might make trouble then

Definition at line 2336 of file mapgen.c.

Referenced by map_fractal_generate().

◆ mapgenerator4()

static void mapgenerator4 ( void  )
static

Generator for placing a couple of players to each island.

PS: The weights NEED to sum up to totalweight (dammit)

Definition at line 2433 of file mapgen.c.

Referenced by map_fractal_generate().

◆ near_safe_tiles()

static bool near_safe_tiles ( struct tile ptile)
static

Return TRUE if a safe tile is in a radius of 1. This function is used to test where to place specials on the sea.

Definition at line 1513 of file mapgen.c.

Referenced by add_resources().

◆ ok_for_separate_poles()

static bool ok_for_separate_poles ( struct tile ptile)
static

If separatepoles is set, return false if this tile has to keep ocean

Definition at line 354 of file mapgen.c.

Referenced by make_polar_land().

◆ place_island()

static bool place_island ( struct gen234_state pstate)
static

Finds a place and drop the island created when called with islemass != 0

Definition at line 1850 of file mapgen.c.

Referenced by create_island().

◆ place_terrain()

static void place_terrain ( struct tile ptile,
int  diff,
struct terrain pterrain,
int *  to_be_placed,
wetness_c  wc,
temperature_type  tc,
miscellaneous_c  mc 
)
static

Recursively generate terrains.

Definition at line 394 of file mapgen.c.

Referenced by place_terrain().

◆ print_mapgen_map()

static void print_mapgen_map ( void  )
static

Debugging function to print information about the map that's been generated.

Definition at line 1201 of file mapgen.c.

Referenced by map_fractal_generate().

◆ rand_map_pos_characteristic()

static struct tile * rand_map_pos_characteristic ( wetness_c  wc,
temperature_type  tc,
miscellaneous_c  mc 
)
static

Return random map coordinates which have some conditions and which are not yet placed on pmap. Returns NULL if there is no such position.

Definition at line 259 of file mapgen.c.

Referenced by make_huts(), make_rivers(), and make_terrains().

◆ remove_tiny_islands()

static void remove_tiny_islands ( void  )
static

Removes all 1x1 islands (sets them to ocean). This happens before regenerate_lakes(), so don't need to worry about TER_FRESHWATER here.

Definition at line 1177 of file mapgen.c.

Referenced by map_fractal_generate().

◆ river_blockmark()

static void river_blockmark ( struct river_map privermap,
struct tile ptile 
)
static

Called from make_river. Marks all directions as blocked. -Erik Sigra

Definition at line 667 of file mapgen.c.

Referenced by make_river().

◆ river_test_adjacent_highlands()

static int river_test_adjacent_highlands ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 615 of file mapgen.c.

◆ river_test_adjacent_ocean()

static int river_test_adjacent_ocean ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 594 of file mapgen.c.

◆ river_test_adjacent_river()

static int river_test_adjacent_river ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 605 of file mapgen.c.

◆ river_test_adjacent_swamp()

static int river_test_adjacent_swamp ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 641 of file mapgen.c.

◆ river_test_blocked()

static int river_test_blocked ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 552 of file mapgen.c.

◆ river_test_height_map()

static int river_test_height_map ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 657 of file mapgen.c.

◆ river_test_highlands()

static int river_test_highlands ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 584 of file mapgen.c.

◆ river_test_rivergrid()

static int river_test_rivergrid ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 573 of file mapgen.c.

◆ river_test_swamp()

static int river_test_swamp ( struct river_map privermap,
struct tile ptile,
struct extra_type priver 
)
static

Help function used in make_river(). See the help there.

Definition at line 631 of file mapgen.c.

◆ river_types_init()

static void river_types_init ( void  )
static

Initialize river types array

Definition at line 2501 of file mapgen.c.

Referenced by map_fractal_generate().

◆ terrain_is_too_high()

static bool terrain_is_too_high ( struct tile ptile,
int  thill,
int  my_height 
)
static

We don't want huge areas of hills/mountains, so we put in a plains here and there, where it gets too 'high'

Return TRUE if the terrain at the given map position is too high.

Definition at line 278 of file mapgen.c.

Referenced by make_relief().

◆ tersel_free()

static void tersel_free ( struct terrain_select ptersel)
static

Free resources allocated for terrain_select structure.

Definition at line 1643 of file mapgen.c.

Referenced by island_terrain_init().

◆ tersel_new()

static struct terrain_select * tersel_new ( int  weight,
enum mapgen_terrain_property  target,
enum mapgen_terrain_property  prefer,
enum mapgen_terrain_property  avoid,
int  temp_condition,
int  wet_condition 
)
static

Allocate and initialize new terrain_select structure.

Definition at line 1621 of file mapgen.c.

Referenced by island_terrain_init().

◆ test_miscellaneous()

static bool test_miscellaneous ( const struct tile ptile,
miscellaneous_c  c 
)
static

Checks if the given location satisfy some miscellaneous condition

Definition at line 217 of file mapgen.c.

Referenced by condition_filter(), and place_terrain().

◆ test_wetness()

static bool test_wetness ( const struct tile ptile,
wetness_c  c 
)
static

Checks if the given location satisfy some wetness condition

Definition at line 200 of file mapgen.c.

Referenced by condition_filter(), fill_island(), fill_island_rivers(), and place_terrain().

Variable Documentation

◆ checkmass

long int checkmass
static

Definition at line 1845 of file mapgen.c.

Referenced by make_island(), mapgenerator2(), mapgenerator3(), mapgenerator4(), and place_island().

◆ desert

struct terrain_select_list* desert

Definition at line 95 of file mapgen.c.

◆ desert_pct

int desert_pct = 0
static

◆ forest

struct terrain_select_list* forest

Definition at line 94 of file mapgen.c.

◆ forest_pct

int forest_pct = 0
static

◆ hmap_low_level

int hmap_low_level = 0
static

Definition at line 182 of file mapgen.c.

◆ init

bool init

Definition at line 93 of file mapgen.c.

◆ [struct]

struct { ... } island_terrain

◆ jungle_pct

int jungle_pct = 0
static

◆ mountain

struct terrain_select_list* mountain

Definition at line 96 of file mapgen.c.

◆ mountain_pct

int mountain_pct = 0
static

◆ river_pct

int river_pct = 0
static

Definition at line 164 of file mapgen.c.

Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), and make_rivers().

◆ river_type_count

int river_type_count = 0
static

Definition at line 73 of file mapgen.c.

Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().

◆ river_types

struct extra_type* river_types[MAX_EXTRA_TYPES]
static

Definition at line 72 of file mapgen.c.

Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().

◆ swamp

struct terrain_select_list* swamp

Definition at line 97 of file mapgen.c.

◆ swamp_pct

int swamp_pct = 0
static

◆ test_funcs

struct test_func test_funcs[NUM_TEST_FUNCTIONS]
static
Initial value:
= {
}
static int river_test_adjacent_swamp(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:641
static int river_test_height_map(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:657
static int river_test_adjacent_ocean(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:594
static int river_test_adjacent_highlands(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:615
static int river_test_highlands(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:584
static int river_test_rivergrid(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:573
static int river_test_adjacent_river(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:605
static int river_test_swamp(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:631
static int river_test_blocked(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
Definition mapgen.c:552

Definition at line 685 of file mapgen.c.

Referenced by make_river().