Freeciv21
Develop your civilization from humble roots to a global empire
map.h File Reference
#include <cmath>
#include "bitvector.h"
#include "iterator.h"
#include "log.h"
#include "game.h"
#include "map_types.h"
+ Include dependency graph for map.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 topo_has_flag(topo, flag)   (((topo) & (flag)) != 0)
 
#define current_topo_has_flag(flag)   topo_has_flag((CURRENT_TOPOLOGY), (flag))
 
#define ALL_DIRECTIONS_CARDINAL()   topo_has_flag((CURRENT_TOPOLOGY), TF_HEX)
 
#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_natural_pos(ntl_x, ntl_y, map_x, map_y)
 
#define do_in_natural_pos_end
 
#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)    ((dest_x) = DIR_DX[(dir)], (dest_y) = DIR_DY[(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)    iterate_outward_dxy(nmap, start_tile, max_dist, itr_tile, _dx_itr, _dy_itr)
 
#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)   ((enum direction8)(7 - (dir)))
 
#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_WRAPX | TF_ISO)
 
#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   100
 
#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_SINGLE_POLE   false
 
#define MAP_MIN_SINGLE_POLE   false
 
#define MAP_MAX_SINGLE_POLE   true
 
#define MAP_DEFAULT_ALLTEMPERATE   false
 
#define MAP_MIN_ALLTEMPERATE   false
 
#define MAP_MAX_ALLTEMPERATE   true
 
#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 ()
 Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded. More...
 
void map_init (struct civ_map *imap, bool server_side)
 Put some sensible values into the map structure. More...
 
void map_init_topology ()
 map_init_topology needs to be called after map.topology_id is changed. More...
 
void map_allocate (struct civ_map *amap)
 Allocate space for map, and initialise the tiles. More...
 
void main_map_allocate ()
 Allocate main map and related global structures. More...
 
void map_free (struct civ_map *fmap)
 Frees the allocated memory of the map. More...
 
void main_map_free ()
 Free main map and related global structures. More...
 
int map_vector_to_real_distance (int dx, int dy)
 Return the "real" distance for a given vector. More...
 
int map_vector_to_sq_distance (int dx, int dy)
 Return the sq_distance for a given vector. More...
 
int map_distance (const struct tile *tile0, const struct tile *tile1)
 Return Manhattan distance between two tiles. More...
 
int real_map_distance (const struct tile *tile0, const struct tile *tile1)
 Return real distance between two tiles. More...
 
int sq_map_distance (const struct tile *tile0, const struct tile *tile1)
 Return squared distance between two tiles. More...
 
bool same_pos (const struct tile *tile0, const struct tile *tile1)
 Are (x1,y1) and (x2,y2) really the same when adjusted? This function might be necessary ALOT of places... More...
 
bool base_get_direction_for_step (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_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. More...
 
int get_direction_for_step (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_tile)
 Return the direction which is needed for a step on the map from (start_x, start_y) to (end_x, end_y). More...
 
int startpos_number (const struct startpos *psp)
 Returns the unique ID number for this start position. More...
 
bool startpos_allow (struct startpos *psp, struct nation_type *pnation)
 Allow the nation to start at the start position. More...
 
bool startpos_disallow (struct startpos *psp, struct nation_type *pnation)
 Disallow the nation to start at the start position. More...
 
struct tilestartpos_tile (const struct startpos *psp)
 Returns the tile where this start position is located. More...
 
bool startpos_nation_allowed (const struct startpos *psp, const struct nation_type *pnation)
 Returns TRUE if the given nation can start here. More...
 
bool startpos_allows_all (const struct startpos *psp)
 Returns TRUE if any nation can start here. More...
 
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. More...
 
bool startpos_unpack (struct startpos *psp, const struct packet_edit_startpos_full *packet)
 Fills the start position with the nation information in the packet. More...
 
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. More...
 
QSet< const struct nation_type * > * startpos_raw_nations (const struct startpos *psp)
 Return a the nations hash, used for the property editor. More...
 
int map_startpos_count ()
 Is there start positions set for map. More...
 
struct startposmap_startpos_new (struct tile *ptile)
 Create a new start position at the given tile and return it. More...
 
struct startposmap_startpos_get (const struct tile *ptile)
 Returns the start position at the given tile, or nullptr if none exists there. More...
 
bool map_startpos_remove (struct tile *ptile)
 Remove the start position at the given tile. More...
 
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)
 Step from the given tile in the given direction. More...
 
struct tilemap_pos_to_tile (const struct civ_map *nmap, int x, int y)
 Return the tile for the given cartesian (map) position. More...
 
struct tilenative_pos_to_tile (const struct civ_map *nmap, int nat_x, int nat_y)
 Return the tile for the given native position. More...
 
struct tileindex_to_tile (const struct civ_map *imap, int mindex)
 Return the tile for the given index position. More...
 
bool is_normal_map_pos (int x, int y)
 Returns TRUE iff the map position is normal. More...
 
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. More...
 
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. More...
 
struct tilenearest_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. More...
 
void base_map_distance_vector (int *dx, int *dy, int x0, int y0, int x1, int y1)
 Finds the difference between the two (unnormalized) positions, in cartesian (map) coordinates. More...
 
void map_distance_vector (int *dx, int *dy, const struct tile *ptile0, const struct tile *ptile1)
 Topology function to find the vector which has the minimum "real" distance between the map positions (x0, y0) and (x1, y1). More...
 
int map_num_tiles ()
 Returns the total number of (real) positions (or tiles) on the map. More...
 
struct tilerand_map_pos (const struct civ_map *nmap)
 Random square anywhere on the map. More...
 
struct tilerand_map_pos_filtered (const struct civ_map *nmap, void *data, bool(*filter)(const struct tile *ptile, const void *data))
 Give a random tile anywhere on the map for which the 'filter' function returns TRUE. More...
 
bool is_tiles_adjacent (const struct tile *ptile0, const struct tile *ptile1)
 Are two tiles adjacent to each other. More...
 
bool is_move_cardinal (const struct civ_map *nmap, const struct tile *src_tile, const struct tile *dst_tile)
 Returns TRUE iff the move from the position (start_x,start_y) to (end_x,end_y) is a cardinal one. More...
 
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. More...
 
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)
 Return TRUE if this ocean terrain is adjacent to a safe coastline. More...
 
bv_extras get_tile_infrastructure_set (const struct tile *ptile, int *count)
 Return a bitfield of the extras on the tile that are infrastructure. More...
 
bool can_channel_land (const struct tile *ptile)
 This function returns true if the tile at the given location can be "channeled" from land into ocean. More...
 
bool can_reclaim_ocean (const struct tile *ptile)
 This function returns true if the tile at the given location can be "reclaimed" from ocean into land. More...
 
bool can_thaw_terrain (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. More...
 
bool can_freeze_terrain (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. More...
 
bool terrain_surroundings_allow_change (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. More...
 
 BV_DEFINE (dir_vector, 8)
 
enum direction8 dir_cw (enum direction8 dir)
 Returns the next direction clock-wise. More...
 
enum direction8 dir_ccw (enum direction8 dir)
 Returns the next direction counter-clock-wise. More...
 
const char * dir_get_name (enum direction8 dir)
 Return the debugging name of the direction. More...
 
bool map_untrusted_dir_is_valid (enum direction8 dir)
 Returns TRUE iff the given direction is a valid one. More...
 
bool is_valid_dir (enum direction8 dir)
 Returns TRUE iff the given direction is a valid one. More...
 
bool is_cardinal_dir (enum direction8 dir)
 Returns TRUE iff the given direction is a cardinal one. More...
 
 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 ()
 Return random direction that is valid in current map. More...
 
enum direction8 opposite_direction (enum direction8 dir)
 Return direction that is opposite to given one. More...
 

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:
adjc_dirlist_base_iterate(nmap, center_tile, dir_itr, wld.map.valid_dirs, \
struct world wld
Definition: game.cpp:48
#define adjc_dirlist_base_iterate(nmap, center_tile, _dir, dirlist, dircount)
Definition: map.h:447
enum direction8 valid_dirs[8]
Definition: map_types.h:69
int num_valid_dirs
Definition: map_types.h:70
struct civ_map map
Definition: world_object.h:21

Definition at line 371 of file map.h.

◆ adjc_dir_base_iterate_end

#define adjc_dir_base_iterate_end   adjc_dirlist_base_iterate_end

Definition at line 375 of file map.h.

◆ adjc_dir_iterate

#define adjc_dir_iterate (   nmap,
  center_tile,
  itr_tile,
  dir_itr 
)
Value:
adjc_dirlist_iterate(nmap, center_tile, itr_tile, dir_itr, \
#define adjc_dirlist_iterate(nmap, center_tile, _tile, _dir, dirlist, dircount)
Definition: map.h:423

Definition at line 364 of file map.h.

◆ adjc_dir_iterate_end

#define adjc_dir_iterate_end   adjc_dirlist_iterate_end

Definition at line 368 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); \
bool _tile##_is_border = is_border_tile(_tile##_center, 1); \
int _tile##_index = 0; \
index_to_map_pos(&_center##_x, &_center##_y, \
tile_index(_tile##_center)); \
for (; _tile##_index < (dircount); _tile##_index++) { \
_dir = dirlist[_tile##_index]; \
DIRSTEP(_tile##_x, _tile##_y, _dir); \
_tile##_x += _center##_x; \
_tile##_y += _center##_y; \
if (_tile##_is_border \
&& !normalize_map_pos(nmap, &_tile##_x, &_tile##_y)) { \
continue; \
}
static bool is_border_tile(const struct tile *ptile, int dist)
Definition: map.h:630
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.
Definition: map.cpp:919
Definition: tile.h:42
#define tile_index(_pt_)
Definition: tile.h:70

Definition at line 447 of file map.h.

◆ adjc_dirlist_base_iterate_end

#define adjc_dirlist_base_iterate_end
Value:
} \
}

Definition at line 467 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; \
index_to_map_pos(&_tile##_cx, &_tile##_cy, tile_index(_tile##_center)); \
for (; _tile##_index < (dircount); _tile##_index++) { \
_dir = dirlist[_tile##_index]; \
DIRSTEP(_tile##_x, _tile##_y, _dir); \
_tile##_x += _tile##_cx; \
_tile##_y += _tile##_cy; \
_tile = map_pos_to_tile(nmap, _tile##_x, _tile##_y); \
if (nullptr == _tile) { \
continue; \
}
struct tile * map_pos_to_tile(const struct civ_map *nmap, int x, int y)
Return the tile for the given cartesian (map) position.
Definition: map.cpp:391

Definition at line 423 of file map.h.

◆ adjc_dirlist_iterate_end

#define adjc_dirlist_iterate_end
Value:
} \
}

Definition at line 442 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. */ \
adjc_dir_iterate(nmap, center_tile, itr_tile, \
ADJC_ITERATE_dir_itr##itr_tile) \
{

Definition at line 351 of file map.h.

◆ adjc_iterate_end

#define adjc_iterate_end
Value:
} \
adjc_dir_iterate_end; \
}

Definition at line 358 of file map.h.

◆ ALL_DIRECTIONS_CARDINAL

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

Definition at line 39 of file map.h.

◆ cardinal_adjc_dir_base_iterate

#define cardinal_adjc_dir_base_iterate (   nmap,
  center_tile,
  dir_itr 
)
Value:
adjc_dirlist_base_iterate(nmap, center_tile, dir_itr, \
int num_cardinal_dirs
Definition: map_types.h:70
enum direction8 cardinal_dirs[8]
Definition: map_types.h:69

Definition at line 394 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 399 of file map.h.

◆ cardinal_adjc_dir_iterate

#define cardinal_adjc_dir_iterate (   nmap,
  center_tile,
  itr_tile,
  dir_itr 
)
Value:
adjc_dirlist_iterate(nmap, center_tile, itr_tile, dir_itr, \

Definition at line 387 of file map.h.

◆ cardinal_adjc_dir_iterate_end

#define cardinal_adjc_dir_iterate_end   adjc_dirlist_iterate_end

Definition at line 391 of file map.h.

◆ cardinal_adjc_iterate

#define cardinal_adjc_iterate (   nmap,
  center_tile,
  itr_tile 
)
Value:
adjc_dirlist_iterate(nmap, center_tile, itr_tile, _dir_itr##center_tile, \

Definition at line 380 of file map.h.

◆ cardinal_adjc_iterate_end

#define cardinal_adjc_iterate_end   adjc_dirlist_iterate_end

Definition at line 384 of file map.h.

◆ cardinal_between_iterate

#define cardinal_between_iterate (   nmap,
  tile1,
  tile2,
  between 
)
Value:
cardinal_adjc_iterate(nmap, tile1, between) \
{ \
cardinal_adjc_iterate(nmap, between, second) \
{ \
if (same_pos(second, tile2)) {
bool same_pos(const struct tile *tile0, const struct tile *tile1)
Are (x1,y1) and (x2,y2) really the same when adjusted? This function might be necessary ALOT of place...
Definition: map.cpp:887
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition: map.h:380

Definition at line 402 of file map.h.

◆ cardinal_between_iterate_end

#define cardinal_between_iterate_end
Value:
} \
} \
cardinal_adjc_iterate_end; \
} \
cardinal_adjc_iterate_end;

Definition at line 409 of file map.h.

◆ CHECK_INDEX

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

Definition at line 103 of file map.h.

◆ CHECK_MAP_POS

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

Definition at line 101 of file map.h.

◆ CHECK_NATIVE_POS

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

Definition at line 102 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)); \
square_dxy_iterate(nmap, center_tile, _tile##_cr_radius, _tile, dx, dy) \
{ \
const int dr = map_vector_to_sq_distance(dx, dy); \
\
if (dr <= _tile##_sq_radius) {
int map_vector_to_sq_distance(int dx, int dy)
Return the sq_distance for a given vector.
Definition: map.cpp:583
#define square_dxy_iterate(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)
Definition: map.h:301
#define MAX(x, y)
Definition: shared.h:48

Definition at line 329 of file map.h.

◆ circle_dxyr_iterate_end

#define circle_dxyr_iterate_end
Value:
} \
} \
square_dxy_iterate_end; \
}

Definition at line 342 of file map.h.

◆ circle_iterate

#define circle_iterate (   nmap,
  center_tile,
  sq_radius,
  tile_itr 
)     circle_dxyr_iterate(nmap, center_tile, sq_radius, tile_itr, _dx, _dy, _dr)

Definition at line 322 of file map.h.

◆ circle_iterate_end

#define circle_iterate_end   circle_dxyr_iterate_end

Definition at line 325 of file map.h.

◆ current_topo_has_flag

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

Definition at line 37 of file map.h.

◆ CURRENT_TOPOLOGY

#define CURRENT_TOPOLOGY   (wld.map.topology_id)

Definition at line 34 of file map.h.

◆ DIR_REVERSE

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

Definition at line 487 of file map.h.

◆ DIRSTEP

#define DIRSTEP (   dest_x,
  dest_y,
  dir 
)     ((dest_x) = DIR_DX[(dir)], (dest_y) = DIR_DY[(dir)])

Definition at line 170 of file map.h.

◆ do_in_natural_pos

#define do_in_natural_pos (   ntl_x,
  ntl_y,
  map_x,
  map_y 
)
Value:
{ \
int _ntl_x, _ntl_y; \
MAP_TO_NATURAL_POS(&_ntl_x, &_ntl_y, map_x, map_y); \
{ \
const int ntl_x = _ntl_x, ntl_y = _ntl_y;

Definition at line 143 of file map.h.

◆ do_in_natural_pos_end

#define do_in_natural_pos_end
Value:
} \
}

Definition at line 150 of file map.h.

◆ index_to_map_pos

#define index_to_map_pos (   pmap_x,
  pmap_y,
  mindex 
)
Value:
(CHECK_INDEX(mindex), index_to_native_pos(pmap_x, pmap_y, mindex), \
NATIVE_TO_MAP_POS(pmap_x, pmap_y, *(pmap_x), *(pmap_y)))
#define CHECK_INDEX(mindex)
Definition: map.h:103
#define index_to_native_pos(pnat_x, pnat_y, mindex)
Definition: map.h:111

Definition at line 164 of file map.h.

◆ index_to_native_pos

#define index_to_native_pos (   pnat_x,
  pnat_y,
  mindex 
)
Value:
(*(pnat_x) = index_to_native_pos_x(mindex), \
*(pnat_y) = index_to_native_pos_y(mindex))
#define index_to_native_pos_y(mindex)
Definition: map.h:115
#define index_to_native_pos_x(mindex)
Definition: map.h:114

Definition at line 111 of file map.h.

◆ index_to_native_pos_x

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

Definition at line 114 of file map.h.

◆ index_to_native_pos_y

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

Definition at line 115 of file map.h.

◆ iterate_outward

#define iterate_outward (   nmap,
  start_tile,
  max_dist,
  itr_tile 
)     iterate_outward_dxy(nmap, start_tile, max_dist, itr_tile, _dx_itr, _dy_itr)

Definition at line 288 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; \
index_to_map_pos(&_start##_x, &_start##_y, tile_index(_tile##_start)); \
for (; _tile##_index < wld.map.num_iterate_outwards_indices; \
_tile##_index++) { \
if (wld.map.iterate_outwards_indices[_tile##_index].dist \
> _tile##_max) { \
break; \
} \
_x = wld.map.iterate_outwards_indices[_tile##_index].dx; \
_y = wld.map.iterate_outwards_indices[_tile##_index].dy; \
_tile##_x = _x + _start##_x; \
_tile##_y = _y + _start##_y; \
_tile = map_pos_to_tile(nmap, _tile##_x, _tile##_y); \
if (nullptr == _tile) { \
continue; \
}
int num_iterate_outwards_indices
Definition: map_types.h:72
struct iter_index * iterate_outwards_indices
Definition: map_types.h:71
int dist
Definition: city.h:83
int dx
Definition: city.h:83
int dy
Definition: city.h:83

Definition at line 260 of file map.h.

◆ iterate_outward_dxy_end

#define iterate_outward_dxy_end
Value:
} \
}

Definition at line 283 of file map.h.

◆ iterate_outward_end

#define iterate_outward_end   iterate_outward_dxy_end

Definition at line 291 of file map.h.

◆ MAP_DEFAULT_ALLTEMPERATE

#define MAP_DEFAULT_ALLTEMPERATE   false

Definition at line 581 of file map.h.

◆ MAP_DEFAULT_ANIMALS

#define MAP_DEFAULT_ANIMALS   20

Definition at line 506 of file map.h.

◆ MAP_DEFAULT_FLATPOLES

#define MAP_DEFAULT_FLATPOLES   100

Definition at line 573 of file map.h.

◆ MAP_DEFAULT_GENERATOR

#define MAP_DEFAULT_GENERATOR   MAPGEN_RANDOM

Definition at line 561 of file map.h.

◆ MAP_DEFAULT_HUTS

#define MAP_DEFAULT_HUTS   15

Definition at line 502 of file map.h.

◆ MAP_DEFAULT_LANDMASS

#define MAP_DEFAULT_LANDMASS   30

Definition at line 545 of file map.h.

◆ MAP_DEFAULT_LINEAR_SIZE

#define MAP_DEFAULT_LINEAR_SIZE   64

Definition at line 529 of file map.h.

◆ MAP_DEFAULT_MAPSIZE

#define MAP_DEFAULT_MAPSIZE   MAPSIZE_FULLSIZE

Definition at line 510 of file map.h.

◆ MAP_DEFAULT_RICHES

#define MAP_DEFAULT_RICHES   250

Definition at line 549 of file map.h.

◆ MAP_DEFAULT_SEED

#define MAP_DEFAULT_SEED   0

Definition at line 541 of file map.h.

◆ MAP_DEFAULT_SEPARATE_POLES

#define MAP_DEFAULT_SEPARATE_POLES   true

Definition at line 569 of file map.h.

◆ MAP_DEFAULT_SINGLE_POLE

#define MAP_DEFAULT_SINGLE_POLE   false

Definition at line 577 of file map.h.

◆ MAP_DEFAULT_SIZE

#define MAP_DEFAULT_SIZE   4

Definition at line 515 of file map.h.

◆ MAP_DEFAULT_STARTPOS

#define MAP_DEFAULT_STARTPOS   MAPSTARTPOS_DEFAULT

Definition at line 563 of file map.h.

◆ MAP_DEFAULT_STEEPNESS

#define MAP_DEFAULT_STEEPNESS   30

Definition at line 553 of file map.h.

◆ MAP_DEFAULT_TEAM_PLACEMENT

#define MAP_DEFAULT_TEAM_PLACEMENT   TEAM_PLACEMENT_CLOSEST

Definition at line 589 of file map.h.

◆ MAP_DEFAULT_TEMPERATURE

#define MAP_DEFAULT_TEMPERATURE   50

Definition at line 585 of file map.h.

◆ MAP_DEFAULT_TILESPERPLAYER

#define MAP_DEFAULT_TILESPERPLAYER   100

Definition at line 524 of file map.h.

◆ MAP_DEFAULT_TINYISLES

#define MAP_DEFAULT_TINYISLES   false

Definition at line 565 of file map.h.

◆ MAP_DEFAULT_TOPO

#define MAP_DEFAULT_TOPO   (TF_WRAPX | TF_ISO)

Definition at line 539 of file map.h.

◆ MAP_DEFAULT_WETNESS

#define MAP_DEFAULT_WETNESS   50

Definition at line 557 of file map.h.

◆ MAP_DISTANCE_MAX

#define MAP_DISTANCE_MAX   (MAP_MAX_LINEAR_SIZE + MAP_MIN_LINEAR_SIZE)

Definition at line 536 of file map.h.

◆ MAP_INDEX_SIZE

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

Definition at line 91 of file map.h.

◆ MAP_IS_ISOMETRIC

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

Definition at line 32 of file map.h.

◆ MAP_MAX_ALLTEMPERATE

#define MAP_MAX_ALLTEMPERATE   true

Definition at line 583 of file map.h.

◆ MAP_MAX_ANIMALS

#define MAP_MAX_ANIMALS   500

Definition at line 508 of file map.h.

◆ MAP_MAX_FLATPOLES

#define MAP_MAX_FLATPOLES   100

Definition at line 575 of file map.h.

◆ MAP_MAX_HUTS

#define MAP_MAX_HUTS   500

Definition at line 504 of file map.h.

◆ MAP_MAX_LANDMASS

#define MAP_MAX_LANDMASS   100

Definition at line 547 of file map.h.

◆ MAP_MAX_LINEAR_SIZE

#define MAP_MAX_LINEAR_SIZE   (MAP_MAX_SIZE * 1000 / MAP_MIN_LINEAR_SIZE)

Definition at line 530 of file map.h.

◆ MAP_MAX_RICHES

#define MAP_MAX_RICHES   1000

Definition at line 551 of file map.h.

◆ MAP_MAX_SEED

#define MAP_MAX_SEED   (MAX_UINT32 >> 1)

Definition at line 543 of file map.h.

◆ MAP_MAX_SEPARATE_POLES

#define MAP_MAX_SEPARATE_POLES   true

Definition at line 571 of file map.h.

◆ MAP_MAX_SINGLE_POLE

#define MAP_MAX_SINGLE_POLE   true

Definition at line 579 of file map.h.

◆ MAP_MAX_SIZE

#define MAP_MAX_SIZE   2048

Definition at line 517 of file map.h.

◆ MAP_MAX_STEEPNESS

#define MAP_MAX_STEEPNESS   100

Definition at line 555 of file map.h.

◆ MAP_MAX_TEMPERATURE

#define MAP_MAX_TEMPERATURE   100

Definition at line 587 of file map.h.

◆ MAP_MAX_TILESPERPLAYER

#define MAP_MAX_TILESPERPLAYER   1000

Definition at line 526 of file map.h.

◆ MAP_MAX_TINYISLES

#define MAP_MAX_TINYISLES   true

Definition at line 567 of file map.h.

◆ MAP_MAX_WETNESS

#define MAP_MAX_WETNESS   100

Definition at line 559 of file map.h.

◆ MAP_MIN_ALLTEMPERATE

#define MAP_MIN_ALLTEMPERATE   false

Definition at line 582 of file map.h.

◆ MAP_MIN_ANIMALS

#define MAP_MIN_ANIMALS   0

Definition at line 507 of file map.h.

◆ MAP_MIN_FLATPOLES

#define MAP_MIN_FLATPOLES   0

Definition at line 574 of file map.h.

◆ MAP_MIN_HUTS

#define MAP_MIN_HUTS   0

Definition at line 503 of file map.h.

◆ MAP_MIN_LANDMASS

#define MAP_MIN_LANDMASS   15

Definition at line 546 of file map.h.

◆ MAP_MIN_LINEAR_SIZE

#define MAP_MIN_LINEAR_SIZE   16

Definition at line 531 of file map.h.

◆ MAP_MIN_RICHES

#define MAP_MIN_RICHES   0

Definition at line 550 of file map.h.

◆ MAP_MIN_SEED

#define MAP_MIN_SEED   0

Definition at line 542 of file map.h.

◆ MAP_MIN_SEPARATE_POLES

#define MAP_MIN_SEPARATE_POLES   false

Definition at line 570 of file map.h.

◆ MAP_MIN_SINGLE_POLE

#define MAP_MIN_SINGLE_POLE   false

Definition at line 578 of file map.h.

◆ MAP_MIN_SIZE

#define MAP_MIN_SIZE   0

Definition at line 516 of file map.h.

◆ MAP_MIN_STEEPNESS

#define MAP_MIN_STEEPNESS   0

Definition at line 554 of file map.h.

◆ MAP_MIN_TEMPERATURE

#define MAP_MIN_TEMPERATURE   0

Definition at line 586 of file map.h.

◆ MAP_MIN_TILESPERPLAYER

#define MAP_MIN_TILESPERPLAYER   1

Definition at line 525 of file map.h.

◆ MAP_MIN_TINYISLES

#define MAP_MIN_TINYISLES   false

Definition at line 566 of file map.h.

◆ MAP_MIN_WETNESS

#define MAP_MIN_WETNESS   0

Definition at line 558 of file map.h.

◆ MAP_ORIGINAL_TOPO

#define MAP_ORIGINAL_TOPO   TF_WRAPX

Definition at line 538 of file map.h.

◆ map_size_checked

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

Definition at line 200 of file map.h.

◆ MAP_TILE_OWNER_NULL

#define MAP_TILE_OWNER_NULL   MAX_UINT8

Definition at line 500 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:32
int xsize
Definition: map_types.h:73

Definition at line 123 of file map.h.

◆ MAP_TO_NATURAL_POS

#define MAP_TO_NATURAL_POS (   pnat_x,
  pnat_y,
  map_x,
  map_y 
)
Value:
(MAP_IS_ISOMETRIC ? (*(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 134 of file map.h.

◆ native_pos_to_index

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

Definition at line 108 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 106 of file map.h.

◆ NATIVE_TO_MAP_POS

#define NATIVE_TO_MAP_POS (   pmap_x,
  pmap_y,
  nat_x,
  nat_y 
)
Value:
(MAP_IS_ISOMETRIC ? (*(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 118 of file map.h.

◆ NATURAL_HEIGHT

#define NATURAL_HEIGHT   wld.map.ysize

Definition at line 158 of file map.h.

◆ NATURAL_TO_MAP_POS

#define NATURAL_TO_MAP_POS (   pmap_x,
  pmap_y,
  nat_x,
  nat_y 
)
Value:
(MAP_IS_ISOMETRIC ? (*(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 129 of file map.h.

◆ NATURAL_WIDTH

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

Definition at line 157 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 301 of file map.h.

◆ square_dxy_iterate_end

#define square_dxy_iterate_end   iterate_outward_dxy_end

Definition at line 305 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 312 of file map.h.

◆ square_iterate_end

#define square_iterate_end   square_dxy_iterate_end

Definition at line 315 of file map.h.

◆ topo_has_flag

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

Definition at line 36 of file map.h.

◆ whole_map_iterate

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

Definition at line 473 of file map.h.

◆ whole_map_iterate_end

#define whole_map_iterate_end
Value:
} \
}

Definition at line 480 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 1267 of file map.cpp.

Referenced by do_attack(), get_direction_for_step(), is_valid_goto_draw_line(), mapdeco_set_gotoroute(), 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 961 of file map.cpp.

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 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 668 of file map.cpp.

Referenced by terrain_surroundings_allow_change().

◆ can_freeze_terrain()

bool can_freeze_terrain ( 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 694 of file map.cpp.

Referenced by terrain_surroundings_allow_change().

◆ can_reclaim_ocean()

bool can_reclaim_ocean ( 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 655 of file map.cpp.

Referenced by terrain_surroundings_allow_change().

◆ can_thaw_terrain()

bool can_thaw_terrain ( 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 681 of file map.cpp.

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 1084 of file map.cpp.

Referenced by api_utilities_dir_ccw(), and freeciv::layer_terrain::fill_terrain_sprite_array().

◆ dir_cw()

enum direction8 dir_cw ( enum direction8  dir)

Returns the next direction clock-wise.

Definition at line 1084 of file map.cpp.

Referenced by api_utilities_dir_cw(), freeciv::layer_terrain::fill_terrain_sprite_array(), 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 1084 of file map.cpp.

Referenced by handle_unit_orders(), make_path_orders(), and operator<<().

◆ FC_STATIC_ASSERT()

FC_STATIC_ASSERT ( )

◆ get_direction_for_step()

int get_direction_for_step ( const struct civ_map nmap,
const struct tile src_tile,
const struct tile dst_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 1288 of file map.cpp.

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

◆ get_tile_infrastructure_set()

bv_extras get_tile_infrastructure_set ( const struct tile ptile,
int *  count 
)

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

Definition at line 72 of file map.cpp.

◆ 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 
)

◆ is_border_tile()

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

Definition at line 630 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 1255 of file map.cpp.

Referenced by fair_map_island_new().

◆ is_move_cardinal()

bool is_move_cardinal ( const struct civ_map nmap,
const struct tile src_tile,
const struct tile dst_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 1306 of file map.cpp.

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 902 of file map.cpp.

Referenced by event_cache_load().

◆ 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 636 of file map.cpp.

Referenced by can_exist_at_tile(), can_unit_survive_at_tile(), is_possible_base_fuel(), is_unit_being_refueled(), and try_summon_barbarians().

◆ 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 1329 of file map.cpp.

Referenced by near_singularity().

◆ is_tiles_adjacent()

bool is_tiles_adjacent ( const struct tile ptile0,
const struct tile ptile1 
)

◆ 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() in stead.

Definition at line 1199 of file map.cpp.

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

◆ main_map_allocate()

void main_map_allocate ( )

Allocate main map and related global structures.

Definition at line 487 of file map.cpp.

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

◆ main_map_free()

void main_map_free ( )

Free main map and related global structures.

Definition at line 525 of file map.cpp.

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 462 of file map.cpp.

Referenced by main_map_allocate(), and texai_map_init().

◆ map_distance()

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

Return Manhattan distance between two tiles.

Definition at line 623 of file map.cpp.

Referenced by area_is_too_flat(), city_incite_cost(), dai_fill_unit_param(), search_homecity_for_caravan(), and unit_bribe_cost().

◆ 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 1012 of file map.cpp.

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(), and team_placement_vertical().

◆ map_free()

void map_free ( struct civ_map fmap)

Frees the allocated memory of the map.

Definition at line 498 of file map.cpp.

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 129 of file map.cpp.

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

◆ map_init_topology()

void map_init_topology ( )

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 276 of file map.cpp.

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

◆ map_is_empty()

bool map_is_empty ( )

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 124 of file map.cpp.

Referenced by generator_validate(), handle_map_info(), map_canvas_resized(), map_generate(), mapimg_create(), player_limit_to_max_rates(), set_rulesetdir(), setting_is_free_to_change(), sg_save_map(), srv_ready(), texai_thread_start(), tile_virtual_check(), and freeciv::renderer::unqueue_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 232 of file map.h.

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

◆ map_move_cost_unit()

◆ map_num_tiles()

◆ map_pos_to_index()

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

Definition at line 596 of file map.h.

Referenced by event_cache_load().

◆ map_pos_to_tile()

◆ map_startpos_count()

int map_startpos_count ( )

◆ map_startpos_get()

struct startpos* map_startpos_get ( const struct tile ptile)

Returns the start position at the given tile, or nullptr if none exists there.

Definition at line 1548 of file map.cpp.

Referenced by freeciv::layer_editor::fill_sprite_array(), handle_edit_startpos(), and handle_edit_startpos_full().

◆ 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 1531 of file map.cpp.

Referenced by create_start_positions(), handle_edit_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 1565 of file map.cpp.

Referenced by 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 1212 of file map.cpp.

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 549 of file map.cpp.

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 583 of file map.cpp.

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

◆ mapstep()

◆ native_pos_to_tile()

◆ 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 935 of file map.cpp.

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_pos on these values.

Definition at line 919 of file map.cpp.

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(), 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 1565 of file map.cpp.

Referenced by api_utilities_opposite_dir(), do_attack(), and is_valid_goto_draw_line().

◆ rand_direction()

enum direction8 rand_direction ( )

Return random direction that is valid in current map.

Definition at line 1565 of file map.cpp.

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 1026 of file map.cpp.

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 nullptr if any position is okay; if non-nullptr it shouldn't have any side effects.

Definition at line 1039 of file map.cpp.

Referenced by create_start_positions(), and rand_map_pos_characteristic().

◆ real_map_distance()

◆ same_pos()

◆ 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 1385 of file map.cpp.

Referenced by 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 1439 of file map.cpp.

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

◆ 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 1402 of file map.cpp.

Referenced by 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 1496 of file map.cpp.

Referenced by sg_save_map_startpos().

◆ 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 1428 of file map.cpp.

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 1375 of file map.cpp.

Referenced by handle_edit_startpos_full(), 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 1449 of file map.cpp.

Referenced by edithand_send_initial_packets().

◆ startpos_raw_nations()

QSet<const struct nation_type *>* 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 1509 of file map.cpp.

Referenced by 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 1419 of file map.cpp.

Referenced by edithand_send_initial_packets(), init_new_game(), is_valid_start_pos(), 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 1469 of file map.cpp.

Referenced by handle_edit_startpos_full().

◆ terrain_surroundings_allow_change()

bool terrain_surroundings_allow_change ( 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 706 of file map.cpp.

Referenced by 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 == nullptr, in which case punit tests are not done (for unit-independent results).

Definition at line 743 of file map.cpp.

Referenced by map_move_cost(), and map_move_cost_unit().

Variable Documentation

◆ C_ADJACENT

const bool C_ADJACENT = false
static

Definition at line 27 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 28 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 29 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 30 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 57 of file map.cpp.

Referenced by draw_segment().

◆ DIR_DY

const int DIR_DY[8]
extern

Definition at line 58 of file map.cpp.

Referenced by draw_segment().

◆ terrain_control