76#define SPECLIST_TAG terrain_select
79#define terrain_select_list_iterate(tersel_list, ptersel) \
80 TYPED_LIST_ITERATE(struct terrain_select, tersel_list, ptersel)
81#define terrain_select_list_iterate_end \
111#define RIVERS_MAXTRIES 32767
158 (MIN(COLD_LEVEL, 2 * ICE_BASE_LEVEL) > MIN_REAL_COLATITUDE(wld.map))
175#define map_pos_is_dry(ptile) \
176 (map_colatitude((ptile)) <= DRY_MAX_LEVEL \
177 && map_colatitude((ptile)) > DRY_MIN_LEVEL \
178 && count_terrain_class_near_tile(&(wld.map), (ptile), \
179 FALSE, TRUE, TC_OCEAN) <= 35)
186#define ini_hmap_low_level() \
188hmap_low_level = (4 * swamp_pct * \
189 (hmap_max_level - hmap_shore_level)) / 100 + hmap_shore_level; \
193#define map_pos_is_low(ptile) ((hmap((ptile)) < hmap_low_level))
232 log_error(
"Invalid miscellaneous_c %d", c);
470#define PLACE_ONE_TYPE(count, alternate, ter, wc, tc, mc, weight) \
472 struct tile *ptile; \
474 if ((ptile = rand_map_pos_characteristic((wc), (tc), (mc)))) { \
475 place_terrain(ptile, (weight), (ter), &(count), (wc),(tc), (mc)); \
479 (alternate) += (count); \
689#define NUM_TEST_FUNCTIONS 9
807 log_debug(
"The tile at (%d, %d) has been marked as river in river_map.",
823 log_debug(
"The river did not end at (%d, %d). Evaluating directions...",
880 log_debug(
"mapgen.c: Had to let the random number"
881 " generator select a direction for a river.");
883 log_debug(
"mapgen.c: direction: %d", direction);
1008 log_debug(
"Found a suitable starting tile for a river at (%d, %d)."
1009 " Starting to make it.",
TILE_XY(ptile));
1032 log_debug(
"mapgen.c: A river failed. It might have gotten stuck "
1037 log_debug(
"current_riverlength: %d; desirable_riverlength: %d; "
1038 "iteration_counter: %d",
1072 "No land terrain type could be found for the purpose "
1073 "of temporarily filling in land tiles during map "
1074 "generation. This could be an error in Freeciv, or a "
1075 "mistake in the terrain.ruleset file. Please make sure "
1076 "there is at least one land terrain type in the "
1077 "ruleset, or use a different map generator. If this "
1078 "error persists, please report it at: %s",
BUG_URL);
1099 depth += 30 * (ocean -
land) /
MAX(1, (ocean +
land));
1115 if (
frozen && !pterrain) {
1210 int total = 0, ocean = 0;
1236 log_verbose(
" %-20s : %6d %5.1f%% (ocean: %5.1f%%)",
1244 log_verbose(
" %-20s : %6d %5.1f%% (land: %5.1f%%)",
1282#ifdef FREECIV_TESTMATIC
1413 "Fair island generator failed to allocated "
1414 "start positions!");
1433 log_verbose(
"Map generator chose startpos=SINGLE");
1473 log_error(
_(
"The server couldn't allocate starting positions."));
1549 if (
phut !=
nullptr) {
1589 if (
res !=
nullptr) {
1660 if (*bucket <= 0 ) {
1718 log_debug(
"[fill_island] placed terrain '%s' at (%2d,%2d)",
1795 i = (
i * 175) / 100;
1899 log_error(
"mapgen.c: mass doesn't sum up.");
1959 while (
i > 0 &&
tries-->0) {
1986 if (
hmap(ptile) == 0 &&
i > 0
2117 if (
pstate->totalmass > 3000) {
2118 log_normal(
_(
"High landmass - this may take a few seconds."));
2122 i = (
i <= 90) ? 100 :
i * 11 / 10;
2223 ptile->extras_owner =
nullptr;
2261 log_verbose(
"ISLAND generator: falling back to RANDOM generator");
2295 log_verbose(
"Island too small, trying again with all smaller "
2308 log_verbose(
"ISLAND generator: falling back to RANDOM generator");
2354 log_verbose(
"ISLAND generator: falling back to FRACTAL generator due "
2355 "to landpercent > 80.");
2361 log_verbose(
"ISLAND generator: falling back to FRACTAL generator due "
2362 "to unsupported map size.");
2401 log_normal(
_(
"Generator 3 didn't place all big islands."));
2452 log_verbose(
"ISLAND generator: falling back to startpos=SINGLE");
2669 return (diff != 0 ? diff :
index1->dist -
index2->dist);
2683 return (diff != 0 ? diff :
index1->dist -
index2->dist);
2727#define fair_do_iso_hex_symmetry2 fair_do_rotation
2802 for (steps =
fc_rand(99) % 3; steps > 0; steps--) {
2815 for (steps =
fc_rand(99) % 3; steps > 0; steps--) {
2834 int startpos_team_id)
2894 if (
pstile->pterrain !=
nullptr) {
2919 for (
i = 0;
i < 10;
i++) {
2948 int startpos_team_id)
2963 startpos_team_id)) {
3008 if (
pftile->presource !=
nullptr) {
3050 if (
pftile->pterrain ==
nullptr) {
3060 if (
phut !=
nullptr) {
3121 log_debug(
"Generating an island with %d land tiles [fantasy=%d].",
3189 }
while (
terrain[j].count == 0);
3232 for (
i = 0;
i <
n;
i++) {
3335 if (
pend ==
nullptr) {
3339 log_debug(
"Make river from (%d, %d) to (%d, %d) [dir=%s, length=%d]",
3478 ptile->extras_owner =
nullptr;
3511 log_verbose(
"Creating a map with fair island generator");
3516 log_debug(
"teams_num=%d, team_players_num=%d, single_players_num=%d",
3518 log_debug(
"playermass=%d, islandmass1=%d, islandmass2=%d, islandmass3=%d",
3523 while (--
iter >= 0) {
3549 log_debug(
"Place main islands on the map.");
3621 log_verbose(
"Team %d (%s) will start on (%d, %d)",
3627 log_verbose(
"Failed to place island number %d for team %d (%s).",
3657 log_debug(
"Create and place small islands on the map.");
3661 log_verbose(
"Failed to place small island2 number %d.",
i);
3673 log_verbose(
"Failed to place small island3 number %d.",
i);
3729 ptile->extras =
pftile->extras;
3734 if (
pftile->startpos_team_id != -1) {
3736 (
pftile->startpos_team_id)), pplayer) {
3750 log_verbose(
"Fair island map created with success!");
void dbv_init(struct dbv *pdbv, int bits)
void dbv_set(struct dbv *pdbv, int bit)
bool dbv_isset(const struct dbv *pdbv, int bit)
void dbv_free(struct dbv *pdbv)
void dbv_clr_all(struct dbv *pdbv)
#define BV_ISSET(bv, bit)
#define CITY_MAP_DEFAULT_RADIUS_SQ
#define CITY_MAP_DEFAULT_RADIUS
void make_fracture_map(void)
void make_fracture_relief(void)
static map_landmass * landmass
void renormalize_hmap_poles(void)
void height_map_to_map(void)
void normalize_hmap_poles(void)
bool area_is_too_flat(struct tile *ptile, int thill, int my_height)
void make_pseudofractal1_hmap(int extra_div)
void make_random_hmap(int smooth)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert_exit_msg(condition, message,...)
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
#define log_testmatic(message,...)
struct startpos * map_startpos_new(struct tile *ptile)
bool startpos_allows_all(const struct startpos *psp)
struct tile * rand_map_pos(const struct civ_map *nmap)
void main_map_allocate(void)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
int map_vector_to_sq_distance(int dx, int dy)
struct tile * rand_map_pos_filtered(const struct civ_map *nmap, void *data, bool(*filter)(const struct tile *ptile, const void *data))
int map_startpos_count(void)
bool is_cardinal_dir(enum direction8 dir)
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
#define current_topo_has_flag(flag)
#define native_pos_to_index(nat_x, nat_y)
static int index_to_map_pos_y(int mindex)
static const bool C_PERCENT
static const bool C_NUMBER
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define cardinal_adjc_iterate_end
#define adjc_iterate(nmap, center_tile, itr_tile)
#define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y)
static const bool C_ADJACENT
#define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y)
#define cardinal_adjc_dir_iterate_end
#define square_iterate_end
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
#define circle_iterate(nmap, center_tile, sq_radius, tile_itr)
static int index_to_map_pos_x(int mindex)
#define whole_map_iterate(_map, _tile)
static const bool C_CARDINAL
#define cardinal_adjc_dir_base_iterate_end
#define current_wrap_has_flag(flag)
#define cardinal_adjc_dir_base_iterate(nmap, center_tile, dir_itr)
#define index_to_native_pos(pnat_x, pnat_y, mindex)
#define cardinal_adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr)
#define whole_map_iterate_end
#define index_to_map_pos(pmap_x, pmap_y, mindex)
#define circle_iterate_end
#define DIRSTEP(dest_x, dest_y, dir)
static void make_plains(void)
static int fair_team_placement_vertical(const void *a, const void *b)
static void make_terrains(void)
static int hmap_low_level
static void make_rivers(void)
static void mapgenerator2(void)
#define terrain_select_list_iterate_end
#define NUM_TEST_FUNCTIONS
static void fair_do_hex_symmetry1(int *x, int *y)
#define fair_do_iso_hex_symmetry2
static void fair_map_make_resources(struct fair_tile *pmap)
static bool make_island(int islemass, int starters, struct gen234_state *pstate, int min_specific_island_size)
static int river_test_adjacent_swamp(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static struct fair_tile * fair_map_new(void)
static int river_test_height_map(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
struct terrain_select_list * mountain
static void fair_geometry_rand(struct fair_geometry_data *data)
#define map_pos_is_dry(ptile)
void(* fair_geometry_func)(int *x, int *y)
static void fair_do_iso_hex_symmetry1(int *x, int *y)
static void fair_do_geometry(const struct fair_geometry_data *data, int *x, int *y)
static void make_land(void)
static void initworld(struct gen234_state *pstate)
static struct fair_tile * fair_map_island_new(int size, int startpos_num)
static void fair_map_destroy(struct fair_tile *pmap)
static bool fair_map_tile_border(struct fair_tile *pmap, struct fair_tile *ptile, int dist)
static void mapgenerator4(void)
static void make_polar_land(void)
static void fair_do_hex_symmetry2(int *x, int *y)
static struct @99 island_terrain
static void fill_island(int coast, long int *bucket, const struct terrain_select_list *tersel_list, const struct gen234_state *const pstate)
#define map_pos_is_low(ptile)
static struct tile * rand_map_pos_characteristic(wetness_c wc, temperature_type tc, miscellaneous_c mc)
#define ini_hmap_low_level()
static void fair_map_tile_pos(struct fair_tile *pmap, struct fair_tile *ptile, int *x, int *y)
static void adjust_terrain_param(void)
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)
#define terrain_select_list_iterate(tersel_list, ptersel)
static bool test_miscellaneous(const struct tile *ptile, miscellaneous_c c)
static int river_test_adjacent_ocean(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static void print_mapgen_map(void)
struct terrain_select_list * forest
static bool place_island(struct gen234_state *pstate)
static void river_blockmark(struct river_map *privermap, struct tile *ptile)
static void make_huts(int number)
static bool test_wetness(const struct tile *ptile, wetness_c c)
static void island_terrain_free(void)
static bool is_tiny_island(struct tile *ptile)
struct terrain_select_list * swamp
static struct extra_type * river_types[MAX_EXTRA_TYPES]
static int river_type_count
#define PLACE_ONE_TYPE(count, alternate, ter, wc, tc, mc, weight)
static int river_test_adjacent_highlands(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static void river_types_init(void)
static bool near_safe_tiles(struct tile *ptile)
static bool ok_for_separate_poles(struct tile *ptile)
static void fair_do_symmetry1(int *x, int *y)
static bool is_near_land(struct tile *ptile)
static int fair_team_placement_horizontal(const void *a, const void *b)
static bool condition_filter(const struct tile *ptile, const void *data)
static struct tile * get_random_map_position_from_state(const struct gen234_state *const pstate)
static bool is_resource_close(const struct tile *ptile)
static void add_resources(int prob)
static void mapgenerator3(void)
static void fair_do_rotation(int *x, int *y)
static bool fair_map_place_island_rand(struct fair_tile *ptarget, struct fair_tile *psource)
static int river_test_highlands(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static void fill_island_rivers(int coast, long int *bucket, const struct gen234_state *const pstate)
static void fair_map_make_huts(struct fair_tile *pmap)
static int fair_team_placement_closest(const void *a, const void *b)
static bool make_river(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static void island_terrain_init(void)
static bool island_river_mouth_suitability(const struct tile *ptile, const struct extra_type *priver)
static int river_test_rivergrid(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static bool map_generate_fair_islands(void)
static void fair_do_iso_hex_rotation(int *x, int *y)
static void make_polar(void)
static bool create_island(int islemass, struct gen234_state *pstate)
static void make_plain(struct tile *ptile, int *to_be_placed)
static bool island_river_suitability(const struct tile *ptile, const struct extra_type *priver)
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 struct test_func test_funcs[NUM_TEST_FUNCTIONS]
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)
struct terrain_select_list * desert
static void make_relief(void)
static int river_test_adjacent_river(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static void fair_do_hex_rotation(int *x, int *y)
static void remove_tiny_islands(void)
static int river_test_swamp(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
static int count_card_adjc_elevated_tiles(struct tile *ptile)
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 bool terrain_is_too_high(struct tile *ptile, int thill, int my_height)
bool map_fractal_generate(bool autosize, struct unit_type *initial_unit)
static void fair_do_symmetry2(int *x, int *y)
static struct fair_tile * fair_map_pos_tile(struct fair_tile *pmap, int x, int y)
static void tersel_free(struct terrain_select *ptersel)
static long int checkmass
static struct fair_tile * fair_map_tile_step(struct fair_tile *pmap, struct fair_tile *ptile, enum direction8 dir)
static int river_test_blocked(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
void generator_init_topology(bool autosize)
int map_colatitude(const struct tile *ptile)
bool near_singularity(const struct tile *ptile)
struct extra_type * pick_resource(const struct terrain *pterrain)
void set_all_ocean_tiles_placed(void)
void create_placed_map(void)
void map_set_placed(struct tile *ptile)
void destroy_placed_map(void)
bool not_placed(const struct tile *ptile)
struct terrain * pick_terrain_by_flag(enum terrain_flag_id flag)
void assign_continent_numbers(void)
void regenerate_lakes(void)
void set_placed_near_pos(struct tile *ptile, int dist)
void smooth_water_depth(void)
bool placed_map_is_initialized(void)
struct terrain * pick_terrain(enum mapgen_terrain_property target, enum mapgen_terrain_property prefer, enum mapgen_terrain_property avoid)
struct terrain * most_shallow_ocean(bool frozen)
struct terrain * pick_ocean(int depth, bool frozen)
void map_unset_placed(struct tile *ptile)
#define fc_calloc(n, esz)
struct nation_type * nation_of_player(const struct player *pplayer)
#define player_list_iterate(playerlist, pplayer)
#define player_list_iterate_end
RANDOM_STATE fc_rand_state(void)
void fc_srand(RANDOM_TYPE seed)
void fc_rand_set_state(RANDOM_STATE state)
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
bool is_cardinal_only_road(const struct extra_type *pextra)
int count_river_type_tile_card(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
int count_river_type_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
int count_river_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver)
void array_shuffle(int *array, int n)
#define CLIP(lower, current, upper)
#define FC_WRAP(value, range)
bool create_start_positions(enum map_startpos mode, struct unit_type *initial_unit)
Continent_id num_continents
enum mapsize_type mapsize
enum map_startpos startpos
enum team_placement team_placement
struct civ_map::@44::@46 server
enum map_generator generator
fair_geometry_func transform[4]
struct terrain * pterrain
enum fair_tile_flag flags
struct extra_type * presource
enum mapgen_terrain_property avoid
enum mapgen_terrain_property target
enum mapgen_terrain_property prefer
int(* func)(struct river_map *privermap, struct tile *ptile, struct extra_type *priver)
struct team * team_by_number(const int team_id)
const char * team_rule_name(const struct team *pteam)
int team_number(const struct team *pteam)
const struct player_list * team_members(const struct team *pteam)
#define teams_iterate_end
#define teams_iterate(_pteam)
bool temperature_is_initialized(void)
bool tmap_is(const struct tile *ptile, temperature_type tt)
bool is_temperature_type_near(const struct tile *ptile, temperature_type tt)
void create_tmap(bool real)
Terrain_type_id terrain_count(void)
int count_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
bool is_terrain_class_card_near(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Terrain_type_id terrain_index(const struct terrain *pterrain)
const char * terrain_rule_name(const struct terrain *pterrain)
int count_terrain_property_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum mapgen_terrain_property prop)
bool is_terrain_near_tile(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
#define terrain_type_iterate(_p)
#define is_ocean(pterrain)
#define is_ocean_tile(ptile)
#define TERRAIN_OCEAN_DEPTH_MINIMUM
#define terrain_type_iterate_end
#define TERRAIN_OCEAN_DEPTH_MAXIMUM
#define terrain_has_flag(terr, flag)
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
void tile_virtual_destroy(struct tile *vtile)
bool tile_has_river(const struct tile *ptile)
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
struct tile * tile_virtual_new(const struct tile *ptile)
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
void tile_set_continent(struct tile *ptile, Continent_id val)
#define tile_resource(_tile)
#define tile_terrain(_tile)
static const bv_extras * tile_extras(const struct tile *ptile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define MAP_ITERATE_OUTWARDS_INDICES
#define MAP_NUM_VALID_DIRS
#define MAP_NUM_ITERATE_OUTWARDS_INDICES
#define MAP_NUM_CARDINAL_DIRS
#define MAP_CARDINAL_DIRS
#define MAP_NATIVE_HEIGHT