Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/generator/mapgen_utils.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
mapgen_utils.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2004 - Marcelo J. Burda
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__MAPGEN_UTILS_H
14#define FC__MAPGEN_UTILS_H
15
16 typedef void (*tile_knowledge_cb)(struct tile *ptile);
17
18#define MG_UNUSED mapgen_terrain_property_invalid()
19
20void generator_free(void);
21
22void regenerate_lakes(void);
23void smooth_water_depth(void);
24void assign_continent_numbers(void);
25int get_lake_surrounders(Continent_id cont);
26int get_continent_size(Continent_id id);
27int get_ocean_size(Continent_id id);
28
29struct terrain *most_shallow_ocean(bool frozen);
30struct terrain *pick_ocean(int depth, bool frozen);
31
32struct terrain *pick_terrain_by_flag(enum terrain_flag_id flag);
33struct terrain *pick_terrain(enum mapgen_terrain_property target,
34 enum mapgen_terrain_property prefer,
35 enum mapgen_terrain_property avoid);
36
37/* Provide a block to convert from native to map coordinates. For instance
38 * do_in_map_pos(mx, my, xn, yn) {
39 * tile_set_terrain(mx, my, T_OCEAN);
40 * } do_in_map_pos_end;
41 * Note: that the map position is declared as const and can't be changed
42 * inside the block.
43 */
44#define do_in_map_pos(nmap, ptile, nat_x, nat_y) \
45{ \
46 struct tile *ptile = native_pos_to_tile(nmap, (nat_x), (nat_y)); \
47 {
48
49#define do_in_map_pos_end \
50 } \
51}
52
53/***************************************************************************
54 iterate on selected axe (x if is_X_axis is TRUE) over a interval of -dist
55 to dist around the center_tile
56 _index : the position in the interval of iteration (from -dist to dist)
57 _tile : the tile pointer
58 ***************************************************************************/
59#define axis_iterate(nmap, center_tile, _tile, _index, dist, is_X_axis) \
60{ \
61 int _tile##_x, _tile##_y; \
62 struct tile *_tile; \
63 const struct tile *_tile##_center = (center_tile); \
64 const bool _index##_axis = (is_X_axis); \
65 const int _index##_d = (dist); \
66 int _index = -(_index##_d); \
67 \
68 for (; _index <= _index##_d; _index++) { \
69 int _nat##_x, _nat##_y; \
70 index_to_native_pos(&_nat##_x, &_nat##_y, tile_index(_tile##_center)); \
71 _tile##_x = _nat##_x + (_index##_axis ? _index : 0); \
72 _tile##_y = _nat##_y + (_index##_axis ? 0 : _index); \
73 _tile = native_pos_to_tile(nmap, _tile##_x, _tile##_y); \
74 if (NULL != _tile) {
75
76#define axis_iterate_end \
77 } \
78 } \
79}
80
81/***************************************************************************
82 pdata or pfilter can be NULL!
83***************************************************************************/
84#define whole_map_iterate_filtered(_tile, pdata, pfilter) \
85{ \
86 bool (*_tile##_filter)(const struct tile *vtile, const void *vdata) = (pfilter);\
87 const void *_tile##_data = (pdata); \
88 \
89 whole_map_iterate(&(wld.map), _tile) { \
90 if (NULL == _tile##_filter || (_tile##_filter)(_tile, _tile##_data)) {
91
92#define whole_map_iterate_filtered_end \
93 } \
94 } whole_map_iterate_end; \
95}
96
97bool is_normal_nat_pos(int x, int y);
98
99/* int maps tools */
100void adjust_int_map_filtered(int *int_map, int int_map_max, void *data,
101 bool (*filter)(const struct tile *ptile,
102 const void *data));
103#define adjust_int_map(int_map, int_map_max) \
104 adjust_int_map_filtered(int_map, int_map_max, (void *)NULL, \
105 (bool (*)(const struct tile *ptile, const void *data) )NULL)
106void smooth_int_map(int *int_map, bool zeroes_at_edges);
107
108/* placed_map tool */
109void create_placed_map(void);
110void destroy_placed_map(void);
111void map_set_placed(struct tile *ptile);
112void map_unset_placed(struct tile *ptile);
113bool not_placed(const struct tile *ptile);
114bool placed_map_is_initialized(void);
115void set_all_ocean_tiles_placed(void) ;
116void set_placed_near_pos(struct tile *ptile, int dist);
117
118#endif /* FC__MAPGEN_UTILS_H */
Continent_id
signed short Continent_id
Definition fc_types.h:342
get_continent_size
int get_continent_size(Continent_id id)
Definition mapgen_utils.c:425
smooth_int_map
void smooth_int_map(int *int_map, bool zeroes_at_edges)
Definition mapgen_utils.c:188
set_all_ocean_tiles_placed
void set_all_ocean_tiles_placed(void)
Definition mapgen_utils.c:95
create_placed_map
void create_placed_map(void)
Definition mapgen_utils.c:48
tile_knowledge_cb
void(* tile_knowledge_cb)(struct tile *ptile)
Definition mapgen_utils.h:16
map_set_placed
void map_set_placed(struct tile *ptile)
Definition mapgen_utils.c:79
destroy_placed_map
void destroy_placed_map(void)
Definition mapgen_utils.c:58
not_placed
bool not_placed(const struct tile *ptile)
Definition mapgen_utils.c:71
pick_terrain_by_flag
struct terrain * pick_terrain_by_flag(enum terrain_flag_id flag)
Definition mapgen_utils.c:679
assign_continent_numbers
void assign_continent_numbers(void)
Definition mapgen_utils.c:449
adjust_int_map_filtered
void adjust_int_map_filtered(int *int_map, int int_map_max, void *data, bool(*filter)(const struct tile *ptile, const void *data))
Definition mapgen_utils.c:122
regenerate_lakes
void regenerate_lakes(void)
Definition mapgen_utils.c:347
set_placed_near_pos
void set_placed_near_pos(struct tile *ptile, int dist)
Definition mapgen_utils.c:107
get_ocean_size
int get_ocean_size(Continent_id id)
Definition mapgen_utils.c:435
generator_free
void generator_free(void)
Definition mapgen_utils.c:659
smooth_water_depth
void smooth_water_depth(void)
Definition mapgen_utils.c:609
placed_map_is_initialized
bool placed_map_is_initialized(void)
Definition mapgen_utils.c:40
is_normal_nat_pos
bool is_normal_nat_pos(int x, int y)
Definition mapgen_utils.c:176
pick_terrain
struct terrain * pick_terrain(enum mapgen_terrain_property target, enum mapgen_terrain_property prefer, enum mapgen_terrain_property avoid)
Definition mapgen_utils.c:722
most_shallow_ocean
struct terrain * most_shallow_ocean(bool frozen)
Definition mapgen_utils.c:497
pick_ocean
struct terrain * pick_ocean(int depth, bool frozen)
Definition mapgen_utils.c:543
map_unset_placed
void map_unset_placed(struct tile *ptile)
Definition mapgen_utils.c:87
get_lake_surrounders
int get_lake_surrounders(Continent_id cont)
Definition mapgen_utils.c:417
terrain
Definition terrain.h:176
tile
Definition tile.h:49