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; \
192#define map_pos_is_low(ptile) ((hmap((ptile)) < hmap_low_level))
230 log_error(
"Invalid miscellaneous_c %d", c);
464#define PLACE_ONE_TYPE(count, alternate, ter, wc, tc, mc, weight) \
466 struct tile *ptile; \
468 if ((ptile = rand_map_pos_characteristic((wc), (tc), (mc)))) { \
469 place_terrain(ptile, (weight), (ter), &(count), (wc),(tc), (mc)); \
473 (alternate) += (count); \
683#define NUM_TEST_FUNCTIONS 9
801 log_debug(
"The tile at (%d, %d) has been marked as river in river_map.",
817 log_debug(
"The river did not end at (%d, %d). Evaluating directions...",
874 log_debug(
"mapgen.c: Had to let the random number"
875 " generator select a direction for a river.");
877 log_debug(
"mapgen.c: direction: %d", direction);
1002 log_debug(
"Found a suitable starting tile for a river at (%d, %d)."
1003 " Starting to make it.",
TILE_XY(ptile));
1026 log_debug(
"mapgen.c: A river failed. It might have gotten stuck "
1031 log_debug(
"current_riverlength: %d; desirable_riverlength: %d; "
1032 "iteration_counter: %d",
1066 "No land terrain type could be found for the purpose "
1067 "of temporarily filling in land tiles during map "
1068 "generation. This could be an error in Freeciv, or a "
1069 "mistake in the terrain.ruleset file. Please make sure "
1070 "there is at least one land terrain type in the "
1071 "ruleset, or use a different map generator. If this "
1072 "error persists, please report it at: %s",
BUG_URL);
1093 depth += 30 * (ocean -
land) /
MAX(1, (ocean +
land));
1109 if (
frozen && !pterrain) {
1203 int total = 0, ocean = 0;
1229 log_verbose(
" %-20s : %6d %5.1f%% (ocean: %5.1f%%)",
1237 log_verbose(
" %-20s : %6d %5.1f%% (land: %5.1f%%)",
1275#ifdef FREECIV_TESTMATIC
1405 "Fair island generator failed to allocated "
1406 "start positions!");
1425 log_verbose(
"Map generator chose startpos=SINGLE");
1465 log_error(
_(
"The server couldn't allocate starting positions."));
1651 if (*bucket <= 0 ) {
1709 log_debug(
"[fill_island] placed terrain '%s' at (%2d,%2d)",
1786 i = (
i * 175) / 100;
1890 log_error(
"mapgen.c: mass doesn't sum up.");
1948 while (
i > 0 &&
tries-->0) {
1975 if (
hmap(ptile) == 0 &&
i > 0
2104 if (
pstate->totalmass > 3000) {
2105 log_normal(
_(
"High landmass - this may take a few seconds."));
2109 i = (
i <= 90) ? 100 :
i * 11 / 10;
2209 ptile->extras_owner =
NULL;
2247 log_verbose(
"ISLAND generator: falling back to RANDOM generator");
2280 log_verbose(
"Island too small, trying again with all smaller "
2293 log_verbose(
"ISLAND generator: falling back to RANDOM generator");
2337 log_verbose(
"ISLAND generator: falling back to FRACTAL generator due "
2338 "to landpercent > 80.");
2344 log_verbose(
"ISLAND generator: falling back to FRACTAL generator due "
2345 "to unsupported map size.");
2385 log_normal(
_(
"Generator 3 didn't place all big islands."));
2436 log_verbose(
"ISLAND generator: falling back to startpos=SINGLE");
2650 return (diff != 0 ? diff :
index1->dist -
index2->dist);
2664 return (diff != 0 ? diff :
index1->dist -
index2->dist);
2708#define fair_do_iso_hex_symmetry2 fair_do_rotation
2783 for (steps =
fc_rand(99) % 3; steps > 0; steps--) {
2796 for (steps =
fc_rand(99) % 3; steps > 0; steps--) {
2813 int startpos_team_id)
2897 for (
i = 0;
i < 10;
i++) {
2926 int startpos_team_id)
2941 startpos_team_id)) {
3099 log_debug(
"Generating an island with %d land tiles [fantasy=%d].",
3166 }
while (
terrain[j].count == 0);
3209 for (
i = 0;
i <
n;
i++) {
3316 log_debug(
"Make river from (%d, %d) to (%d, %d) [dir=%s, length=%d]",
3455 ptile->extras_owner =
NULL;
3488 log_verbose(
"Creating a map with fair island generator");
3493 log_debug(
"teams_num=%d, team_players_num=%d, single_players_num=%d",
3495 log_debug(
"playermass=%d, islandmass1=%d, islandmass2=%d, islandmass3=%d",
3500 while (--
iter >= 0) {
3526 log_debug(
"Place main islands on the map.");
3598 log_verbose(
"Team %d (%s) will start on (%d, %d)",
3604 log_verbose(
"Failed to place island number %d for team %d (%s).",
3634 log_debug(
"Create and place small islands on the map.");
3638 log_verbose(
"Failed to place small island2 number %d.",
i);
3650 log_verbose(
"Failed to place small island3 number %d.",
i);
3706 ptile->extras =
pftile->extras;
3711 if (
pftile->startpos_team_id != -1) {
3713 (
pftile->startpos_team_id)), pplayer) {
3727 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
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction bool fatal
#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 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 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 struct @96 island_terrain
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)
enum direction8 valid_dirs[8]
Continent_id num_continents
int num_iterate_outwards_indices
enum mapsize_type mapsize
enum map_startpos startpos
struct civ_map::@42::@44 server
struct iter_index * iterate_outwards_indices
enum team_placement team_placement
enum direction8 cardinal_dirs[8]
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)