Freeciv-3.2
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
16typedef 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);
28
30struct terrain *pick_ocean(int depth, bool frozen);
31
34 enum mapgen_terrain_property prefer,
35 enum mapgen_terrain_property avoid);
36struct extra_type *pick_resource(const struct terrain *pterrain);
37
38/* Provide a block to convert from native to map coordinates. For instance
39 * do_in_map_pos(mx, my, xn, yn) {
40 * tile_set_terrain(mx, my, T_OCEAN);
41 * } do_in_map_pos_end;
42 * Note: that the map position is declared as const and can't be changed
43 * inside the block.
44 */
45#define do_in_map_pos(nmap, ptile, nat_x, nat_y) \
46{ \
47 struct tile *ptile = native_pos_to_tile(nmap, (nat_x), (nat_y)); \
48 {
49
50#define do_in_map_pos_end \
51 } \
52}
53
54/***************************************************************************
55 iterate on selected axe (x if is_X_axis is TRUE) over a interval of -dist
56 to dist around the center_tile
57 _index : the position in the interval of iteration (from -dist to dist)
58 _tile : the tile pointer
59 ***************************************************************************/
60#define axis_iterate(nmap, center_tile, _tile, _index, dist, is_X_axis) \
61{ \
62 int _tile##_x, _tile##_y; \
63 struct tile *_tile; \
64 const struct tile *_tile##_center = (center_tile); \
65 const bool _index##_axis = (is_X_axis); \
66 const int _index##_d = (dist); \
67 int _index = -(_index##_d); \
68 \
69 for (; _index <= _index##_d; _index++) { \
70 int _nat##_x, _nat##_y; \
71 index_to_native_pos(&_nat##_x, &_nat##_y, tile_index(_tile##_center)); \
72 _tile##_x = _nat##_x + (_index##_axis ? _index : 0); \
73 _tile##_y = _nat##_y + (_index##_axis ? 0 : _index); \
74 _tile = native_pos_to_tile(nmap, _tile##_x, _tile##_y); \
75 if (NULL != _tile) {
76
77#define axis_iterate_end \
78 } \
79 } \
80}
81
82/***************************************************************************
83 pdata or pfilter can be NULL!
84***************************************************************************/
85#define whole_map_iterate_filtered(_tile, pdata, pfilter) \
86{ \
87 bool (*_tile##_filter)(const struct tile *vtile, const void *vdata) = (pfilter);\
88 const void *_tile##_data = (pdata); \
89 \
90 whole_map_iterate(&(wld.map), _tile) { \
91 if (NULL == _tile##_filter || (_tile##_filter)(_tile, _tile##_data)) {
92
93#define whole_map_iterate_filtered_end \
94 } \
95 } whole_map_iterate_end; \
96}
97
98bool is_normal_nat_pos(int x, int y);
99
100/* int maps tools */
102 int int_map_max, void *data,
103 bool (*filter)(const struct tile *ptile,
104 const void *data));
105#define adjust_int_map(int_map, int_map_min, int_map_max) \
106 adjust_int_map_filtered(int_map, int_map_min, int_map_max, \
107 (void *)NULL, \
108 (bool (*)(const struct tile *ptile, const void *data))NULL)
109void smooth_int_map(int *int_map, bool zeroes_at_edges);
110
111/* placed_map tool */
112void create_placed_map(void);
113void destroy_placed_map(void);
114void map_set_placed(struct tile *ptile);
115void map_unset_placed(struct tile *ptile);
116bool not_placed(const struct tile *ptile);
119void set_placed_near_pos(struct tile *ptile, int dist);
120
121#endif /* FC__MAPGEN_UTILS_H */
char * incite_cost
Definition comments.c:75
signed short Continent_id
Definition fc_types.h:372
int get_continent_size(Continent_id id)
struct extra_type * pick_resource(const struct terrain *pterrain)
void smooth_int_map(int *int_map, bool zeroes_at_edges)
void set_all_ocean_tiles_placed(void)
void create_placed_map(void)
void(* tile_knowledge_cb)(struct tile *ptile)
void map_set_placed(struct tile *ptile)
void destroy_placed_map(void)
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))
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)
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)
void map_unset_placed(struct tile *ptile)
int get_lake_surrounders(Continent_id cont)
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct extra_type::@25 data
Definition tile.h:50