50#define SPECHASH_TAG startpos
51#define SPECHASH_IKEY_TYPE struct tile *
52#define SPECHASH_IDATA_TYPE struct startpos *
53#define SPECHASH_IDATA_FREE startpos_destroy
64#define STARTPOS_ITER(p) ((struct startpos_iter *) (p))
85const int DIR_DX[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
86const int DIR_DY[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
95 const struct tile *t2);
161 imap->num_continents = 0;
162 imap->num_oceans = 0;
163 imap->tiles =
nullptr;
164 imap->startpos_table =
nullptr;
165 imap->iterate_outwards_indices =
nullptr;
176 imap->continent_sizes =
nullptr;
177 imap->ocean_sizes =
nullptr;
187 imap->server.huts_absolute = -1;
201 imap->server.island_surrounders =
nullptr;
202 imap->server.lake_surrounders =
nullptr;
297 for (
i = 0;
i < tiles;
i++) {
331 nmap->num_valid_dirs =
nmap->num_cardinal_dirs = 0;
339 for (dir = 0; dir < 8; dir++) {
341 nmap->valid_dirs[
nmap->num_valid_dirs] = dir;
342 nmap->num_valid_dirs++;
348 nmap->cardinal_dirs[
nmap->num_cardinal_dirs] = dir;
349 nmap->num_cardinal_dirs++;
357 &&
nmap->num_cardinal_dirs <=
nmap->num_valid_dirs);
371 ptile->
owner =
nullptr;
443 if (
nmap->tiles ==
nullptr) {
461 if (
nmap->tiles ==
nullptr) {
473 if (
imap->tiles ==
nullptr) {
500 ptile->
label =
nullptr;
510 log_debug(
"map_allocate (was %p) (%d,%d)",
520 ptile->index = ptile -
amap->tiles;
525 if (
amap->startpos_table !=
nullptr) {
555 fmap->tiles =
nullptr;
557 if (
fmap->startpos_table) {
559 fmap->startpos_table =
nullptr;
564 if (
fmap->continent_sizes) {
567 if (
fmap->ocean_sizes) {
572 if (
fmap->server.island_surrounders) {
575 if (
fmap->server.lake_surrounders) {
579 if (
fmap->client.adj_matrix) {
582 for (
i = 0;
i <=
fmap->num_continents;
i++) {
583 if (
fmap->client.adj_matrix[
i]) {
593 fmap->num_continents =
fmap->num_oceans = 0;
631 || (dx > 0 && dy < 0)) {
641 if ((dx > 0 && dy > 0)
642 || (dx < 0 && dy < 0)) {
668 return dx * dx + dy * dy;
730 const struct tile *ptile)
745 const struct tile *ptile)
759 const struct tile *ptile)
774 const struct tile *ptile)
788 const struct tile *ptile,
789 const struct terrain *pterrain)
915 const struct player *pplayer,
916 const struct tile *t1,
const struct tile *t2)
988 switch (
proad->move_mode) {
1034 return cost * 181 >> 7;
1048 const struct tile *t2)
1121 if (ptile !=
nullptr) {
1243 bool (*filter)(
const struct tile *ptile,
1254 }
while (filter !=
nullptr && !filter(ptile, data) && ++
tries <
max_tries);
1258 if (filter ==
nullptr) {
1261 int count = 0, *positions;
1470 const struct tile *start_tile,
1471 const struct tile *end_tile,
1489 const struct tile *start_tile,
1490 const struct tile *end_tile)
1508 const struct tile *start_tile,
1509 const struct tile *end_tile)
1600 x = 2.0 * (
x > 0.5 ? 1.0 -
x :
x);
1601 y = 2.0 * (
y > 0.5 ? 1.0 -
y :
y);
1668 - 0.5 * (
x *
x *
x +
y *
y *
y)
1669 + 1.5 * (
x *
x +
y *
y));
1694 int north_latitude, south_latitude;
1700 if (north_latitude == south_latitude) {
1702 return south_latitude;
1983 if (psp ==
nullptr) {
#define CALL_FUNC_EACH_AI(_func,...)
#define BV_ISSET(bv, bit)
#define BV_ISSET_ANY(vec)
void generate_city_map_indices(void)
int compare_iter_index(const void *a, const void *b)
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 * punit
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 cost
static bool is_server(void)
signed short Continent_id
struct iterator * invalid_iter_init(struct iterator *it)
static void * iterator_get(const struct iterator *it)
static bool iterator_valid(const struct iterator *it)
static void iterator_next(struct iterator *it)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
bv_extras get_tile_infrastructure_set(const struct tile *ptile, int *pcount)
bool can_channel_land(const struct civ_map *nmap, const struct tile *ptile)
struct startpos * map_startpos_get(const struct tile *ptile)
bool is_normal_map_pos(int x, int y)
int get_continent_size(Continent_id id)
int startpos_number(const struct startpos *psp)
bool can_reclaim_ocean(const struct civ_map *nmap, const struct tile *ptile)
bool startpos_disallow(struct startpos *psp, struct nation_type *pnation)
static int map_vector_to_distance(int dx, int dy)
enum direction8 opposite_direction(enum direction8 dir)
bool is_move_cardinal(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
bool can_freeze_terrain(const struct civ_map *nmap, const struct tile *ptile)
struct startpos * map_startpos_new(struct tile *ptile)
bool can_thaw_terrain(const struct civ_map *nmap, const struct tile *ptile)
int tile_move_cost_ptrs(const struct civ_map *nmap, const struct unit *punit, const struct unit_type *punittype, const struct player *pplayer, const struct tile *t1, const struct tile *t2)
static void tile_free(struct tile *ptile)
bool startpos_nation_allowed(const struct startpos *psp, const struct nation_type *pnation)
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
struct tile * startpos_tile(const struct startpos *psp)
bool startpos_allows_all(const struct startpos *psp)
const struct nation_hash * startpos_raw_nations(const struct startpos *psp)
struct tile * rand_map_pos(const struct civ_map *nmap)
static bool restrict_infra(const struct player *pplayer, const struct tile *t1, const struct tile *t2)
static struct tile * base_native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
static void generate_map_indices(void)
const char * dir_get_name(enum direction8 dir)
enum direction8 dir_ccw(enum direction8 dir)
struct iterator * map_startpos_iter_init(struct map_startpos_iter *iter)
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
void map_allocate(struct civ_map *amap)
void map_init_topology(struct civ_map *nmap)
void main_map_allocate(void)
static bool dir_validity[9]
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
static struct startpos * startpos_new(struct tile *ptile)
static double map_relative_southness(const struct tile *ptile)
bool startpos_pack(const struct startpos *psp, struct packet_edit_startpos_full *packet)
static bool is_valid_dir_calculate(enum direction8 dir)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
int map_signed_latitude(const struct tile *ptile)
static bool is_cardinal_dir_calculate(enum direction8 dir)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
int map_vector_to_sq_distance(int dx, int dy)
bool map_startpos_remove(struct tile *ptile)
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)
size_t startpos_iter_sizeof(void)
bool is_cardinal_dir(enum direction8 dir)
static void tile_init(struct tile *ptile)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
bool map_untrusted_dir_is_valid(enum direction8 dir)
bool terrain_surroundings_allow_change(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
int get_ocean_size(Continent_id id)
bool is_valid_dir(enum direction8 dir)
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
enum direction8 dir_cw(enum direction8 dir)
int get_island_surrounder(Continent_id id)
enum direction8 rand_direction(void)
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
static void startpos_destroy(struct startpos *psp)
void map_free(struct civ_map *fmap, bool server_side)
struct terrain_misc terrain_control
static void * startpos_exclude_iter_get(const struct iterator *startpos_iter)
struct tile * nearest_real_tile(const struct civ_map *nmap, int x, int y)
bool base_get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile, enum direction8 *dir)
static void startpos_exclude_iter_next(struct iterator *startpos_iter)
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
int get_lake_surrounder(Continent_id id)
static bool dir_cardinality[9]
void map_init(struct civ_map *imap, bool server_side)
bool startpos_is_excluding(const struct startpos *psp)
int map_distance(const struct tile *tile0, const struct tile *tile1)
struct startpos * map_startpos_by_number(int id)
size_t map_startpos_iter_sizeof(void)
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
static bool startpos_exclude_iter_valid(const struct iterator *startpos_iter)
struct iterator * startpos_iter_init(struct startpos_iter *iter, const struct startpos *psp)
bool is_real_map_pos(const struct civ_map *nmap, int x, int y)
bool is_singular_tile(const struct tile *ptile, int dist)
int map_vector_to_real_distance(int dx, int dy)
#define current_topo_has_flag(flag)
#define MAP_MAX_LINEAR_SIZE
#define adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr)
#define do_in_natural_pos(ntl_x, ntl_y, map_x, map_y)
#define MAP_DEFAULT_LINEAR_SIZE
#define MAP_DEFAULT_STARTPOS
#define MAP_DEFAULT_ANIMALS
#define MAP_DEFAULT_TEAM_PLACEMENT
#define CHECK_INDEX(mindex)
#define cardinal_between_iterate(nmap, tile1, tile2, between)
#define MAP_DEFAULT_MAPSIZE
#define MAP_MIN_LINEAR_SIZE
#define MAP_DEFAULT_LANDMASS
#define adjc_iterate(nmap, center_tile, itr_tile)
#define MAP_SOUTH_LATITUDE(_nmap)
#define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y)
#define ALL_DIRECTIONS_CARDINAL()
#define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y)
#define is_whole_continent_known(cont)
#define cardinal_adjc_dir_iterate_end
#define MAP_DEFAULT_NORTH_LATITUDE
#define MAP_DEFAULT_SEPARATE_POLES
#define MAP_DEFAULT_RICHES
#define MAP_DEFAULT_TINYISLES
#define whole_map_iterate(_map, _tile)
#define MAP_NORTH_LATITUDE(_nmap)
#define MAP_DEFAULT_TILESPERPLAYER
#define adjc_dir_iterate_end
#define MAP_DEFAULT_TEMPERATURE
#define cardinal_between_iterate_end
#define MAP_DEFAULT_SOUTH_LATITUDE
#define current_wrap_has_flag(flag)
#define MAP_DEFAULT_GENERATOR
#define is_whole_ocean_known(ocean)
#define do_in_natural_pos_end
#define MAP_DEFAULT_WETNESS
#define native_pos_to_index_nocheck(nat_x, nat_y)
#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 MAP_DEFAULT_STEEPNESS
#define DIRSTEP(dest_x, dest_y, dir)
#define fc_calloc(n, esz)
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Nation_type_id nation_number(const struct nation_type *pnation)
struct iterator * nation_iter_init(struct nation_iter *it)
size_t nation_iter_sizeof(void)
#define nation_hash_iterate(nationhash, pnation)
#define nations_iterate_end
#define nations_iterate(NAME_pnation)
#define nation_hash_iterate_end
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
bool are_reqs_active(const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
#define CLIP(lower, current, upper)
#define FC_WRAP(value, range)
struct packet_game_info info
struct startpos_hash * startpos_table
Continent_id num_continents
int num_iterate_outwards_indices
struct civ_map::@44::@47 client
Continent_id * island_surrounders
Continent_id * lake_surrounders
struct iter_index * iterate_outwards_indices
struct civ_map::@44::@46 server
bv_startpos_nations nations
const struct startpos * psp
struct nation_hash * nations
struct extra_type * resource
struct player * extras_owner
struct extra_type * placing
int count_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
int count_terrain_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_flag_id flag)
#define is_ocean(pterrain)
#define terrain_has_flag(terr, flag)
void tile_virtual_destroy(struct tile *vtile)
void tile_remove_extra(struct tile *ptile, const struct extra_type *pextra)
struct tile * tile_virtual_new(const struct tile *ptile)
void * tile_hash_key(const struct tile *ptile)
struct city * tile_city(const struct tile *ptile)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define MAP_NUM_VALID_DIRS
#define MAP_NATURAL_HEIGHT
#define MAP_NATURAL_WIDTH
#define MAP_NATIVE_HEIGHT