![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <QBitArray>#include <cstdlib>#include <cstring>#include "bitvector.h"#include "fcintl.h"#include "log.h"#include "rand.h"#include "shared.h"#include "game.h"#include "map.h"#include "road.h"#include "fair_islands.h"#include "fracture_map.h"#include "height_map.h"#include "islands.h"#include "mapgen_topology.h"#include "mapgen_utils.h"#include "startpos.h"#include "temperature_map.h"#include "mapgen.h"
Include dependency graph for mapgen.cpp:Go to the source code of this file.
Classes | |
| struct | river_map |
| struct | DataFilter |
| Passed as data to rand_map_pos_filtered() by rand_map_pos_characteristic() More... | |
| struct | test_func |
Macros | |
| #define | RIVERS_MAXTRIES 32767 |
| #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) |
| This place randomly a cluster of terrains with some characteristics. More... | |
| #define | NUM_TEST_FUNCTIONS 9 |
Enumerations | |
| enum | miscellaneous_c { MC_NONE , MC_LOW , MC_NLOW } |
Functions | |
| static void | make_huts (int number) |
| 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. More... | |
| static void | add_resources (int prob) |
| Add specials to the map with given probability (out of 1000). More... | |
| static void | adjust_terrain_param () |
| Convert parameters from the server into terrains percents parameters for the generators. More... | |
| static int | river_test_blocked (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_rivergrid (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_highlands (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_adjacent_ocean (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_adjacent_river (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_adjacent_highlands (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_swamp (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_adjacent_swamp (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static int | river_test_height_map (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Help function used in make_river(). More... | |
| static void | river_blockmark (struct river_map *privermap, struct tile *ptile) |
| Called from make_river. More... | |
| static bool | make_river (struct river_map *privermap, struct tile *ptile, struct extra_type *priver) |
| Makes a river starting at (x, y). More... | |
| static void | make_rivers () |
| Calls make_river until there are enough river tiles on the map. More... | |
| static void | river_types_init () |
| Initialize river types array. More... | |
| bool | test_wetness (const struct tile *ptile, wetness_c c) |
| These functions test for conditions used in rand_map_pos_characteristic. More... | |
| static bool | test_miscellaneous (const struct tile *ptile, miscellaneous_c c) |
| Checks if the given location satisfy some miscellaneous condition. More... | |
| static bool | condition_filter (const struct tile *ptile, const void *data) |
| A filter function to be passed to rand_map_pos_filtered(). More... | |
| static struct tile * | rand_map_pos_characteristic (wetness_c wc, temperature_type tc, miscellaneous_c mc) |
| Return random map coordinates which have some conditions and which are not yet placed on pmap. More... | |
| static bool | terrain_is_too_high (struct tile *ptile, int thill, int my_height) |
| We don't want huge areas of hill/mountains, so we put in a plains here and there, where it gets too 'heigh'. More... | |
| static void | make_relief () |
| make_relief() will convert all squares that are higher than thill to mountains and hills. More... | |
| void | make_polar () |
| Add frozen tiles in the arctic zone. More... | |
| static bool | ok_for_separate_poles (struct tile *ptile) |
| If separatepoles is set, return false if this tile has to keep ocean. More... | |
| static void | make_polar_land () |
| Place untextured land at the poles on any tile that is not already covered with TER_FROZEN terrain. More... | |
| 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) |
| Recursively generate terrains. More... | |
| static void | make_plain (struct tile *ptile, int *to_be_placed) |
| A simple function that adds plains grassland or tundra to the current location. More... | |
| void | make_plains () |
| Make_plains converts all not yet placed terrains to plains (tundra, grass) used by generators 2-4. More... | |
| static void | make_terrains () |
| Make_terrains calls make_forest, make_dessert,etc with random free locations until there has been made enough. More... | |
| static void | make_land () |
| 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 More... | |
| static bool | is_tiny_island (struct tile *ptile) |
| Returns if this is a 1x1 island. More... | |
| static void | remove_tiny_islands () |
| Removes all 1x1 islands (sets them to ocean). More... | |
| static void | print_mapgen_map () |
| Debugging function to print information about the map that's been generated. More... | |
| bool | map_generate (bool autosize, struct unit_type *initial_unit) |
| See stdinhand.c for information on map generation methods. More... | |
| static bool | near_safe_tiles (struct tile *ptile) |
| Return TRUE if a safe tile is in a radius of 1. More... | |
| static bool | is_resource_close (const struct tile *ptile) |
| Return TRUE iff there's a resource within one tile of the given map position. More... | |
Variables | |
| struct extra_type * | river_types [MAX_ROAD_TYPES] |
| int | river_type_count = 0 |
| int | forest_pct = 0 |
| int | desert_pct = 0 |
| int | swamp_pct = 0 |
| int | mountain_pct = 0 |
| int | jungle_pct = 0 |
| int | river_pct = 0 |
| static int | hmap_low_level = 0 |
| static struct test_func | test_funcs [NUM_TEST_FUNCTIONS] |
| #define ini_hmap_low_level | ( | ) |
Definition at line 104 of file mapgen.cpp.
| #define map_pos_is_low | ( | ptile | ) | ((hmap((ptile)) < hmap_low_level)) |
Definition at line 111 of file mapgen.cpp.
| #define NUM_TEST_FUNCTIONS 9 |
Definition at line 617 of file mapgen.cpp.
| #define PLACE_ONE_TYPE | ( | count, | |
| alternate, | |||
| ter, | |||
| wc, | |||
| tc, | |||
| mc, | |||
| weight | |||
| ) |
This place randomly a cluster of terrains with some characteristics.
Definition at line 394 of file mapgen.cpp.
| #define RIVERS_MAXTRIES 32767 |
Definition at line 50 of file mapgen.cpp.
| enum miscellaneous_c |
| Enumerator | |
|---|---|
| MC_NONE | |
| MC_LOW | |
| MC_NLOW | |
Definition at line 113 of file mapgen.cpp.
|
static |
Add specials to the map with given probability (out of 1000).
Definition at line 1500 of file mapgen.cpp.
Referenced by map_generate().
|
static |
Convert parameters from the server into terrains percents parameters for the generators.
Definition at line 1410 of file mapgen.cpp.
Referenced by map_generate().
|
static |
A filter function to be passed to rand_map_pos_filtered().
See rand_map_pos_characteristic for more explanation.
Definition at line 166 of file mapgen.cpp.
Referenced by rand_map_pos_characteristic().
|
static |
Return TRUE iff there's a resource within one tile of the given map position.
Definition at line 1484 of file mapgen.cpp.
Referenced by add_resources().
|
static |
Returns if this is a 1x1 island.
Definition at line 1104 of file mapgen.cpp.
Referenced by remove_tiny_islands().
|
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 1458 of file mapgen.cpp.
Referenced by map_generate().
|
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 991 of file mapgen.cpp.
Referenced by map_generate().
|
static |
A simple function that adds plains grassland or tundra to the current location.
Definition at line 356 of file mapgen.cpp.
Referenced by make_plains(), and make_terrains().
| void make_plains | ( | ) |
Make_plains converts all not yet placed terrains to plains (tundra, grass) used by generators 2-4.
Definition at line 377 of file mapgen.cpp.
Referenced by map_generate_island_2or3(), map_generate_island_single(), and map_generate_island_variable().
| void make_polar | ( | ) |
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 258 of file mapgen.cpp.
Referenced by initworld().
|
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 301 of file mapgen.cpp.
Referenced by make_land().
|
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 217 of file mapgen.cpp.
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, Freeciv21 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 719 of file mapgen.cpp.
Referenced by make_rivers().
|
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 840 of file mapgen.cpp.
Referenced by make_land().
|
static |
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 415 of file mapgen.cpp.
Referenced by make_land().
| bool map_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 1232 of file mapgen.cpp.
Referenced by srv_ready().
|
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 1441 of file mapgen.cpp.
Referenced by add_resources().
|
static |
If separatepoles is set, return false if this tile has to keep ocean.
Definition at line 281 of file mapgen.cpp.
Referenced by make_polar_land().
|
static |
Recursively generate terrains.
Definition at line 323 of file mapgen.cpp.
|
static |
Debugging function to print information about the map that's been generated.
Definition at line 1160 of file mapgen.cpp.
Referenced by map_generate().
|
static |
Return random map coordinates which have some conditions and which are not yet placed on pmap.
Returns FALSE if there is no such position.
Definition at line 180 of file mapgen.cpp.
Referenced by make_huts(), make_rivers(), and make_terrains().
|
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 1132 of file mapgen.cpp.
Referenced by map_generate().
Called from make_river.
Marks all directions as blocked. -Erik Sigra
Definition at line 598 of file mapgen.cpp.
Referenced by make_river().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Initialize river types array.
Definition at line 1537 of file mapgen.cpp.
Referenced by map_generate().
|
static |
We don't want huge areas of hill/mountains, so we put in a plains here and there, where it gets too 'heigh'.
Return TRUE if the terrain at the given map position is too heigh.
Definition at line 199 of file mapgen.cpp.
Referenced by make_relief().
|
static |
Checks if the given location satisfy some miscellaneous condition.
Definition at line 139 of file mapgen.cpp.
Referenced by condition_filter(), and place_terrain().
These functions test for conditions used in rand_map_pos_characteristic.
Checks if the given location satisfy some wetness condition
Definition at line 122 of file mapgen.cpp.
Referenced by condition_filter(), fill_island(), fill_island_rivers(), and place_terrain().
| int desert_pct = 0 |
Definition at line 94 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
| int forest_pct = 0 |
Definition at line 93 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
|
static |
Definition at line 103 of file mapgen.cpp.
| int jungle_pct = 0 |
Definition at line 97 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_terrains(), and print_mapgen_map().
| int mountain_pct = 0 |
Definition at line 96 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
| int river_pct = 0 |
Definition at line 98 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), and make_rivers().
| int river_type_count = 0 |
Definition at line 44 of file mapgen.cpp.
Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().
| struct extra_type* river_types[MAX_ROAD_TYPES] |
Definition at line 43 of file mapgen.cpp.
Referenced by fair_map_island_new(), fill_island_rivers(), make_rivers(), and river_types_init().
| int swamp_pct = 0 |
Definition at line 95 of file mapgen.cpp.
Referenced by adjust_terrain_param(), fair_map_island_new(), make_island(), make_terrains(), and print_mapgen_map().
|
static |
Definition at line 598 of file mapgen.cpp.
Referenced by make_river().