Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/generator/mapgen_utils.h File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Macros | Typedefs | Functions
mapgen_utils.h File Reference

Go to the source code of this file.

## Macros

#define | MG_UNUSED mapgen_terrain_property_invalid()
#define | do_in_map_pos(nmap, ptile, nat_x, nat_y)
#define | do_in_map_pos_end
#define | axis_iterate(nmap, center_tile, _tile, _index, dist, is_X_axis)
#define | axis_iterate_end
#define | whole_map_iterate_filtered(_tile, pdata, pfilter)
#define | whole_map_iterate_filtered_end
#define | adjust_int_map(int_map, int_map_min, int_map_max)

## Typedefs

typedef void(* | tile_knowledge_cb) (struct tile *ptile)

## Functions

void | generator_free (void)
void | regenerate_lakes (void)
void | smooth_water_depth (void)
void | assign_continent_numbers (void)
int | get_lake_surrounders (Continent_id cont)
int | get_continent_size (Continent_id id)
int | get_ocean_size (Continent_id id)
struct terrain * | most_shallow_ocean (bool frozen)
struct terrain * | pick_ocean (int depth, bool frozen)
struct terrain * | pick_terrain_by_flag (enum terrain_flag_id flag)
struct terrain * | pick_terrain (enum mapgen_terrain_property target, enum mapgen_terrain_property prefer, enum mapgen_terrain_property avoid)
struct extra_type * | pick_resource (const struct terrain *pterrain)
bool | is_normal_nat_pos (int x, int y)
void | adjust_int_map_filtered (int *int_map, int int_map_min, int int_map_max, void *data, bool(*filter)(const struct tile *ptile, const void *data))
void | smooth_int_map (int *int_map, bool zeroes_at_edges)
void | create_placed_map (void)
void | destroy_placed_map (void)
void | map_set_placed (struct tile *ptile)
void | map_unset_placed (struct tile *ptile)
bool | not_placed (const struct tile *ptile)
bool | placed_map_is_initialized (void)
void | set_all_ocean_tiles_placed (void)
void | set_placed_near_pos (struct tile *ptile, int dist)

## Macro Definition Documentation

## ◆ adjust_int_map

#define adjust_int_map | ( |  | int_map,
|  |  | int_map_min,
|  |  | int_map_max
| ) |  |

Value:
adjust_int_map_filtered(int_map, int_map_min, int_map_max, \
(void *)NULL, \
(bool (*)(const struct tile *ptile, const void *data))NULL)
incite_cost
char * incite_cost
Definition comments.c:74
adjust_int_map_filtered
void adjust_int_map_filtered(int *int_map, int int_map_min, int int_map_max, void *data, bool(*filter)(const struct tile *ptile, const void *data))
Definition mapgen_utils.c:123
tile
Definition tile.h:50

Definition at line 105 of file mapgen_utils.h.

## ◆ axis_iterate

#define axis_iterate | ( |  | nmap,
|  |  | center_tile,
|  |  | _tile,
|  |  | _index,
|  |  | dist,
|  |  | is_X_axis
| ) |  |

Value:
{ \
int _tile##_x, _tile##_y; \
struct tile *_tile; \
const struct tile *_tile##_center = (center_tile); \
const bool _index##_axis = (is_X_axis); \
const int _index##_d = (dist); \
int _index = -(_index##_d); \
\
for (; _index <= _index##_d; _index++) { \
int _nat##_x, _nat##_y; \
index_to_native_pos(&_nat##_x, &_nat##_y, tile_index(_tile##_center)); \
_tile##_x = _nat##_x + (_index##_axis ? _index : 0); \
_tile##_y = _nat##_y + (_index##_axis ? 0 : _index); \
_tile = native_pos_to_tile(nmap, _tile##_x, _tile##_y); \
if (NULL != _tile) {
native_pos_to_tile
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Definition map.c:443
center_tile
const struct tile * center_tile
Definition mapview_common.c:80
tile_index
#define tile_index(_pt_)
Definition tile.h:88

Definition at line 60 of file mapgen_utils.h.

## ◆ axis_iterate_end

#define axis_iterate_end

Value:
} \
} \
}

Definition at line 77 of file mapgen_utils.h.

## ◆ do_in_map_pos

#define do_in_map_pos | ( |  | nmap,
|  |  | ptile,
|  |  | nat_x,
|  |  | nat_y
| ) |  |

Value:
{ \
struct tile *ptile = native_pos_to_tile(nmap, (nat_x), (nat_y)); \
{
nat_x
#define nat_x
nat_y
#define nat_y

Definition at line 45 of file mapgen_utils.h.

## ◆ do_in_map_pos_end

#define do_in_map_pos_end

Value:
} \
}

Definition at line 50 of file mapgen_utils.h.

## ◆ MG_UNUSED

#define MG_UNUSED mapgen_terrain_property_invalid()

Definition at line 18 of file mapgen_utils.h.

## ◆ whole_map_iterate_filtered

#define whole_map_iterate_filtered | ( |  | _tile,
|  |  | pdata,
|  |  | pfilter
| ) |  |

Value:
{ \
bool (*_tile##_filter)(const struct tile *vtile, const void *vdata) = (pfilter);\
const void *_tile##_data = (pdata); \
\
whole_map_iterate(&(wld.map), _tile) { \
if (NULL == _tile##_filter || (_tile##_filter)(_tile, _tile##_data)) {
wld
struct world wld
Definition game.c:63
world::map
struct civ_map map
Definition world_object.h:38

Definition at line 85 of file mapgen_utils.h.

## ◆ whole_map_iterate_filtered_end

#define whole_map_iterate_filtered_end

Value:
} \
} whole_map_iterate_end; \
}
whole_map_iterate_end
#define whole_map_iterate_end
Definition map.h:554

Definition at line 93 of file mapgen_utils.h.

## Typedef Documentation

## ◆ tile_knowledge_cb

typedef void(* tile_knowledge_cb) (struct tile *ptile)

Definition at line 16 of file mapgen_utils.h.

## Function Documentation

## ◆ adjust_int_map_filtered()

void adjust_int_map_filtered | ( | int * | int_map,
|  | int | int_map_min,
|  | int | int_map_max,
|  | void * | data,
|  | bool(*)(const struct tile *ptile, const void *data) | filter
| ) |  |

Change the values of the integer map, so that they contain ranking of each tile scaled to [int_map_min .. int_map_max]. E.g. the lowest 20% of tiles will have values lower than int_map_min + 0.2 * (int_map_max - int_map_min).

If filter is non-null then it only tiles for which filter(ptile, data) is TRUE will be considered.

Definition at line 123 of file mapgen_utils.c.

Referenced by create_start_positions().

## ◆ assign_continent_numbers()

void assign_continent_numbers | ( | void |  | ) |

Assigns continent and ocean numbers to all tiles, and set map.num_continents and map.num_oceans. Recalculates continent and ocean sizes, and lake_surrounders[] arrays.

Continents have numbers 1 to map.num_continents inclusive. Oceans have (negative) numbers -1 to -map.num_oceans inclusive.

Definition at line 452 of file mapgen_utils.c.

Referenced by api_edit_change_terrain(), check_edited_tile_terrains(), check_terrain_change(), make_polar_land(), map_fractal_generate(), sg_load_map_tiles(), and sg_load_map_tiles().

## ◆ create_placed_map()

void create_placed_map | ( | void |  | ) |

Create a clean pmap

Definition at line 48 of file mapgen_utils.c.

Referenced by initworld(), make_huts(), make_land(), and make_rivers().

## ◆ destroy_placed_map()

void destroy_placed_map | ( | void |  | ) |

Free the pmap

Definition at line 58 of file mapgen_utils.c.

Referenced by make_huts(), make_land(), make_rivers(), mapgenerator2(), mapgenerator3(), and mapgenerator4().

## ◆ generator_free()

void generator_free | ( | void |  | ) |

Free resources allocated by the generator.

Definition at line 662 of file mapgen_utils.c.

Referenced by server_quit().

## ◆ get_continent_size()

int get_continent_size | ( | Continent_id | id | ) |

Return size in tiles of the given continent (not ocean)

Definition at line 428 of file mapgen_utils.c.

Referenced by calculate_want_for_paratrooper(), initialize_isle_data(), and is_valid_start_pos().

## ◆ get_lake_surrounders()

int get_lake_surrounders | ( | Continent_id | cont | ) |

Get continent surrounding lake, or -1 if there is multiple continents.

Definition at line 420 of file mapgen_utils.c.

Referenced by is_claimable_ocean().

## ◆ get_ocean_size()

int get_ocean_size | ( | Continent_id | id | ) |

Return size in tiles of the given ocean. You should use positive ocean number.

Definition at line 438 of file mapgen_utils.c.

Referenced by is_claimable_ocean().

## ◆ is_normal_nat_pos()

bool is_normal_nat_pos | ( | int | x,
|  | int | y
| ) |  |

Is given native position normal position

Definition at line 179 of file mapgen_utils.c.

## ◆ map_set_placed()

void map_set_placed | ( | struct tile * | ptile | ) |

Mark tile terrain as placed.

Definition at line 79 of file mapgen_utils.c.

Referenced by fill_island(), initworld(), make_fracture_relief(), make_plain(), make_relief(), make_rivers(), place_terrain(), set_all_ocean_tiles_placed(), and set_placed_near_pos().

## ◆ map_unset_placed()

void map_unset_placed | ( | struct tile * | ptile | ) |

Mark tile terrain as not placed.

Definition at line 87 of file mapgen_utils.c.

Referenced by place_island().

## ◆ most_shallow_ocean()

struct terrain * most_shallow_ocean | ( | bool | frozen | ) |

Return most shallow ocean terrain type. Prefers not to return freshwater terrain, and will ignore 'frozen' rather than do so.

Definition at line 500 of file mapgen_utils.c.

Referenced by check_terrain_change(), and remove_tiny_islands().

## ◆ not_placed()

bool not_placed | ( | const struct tile * | ptile | ) |

Checks if land has not yet been placed on pmap at (x, y)

Definition at line 71 of file mapgen_utils.c.

Referenced by condition_filter(), fill_island(), make_fracture_relief(), make_plains(), make_relief(), make_terrains(), and place_terrain().

## ◆ pick_ocean()

struct terrain * pick_ocean | ( | int | depth,
|  | bool | frozen
| ) |  |

Picks an ocean terrain to match the given depth. Only considers terrains with/without Frozen flag depending on 'frozen'. Return NULL when there is no available ocean.

Definition at line 546 of file mapgen_utils.c.

Referenced by fair_map_island_new(), initworld(), make_land(), make_polar(), map_generate_fair_islands(), and smooth_water_depth().

## ◆ pick_resource()

struct extra_type * pick_resource | ( | const struct terrain * | pterrain | ) |

Pick a random resource to put on a tile of the given terrain type. May return NULL when there is no eligible resource.

Definition at line 800 of file mapgen_utils.c.

Referenced by add_resources(), and fair_map_make_resources().

## ◆ pick_terrain()

struct terrain * pick_terrain | ( | enum mapgen_terrain_property | target,
|  | enum mapgen_terrain_property | prefer,
|  | enum mapgen_terrain_property | avoid
| ) |  |

Pick a terrain based on the target property and a property to avoid.

If the target property is given, then all terrains with that property will be considered and one will be picked at random based on the amount of the property each terrain has. If no target property is given all terrains will be assigned equal likelihood.

If the preferred property is given, only terrains with (some of) that property will be chosen.

If the avoid property is given, then any terrain with (any of) that property will be avoided.

This function must always return a valid terrain.

Definition at line 725 of file mapgen_utils.c.

Referenced by fair_map_island_new(), fill_island(), make_fracture_relief(), make_plain(), make_polar(), make_relief(), make_terrains(), and pick_terrain().

## ◆ pick_terrain_by_flag()

struct terrain * pick_terrain_by_flag | ( | enum terrain_flag_id | flag | ) |

Return a random terrain that has the specified flag. Returns T_UNKNOWN when there is no matching terrain.

Definition at line 682 of file mapgen_utils.c.

Referenced by fair_map_island_new(), and make_rivers().

## ◆ placed_map_is_initialized()

bool placed_map_is_initialized | ( | void |  | ) |

Return TRUE if initialized

Definition at line 40 of file mapgen_utils.c.

Referenced by create_placed_map(), destroy_placed_map(), and mapgenerator2().

## ◆ regenerate_lakes()

void regenerate_lakes | ( | void |  | ) |

Regenerate all oceanic tiles for small water bodies as lakes. Assumes assign_continent_numbers() and recalculate_lake_surrounders() have already been done! FIXME: insufficiently generalized, use terrain property.

Definition at line 350 of file mapgen_utils.c.

Referenced by map_fractal_generate().

## ◆ set_all_ocean_tiles_placed()

void set_all_ocean_tiles_placed | ( | void |  | ) |

Set all oceanics tiles in placed_map

Definition at line 95 of file mapgen_utils.c.

Referenced by make_land(), and make_rivers().

## ◆ set_placed_near_pos()

void set_placed_near_pos | ( | struct tile * | ptile,
|  | int | dist
| ) |  |

Set all nearby tiles as placed on pmap.

Definition at line 107 of file mapgen_utils.c.

Referenced by make_huts().

## ◆ smooth_int_map()

void smooth_int_map | ( | int * | int_map,
|  | bool | zeroes_at_edges
| ) |  |

Apply a Gaussian diffusion filter on the map. The size of the map is MAP_INDEX_SIZE and the map is indexed by native_pos_to_index function. If zeroes_at_edges is set, any unreal position on diffusion has 0 value if zeroes_at_edges in unset the unreal position are not counted.

Definition at line 191 of file mapgen_utils.c.

Referenced by create_start_positions(), and make_random_hmap().

## ◆ smooth_water_depth()

void smooth_water_depth | ( | void |  | ) |

Makes a simple depth map for all ocean tiles based on their proximity to any land tiles and reassignes ocean terrain types based on their MG_OCEAN_DEPTH property values.

Definition at line 612 of file mapgen_utils.c.

Referenced by map_fractal_generate().