Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
map.h File Reference
#include <math.h>
#include "bitvector.h"
#include "iterator.h"
#include "log.h"
#include "fc_types.h"
#include "game.h"
#include "map_types.h"
#include "packets.h"
#include "world_object.h"

Go to the source code of this file.

Macros

#define MAP_IS_ISOMETRIC   (CURRENT_TOPOLOGY & (TF_ISO + TF_HEX))
 
#define CURRENT_TOPOLOGY   (wld.map.topology_id)
 
#define CURRENT_WRAP   (wld.map.wrap_id)
 
#define topo_has_flag(topo, flag)   (((topo) & (flag)) != 0)
 
#define current_topo_has_flag(flag)   topo_has_flag((CURRENT_TOPOLOGY), (flag))
 
#define wrap_has_flag(wrap, flag)   (((wrap) & (flag)) != 0)
 
#define current_wrap_has_flag(flag)   wrap_has_flag((CURRENT_WRAP), (flag))
 
#define ALL_DIRECTIONS_CARDINAL()   topo_has_flag((CURRENT_TOPOLOGY), TF_HEX)
 
#define startpos_nations_iterate(ARG_psp, NAME_pnation)
 
#define startpos_nations_iterate_end   generic_iterate_end
 
#define map_startpos_iterate(NAME_psp)
 
#define map_startpos_iterate_end   generic_iterate_end
 
#define MAP_INDEX_SIZE   (wld.map.xsize * wld.map.ysize)
 
#define CHECK_MAP_POS(x, y)   ((void)0)
 
#define CHECK_NATIVE_POS(x, y)   ((void)0)
 
#define CHECK_INDEX(mindex)   ((void)0)
 
#define native_pos_to_index_nocheck(nat_x, nat_y)    ((nat_x) + (nat_y) * wld.map.xsize)
 
#define native_pos_to_index(nat_x, nat_y)
 
#define index_to_native_pos(pnat_x, pnat_y, mindex)
 
#define index_to_native_pos_x(mindex)    ((mindex) % wld.map.xsize)
 
#define index_to_native_pos_y(mindex)    ((mindex) / wld.map.xsize)
 
#define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y)
 
#define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y)
 
#define NATURAL_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y)
 
#define MAP_TO_NATURAL_POS(pnat_x, pnat_y, map_x, map_y)
 
#define do_in_native_pos(nat_x, nat_y, map_x, map_y)
 
#define do_in_native_pos_end
 
#define do_in_natural_pos(ntl_x, ntl_y, map_x, map_y)
 
#define do_in_natural_pos_end
 
#define NATIVE_WIDTH   wld.map.xsize
 
#define NATIVE_HEIGHT   wld.map.ysize
 
#define NATURAL_WIDTH   (MAP_IS_ISOMETRIC ? 2 * wld.map.xsize : wld.map.xsize)
 
#define NATURAL_HEIGHT   wld.map.ysize
 
#define index_to_map_pos(pmap_x, pmap_y, mindex)
 
#define DIRSTEP(dest_x, dest_y, dir)
 
#define map_size_checked()   MAX(map_num_tiles() / 1000, 1)
 
#define iterate_outward_dxy(nmap, start_tile, max_dist, _tile, _x, _y)
 
#define iterate_outward_dxy_end
 
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
 
#define iterate_outward_end   iterate_outward_dxy_end
 
#define square_dxy_iterate(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)    iterate_outward_dxy(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)
 
#define square_dxy_iterate_end   iterate_outward_dxy_end
 
#define square_iterate(nmap, center_tile, radius, tile_itr)    square_dxy_iterate(nmap, center_tile, radius, tile_itr, _dummy_x, dummy_y)
 
#define square_iterate_end   square_dxy_iterate_end
 
#define circle_iterate(nmap, center_tile, sq_radius, tile_itr)    circle_dxyr_iterate(nmap, center_tile, sq_radius, tile_itr, _dx, _dy, _dr)
 
#define circle_iterate_end    circle_dxyr_iterate_end
 
#define circle_dxyr_iterate(nmap, center_tile, sq_radius, _tile, dx, dy, dr)
 
#define circle_dxyr_iterate_end
 
#define adjc_iterate(nmap, center_tile, itr_tile)
 
#define adjc_iterate_end
 
#define adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr)
 
#define adjc_dir_iterate_end   adjc_dirlist_iterate_end
 
#define adjc_dir_base_iterate(nmap, center_tile, dir_itr)
 
#define adjc_dir_base_iterate_end    adjc_dirlist_base_iterate_end
 
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
 
#define cardinal_adjc_iterate_end   adjc_dirlist_iterate_end
 
#define cardinal_adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr)
 
#define cardinal_adjc_dir_iterate_end   adjc_dirlist_iterate_end
 
#define cardinal_adjc_dir_base_iterate(nmap, center_tile, dir_itr)
 
#define cardinal_adjc_dir_base_iterate_end    adjc_dirlist_base_iterate_end
 
#define cardinal_between_iterate(nmap, tile1, tile2, between)
 
#define cardinal_between_iterate_end
 
#define adjc_dirlist_iterate(nmap, center_tile, _tile, _dir, dirlist, dircount)
 
#define adjc_dirlist_iterate_end
 
#define adjc_dirlist_base_iterate(nmap, center_tile, _dir, dirlist, dircount)
 
#define adjc_dirlist_base_iterate_end
 
#define whole_map_iterate(_map, _tile)
 
#define whole_map_iterate_end
 
#define DIR_REVERSE(dir)   (7 - (dir))
 
#define MAP_MAX_LATITUDE   1000
 
#define MAP_MAX_LATITUDE_BOUND   (MAP_MAX_LATITUDE)
 
#define MAP_MIN_LATITUDE_BOUND   (-MAP_MAX_LATITUDE)
 
#define MAP_DEFAULT_NORTH_LATITUDE   MAP_MAX_LATITUDE_BOUND
 
#define MAP_DEFAULT_SOUTH_LATITUDE   MAP_MIN_LATITUDE_BOUND
 
#define MAP_NORTH_LATITUDE(_nmap)   ((_nmap).north_latitude)
 
#define MAP_SOUTH_LATITUDE(_nmap)   ((_nmap).south_latitude)
 
#define MAP_MAX_REAL_LATITUDE(_nmap)    MAX(MAP_NORTH_LATITUDE(_nmap), MAP_SOUTH_LATITUDE(_nmap))
 
#define MAP_MIN_REAL_LATITUDE(_nmap)    MIN(MAP_NORTH_LATITUDE(_nmap), MAP_SOUTH_LATITUDE(_nmap))
 
#define MAP_REAL_LATITUDE_RANGE(_nmap)    (MAP_MAX_REAL_LATITUDE(_nmap) - MAP_MIN_REAL_LATITUDE(_nmap))
 
#define MAP_MAX_ABS_LATITUDE(_nmap)    MAX(MAP_MAX_REAL_LATITUDE(_nmap), -MAP_MIN_REAL_LATITUDE(_nmap))
 
#define MAP_MIN_ABS_LATITUDE(_nmap)    MAX(0, MAX(MAP_MIN_REAL_LATITUDE(_nmap), -MAP_MAX_REAL_LATITUDE(_nmap)))
 
#define MAP_TILE_OWNER_NULL   MAX_UINT8
 
#define MAP_DEFAULT_HUTS   15
 
#define MAP_MIN_HUTS   0
 
#define MAP_MAX_HUTS   500
 
#define MAP_DEFAULT_ANIMALS   20
 
#define MAP_MIN_ANIMALS   0
 
#define MAP_MAX_ANIMALS   500
 
#define MAP_DEFAULT_MAPSIZE   MAPSIZE_FULLSIZE
 
#define MAP_DEFAULT_SIZE   4
 
#define MAP_MIN_SIZE   0
 
#define MAP_MAX_SIZE   2048
 
#define MAP_DEFAULT_TILESPERPLAYER   100
 
#define MAP_MIN_TILESPERPLAYER   1
 
#define MAP_MAX_TILESPERPLAYER   1000
 
#define MAP_DEFAULT_LINEAR_SIZE   64
 
#define MAP_MAX_LINEAR_SIZE   (MAP_MAX_SIZE * 1000 / MAP_MIN_LINEAR_SIZE)
 
#define MAP_MIN_LINEAR_SIZE   16
 
#define MAP_DISTANCE_MAX   (MAP_MAX_LINEAR_SIZE + MAP_MIN_LINEAR_SIZE)
 
#define MAP_ORIGINAL_TOPO   TF_WRAPX
 
#define MAP_DEFAULT_TOPO   (TF_ISO|TF_HEX)
 
#define MAP_DEFAULT_WRAP   (WRAP_X)
 
#define MAP_DEFAULT_SEED   0
 
#define MAP_MIN_SEED   0
 
#define MAP_MAX_SEED   (MAX_UINT32 >> 1)
 
#define MAP_DEFAULT_LANDMASS   30
 
#define MAP_MIN_LANDMASS   15
 
#define MAP_MAX_LANDMASS   85
 
#define MAP_DEFAULT_RICHES   250
 
#define MAP_MIN_RICHES   0
 
#define MAP_MAX_RICHES   1000
 
#define MAP_DEFAULT_STEEPNESS   30
 
#define MAP_MIN_STEEPNESS   0
 
#define MAP_MAX_STEEPNESS   100
 
#define MAP_DEFAULT_WETNESS   50
 
#define MAP_MIN_WETNESS   0
 
#define MAP_MAX_WETNESS   100
 
#define MAP_DEFAULT_GENERATOR   MAPGEN_RANDOM
 
#define MAP_DEFAULT_STARTPOS   MAPSTARTPOS_DEFAULT
 
#define MAP_DEFAULT_TINYISLES   FALSE
 
#define MAP_MIN_TINYISLES   FALSE
 
#define MAP_MAX_TINYISLES   TRUE
 
#define MAP_DEFAULT_SEPARATE_POLES   TRUE
 
#define MAP_MIN_SEPARATE_POLES   FALSE
 
#define MAP_MAX_SEPARATE_POLES   TRUE
 
#define MAP_DEFAULT_FLATPOLES   100
 
#define MAP_MIN_FLATPOLES   0
 
#define MAP_MAX_FLATPOLES   100
 
#define MAP_DEFAULT_TEMPERATURE   50
 
#define MAP_MIN_TEMPERATURE   0
 
#define MAP_MAX_TEMPERATURE   100
 
#define MAP_DEFAULT_TEAM_PLACEMENT   TEAM_PLACEMENT_CLOSEST
 

Functions

bool map_is_empty (void)
 
void map_init (struct civ_map *imap, bool server_side)
 
void map_init_topology (struct civ_map *nmap)
 
void map_allocate (struct civ_map *amap)
 
void main_map_allocate (void)
 
void map_free (struct civ_map *fmap)
 
void main_map_free (void)
 
int map_vector_to_real_distance (int dx, int dy)
 
int map_vector_to_sq_distance (int dx, int dy)
 
int map_distance (const struct tile *tile0, const struct tile *tile1)
 
int real_map_distance (const struct tile *tile0, const struct tile *tile1)
 
int sq_map_distance (const struct tile *tile0, const struct tile *tile1)
 
bool same_pos (const struct tile *tile0, const struct tile *tile1)
 
bool base_get_direction_for_step (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_tile, enum direction8 *dir)
 
int get_direction_for_step (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_tile)
 
struct startposmap_startpos_by_number (int id)
 
int startpos_number (const struct startpos *psp)
 
bool startpos_allow (struct startpos *psp, struct nation_type *pnation)
 
bool startpos_disallow (struct startpos *psp, struct nation_type *pnation)
 
struct tilestartpos_tile (const struct startpos *psp)
 
bool startpos_nation_allowed (const struct startpos *psp, const struct nation_type *pnation)
 
bool startpos_allows_all (const struct startpos *psp)
 
bool startpos_pack (const struct startpos *psp, struct packet_edit_startpos_full *packet)
 
bool startpos_unpack (struct startpos *psp, const struct packet_edit_startpos_full *packet)
 
bool startpos_is_excluding (const struct startpos *psp)
 
const struct nation_hashstartpos_raw_nations (const struct startpos *psp)
 
size_t startpos_iter_sizeof (void)
 
struct iteratorstartpos_iter_init (struct startpos_iter *it, const struct startpos *psp)
 
int map_startpos_count (void)
 
struct startposmap_startpos_new (struct tile *ptile)
 
struct startposmap_startpos_get (const struct tile *ptile)
 
bool map_startpos_remove (struct tile *ptile)
 
size_t map_startpos_iter_sizeof (void)
 
struct iteratormap_startpos_iter_init (struct map_startpos_iter *iter)
 
static int map_pos_to_index (struct civ_map *nmap, int map_x, int map_y)
 
static int index_to_map_pos_x (int mindex)
 
static int index_to_map_pos_y (int mindex)
 
struct tilemapstep (const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
 
struct tilemap_pos_to_tile (const struct civ_map *nmap, int x, int y)
 
struct tilenative_pos_to_tile (const struct civ_map *nmap, int nat_x, int nat_y)
 
struct tileindex_to_tile (const struct civ_map *imap, int mindex)
 
bool is_real_map_pos (const struct civ_map *nmap, int x, int y)
 
bool is_normal_map_pos (int x, int y)
 
bool is_singular_tile (const struct tile *ptile, int dist)
 
bool normalize_map_pos (const struct civ_map *nmap, int *x, int *y)
 
struct tilenearest_real_tile (const struct civ_map *nmap, int x, int y)
 
void base_map_distance_vector (int *dx, int *dy, int x0, int y0, int x1, int y1)
 
void map_distance_vector (int *dx, int *dy, const struct tile *ptile0, const struct tile *ptile1)
 
int map_num_tiles (void)
 
struct tilerand_map_pos (const struct civ_map *nmap)
 
struct tilerand_map_pos_filtered (const struct civ_map *nmap, void *data, bool(*filter)(const struct tile *ptile, const void *data))
 
bool is_tiles_adjacent (const struct tile *ptile0, const struct tile *ptile1)
 
bool is_move_cardinal (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_tile)
 
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 int map_move_cost_unit (const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
 
static int map_move_cost (const struct civ_map *nmap, const struct player *pplayer, const struct unit_type *punittype, const struct tile *src_tile, const struct tile *dst_tile)
 
bool is_safe_ocean (const struct civ_map *nmap, const struct tile *ptile)
 
bv_extras get_tile_infrastructure_set (const struct tile *ptile, int *count)
 
bool can_channel_land (const struct civ_map *nmap, const struct tile *ptile)
 
bool can_reclaim_ocean (const struct civ_map *nmap, const struct tile *ptile)
 
bool can_thaw_terrain (const struct civ_map *nmap, const struct tile *ptile)
 
bool can_freeze_terrain (const struct civ_map *nmap, const struct tile *ptile)
 
bool terrain_surroundings_allow_change (const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain)
 
 BV_DEFINE (dir_vector, 8)
 
enum direction8 dir_cw (enum direction8 dir)
 
enum direction8 dir_ccw (enum direction8 dir)
 
const chardir_get_name (enum direction8 dir)
 
bool map_untrusted_dir_is_valid (enum direction8 dir)
 
bool is_valid_dir (enum direction8 dir)
 
bool is_cardinal_dir (enum direction8 dir)
 
int map_signed_latitude (const struct tile *ptile)
 
 FC_STATIC_ASSERT (MAP_MAX_SIZE *1000<=MAX_DBV_LENGTH, map_too_big_for_bitvector)
 
 FC_STATIC_ASSERT ((long unsigned) MAP_MAX_SIZE *1000<(long unsigned) 1<< 31, map_too_big_for_network)
 
static bool is_border_tile (const struct tile *ptile, int dist)
 
enum direction8 rand_direction (void)
 
enum direction8 opposite_direction (enum direction8 dir)
 

Variables

static const bool C_ADJACENT = FALSE
 
static const bool C_CARDINAL = TRUE
 
static const bool C_NUMBER = FALSE
 
static const bool C_PERCENT = TRUE
 
struct terrain_misc terrain_control
 
const int DIR_DX [8]
 
const int DIR_DY [8]
 

Macro Definition Documentation

◆ adjc_dir_base_iterate

#define adjc_dir_base_iterate (   nmap,
  center_tile,
  dir_itr 
)
Value:
(nmap)->valid_dirs, (nmap)->num_valid_dirs)
char * incite_cost
Definition comments.c:75
#define adjc_dirlist_base_iterate(nmap, center_tile, _dir, dirlist, dircount)
Definition map.h:520
const struct tile * center_tile

Definition at line 445 of file map.h.

◆ adjc_dir_base_iterate_end

#define adjc_dir_base_iterate_end    adjc_dirlist_base_iterate_end

Definition at line 449 of file map.h.

◆ adjc_dir_iterate

#define adjc_dir_iterate (   nmap,
  center_tile,
  itr_tile,
  dir_itr 
)
Value:
(nmap)->valid_dirs, (nmap)->num_valid_dirs)
#define adjc_dirlist_iterate(nmap, center_tile, _tile, _dir, dirlist, dircount)
Definition map.h:494

Definition at line 438 of file map.h.

◆ adjc_dir_iterate_end

#define adjc_dir_iterate_end   adjc_dirlist_iterate_end

Definition at line 442 of file map.h.

◆ adjc_dirlist_base_iterate

#define adjc_dirlist_base_iterate (   nmap,
  center_tile,
  _dir,
  dirlist,
  dircount 
)
Value:
{ \
enum direction8 _dir; \
int _tile##_x, _tile##_y, _center##_x, _center##_y; \
const struct tile *_tile##_center = (center_tile); \
int _tile##_index = 0; \
for (; \
_tile##_index++) { \
_tile##_x += _center##_x; \
continue; \
}
static bool is_border_tile(const struct tile *ptile, int dist)
Definition map.h:738
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
Definition map.c:979
Definition tile.h:50
#define tile_index(_pt_)
Definition tile.h:88

Definition at line 520 of file map.h.

◆ adjc_dirlist_base_iterate_end

#define adjc_dirlist_base_iterate_end
Value:
} \
}

Definition at line 539 of file map.h.

◆ adjc_dirlist_iterate

#define adjc_dirlist_iterate (   nmap,
  center_tile,
  _tile,
  _dir,
  dirlist,
  dircount 
)
Value:
{ \
enum direction8 _dir; \
int _tile##_x, _tile##_y, _tile##_cx, _tile##_cy; \
struct tile *_tile; \
const struct tile *_tile##_center = (center_tile); \
int _tile##_index = 0; \
for (; \
_tile##_index++) { \
_tile##_x += _tile##_cx; \
_tile##_y += _tile##_cy; \
if (NULL == _tile) { \
continue; \
}
struct tile * map_pos_to_tile(const struct civ_map *nmap, int x, int y)
Definition map.c:419

Definition at line 494 of file map.h.

◆ adjc_dirlist_iterate_end

#define adjc_dirlist_iterate_end
Value:
} \
}

Definition at line 515 of file map.h.

◆ adjc_iterate

#define adjc_iterate (   nmap,
  center_tile,
  itr_tile 
)
Value:
{ \
/* Written as a wrapper to adjc_dir_iterate since it's the cleanest and \
* most efficient. */ \

Definition at line 428 of file map.h.

◆ adjc_iterate_end

#define adjc_iterate_end
Value:
}
#define adjc_dir_iterate_end
Definition map.h:442

Definition at line 433 of file map.h.

◆ ALL_DIRECTIONS_CARDINAL

#define ALL_DIRECTIONS_CARDINAL ( )    topo_has_flag((CURRENT_TOPOLOGY), TF_HEX)

Definition at line 53 of file map.h.

◆ cardinal_adjc_dir_base_iterate

#define cardinal_adjc_dir_base_iterate (   nmap,
  center_tile,
  dir_itr 
)
Value:
(nmap)->cardinal_dirs, (nmap)->num_cardinal_dirs)

Definition at line 469 of file map.h.

◆ cardinal_adjc_dir_base_iterate_end

#define cardinal_adjc_dir_base_iterate_end    adjc_dirlist_base_iterate_end

Definition at line 473 of file map.h.

◆ cardinal_adjc_dir_iterate

#define cardinal_adjc_dir_iterate (   nmap,
  center_tile,
  itr_tile,
  dir_itr 
)
Value:
(nmap)->cardinal_dirs, (nmap)->num_cardinal_dirs)

Definition at line 462 of file map.h.

◆ cardinal_adjc_dir_iterate_end

#define cardinal_adjc_dir_iterate_end   adjc_dirlist_iterate_end

Definition at line 466 of file map.h.

◆ cardinal_adjc_iterate

#define cardinal_adjc_iterate (   nmap,
  center_tile,
  itr_tile 
)
Value:
(nmap)->cardinal_dirs, (nmap)->num_cardinal_dirs)

Definition at line 455 of file map.h.

◆ cardinal_adjc_iterate_end

#define cardinal_adjc_iterate_end   adjc_dirlist_iterate_end

Definition at line 459 of file map.h.

◆ cardinal_between_iterate

#define cardinal_between_iterate (   nmap,
  tile1,
  tile2,
  between 
)
Value:
bool same_pos(const struct tile *tile0, const struct tile *tile1)
Definition map.c:940
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:455

Definition at line 477 of file map.h.

◆ cardinal_between_iterate_end

#define cardinal_between_iterate_end
Value:
} \
#define cardinal_adjc_iterate_end
Definition map.h:459

Definition at line 482 of file map.h.

◆ CHECK_INDEX

#define CHECK_INDEX (   mindex)    ((void)0)

Definition at line 149 of file map.h.

◆ CHECK_MAP_POS

#define CHECK_MAP_POS (   x,
  y 
)    ((void)0)

Definition at line 147 of file map.h.

◆ CHECK_NATIVE_POS

#define CHECK_NATIVE_POS (   x,
  y 
)    ((void)0)

Definition at line 148 of file map.h.

◆ circle_dxyr_iterate

#define circle_dxyr_iterate (   nmap,
  center_tile,
  sq_radius,
  _tile,
  dx,
  dy,
  dr 
)
Value:
{ \
const int _tile##_sq_radius = (sq_radius); \
const int _tile##_cr_radius = (int)sqrt((double)MAX(_tile##_sq_radius, 0)); \
const int dr = map_vector_to_sq_distance(dx, dy); \
int map_vector_to_sq_distance(int dx, int dy)
Definition map.c:614
#define MAX(x, y)
Definition shared.h:54

Definition at line 409 of file map.h.

◆ circle_dxyr_iterate_end

#define circle_dxyr_iterate_end
Value:
} \
}
#define square_dxy_iterate_end
Definition map.h:384

Definition at line 420 of file map.h.

◆ circle_iterate

Definition at line 401 of file map.h.

◆ circle_iterate_end

#define circle_iterate_end    circle_dxyr_iterate_end

Definition at line 404 of file map.h.

◆ current_topo_has_flag

#define current_topo_has_flag (   flag)    topo_has_flag((CURRENT_TOPOLOGY), (flag))

Definition at line 48 of file map.h.

◆ CURRENT_TOPOLOGY

#define CURRENT_TOPOLOGY   (wld.map.topology_id)

Definition at line 44 of file map.h.

◆ CURRENT_WRAP

#define CURRENT_WRAP   (wld.map.wrap_id)

Definition at line 45 of file map.h.

◆ current_wrap_has_flag

#define current_wrap_has_flag (   flag)    wrap_has_flag((CURRENT_WRAP), (flag))

Definition at line 51 of file map.h.

◆ DIR_REVERSE

#define DIR_REVERSE (   dir)    (7 - (dir))

Definition at line 561 of file map.h.

◆ DIRSTEP

#define DIRSTEP (   dest_x,
  dest_y,
  dir 
)
Value:
( (dest_x) = DIR_DX[(dir)], \
(dest_y) = DIR_DY[(dir)])
const int DIR_DY[8]
Definition map.c:87
const int DIR_DX[8]
Definition map.c:86

Definition at line 240 of file map.h.

◆ do_in_native_pos

#define do_in_native_pos (   nat_x,
  nat_y,
  map_x,
  map_y 
)
Value:
{ \
int _nat_x, _nat_y; \
{ \
const int nat_x = _nat_x, nat_y = _nat_y;
#define nat_x
#define nat_y

Definition at line 195 of file map.h.

◆ do_in_native_pos_end

#define do_in_native_pos_end
Value:
} \
}

Definition at line 202 of file map.h.

◆ do_in_natural_pos

#define do_in_natural_pos (   ntl_x,
  ntl_y,
  map_x,
  map_y 
)
Value:

Definition at line 210 of file map.h.

◆ do_in_natural_pos_end

#define do_in_natural_pos_end
Value:
} \
}

Definition at line 217 of file map.h.

◆ index_to_map_pos

#define index_to_map_pos (   pmap_x,
  pmap_y,
  mindex 
)
Value:

Definition at line 233 of file map.h.

◆ index_to_native_pos

#define index_to_native_pos (   pnat_x,
  pnat_y,
  mindex 
)
Value:
#define index_to_native_pos_y(mindex)
Definition map.h:162
#define index_to_native_pos_x(mindex)
Definition map.h:160

Definition at line 157 of file map.h.

◆ index_to_native_pos_x

#define index_to_native_pos_x (   mindex)     ((mindex) % wld.map.xsize)

Definition at line 160 of file map.h.

◆ index_to_native_pos_y

#define index_to_native_pos_y (   mindex)     ((mindex) / wld.map.xsize)

Definition at line 162 of file map.h.

◆ iterate_outward

#define iterate_outward (   nmap,
  start_tile,
  max_dist,
  itr_tile 
)
Value:
#define iterate_outward_dxy(nmap, start_tile, max_dist, _tile, _x, _y)
Definition map.h:339

Definition at line 367 of file map.h.

◆ iterate_outward_dxy

#define iterate_outward_dxy (   nmap,
  start_tile,
  max_dist,
  _tile,
  _x,
  _y 
)
Value:
{ \
int _x, _y, _tile##_x, _tile##_y, _start##_x, _start##_y; \
struct tile *_tile; \
const struct tile *_tile##_start = (start_tile); \
int _tile##_max = (max_dist); \
int _tile##_index = 0; \
for (; \
_tile##_index++) { \
break; \
} \
_tile##_x = _x + _start##_x; \
_tile##_y = _y + _start##_y; \
if (NULL == _tile) { \
continue; \
}
struct world wld
Definition game.c:63
int num_iterate_outwards_indices
Definition map_types.h:77
struct iter_index * iterate_outwards_indices
Definition map_types.h:76
int dist
Definition city.h:110
int dx
Definition city.h:110
int dy
Definition city.h:110
struct civ_map map

Definition at line 339 of file map.h.

◆ iterate_outward_dxy_end

#define iterate_outward_dxy_end
Value:
} \
}

Definition at line 362 of file map.h.

◆ iterate_outward_end

#define iterate_outward_end   iterate_outward_dxy_end

Definition at line 371 of file map.h.

◆ MAP_DEFAULT_ANIMALS

#define MAP_DEFAULT_ANIMALS   20

Definition at line 608 of file map.h.

◆ MAP_DEFAULT_FLATPOLES

#define MAP_DEFAULT_FLATPOLES   100

Definition at line 690 of file map.h.

◆ MAP_DEFAULT_GENERATOR

#define MAP_DEFAULT_GENERATOR   MAPGEN_RANDOM

Definition at line 678 of file map.h.

◆ MAP_DEFAULT_HUTS

#define MAP_DEFAULT_HUTS   15

Definition at line 604 of file map.h.

◆ MAP_DEFAULT_LANDMASS

#define MAP_DEFAULT_LANDMASS   30

Definition at line 662 of file map.h.

◆ MAP_DEFAULT_LINEAR_SIZE

#define MAP_DEFAULT_LINEAR_SIZE   64

Definition at line 639 of file map.h.

◆ MAP_DEFAULT_MAPSIZE

#define MAP_DEFAULT_MAPSIZE   MAPSIZE_FULLSIZE

Definition at line 612 of file map.h.

◆ MAP_DEFAULT_NORTH_LATITUDE

#define MAP_DEFAULT_NORTH_LATITUDE   MAP_MAX_LATITUDE_BOUND

Definition at line 578 of file map.h.

◆ MAP_DEFAULT_RICHES

#define MAP_DEFAULT_RICHES   250

Definition at line 666 of file map.h.

◆ MAP_DEFAULT_SEED

#define MAP_DEFAULT_SEED   0

Definition at line 658 of file map.h.

◆ MAP_DEFAULT_SEPARATE_POLES

#define MAP_DEFAULT_SEPARATE_POLES   TRUE

Definition at line 686 of file map.h.

◆ MAP_DEFAULT_SIZE

#define MAP_DEFAULT_SIZE   4

Definition at line 622 of file map.h.

◆ MAP_DEFAULT_SOUTH_LATITUDE

#define MAP_DEFAULT_SOUTH_LATITUDE   MAP_MIN_LATITUDE_BOUND

Definition at line 579 of file map.h.

◆ MAP_DEFAULT_STARTPOS

#define MAP_DEFAULT_STARTPOS   MAPSTARTPOS_DEFAULT

Definition at line 680 of file map.h.

◆ MAP_DEFAULT_STEEPNESS

#define MAP_DEFAULT_STEEPNESS   30

Definition at line 670 of file map.h.

◆ MAP_DEFAULT_TEAM_PLACEMENT

#define MAP_DEFAULT_TEAM_PLACEMENT   TEAM_PLACEMENT_CLOSEST

Definition at line 698 of file map.h.

◆ MAP_DEFAULT_TEMPERATURE

#define MAP_DEFAULT_TEMPERATURE   50

Definition at line 694 of file map.h.

◆ MAP_DEFAULT_TILESPERPLAYER

#define MAP_DEFAULT_TILESPERPLAYER   100

Definition at line 634 of file map.h.

◆ MAP_DEFAULT_TINYISLES

#define MAP_DEFAULT_TINYISLES   FALSE

Definition at line 682 of file map.h.

◆ MAP_DEFAULT_TOPO

#define MAP_DEFAULT_TOPO   (TF_ISO|TF_HEX)

Definition at line 654 of file map.h.

◆ MAP_DEFAULT_WETNESS

#define MAP_DEFAULT_WETNESS   50

Definition at line 674 of file map.h.

◆ MAP_DEFAULT_WRAP

#define MAP_DEFAULT_WRAP   (WRAP_X)

Definition at line 655 of file map.h.

◆ MAP_DISTANCE_MAX

#define MAP_DISTANCE_MAX   (MAP_MAX_LINEAR_SIZE + MAP_MIN_LINEAR_SIZE)

Definition at line 646 of file map.h.

◆ MAP_INDEX_SIZE

#define MAP_INDEX_SIZE   (wld.map.xsize * wld.map.ysize)

Definition at line 137 of file map.h.

◆ MAP_IS_ISOMETRIC

#define MAP_IS_ISOMETRIC   (CURRENT_TOPOLOGY & (TF_ISO + TF_HEX))

Definition at line 42 of file map.h.

◆ MAP_MAX_ABS_LATITUDE

#define MAP_MAX_ABS_LATITUDE (   _nmap)     MAX(MAP_MAX_REAL_LATITUDE(_nmap), -MAP_MIN_REAL_LATITUDE(_nmap))

Definition at line 594 of file map.h.

◆ MAP_MAX_ANIMALS

#define MAP_MAX_ANIMALS   500

Definition at line 610 of file map.h.

◆ MAP_MAX_FLATPOLES

#define MAP_MAX_FLATPOLES   100

Definition at line 692 of file map.h.

◆ MAP_MAX_HUTS

#define MAP_MAX_HUTS   500

Definition at line 606 of file map.h.

◆ MAP_MAX_LANDMASS

#define MAP_MAX_LANDMASS   85

Definition at line 664 of file map.h.

◆ MAP_MAX_LATITUDE

#define MAP_MAX_LATITUDE   1000

Definition at line 574 of file map.h.

◆ MAP_MAX_LATITUDE_BOUND

#define MAP_MAX_LATITUDE_BOUND   (MAP_MAX_LATITUDE)

Definition at line 576 of file map.h.

◆ MAP_MAX_LINEAR_SIZE

#define MAP_MAX_LINEAR_SIZE   (MAP_MAX_SIZE * 1000 / MAP_MIN_LINEAR_SIZE)

Definition at line 640 of file map.h.

◆ MAP_MAX_REAL_LATITUDE

#define MAP_MAX_REAL_LATITUDE (   _nmap)     MAX(MAP_NORTH_LATITUDE(_nmap), MAP_SOUTH_LATITUDE(_nmap))

Definition at line 586 of file map.h.

◆ MAP_MAX_RICHES

#define MAP_MAX_RICHES   1000

Definition at line 668 of file map.h.

◆ MAP_MAX_SEED

#define MAP_MAX_SEED   (MAX_UINT32 >> 1)

Definition at line 660 of file map.h.

◆ MAP_MAX_SEPARATE_POLES

#define MAP_MAX_SEPARATE_POLES   TRUE

Definition at line 688 of file map.h.

◆ MAP_MAX_SIZE

#define MAP_MAX_SIZE   2048

Definition at line 624 of file map.h.

◆ MAP_MAX_STEEPNESS

#define MAP_MAX_STEEPNESS   100

Definition at line 672 of file map.h.

◆ MAP_MAX_TEMPERATURE

#define MAP_MAX_TEMPERATURE   100

Definition at line 696 of file map.h.

◆ MAP_MAX_TILESPERPLAYER

#define MAP_MAX_TILESPERPLAYER   1000

Definition at line 636 of file map.h.

◆ MAP_MAX_TINYISLES

#define MAP_MAX_TINYISLES   TRUE

Definition at line 684 of file map.h.

◆ MAP_MAX_WETNESS

#define MAP_MAX_WETNESS   100

Definition at line 676 of file map.h.

◆ MAP_MIN_ABS_LATITUDE

#define MAP_MIN_ABS_LATITUDE (   _nmap)     MAX(0, MAX(MAP_MIN_REAL_LATITUDE(_nmap), -MAP_MAX_REAL_LATITUDE(_nmap)))

Definition at line 596 of file map.h.

◆ MAP_MIN_ANIMALS

#define MAP_MIN_ANIMALS   0

Definition at line 609 of file map.h.

◆ MAP_MIN_FLATPOLES

#define MAP_MIN_FLATPOLES   0

Definition at line 691 of file map.h.

◆ MAP_MIN_HUTS

#define MAP_MIN_HUTS   0

Definition at line 605 of file map.h.

◆ MAP_MIN_LANDMASS

#define MAP_MIN_LANDMASS   15

Definition at line 663 of file map.h.

◆ MAP_MIN_LATITUDE_BOUND

#define MAP_MIN_LATITUDE_BOUND   (-MAP_MAX_LATITUDE)

Definition at line 577 of file map.h.

◆ MAP_MIN_LINEAR_SIZE

#define MAP_MIN_LINEAR_SIZE   16

Definition at line 641 of file map.h.

◆ MAP_MIN_REAL_LATITUDE

#define MAP_MIN_REAL_LATITUDE (   _nmap)     MIN(MAP_NORTH_LATITUDE(_nmap), MAP_SOUTH_LATITUDE(_nmap))

Definition at line 588 of file map.h.

◆ MAP_MIN_RICHES

#define MAP_MIN_RICHES   0

Definition at line 667 of file map.h.

◆ MAP_MIN_SEED

#define MAP_MIN_SEED   0

Definition at line 659 of file map.h.

◆ MAP_MIN_SEPARATE_POLES

#define MAP_MIN_SEPARATE_POLES   FALSE

Definition at line 687 of file map.h.

◆ MAP_MIN_SIZE

#define MAP_MIN_SIZE   0

Definition at line 623 of file map.h.

◆ MAP_MIN_STEEPNESS

#define MAP_MIN_STEEPNESS   0

Definition at line 671 of file map.h.

◆ MAP_MIN_TEMPERATURE

#define MAP_MIN_TEMPERATURE   0

Definition at line 695 of file map.h.

◆ MAP_MIN_TILESPERPLAYER

#define MAP_MIN_TILESPERPLAYER   1

Definition at line 635 of file map.h.

◆ MAP_MIN_TINYISLES

#define MAP_MIN_TINYISLES   FALSE

Definition at line 683 of file map.h.

◆ MAP_MIN_WETNESS

#define MAP_MIN_WETNESS   0

Definition at line 675 of file map.h.

◆ MAP_NORTH_LATITUDE

#define MAP_NORTH_LATITUDE (   _nmap)    ((_nmap).north_latitude)

Definition at line 582 of file map.h.

◆ MAP_ORIGINAL_TOPO

#define MAP_ORIGINAL_TOPO   TF_WRAPX

Definition at line 648 of file map.h.

◆ MAP_REAL_LATITUDE_RANGE

#define MAP_REAL_LATITUDE_RANGE (   _nmap)     (MAP_MAX_REAL_LATITUDE(_nmap) - MAP_MIN_REAL_LATITUDE(_nmap))

Definition at line 590 of file map.h.

◆ map_size_checked

#define map_size_checked ( )    MAX(map_num_tiles() / 1000, 1)

Definition at line 271 of file map.h.

◆ MAP_SOUTH_LATITUDE

#define MAP_SOUTH_LATITUDE (   _nmap)    ((_nmap).south_latitude)

Definition at line 583 of file map.h.

◆ map_startpos_iterate

#define map_startpos_iterate (   NAME_psp)
Value:
#define generic_iterate(TYPE_it, TYPE_a, NAME_a, FUNC_size, FUNC_init,...)
Definition iterator.h:117
struct iterator * map_startpos_iter_init(struct map_startpos_iter *iter)
Definition map.c:1920
size_t map_startpos_iter_sizeof(void)
Definition map.c:1911
Definition map.c:41

Definition at line 130 of file map.h.

◆ map_startpos_iterate_end

#define map_startpos_iterate_end   generic_iterate_end

Definition at line 133 of file map.h.

◆ MAP_TILE_OWNER_NULL

#define MAP_TILE_OWNER_NULL   MAX_UINT8

Definition at line 602 of file map.h.

◆ MAP_TO_NATIVE_POS

#define MAP_TO_NATIVE_POS (   pnat_x,
  pnat_y,
  map_x,
  map_y 
)
Value:
? (*(pnat_y) = (map_x) + (map_y) - wld.map.xsize, \
*(pnat_x) = (2 * (map_x) - *(pnat_y) - (*(pnat_y) & 1)) / 2) \
: (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
#define MAP_IS_ISOMETRIC
Definition map.h:42
int xsize
Definition map_types.h:78

Definition at line 172 of file map.h.

◆ MAP_TO_NATURAL_POS

#define MAP_TO_NATURAL_POS (   pnat_x,
  pnat_y,
  map_x,
  map_y 
)
Value:
? (*(pnat_y) = (map_x) + (map_y) - wld.map.xsize, \
*(pnat_x) = 2 * (map_x) - *(pnat_y)) \
: (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))

Definition at line 184 of file map.h.

◆ NATIVE_HEIGHT

#define NATIVE_HEIGHT   wld.map.ysize

Definition at line 223 of file map.h.

◆ native_pos_to_index

#define native_pos_to_index (   nat_x,
  nat_y 
)
Value:
#define CHECK_NATIVE_POS(x, y)
Definition map.h:148

Definition at line 154 of file map.h.

◆ native_pos_to_index_nocheck

#define native_pos_to_index_nocheck (   nat_x,
  nat_y 
)     ((nat_x) + (nat_y) * wld.map.xsize)

Definition at line 152 of file map.h.

◆ NATIVE_TO_MAP_POS

#define NATIVE_TO_MAP_POS (   pmap_x,
  pmap_y,
  nat_x,
  nat_y 
)
Value:
? (*(pmap_x) = ((nat_y) + ((nat_y) & 1)) / 2 + (nat_x), \
*(pmap_y) = (nat_y) - *(pmap_x) + wld.map.xsize) \
: (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))

Definition at line 166 of file map.h.

◆ NATIVE_WIDTH

#define NATIVE_WIDTH   wld.map.xsize

Definition at line 222 of file map.h.

◆ NATURAL_HEIGHT

#define NATURAL_HEIGHT   wld.map.ysize

Definition at line 227 of file map.h.

◆ NATURAL_TO_MAP_POS

#define NATURAL_TO_MAP_POS (   pmap_x,
  pmap_y,
  nat_x,
  nat_y 
)
Value:
? (*(pmap_x) = ((nat_y) + (nat_x)) / 2, \
*(pmap_y) = (nat_y) - *(pmap_x) + wld.map.xsize) \
: (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))

Definition at line 178 of file map.h.

◆ NATURAL_WIDTH

#define NATURAL_WIDTH   (MAP_IS_ISOMETRIC ? 2 * wld.map.xsize : wld.map.xsize)

Definition at line 226 of file map.h.

◆ square_dxy_iterate

#define square_dxy_iterate (   nmap,
  center_tile,
  radius,
  tile_itr,
  dx_itr,
  dy_itr 
)     iterate_outward_dxy(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)

Definition at line 381 of file map.h.

◆ square_dxy_iterate_end

#define square_dxy_iterate_end   iterate_outward_dxy_end

Definition at line 384 of file map.h.

◆ square_iterate

#define square_iterate (   nmap,
  center_tile,
  radius,
  tile_itr 
)     square_dxy_iterate(nmap, center_tile, radius, tile_itr, _dummy_x, dummy_y)

Definition at line 391 of file map.h.

◆ square_iterate_end

#define square_iterate_end   square_dxy_iterate_end

Definition at line 394 of file map.h.

◆ startpos_nations_iterate

#define startpos_nations_iterate (   ARG_psp,
  NAME_pnation 
)
Value:
generic_iterate(struct startpos_iter, const struct nation_type *, \
size_t startpos_iter_sizeof(void)
Definition map.c:1777
struct iterator * startpos_iter_init(struct startpos_iter *it, const struct startpos *psp)
Definition map.c:1825

Definition at line 110 of file map.h.

◆ startpos_nations_iterate_end

#define startpos_nations_iterate_end   generic_iterate_end

Definition at line 114 of file map.h.

◆ topo_has_flag

#define topo_has_flag (   topo,
  flag 
)    (((topo) & (flag)) != 0)

Definition at line 47 of file map.h.

◆ whole_map_iterate

#define whole_map_iterate (   _map,
  _tile 
)
Value:
{ \
struct tile *_tile; \
int _tile##_index = 0; \
for (; \
_tile##_index++) { \
_tile = (_map)->tiles + _tile##_index;
#define MAP_INDEX_SIZE
Definition map.h:137

Definition at line 545 of file map.h.

◆ whole_map_iterate_end

#define whole_map_iterate_end
Value:
} \
}

Definition at line 554 of file map.h.

◆ wrap_has_flag

#define wrap_has_flag (   wrap,
  flag 
)    (((wrap) & (flag)) != 0)

Definition at line 50 of file map.h.

Function Documentation

◆ base_get_direction_for_step()

bool base_get_direction_for_step ( const struct civ_map nmap,
const struct tile start_tile,
const struct tile end_tile,
enum direction8 dir 
)

Return TRUE and sets dir to the direction of the step if (end_x, end_y) can be reached from (start_x, start_y) in one step. Return FALSE otherwise (value of dir is unchanged in this case).

Definition at line 1328 of file map.c.

Referenced by do_attack(), get_direction_for_step(), unit_bombard(), and unit_move().

◆ base_map_distance_vector()

void base_map_distance_vector ( int dx,
int dy,
int  x0dv,
int  y0dv,
int  x1dv,
int  y1dv 
)

Finds the difference between the two (unnormalized) positions, in cartesian (map) coordinates. Most callers should use map_distance_vector instead.

Definition at line 1024 of file map.c.

Referenced by client_city_tile(), draw_calculated_trade_routes(), gui_distance_vector(), map_distance_vector(), tile_to_canvas_pos(), and trade_route_to_canvas_lines().

◆ BV_DEFINE()

BV_DEFINE ( dir_vector  ,
 
)

◆ can_channel_land()

bool can_channel_land ( const struct civ_map nmap,
const struct tile ptile 
)

This function returns true if the tile at the given location can be "channeled" from land into ocean. This is the case only when there are a sufficient number of adjacent tiles that are ocean.

Definition at line 699 of file map.c.

Referenced by terrain_surroundings_allow_change().

◆ can_freeze_terrain()

bool can_freeze_terrain ( const struct civ_map nmap,
const struct tile ptile 
)

Returns true if the tile at the given location can be turned from terrain without a 'Frozen' flag to terrain with. This requires a sufficient number of adjacent frozen tiles.

Definition at line 728 of file map.c.

Referenced by terrain_surroundings_allow_change().

◆ can_reclaim_ocean()

bool can_reclaim_ocean ( const struct civ_map nmap,
const struct tile ptile 
)

This function returns true if the tile at the given location can be "reclaimed" from ocean into land. This is the case only when there are a sufficient number of adjacent tiles that are not ocean.

Definition at line 684 of file map.c.

Referenced by terrain_surroundings_allow_change().

◆ can_thaw_terrain()

bool can_thaw_terrain ( const struct civ_map nmap,
const struct tile ptile 
)

Returns true if the tile at the given location can be thawed from terrain with a 'Frozen' flag to terrain without. This requires a sufficient number of adjacent unfrozen tiles.

Definition at line 713 of file map.c.

Referenced by terrain_surroundings_allow_change().

◆ dir_ccw()

enum direction8 dir_ccw ( enum direction8  dir)

Returns the next direction counter-clock-wise.

Definition at line 1203 of file map.c.

Referenced by api_utilities_dir_ccw(), fill_terrain_sprite_array(), and gui_to_map_dir().

◆ dir_cw()

enum direction8 dir_cw ( enum direction8  dir)

Returns the next direction clock-wise.

Definition at line 1174 of file map.c.

Referenced by api_utilities_dir_cw(), fill_terrain_sprite_array(), map_to_gui_dir(), tileset_read_toplevel(), and tileset_setup_unit_direction().

◆ dir_get_name()

const char * dir_get_name ( enum direction8  dir)

Return the debugging name of the direction.

Definition at line 1146 of file map.c.

Referenced by handle_unit_orders(), make_path_orders(), and pf_path_print_real().

◆ FC_STATIC_ASSERT() [1/2]

FC_STATIC_ASSERT ( )

◆ FC_STATIC_ASSERT() [2/2]

FC_STATIC_ASSERT ( MAP_MAX_SIZE *1000<=  MAX_DBV_LENGTH,
map_too_big_for_bitvector   
)

◆ get_direction_for_step()

int get_direction_for_step ( const struct civ_map nmap,
const struct tile start_tile,
const struct tile end_tile 
)

Return the direction which is needed for a step on the map from (start_x, start_y) to (end_x, end_y).

Definition at line 1347 of file map.c.

Referenced by make_path_orders(), request_unit_non_action_move(), send_connect_route(), send_goto_route(), and mr_menu::slot_execute_orders().

◆ get_tile_infrastructure_set()

bv_extras get_tile_infrastructure_set ( const struct tile ptile,
int pcount 
)

Return a bitfield of the extras on the tile that are infrastructure.

Definition at line 101 of file map.c.

Referenced by actres_possible().

◆ index_to_map_pos_x()

static int index_to_map_pos_x ( int  mindex)
inlinestatic

◆ index_to_map_pos_y()

static int index_to_map_pos_y ( int  mindex)
inlinestatic

◆ index_to_tile()

struct tile * index_to_tile ( const struct civ_map imap,
int  mindex 
)

Return the tile for the given index position.

Definition at line 456 of file map.c.

Referenced by act_sel_new_extra_tgt_callback(), act_sel_new_unit_tgt_callback(), chatwdg::anchor_clicked(), api_find_tile_by_index(), attack(), base(), clean(), cultivate(), disembark1(), disembark2(), enter_hut(), enter_hut2(), event_after(), event_after(), event_cache_save(), execute_call(), execute_orders(), fair_map_island_new(), fair_map_make_huts(), frighten_hut(), frighten_hut2(), handle_chat_msg(), handle_city_info(), handle_city_make_specialist(), handle_city_make_worker(), handle_city_short_info(), handle_early_chat_msg(), handle_edit_city_create(), handle_edit_player_vision(), handle_edit_startpos(), handle_edit_startpos(), handle_edit_startpos_full(), handle_edit_startpos_full(), handle_edit_tile(), handle_edit_tile_extra(), handle_edit_tile_terrain(), handle_edit_unit_create(), handle_edit_unit_remove(), handle_nuke_tile_info(), handle_player_diplstate(), handle_player_place_infra(), handle_tile_info(), handle_unit_actions(), handle_unit_get_actions(), handle_unit_orders(), handle_unit_sscs_set(), handle_worker_task(), handle_worker_task(), irrigate(), link_mark_tile(), map_startpos_by_number(), mine(), name_new_city_popup_callback(), notify_conn_packet(), nuke(), objtype_get_object_from_id(), paradrop(), paradrop_conquer(), paradrop_enter(), paradrop_enter_conquer(), paradrop_frighten(), paradrop_frighten_conquer(), pf_danger_map_iterate(), pf_fuel_map_iterate(), pf_jumbo_map_iterate(), pf_normal_map_iterate(), pillage(), plant(), popup_newcity_dialog(), regular_move(), request_action_details_callback(), road(), sg_load_map_owner(), sg_load_map_owner(), simple_action_callback(), simple_action_callback(), suicide_attack(), texai_city_info_recv(), texai_tile_info_recv(), texai_unit_info_recv(), texai_unit_moved_recv(), text_tag_start_sequence(), transform_terrain(), unit_order_list_is_sane(), unit_perform_action(), unpackage_short_unit(), unpackage_unit(), and upgrade_unit_order_targets().

◆ is_border_tile()

static bool is_border_tile ( const struct tile ptile,
int  dist 
)
inlinestatic

Definition at line 738 of file map.h.

◆ is_cardinal_dir()

bool is_cardinal_dir ( enum direction8  dir)

Returns TRUE iff the given direction is a cardinal one.

Cardinal directions are those in which adjacent tiles share an edge not just a vertex.

Definition at line 1316 of file map.c.

Referenced by api_utilities_direction_is_cardinal(), fair_map_island_new(), and get_connect_irrig().

◆ is_move_cardinal()

bool is_move_cardinal ( const struct civ_map nmap,
const struct tile start_tile,
const struct tile end_tile 
)

Returns TRUE iff the move from the position (start_x,start_y) to (end_x,end_y) is a cardinal one.

Definition at line 1365 of file map.c.

Referenced by is_native_move(), and tile_move_cost_ptrs().

◆ is_normal_map_pos()

bool is_normal_map_pos ( int  x,
int  y 
)

Returns TRUE iff the map position is normal. "Normal" here means that it is both a real/valid coordinate set and that the coordinates are in their canonical/proper form. In plain English: the coordinates must be on the map.

Definition at line 963 of file map.c.

Referenced by event_cache_load(), and is_normal_nat_pos().

◆ is_real_map_pos()

bool is_real_map_pos ( const struct civ_map nmap,
int  x,
int  y 
)

Is given position real position

Definition at line 952 of file map.c.

◆ is_safe_ocean()

bool is_safe_ocean ( const struct civ_map nmap,
const struct tile ptile 
)

Return TRUE if this ocean terrain is adjacent to a safe coastline.

Definition at line 667 of file map.c.

Referenced by can_exist_at_tile(), can_unit_survive_at_tile(), is_possible_base_fuel(), is_refuel_tile(), pf_get_move_scope(), remove_city(), try_summon_barbarians(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().

◆ is_singular_tile()

bool is_singular_tile ( const struct tile ptile,
int  dist 
)

A "SINGULAR" position is any map position that has an abnormal number of tiles in the radius of dist.

(map_x, map_y) must be normalized.

dist is the "real" map distance.

Definition at line 1581 of file map.c.

Referenced by near_singularity().

◆ is_tiles_adjacent()

bool is_tiles_adjacent ( const struct tile tile0,
const struct tile tile1 
)

◆ is_valid_dir()

bool is_valid_dir ( enum direction8  dir)

Returns TRUE iff the given direction is a valid one.

If the direction could be out of range you should use map_untrusted_dir_is_valid() instead.

Definition at line 1260 of file map.c.

Referenced by api_utilities_dir2str(), api_utilities_dir_ccw(), api_utilities_dir_cw(), get_unittype_sprite(), goto_path_redraw(), goto_path_undraw(), luascript_dir(), map_untrusted_dir_is_valid(), and mapstep().

◆ main_map_allocate()

void main_map_allocate ( void  )

Allocate main map and related global structures.

Definition at line 519 of file map.c.

Referenced by handle_map_info(), map_fractal_generate(), sg_load_map_tiles(), sg_load_map_tiles(), and srv_ready().

◆ main_map_free()

void main_map_free ( void  )

Free main map and related global structures.

Definition at line 554 of file map.c.

Referenced by game_free(), game_reset(), and srv_ready().

◆ map_allocate()

void map_allocate ( struct civ_map amap)

Allocate space for map, and initialise the tiles. Uses current map.xsize and map.ysize.

Definition at line 493 of file map.c.

Referenced by main_map_allocate(), and texai_map_init().

◆ map_distance()

int map_distance ( const struct tile tile0,
const struct tile tile1 
)

◆ map_distance_vector()

void map_distance_vector ( int dx,
int dy,
const struct tile tile0,
const struct tile tile1 
)

Topology function to find the vector which has the minimum "real" distance between the map positions (x0, y0) and (x1, y1). If there is more than one vector with equal distance, no guarantee is made about which is found.

Real distance is defined as the larger of the distances in the x and y direction; since units can travel diagonally this is the "real" distance a unit has to travel to get from point to point.

(See also: real_map_distance, map_distance, and sq_map_distance.)

With the standard topology the ranges of the return value are: -map.xsize / 2 <= dx <= map.xsize / 2 -map.ysize < dy < map.ysize

Definition at line 1073 of file map.c.

Referenced by city_tile_to_city_map(), do_move_unit(), edit_buffer_paste(), editor_get_selection_center(), map_claim_border(), map_distance(), real_map_distance(), sq_map_distance(), team_placement_horizontal(), team_placement_vertical(), and update_selection_rectangle().

◆ map_free()

void map_free ( struct civ_map fmap)

Frees the allocated memory of the map.

Definition at line 530 of file map.c.

Referenced by handle_map_info(), main_map_free(), and texai_map_close().

◆ map_init()

void map_init ( struct civ_map imap,
bool  server_side 
)

Put some sensible values into the map structure

Definition at line 157 of file map.c.

Referenced by game_init(), game_reset(), and texai_map_init().

◆ map_init_topology()

void map_init_topology ( struct civ_map nmap)

map_init_topology needs to be called after map.topology_id is changed.

map.xsize and map.ysize must be set before calling map_init_topology(). This is done by the map generator code (server), when loading a savegame or a scenario with map (server), and packhand code (client).

Definition at line 303 of file map.c.

Referenced by generator_init_topology(), handle_map_info(), sg_load_map_tiles(), sg_load_map_tiles(), and texai_map_init().

◆ map_is_empty()

bool map_is_empty ( void  )

Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded. (To be precise, returns TRUE if map_allocate() has not yet been called.)

Definition at line 149 of file map.c.

Referenced by generator_validate(), handle_map_info(), leave_mapcanvas(), map_canvas_draw(), map_canvas_draw(), map_canvas_resized(), map_fractal_generate(), mapimg_create(), server_remove_player(), set_rulesetdir(), setting_is_free_to_change(), sg_save_map(), srv_ready(), texai_thread_start(), tile_map_check(), and unqueue_mapview_updates().

◆ map_move_cost()

static int map_move_cost ( const struct civ_map nmap,
const struct player pplayer,
const struct unit_type punittype,
const struct tile src_tile,
const struct tile dst_tile 
)
inlinestatic

Definition at line 305 of file map.h.

Referenced by normal_move(), overlap_move(), and utype_pays_mp_for_action_estimate().

◆ map_move_cost_unit()

static int map_move_cost_unit ( const struct civ_map nmap,
struct unit punit,
const struct tile ptile 
)
inlinestatic

◆ map_num_tiles()

int map_num_tiles ( void  )

◆ map_pos_to_index()

static int map_pos_to_index ( struct civ_map nmap,
int  map_x,
int  map_y 
)
inlinestatic

Definition at line 705 of file map.h.

Referenced by event_cache_load().

◆ map_pos_to_tile()

struct tile * map_pos_to_tile ( const struct civ_map nmap,
int  map_x,
int  map_y 
)

◆ map_signed_latitude()

int map_signed_latitude ( const struct tile ptile)

Returns the latitude of this map position. This is a value in the range of -MAP_MAX_LATITUDE to MAP_MAX_LATITUDE (inclusive).

latitude reaches MAP_MAX_LATITUDE in the northern polar region, reaches -MAP_MAX_LATITUDE in the southern polar region, and is around 0 in the tropics.

Definition at line 1550 of file map.c.

Referenced by is_latitude_req_active(), map_colatitude(), and popup_info_text().

◆ map_startpos_by_number()

struct startpos * map_startpos_by_number ( int  id)

Returns the start position associated to the given ID.

Definition at line 1624 of file map.c.

Referenced by objtype_get_object_from_id().

◆ map_startpos_count()

int map_startpos_count ( void  )

◆ map_startpos_get()

struct startpos * map_startpos_get ( const struct tile ptile)

◆ map_startpos_iter_init()

struct iterator * map_startpos_iter_init ( struct map_startpos_iter iter)

Implementation of iterator init function. NB: map_sp_iter just wraps startpos_hash_iter.

Definition at line 1920 of file map.c.

◆ map_startpos_iter_sizeof()

size_t map_startpos_iter_sizeof ( void  )

Implementation of iterator sizeof function. NB: map_sp_iter just wraps startpos_hash_iter.

Definition at line 1911 of file map.c.

◆ map_startpos_new()

struct startpos * map_startpos_new ( struct tile ptile)

Create a new start position at the given tile and return it. If a start position already exists there, it is first removed.

Definition at line 1866 of file map.c.

Referenced by create_start_positions(), handle_edit_startpos(), handle_edit_startpos(), map_generate_fair_islands(), sg_load_map_startpos(), and sg_load_map_startpos().

◆ map_startpos_remove()

bool map_startpos_remove ( struct tile ptile)

Remove the start position at the given tile. Returns TRUE if the start position was removed.

Definition at line 1899 of file map.c.

Referenced by handle_edit_startpos(), and handle_edit_startpos().

◆ map_untrusted_dir_is_valid()

bool map_untrusted_dir_is_valid ( enum direction8  dir)

Returns TRUE iff the given direction is a valid one.

Doesn't trust the input. Can be used to validate a direction from an untrusted source.

Definition at line 1273 of file map.c.

Referenced by unit_order_list_is_sane().

◆ map_vector_to_real_distance()

int map_vector_to_real_distance ( int  dx,
int  dy 
)

Return the "real" distance for a given vector.

Definition at line 578 of file map.c.

Referenced by generate_map_indices(), get_closest_safe_tile_distance(), map_vector_to_distance(), map_vector_to_sq_distance(), real_distance_to_land(), and real_map_distance().

◆ map_vector_to_sq_distance()

int map_vector_to_sq_distance ( int  dx,
int  dy 
)

Return the sq_distance for a given vector.

Definition at line 614 of file map.c.

Referenced by generate_city_map_indices(), is_valid_city_coords(), map_claim_border(), map_generate_fair_islands(), and sq_map_distance().

◆ mapstep()

struct tile * mapstep ( const struct civ_map nmap,
const struct tile ptile,
enum direction8  dir 
)

◆ native_pos_to_tile()

struct tile * native_pos_to_tile ( const struct civ_map nmap,
int  nat_x,
int  nat_y 
)

◆ nearest_real_tile()

struct tile * nearest_real_tile ( const struct civ_map nmap,
int  x,
int  y 
)

Twiddle *x and *y to point to the nearest real tile, and ensure that the position is normalized.

Definition at line 995 of file map.c.

Referenced by canvas_pos_to_nearest_tile().

◆ normalize_map_pos()

bool normalize_map_pos ( const struct civ_map nmap,
int x,
int y 
)

If the position is real, it will be normalized and TRUE will be returned. If the position is unreal, it will be left unchanged and FALSE will be returned.

Note, we need to leave x and y with sane values even in the unreal case. Some callers may for instance call nearest_real_tile() on these values.

Definition at line 979 of file map.c.

Referenced by api_methods_private_tile_for_outward_index(), api_methods_private_tile_next_outward_index(), canvas_pos_to_tile(), fair_map_place_island_team(), is_real_map_pos(), and overview_to_map_pos().

◆ opposite_direction()

enum direction8 opposite_direction ( enum direction8  dir)

Return direction that is opposite to given one.

Definition at line 1937 of file map.c.

Referenced by api_utilities_opposite_dir(), and do_attack().

◆ rand_direction()

enum direction8 rand_direction ( void  )

Return random direction that is valid in current map.

Definition at line 1929 of file map.c.

Referenced by unit_virtual_create().

◆ rand_map_pos()

struct tile * rand_map_pos ( const struct civ_map nmap)

Random square anywhere on the map. Only normal positions (for which is_normal_map_pos returns true) will be found.

Definition at line 1088 of file map.c.

Referenced by climate_change(), place_animal(), place_island(), and try_summon_barbarians().

◆ rand_map_pos_filtered()

struct tile * rand_map_pos_filtered ( const struct civ_map nmap,
void data,
bool(*)(const struct tile *ptile, const void *data)  filter 
)

Give a random tile anywhere on the map for which the 'filter' function returns TRUE. Return FALSE if none can be found. The filter may be NULL if any position is okay; if non-NULL it shouldn't have any side effects.

Definition at line 1101 of file map.c.

Referenced by create_start_positions(), and rand_map_pos_characteristic().

◆ real_map_distance()

int real_map_distance ( const struct tile tile0,
const struct tile tile1 
)

◆ same_pos()

bool same_pos ( const struct tile tile1,
const struct tile tile2 
)

◆ sq_map_distance()

int sq_map_distance ( const struct tile tile0,
const struct tile tile1 
)

◆ startpos_allow()

bool startpos_allow ( struct startpos psp,
struct nation_type pnation 
)

Allow the nation to start at the start position. NB: in "excluding" mode, this remove the nation from the excluded list.

Definition at line 1643 of file map.c.

Referenced by map_generate_fair_islands(), sg_load_map_startpos(), and sg_load_map_startpos().

◆ startpos_allows_all()

bool startpos_allows_all ( const struct startpos psp)

Returns TRUE if any nation can start here.

Definition at line 1696 of file map.c.

Referenced by generate_players(), init_new_game(), map_generate_fair_islands(), sg_save_map_startpos(), and startpos_iter_init().

◆ startpos_disallow()

bool startpos_disallow ( struct startpos psp,
struct nation_type pnation 
)

Disallow the nation to start at the start position. NB: in "excluding" mode, this add the nation to the excluded list.

Definition at line 1660 of file map.c.

Referenced by sg_load_map_startpos(), and sg_load_map_startpos().

◆ startpos_is_excluding()

bool startpos_is_excluding ( const struct startpos psp)

Returns TRUE if the nations returned by startpos_raw_nations() are actually excluded from the nations allowed to start at this position.

FIXME: This function exposes the internal implementation and should be removed when no longer needed by the property editor system.

Definition at line 1753 of file map.c.

Referenced by objbind_get_value_from_object(), and sg_save_map_startpos().

◆ startpos_iter_init()

struct iterator * startpos_iter_init ( struct startpos_iter iter,
const struct startpos psp 
)

Initialize and return an iterator for the nations at this start position.

Definition at line 1825 of file map.c.

◆ startpos_iter_sizeof()

size_t startpos_iter_sizeof ( void  )

Implementation of iterator 'sizeof' function.

struct startpos_iter can be either a 'struct nation_hash_iter', a 'struct nation_iter' or 'struct startpos_iter'.

Definition at line 1777 of file map.c.

◆ startpos_nation_allowed()

bool startpos_nation_allowed ( const struct startpos psp,
const struct nation_type pnation 
)

Returns TRUE if the given nation can start here.

Definition at line 1685 of file map.c.

Referenced by generate_players(), init_new_game(), and update_nations_with_startpos().

◆ startpos_number()

int startpos_number ( const struct startpos psp)

Returns the unique ID number for this start position. This is just the tile index of the tile where this start position is located.

Definition at line 1633 of file map.c.

Referenced by handle_edit_startpos_full(), objtype_get_id_from_object(), and startpos_pack().

◆ startpos_pack()

bool startpos_pack ( const struct startpos psp,
struct packet_edit_startpos_full packet 
)

Fills the packet with all of the information at this start position. Returns TRUE if the packet can be sent.

Definition at line 1706 of file map.c.

Referenced by edithand_send_initial_packets(), and objbind_pack_current_values().

◆ startpos_raw_nations()

const struct nation_hash * startpos_raw_nations ( const struct startpos psp)

Return a the nations hash, used for the property editor.

FIXME: This function exposes the internal implementation and should be removed when no longer needed by the property editor system.

Definition at line 1765 of file map.c.

Referenced by objbind_get_value_from_object(), and sg_save_map_startpos().

◆ startpos_tile()

struct tile * startpos_tile ( const struct startpos psp)

Returns the tile where this start position is located.

Definition at line 1676 of file map.c.

Referenced by edithand_send_initial_packets(), init_new_game(), is_valid_start_pos(), objbind_get_value_from_object(), and sg_save_map_startpos().

◆ startpos_unpack()

bool startpos_unpack ( struct startpos psp,
const struct packet_edit_startpos_full packet 
)

Fills the start position with the nation information in the packet. Returns TRUE if the start position was changed.

Definition at line 1726 of file map.c.

Referenced by handle_edit_startpos_full(), and handle_edit_startpos_full().

◆ terrain_surroundings_allow_change()

bool terrain_surroundings_allow_change ( const struct civ_map nmap,
const struct tile ptile,
const struct terrain pterrain 
)

Returns FALSE if a terrain change to 'pterrain' would be prevented by not having enough similar terrain surrounding ptile.

Definition at line 742 of file map.c.

Referenced by actres_possible(), adv_calc_transform(), and climate_change().

◆ tile_move_cost_ptrs()

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 
)

The basic cost to move punit from tile t1 to tile t2. That is, tile_move_cost(), with pre-calculated tile pointers; the tiles are assumed to be adjacent, and the (x,y) values are used only to get the river bonus correct.

May also be used with punit == NULL, in which case punit tests are not done (for unit-independent results).

Definition at line 780 of file map.c.

Referenced by map_move_cost(), and map_move_cost_unit().

Variable Documentation

◆ C_ADJACENT

const bool C_ADJACENT = FALSE
static

Definition at line 37 of file map.h.

Referenced by island_river_mouth_suitability(), and island_river_suitability().

◆ C_CARDINAL

const bool C_CARDINAL = TRUE
static

Definition at line 38 of file map.h.

Referenced by island_river_mouth_suitability(), and island_river_suitability().

◆ C_NUMBER

const bool C_NUMBER = FALSE
static

Definition at line 39 of file map.h.

Referenced by island_river_mouth_suitability(), and island_river_suitability().

◆ C_PERCENT

const bool C_PERCENT = TRUE
static

Definition at line 40 of file map.h.

Referenced by island_river_mouth_suitability(), and island_river_suitability().

◆ DIR_DX

const int DIR_DX[8]
extern

Definition at line 86 of file map.c.

Referenced by draw_segment(), and scroll_mapview().

◆ DIR_DY

const int DIR_DY[8]
extern

Definition at line 87 of file map.c.

Referenced by draw_segment(), and scroll_mapview().

◆ terrain_control

struct terrain_misc terrain_control
extern