51#define SPECHASH_TAG startpos
52#define SPECHASH_IKEY_TYPE struct tile *
53#define SPECHASH_IDATA_TYPE struct startpos *
54#define SPECHASH_IDATA_FREE startpos_destroy
65#define STARTPOS_ITER(p) ((struct startpos_iter *) (p))
86const int DIR_DX[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
87const int DIR_DY[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
96 const struct tile *t2);
161 imap->num_continents = 0;
162 imap->num_oceans = 0;
165 imap->iterate_outwards_indices =
NULL;
184 imap->server.huts_absolute = -1;
285 for (
i = 0;
i < tiles;
i++) {
319 nmap->num_valid_dirs =
nmap->num_cardinal_dirs = 0;
327 for (dir = 0; dir < 8; dir++) {
329 nmap->valid_dirs[
nmap->num_valid_dirs] = dir;
330 nmap->num_valid_dirs++;
336 nmap->cardinal_dirs[
nmap->num_cardinal_dirs] = dir;
337 nmap->num_cardinal_dirs++;
345 &&
nmap->num_cardinal_dirs <=
nmap->num_valid_dirs);
495 log_debug(
"map_allocate (was %p) (%d,%d)",
505 ptile->index = ptile -
amap->tiles;
542 if (
fmap->startpos_table) {
586 || (dx > 0 && dy < 0)) {
596 if ((dx > 0 && dy > 0)
597 || (dx < 0 && dy < 0)) {
623 return dx * dx + dy * dy;
685 const struct tile *ptile)
700 const struct tile *ptile)
714 const struct tile *ptile)
729 const struct tile *ptile)
743 const struct tile *ptile,
744 const struct terrain *pterrain)
783 const struct player *pplayer,
784 const struct tile *t1,
const struct tile *t2)
856 switch (
proad->move_mode) {
898 return cost * 181 >> 7;
912 const struct tile *t2)
1102 bool (*filter)(
const struct tile *ptile,
1117 if (filter ==
NULL) {
1120 int count = 0, *positions;
1329 const struct tile *start_tile,
1330 const struct tile *end_tile,
1348 const struct tile *start_tile,
1349 const struct tile *end_tile)
1366 const struct tile *start_tile,
1367 const struct tile *end_tile)
1458 x = 2.0 * (
x > 0.5 ? 1.0 -
x :
x);
1459 y = 2.0 * (
y > 0.5 ? 1.0 -
y :
y);
1526 - 0.5 * (
x *
x *
x +
y *
y *
y)
1527 + 1.5 * (
x *
x +
y *
y));
1552 int north_latitude, south_latitude;
1558 if (north_latitude == south_latitude) {
1560 return south_latitude;
#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
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 startpos_number(const struct startpos *psp)
bool can_reclaim_ocean(const struct civ_map *nmap, const struct tile *ptile)
void map_free(struct civ_map *fmap)
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)
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)
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)
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)
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 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 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 player *other_player, 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
enum direction8 valid_dirs[8]
int num_iterate_outwards_indices
struct iter_index * iterate_outwards_indices
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)