66#define pmap(_tile) (placed_map[tile_index(_tile)])
123 bool (*filter)(
const struct tile *ptile,
126 int minval = 0, maxval = 0, total = 0;
147 int const size = 1 + maxval - minval;
148 int i, count = 0, frequencies[
size];
161 for (i = 0; i <
size; i++) {
162 count += frequencies[i];
163 frequencies[i] = (count * int_map_max) / total;
190 static const float weight_standard[5] = { 0.13, 0.19, 0.37, 0.19, 0.13 };
191 static const float weight_isometric[5] = { 0.15, 0.21, 0.29, 0.21, 0.15 };
194 int *target_map, *source_map;
199 weight = weight_standard;
200 target_map = alt_int_map;
201 source_map = int_map;
209 N += weight[i + 2] * source_map[
tile_index(pnear)];
211 if (zeroes_at_edges) {
218 weight = weight_isometric;
223 source_map = alt_int_map;
224 target_map = int_map;
289 struct tile_list *tlist = NULL;
290 const struct terrain *pterrain;
294#ifndef FREECIV_NDEBUG
303 tlist = tile_list_new();
304 tile_list_append(tlist, ptile);
306 while (tile_list_size(tlist) > 0) {
307 struct tile *ptile2 = tile_list_get(tlist, 0);
321 if (!tile_list_search(tlist, ptile3)) {
322 tile_list_append(tlist, ptile3);
328 tile_list_remove(tlist, ptile2);
338 tile_list_destroy(tlist);
353 int num_laketypes[2] = { 0, 0 };
361 if (num_laketypes[frozen] <
ARRAY_SIZE(lakes[frozen])) {
362 lakes[frozen][num_laketypes[frozen]++] = pterr;
364 log_verbose(
"Ruleset has more than %d %s lake types, ignoring %s",
366 frozen ?
"frozen" :
"unfrozen",
377 if (num_laketypes[0] == 0) {
379 }
else if (num_laketypes[1] == 0) {
381 lake_for_ocean[0][i] = lake_for_ocean[1][i]
382 = lakes[0][
fc_rand(num_laketypes[0])];
387 for (frozen = 0; frozen < 2; frozen++) {
388 lake_for_ocean[frozen][i]
389 = lakes[frozen][
fc_rand(num_laketypes[frozen])];
500 struct terrain *shallow = NULL;
507 if (!oceans && nonfresh) {
511 frozenmatch = frozen_ok;
513 }
else if (oceans && !nonfresh) {
517 if (!frozenmatch && frozen_ok) {
523 }
else if (frozenmatch && !frozen_ok) {
528 || pterr->
property[MG_OCEAN_DEPTH] <
529 shallow->
property[MG_OCEAN_DEPTH]) {
545 struct terrain *best_terrain = NULL;
550 && TERRAIN_OCEAN_DEPTH_MINIMUM <= pterrain->
property[MG_OCEAN_DEPTH]
553 int match = abs(depth - pterrain->property[MG_OCEAN_DEPTH]);
555 if (best_match > match) {
557 best_terrain = pterrain;
595 if (pterrain ==
tile_terrain(atile) && need <= ++count) {
611 const int OCEAN_DEPTH_STEP = 25;
612 const int OCEAN_DEPTH_RAND = 15;
624 if (dist <= OCEAN_DIST_MAX) {
630 log_debug(
"Replacing %s by %s at (%d, %d) "
631 "to have shallow ocean on coast.",
647 log_debug(
"Replacing %s by %s at (%d, %d) "
648 "to smooth the ocean types.",
723 enum mapgen_terrain_property prefer,
724 enum mapgen_terrain_property avoid)
731 if (avoid !=
MG_UNUSED && pterrain->property[avoid] > 0) {
734 if (prefer !=
MG_UNUSED && pterrain->property[prefer] == 0) {
754 if (avoid !=
MG_UNUSED && pterrain->property[avoid] > 0) {
757 if (prefer !=
MG_UNUSED && pterrain->property[prefer] == 0) {
762 property = pterrain->property[target];
776 log_debug(
"pick_terrain(target: %s, [dropping prefer: %s], avoid: %s)",
777 mapgen_terrain_property_name(target),
778 mapgen_terrain_property_name(prefer),
779 mapgen_terrain_property_name(avoid));
782 log_debug(
"pick_terrain(target: %s, prefer: MG_UNUSED, [dropping avoid: %s])",
783 mapgen_terrain_property_name(target),
784 mapgen_terrain_property_name(avoid));
787 log_debug(
"pick_terrain([dropping target: %s], prefer: MG_UNUSED, avoid: MG_UNUSED)",
788 mapgen_terrain_property_name(target));
signed short Continent_id
#define fc_assert_ret(condition)
#define log_verbose(message,...)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
bool is_normal_map_pos(int x, int y)
struct terrain_misc terrain_control
int map_vector_to_real_distance(int dx, int dy)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y)
#define square_iterate_end
#define whole_map_iterate(_map, _tile)
#define square_dxy_iterate(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)
#define whole_map_iterate_end
#define square_dxy_iterate_end
int get_continent_size(Continent_id id)
static struct terrain * most_adjacent_ocean_type(const struct tile *ptile)
static int * continent_sizes
void smooth_int_map(int *int_map, bool zeroes_at_edges)
void set_all_ocean_tiles_placed(void)
void create_placed_map(void)
static int real_distance_to_land(const struct tile *ptile, int max)
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)
static Continent_id * lake_surrounders
void adjust_int_map_filtered(int *int_map, int int_map_max, void *data, bool(*filter)(const struct tile *ptile, const void *data))
void regenerate_lakes(void)
static void recalculate_lake_surrounders(void)
void set_placed_near_pos(struct tile *ptile, int dist)
int get_ocean_size(Continent_id id)
void generator_free(void)
void smooth_water_depth(void)
bool placed_map_is_initialized(void)
bool is_normal_nat_pos(int x, int y)
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)
static void assign_continent_flood(struct tile *ptile, bool is_land, int nr)
void map_unset_placed(struct tile *ptile)
int get_lake_surrounders(Continent_id cont)
#define whole_map_iterate_filtered(_tile, pdata, pfilter)
#define axis_iterate(nmap, center_tile, _tile, _index, dist, is_X_axis)
#define whole_map_iterate_filtered_end
#define fc_calloc(n, esz)
#define fc_realloc(ptr, sz)
#define INITIALIZE_ARRAY(array, size, value)
Terrain_type_id terrain_count(void)
Terrain_type_id terrain_index(const struct terrain *pterrain)
const char * terrain_rule_name(const struct terrain *pterrain)
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
#define terrain_type_iterate(_p)
#define is_ocean(pterrain)
#define is_ocean_tile(ptile)
#define terrain_type_iterate_end
#define TERRAIN_OCEAN_DEPTH_MAXIMUM
#define terrain_has_flag(terr, flag)
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
void tile_set_continent(struct tile *ptile, Continent_id val)
#define tile_terrain(_tile)
#define tile_continent(_tile)