Freeciv-3.3
|
#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 "nation.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 (MIN(COLD_LEVEL, 2 * ICE_BASE_LEVEL) > MIN_REAL_COLATITUDE(wld.map)) |
#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 } |
Variables | ||
static struct extra_type * | river_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 | |
#define fair_do_iso_hex_symmetry2 fair_do_rotation |
#define HAS_POLES (MIN(COLD_LEVEL, 2 * ICE_BASE_LEVEL) > MIN_REAL_COLATITUDE(wld.map)) |
#define ini_hmap_low_level | ( | ) |
#define map_pos_is_dry | ( | ptile | ) |
Conditions used mainly in rand_map_pos_characteristic()
#define map_pos_is_low | ( | ptile | ) | ((hmap((ptile)) < hmap_low_level)) |
This place randomly a cluster of terrains with some characteristics
#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 |
Add specials to the map with given probability (out of 1000).
Definition at line 1577 of file mapgen.c.
Referenced by map_fractal_generate().
Convert parameters from the server into terrains percents parameters for the generators
Definition at line 1492 of file mapgen.c.
Referenced by map_fractal_generate().
A filter function to be passed to rand_map_pos_filtered(). See rand_map_pos_characteristic() for more explanation.
Definition at line 250 of file mapgen.c.
Referenced by rand_map_pos_characteristic().
Returns the number of cardinally adjacent tiles have a non-zero elevation.
Definition at line 1923 of file mapgen.c.
Referenced by create_island().
|
static |
Finds a place and drop the island created when called with islemass != 0
Definition at line 1939 of file mapgen.c.
Referenced by make_island().
Perform transformations defined into 'data' to position ('x', 'y').
Definition at line 2765 of file mapgen.c.
Referenced by fair_map_copy().
Rotation matrix for hexgonal topology.
Definition at line 2743 of file mapgen.c.
Referenced by fair_geometry_rand().
Symmetry matrix for hexagonal topologies.
Definition at line 2705 of file mapgen.c.
Referenced by fair_geometry_rand().
Symmetry matrix for hexagonal topologies.
Definition at line 2713 of file mapgen.c.
Referenced by fair_geometry_rand().
Rotation matrix for hexgonal-isometric topology.
Definition at line 2754 of file mapgen.c.
Referenced by fair_geometry_rand().
Symmetry matrix for hexgonal-isometric topology.
Definition at line 2722 of file mapgen.c.
Referenced by fair_geometry_rand().
Rotation matrix, also symmetry matrix for hexagonal-isometric topology.
Definition at line 2732 of file mapgen.c.
Referenced by fair_geometry_rand().
|
static |
Push random transformations to 'data'.
Definition at line 2778 of file mapgen.c.
Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().
|
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 2831 of file mapgen.c.
Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().
Generate a map where an island would be placed in the center.
Definition at line 3077 of file mapgen.c.
Referenced by map_generate_fair_islands().
Add huts on 'pmap'.
Definition at line 3025 of file mapgen.c.
Referenced by fair_map_island_new(), and map_generate_fair_islands().
Add resources on 'pmap'.
Definition at line 2975 of file mapgen.c.
Referenced by fair_map_island_new(), and map_generate_fair_islands().
Create a map. Note that all maps have the same dimensions, to be able to call map utilities.
Definition at line 2553 of file mapgen.c.
Referenced by fair_map_island_new(), and map_generate_fair_islands().
|
static |
Attempts to copy 'psource' to 'ptarget' at a random position, with random geometric effects.
Definition at line 2910 of file mapgen.c.
Referenced by map_generate_fair_islands().
|
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 2945 of file mapgen.c.
Referenced by map_generate_fair_islands().
Get the tile at the position ('x', 'y').
Definition at line 2579 of file mapgen.c.
Referenced by fair_map_copy(), fair_map_island_new(), and fair_map_tile_step().
|
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 2624 of file mapgen.c.
Referenced by fair_map_island_new().
|
inlinestatic |
Get the coordinates of tile 'ptile'.
Definition at line 2569 of file mapgen.c.
Referenced by fair_map_copy(), and fair_map_tile_step().
|
inlinestatic |
Get the next tile in direction 'dir'.
Definition at line 2608 of file mapgen.c.
Referenced by fair_map_island_new(), and fair_map_make_resources().
Compare two iter_index values for doing closest team placement.
Definition at line 2651 of file mapgen.c.
Referenced by map_generate_fair_islands().
Compare two iter_index values for doing horizontal team placement.
Definition at line 2661 of file mapgen.c.
Referenced by map_generate_fair_islands().
Compare two iter_index values for doing vertical team placement.
Definition at line 2675 of file mapgen.c.
Referenced by map_generate_fair_islands().
|
static |
Fill an island with different types of terrains; rivers have extra code.
Definition at line 1652 of file mapgen.c.
Referenced by make_island().
|
static |
Returns a random position in the rectangle denoted by the given state.
Definition at line 1601 of file mapgen.c.
Referenced by create_island(), fill_island(), and fill_island_rivers().
|
static |
Fill ocean and make polar A temperature map is created in map_fractal_generate().
Definition at line 2208 of file mapgen.c.
Referenced by mapgenerator2(), mapgenerator3(), and mapgenerator4().
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 1832 of file mapgen.c.
Referenced by place_island().
Return TRUE iff there's a resource within one tile of the given map position.
Definition at line 1563 of file mapgen.c.
Referenced by add_resources().
Returns if this is a 1x1 island
Definition at line 1156 of file mapgen.c.
Referenced by remove_tiny_islands().
|
static |
Returns TRUE if ptile is suitable for a river mouth.
Definition at line 1731 of file mapgen.c.
Referenced by fill_island_rivers().
|
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 1752 of file mapgen.c.
Referenced by fill_island_rivers().
Free memory allocated for terrain selection lists.
Definition at line 2074 of file mapgen.c.
Referenced by map_fractal_generate().
Initialize terrain selection lists for make_island().
Definition at line 2013 of file mapgen.c.
Referenced by map_fractal_generate().
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 1535 of file mapgen.c.
Referenced by map_fractal_generate().
|
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 2094 of file mapgen.c.
Referenced by initworld(), mapgenerator2(), mapgenerator3(), and mapgenerator4().
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 1053 of file mapgen.c.
Referenced by map_fractal_generate().
A simple function that adds plains grassland or tundra to the current location.
Definition at line 434 of file mapgen.c.
Referenced by make_plains(), and make_terrains().
Make_plains converts all not yet placed terrains to plains (tundra, grass) used by generators 2-4
Definition at line 455 of file mapgen.c.
Referenced by mapgenerator2(), mapgenerator3(), and mapgenerator4().
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 335 of file mapgen.c.
Referenced by initworld(), and map_generate_fair_islands().
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 376 of file mapgen.c.
Referenced by make_land().
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 298 of file mapgen.c.
Referenced by make_land().
|
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.
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 desicion. -Erik Sigra
Definition at line 792 of file mapgen.c.
Referenced by make_rivers().
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 906 of file mapgen.c.
Referenced by make_land().
Make_terrains calls make_forest, make_dessert,etc with random free locations until there has been made enough. Comment: funtions as make_swamp, etc. has to have a non 0 probability to place one terrains in called position. Else make_terrains will get in a infinite loop!
Definition at line 491 of file mapgen.c.
Referenced by make_land().
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 1268 of file mapgen.c.
Referenced by srv_ready().
Build a map using generator 'FAIR'.
Definition at line 3389 of file mapgen.c.
Referenced by map_fractal_generate().
Island base map generators
Definition at line 2245 of file mapgen.c.
Referenced by map_fractal_generate().
On popular demand, this tries to mimick 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 2343 of file mapgen.c.
Referenced by map_fractal_generate().
Generator for placing a couple of players to each island.
PS: The weights NEED to sum up to totalweight (dammit)
Definition at line 2440 of file mapgen.c.
Referenced by map_fractal_generate().
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 1520 of file mapgen.c.
Referenced by add_resources().
If separatepoles is set, return false if this tile has to keep ocean
Definition at line 357 of file mapgen.c.
Referenced by make_polar_land().
|
static |
Finds a place and drop the island created when called with islemass != 0
Definition at line 1849 of file mapgen.c.
Referenced by create_island().
|
static |
Recursively generate terrains.
Definition at line 398 of file mapgen.c.
Referenced by place_terrain().
Debugging function to print information about the map that's been generated.
Definition at line 1207 of file mapgen.c.
Referenced by map_fractal_generate().
|
static |
Return random map coordinates which have some conditions and which are not yet placed on pmap. Returns nullptr if there is no such position.
Definition at line 265 of file mapgen.c.
Referenced by make_huts(), make_rivers(), and make_terrains().
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 1182 of file mapgen.c.
Referenced by map_fractal_generate().
Called from make_river(). Marks all directions as blocked. -Erik Sigra
Definition at line 672 of file mapgen.c.
Referenced by make_river().
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
|
static |
Help function used in make_river(). See the help there.
Initialize river types array
Definition at line 2509 of file mapgen.c.
Referenced by map_fractal_generate().
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 280 of file mapgen.c.
Referenced by make_relief().
|
static |
Free resources allocated for terrain_select structure.
Definition at line 1642 of file mapgen.c.
Referenced by island_terrain_init().
|
static |
Allocate and initialize new terrain_select structure.
Definition at line 1620 of file mapgen.c.
Referenced by island_terrain_init().
Checks if the given location satisfy some miscellaneous condition
Definition at line 222 of file mapgen.c.
Referenced by condition_filter(), and place_terrain().
Checks if the given location satisfy some wetness condition
Definition at line 204 of file mapgen.c.
Referenced by condition_filter(), fill_island(), fill_island_rivers(), and place_terrain().
Definition at line 1844 of file mapgen.c.
Referenced by make_island(), mapgenerator2(), mapgenerator3(), mapgenerator4(), and place_island().
struct terrain_select_list* desert |
|
static |
Definition at line 163 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
struct terrain_select_list* forest |
|
static |
Definition at line 162 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
struct { ... } island_terrain |
Referenced by island_terrain_free(), island_terrain_init(), and make_island().
|
static |
Definition at line 166 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_terrains(), and print_mapgen_map().
struct terrain_select_list* mountain |
|
static |
Definition at line 165 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
|
static |
Definition at line 167 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), and make_rivers().
|
static |
Definition at line 74 of file mapgen.c.
Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().
|
static |
Definition at line 73 of file mapgen.c.
Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().
struct terrain_select_list* swamp |
|
static |
Definition at line 164 of file mapgen.c.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
|
static |
Definition at line 690 of file mapgen.c.
Referenced by make_river().