32 #define MAP_IS_ISOMETRIC (CURRENT_TOPOLOGY & (TF_ISO + TF_HEX))
34 #define CURRENT_TOPOLOGY (wld.map.topology_id)
36 #define topo_has_flag(topo, flag) (((topo) & (flag)) != 0)
37 #define current_topo_has_flag(flag) topo_has_flag((CURRENT_TOPOLOGY), (flag))
39 #define ALL_DIRECTIONS_CARDINAL() topo_has_flag((CURRENT_TOPOLOGY), TF_HEX)
57 const struct tile *src_tile,
58 const struct tile *dst_tile,
59 enum direction8 *dir);
61 const struct tile *src_tile,
62 const struct tile *dst_tile);
75 struct packet_edit_startpos_full *packet);
77 const struct packet_edit_startpos_full *packet);
81 QSet<const struct nation_type *> *
91 #define MAP_INDEX_SIZE (wld.map.xsize * wld.map.ysize)
94 #define CHECK_MAP_POS(x, y) fc_assert(is_normal_map_pos((x), (y)))
95 #define CHECK_NATIVE_POS(x, y) \
96 fc_assert((x) >= 0 && (x) < wld.map.xsize && (y) >= 0 \
97 && (y) < wld.map.ysize)
98 #define CHECK_INDEX(mindex) \
99 fc_assert((mindex) >= 0 && (mindex) < MAP_INDEX_SIZE)
101 #define CHECK_MAP_POS(x, y) ((void) 0)
102 #define CHECK_NATIVE_POS(x, y) ((void) 0)
103 #define CHECK_INDEX(mindex) ((void) 0)
106 #define native_pos_to_index_nocheck(nat_x, nat_y) \
107 ((nat_x) + (nat_y) *wld.map.xsize)
108 #define native_pos_to_index(nat_x, nat_y) \
109 (CHECK_NATIVE_POS((nat_x), (nat_y)), \
110 native_pos_to_index_nocheck(nat_x, nat_y))
111 #define index_to_native_pos(pnat_x, pnat_y, mindex) \
112 (*(pnat_x) = index_to_native_pos_x(mindex), \
113 *(pnat_y) = index_to_native_pos_y(mindex))
114 #define index_to_native_pos_x(mindex) ((mindex) % wld.map.xsize)
115 #define index_to_native_pos_y(mindex) ((mindex) / wld.map.xsize)
118 #define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y) \
119 (MAP_IS_ISOMETRIC ? (*(pmap_x) = ((nat_y) + ((nat_y) &1)) / 2 + (nat_x), \
120 *(pmap_y) = (nat_y) - *(pmap_x) + wld.map.xsize) \
121 : (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))
123 #define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y) \
125 ? (*(pnat_y) = (map_x) + (map_y) -wld.map.xsize, \
126 *(pnat_x) = (2 * (map_x) - *(pnat_y) - (*(pnat_y) &1)) / 2) \
127 : (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
129 #define NATURAL_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y) \
130 (MAP_IS_ISOMETRIC ? (*(pmap_x) = ((nat_y) + (nat_x)) / 2, \
131 *(pmap_y) = (nat_y) - *(pmap_x) + wld.map.xsize) \
132 : (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))
134 #define MAP_TO_NATURAL_POS(pnat_x, pnat_y, map_x, map_y) \
135 (MAP_IS_ISOMETRIC ? (*(pnat_y) = (map_x) + (map_y) -wld.map.xsize, \
136 *(pnat_x) = 2 * (map_x) - *(pnat_y)) \
137 : (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
143 #define do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) \
145 int _ntl_x, _ntl_y; \
146 MAP_TO_NATURAL_POS(&_ntl_x, &_ntl_y, map_x, map_y); \
148 const int ntl_x = _ntl_x, ntl_y = _ntl_y;
150 #define do_in_natural_pos_end \
157 #define NATURAL_WIDTH (MAP_IS_ISOMETRIC ? 2 * wld.map.xsize : wld.map.xsize)
158 #define NATURAL_HEIGHT wld.map.ysize
164 #define index_to_map_pos(pmap_x, pmap_y, mindex) \
165 (CHECK_INDEX(mindex), index_to_native_pos(pmap_x, pmap_y, mindex), \
166 NATIVE_TO_MAP_POS(pmap_x, pmap_y, *(pmap_x), *(pmap_y)))
170 #define DIRSTEP(dest_x, dest_y, dir) \
171 ((dest_x) = DIR_DX[(dir)], (dest_y) = DIR_DY[(dir)])
183 enum direction8 dir);
198 const struct tile *ptile1);
200 #define map_size_checked() MAX(map_num_tiles() / 1000, 1)
204 bool (*filter)(
const struct tile *ptile,
209 const struct tile *src_tile,
210 const struct tile *dst_tile);
214 const struct player *pplayer,
const struct tile *t1,
215 const struct tile *t2);
223 const struct tile *ptile)
233 const struct player *pplayer,
235 const struct tile *src_tile,
236 const struct tile *dst_tile)
250 const struct terrain *pterrain);
260 #define iterate_outward_dxy(nmap, start_tile, max_dist, _tile, _x, _y) \
262 int _x, _y, _tile##_x, _tile##_y, _start##_x, _start##_y; \
263 struct tile *_tile; \
264 const struct tile *_tile##_start = (start_tile); \
265 int _tile##_max = (max_dist); \
266 int _tile##_index = 0; \
267 index_to_map_pos(&_start##_x, &_start##_y, tile_index(_tile##_start)); \
268 for (; _tile##_index < wld.map.num_iterate_outwards_indices; \
270 if (wld.map.iterate_outwards_indices[_tile##_index].dist \
274 _x = wld.map.iterate_outwards_indices[_tile##_index].dx; \
275 _y = wld.map.iterate_outwards_indices[_tile##_index].dy; \
276 _tile##_x = _x + _start##_x; \
277 _tile##_y = _y + _start##_y; \
278 _tile = map_pos_to_tile(nmap, _tile##_x, _tile##_y); \
279 if (nullptr == _tile) { \
283 #define iterate_outward_dxy_end \
288 #define iterate_outward(nmap, start_tile, max_dist, itr_tile) \
289 iterate_outward_dxy(nmap, start_tile, max_dist, itr_tile, _dx_itr, _dy_itr)
291 #define iterate_outward_end iterate_outward_dxy_end
301 #define square_dxy_iterate(nmap, center_tile, radius, tile_itr, dx_itr, \
303 iterate_outward_dxy(nmap, center_tile, radius, tile_itr, dx_itr, dy_itr)
305 #define square_dxy_iterate_end iterate_outward_dxy_end
312 #define square_iterate(nmap, center_tile, radius, tile_itr) \
313 square_dxy_iterate(nmap, center_tile, radius, tile_itr, _dummy_x, dummy_y)
315 #define square_iterate_end square_dxy_iterate_end
322 #define circle_iterate(nmap, center_tile, sq_radius, tile_itr) \
323 circle_dxyr_iterate(nmap, center_tile, sq_radius, tile_itr, _dx, _dy, _dr)
325 #define circle_iterate_end circle_dxyr_iterate_end
329 #define circle_dxyr_iterate(nmap, center_tile, sq_radius, _tile, dx, dy, \
332 const int _tile##_sq_radius = (sq_radius); \
333 const int _tile##_cr_radius = \
334 (int) sqrt((double) MAX(_tile##_sq_radius, 0)); \
336 square_dxy_iterate(nmap, center_tile, _tile##_cr_radius, _tile, dx, dy) \
338 const int dr = map_vector_to_sq_distance(dx, dy); \
340 if (dr <= _tile##_sq_radius) {
342 #define circle_dxyr_iterate_end \
345 square_dxy_iterate_end; \
351 #define adjc_iterate(nmap, center_tile, itr_tile) \
355 adjc_dir_iterate(nmap, center_tile, itr_tile, \
356 ADJC_ITERATE_dir_itr##itr_tile) \
359 #define adjc_iterate_end \
361 adjc_dir_iterate_end; \
365 #define adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr) \
366 adjc_dirlist_iterate(nmap, center_tile, itr_tile, dir_itr, \
367 wld.map.valid_dirs, wld.map.num_valid_dirs)
369 #define adjc_dir_iterate_end adjc_dirlist_iterate_end
372 #define adjc_dir_base_iterate(nmap, center_tile, dir_itr) \
373 adjc_dirlist_base_iterate(nmap, center_tile, dir_itr, wld.map.valid_dirs, \
374 wld.map.num_valid_dirs)
376 #define adjc_dir_base_iterate_end adjc_dirlist_base_iterate_end
381 #define cardinal_adjc_iterate(nmap, center_tile, itr_tile) \
382 adjc_dirlist_iterate(nmap, center_tile, itr_tile, _dir_itr##center_tile, \
383 wld.map.cardinal_dirs, wld.map.num_cardinal_dirs)
385 #define cardinal_adjc_iterate_end adjc_dirlist_iterate_end
388 #define cardinal_adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr) \
389 adjc_dirlist_iterate(nmap, center_tile, itr_tile, dir_itr, \
390 wld.map.cardinal_dirs, wld.map.num_cardinal_dirs)
392 #define cardinal_adjc_dir_iterate_end adjc_dirlist_iterate_end
395 #define cardinal_adjc_dir_base_iterate(nmap, center_tile, dir_itr) \
396 adjc_dirlist_base_iterate(nmap, center_tile, dir_itr, \
397 wld.map.cardinal_dirs, \
398 wld.map.num_cardinal_dirs)
400 #define cardinal_adjc_dir_base_iterate_end adjc_dirlist_base_iterate_end
403 #define cardinal_between_iterate(nmap, tile1, tile2, between) \
404 cardinal_adjc_iterate(nmap, tile1, between) \
406 cardinal_adjc_iterate(nmap, between, second) \
408 if (same_pos(second, tile2)) {
410 #define cardinal_between_iterate_end \
413 cardinal_adjc_iterate_end; \
415 cardinal_adjc_iterate_end;
424 #define adjc_dirlist_iterate(nmap, center_tile, _tile, _dir, dirlist, \
427 enum direction8 _dir; \
428 int _tile##_x, _tile##_y, _tile##_cx, _tile##_cy; \
429 struct tile *_tile; \
430 const struct tile *_tile##_center = (center_tile); \
431 int _tile##_index = 0; \
432 index_to_map_pos(&_tile##_cx, &_tile##_cy, tile_index(_tile##_center)); \
433 for (; _tile##_index < (dircount); _tile##_index++) { \
434 _dir = dirlist[_tile##_index]; \
435 DIRSTEP(_tile##_x, _tile##_y, _dir); \
436 _tile##_x += _tile##_cx; \
437 _tile##_y += _tile##_cy; \
438 _tile = map_pos_to_tile(nmap, _tile##_x, _tile##_y); \
439 if (nullptr == _tile) { \
443 #define adjc_dirlist_iterate_end \
448 #define adjc_dirlist_base_iterate(nmap, center_tile, _dir, dirlist, \
451 enum direction8 _dir; \
452 int _tile##_x, _tile##_y, _center##_x, _center##_y; \
453 const struct tile *_tile##_center = (center_tile); \
454 bool _tile##_is_border = is_border_tile(_tile##_center, 1); \
455 int _tile##_index = 0; \
456 index_to_map_pos(&_center##_x, &_center##_y, \
457 tile_index(_tile##_center)); \
458 for (; _tile##_index < (dircount); _tile##_index++) { \
459 _dir = dirlist[_tile##_index]; \
460 DIRSTEP(_tile##_x, _tile##_y, _dir); \
461 _tile##_x += _center##_x; \
462 _tile##_y += _center##_y; \
463 if (_tile##_is_border \
464 && !normalize_map_pos(nmap, &_tile##_x, &_tile##_y)) { \
468 #define adjc_dirlist_base_iterate_end \
474 #define whole_map_iterate(_map, _tile) \
476 struct tile *_tile; \
477 int _tile##_index = 0; \
478 for (; _tile##_index < MAP_INDEX_SIZE; _tile##_index++) { \
479 _tile = (_map)->tiles + _tile##_index;
481 #define whole_map_iterate_end \
488 #define DIR_REVERSE(dir) ((enum direction8)(7 - (dir)))
490 enum direction8
dir_cw(
enum direction8 dir);
491 enum direction8
dir_ccw(
enum direction8 dir);
497 extern const int DIR_DX[8];
498 extern const int DIR_DY[8];
501 #define MAP_TILE_OWNER_NULL MAX_UINT8
503 #define MAP_DEFAULT_HUTS 15
504 #define MAP_MIN_HUTS 0
505 #define MAP_MAX_HUTS 500
507 #define MAP_DEFAULT_ANIMALS 20
508 #define MAP_MIN_ANIMALS 0
509 #define MAP_MAX_ANIMALS 500
511 #define MAP_DEFAULT_MAPSIZE MAPSIZE_FULLSIZE
516 #define MAP_DEFAULT_SIZE 4
517 #define MAP_MIN_SIZE 0
518 #define MAP_MAX_SIZE 2048
523 map_too_big_for_network);
525 #define MAP_DEFAULT_TILESPERPLAYER 100
526 #define MAP_MIN_TILESPERPLAYER 1
527 #define MAP_MAX_TILESPERPLAYER 1000
530 #define MAP_DEFAULT_LINEAR_SIZE 64
531 #define MAP_MAX_LINEAR_SIZE (MAP_MAX_SIZE * 1000 / MAP_MIN_LINEAR_SIZE)
532 #define MAP_MIN_LINEAR_SIZE 16
537 #define MAP_DISTANCE_MAX (MAP_MAX_LINEAR_SIZE + MAP_MIN_LINEAR_SIZE)
539 #define MAP_ORIGINAL_TOPO TF_WRAPX
540 #define MAP_DEFAULT_TOPO (TF_WRAPX | TF_ISO)
542 #define MAP_DEFAULT_SEED 0
543 #define MAP_MIN_SEED 0
544 #define MAP_MAX_SEED (MAX_UINT32 >> 1)
546 #define MAP_DEFAULT_LANDMASS 30
547 #define MAP_MIN_LANDMASS 15
548 #define MAP_MAX_LANDMASS 100
550 #define MAP_DEFAULT_RICHES 250
551 #define MAP_MIN_RICHES 0
552 #define MAP_MAX_RICHES 1000
554 #define MAP_DEFAULT_STEEPNESS 30
555 #define MAP_MIN_STEEPNESS 0
556 #define MAP_MAX_STEEPNESS 100
558 #define MAP_DEFAULT_WETNESS 50
559 #define MAP_MIN_WETNESS 0
560 #define MAP_MAX_WETNESS 100
562 #define MAP_DEFAULT_GENERATOR MAPGEN_RANDOM
564 #define MAP_DEFAULT_STARTPOS MAPSTARTPOS_DEFAULT
566 #define MAP_DEFAULT_TINYISLES false
567 #define MAP_MIN_TINYISLES false
568 #define MAP_MAX_TINYISLES true
570 #define MAP_DEFAULT_SEPARATE_POLES true
571 #define MAP_MIN_SEPARATE_POLES false
572 #define MAP_MAX_SEPARATE_POLES true
574 #define MAP_DEFAULT_FLATPOLES 100
575 #define MAP_MIN_FLATPOLES 0
576 #define MAP_MAX_FLATPOLES 100
578 #define MAP_DEFAULT_SINGLE_POLE false
579 #define MAP_MIN_SINGLE_POLE false
580 #define MAP_MAX_SINGLE_POLE true
582 #define MAP_DEFAULT_ALLTEMPERATE false
583 #define MAP_MIN_ALLTEMPERATE false
584 #define MAP_MAX_ALLTEMPERATE true
586 #define MAP_DEFAULT_TEMPERATURE 50
587 #define MAP_MIN_TEMPERATURE 0
588 #define MAP_MAX_TEMPERATURE 100
590 #define MAP_DEFAULT_TEAM_PLACEMENT TEAM_PLACEMENT_CLOSEST
#define native_pos_to_index(nat_x, nat_y)
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 terra...
bool is_normal_map_pos(int x, int y)
Returns TRUE iff the map position is normal.
int startpos_number(const struct startpos *psp)
Returns the unique ID number for this start position.
void map_free(struct civ_map *fmap)
Frees the allocated memory of the map.
bool startpos_disallow(struct startpos *psp, struct nation_type *pnation)
Disallow the nation to start at the start position.
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 ter...
enum direction8 opposite_direction(enum direction8 dir)
Return direction that is opposite to given one.
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Return squared distance between two tiles.
static int index_to_map_pos_y(int mindex)
void main_map_free()
Free main map and related global structures.
struct tile * rand_map_pos(const struct civ_map *nmap)
Random square anywhere on the map.
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 ...
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.
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,...
bool startpos_nation_allowed(const struct startpos *psp, const struct nation_type *pnation)
Returns TRUE if the given nation can start here.
static const bool C_PERCENT
static const bool C_NUMBER
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
bool startpos_allows_all(const struct startpos *psp)
Returns TRUE if any nation can start here.
FC_STATIC_ASSERT((long unsigned) MAP_MAX_SIZE *1000<(long unsigned) 1<< 31, map_too_big_for_network)
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.
#define CHECK_MAP_POS(x, y)
enum direction8 dir_ccw(enum direction8 dir)
Returns the next direction counter-clock-wise.
int map_startpos_count()
Is there start positions set for map.
struct startpos * map_startpos_get(const struct tile *ptile)
Returns the start position at the given tile, or nullptr if none exists there.
void map_allocate(struct civ_map *amap)
Allocate space for map, and initialise the tiles.
#define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y)
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.
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...
static const bool C_ADJACENT
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.
enum direction8 rand_direction()
Return random direction that is valid in current map.
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.
static int map_pos_to_index(struct civ_map *nmap, int map_x, int map_y)
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.
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.
int map_vector_to_sq_distance(int dx, int dy)
Return the sq_distance for a given vector.
bool map_startpos_remove(struct tile *ptile)
Remove the start position at the given tile.
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
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.
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 ...
bv_extras get_tile_infrastructure_set(const struct tile *ptile, int *count)
Return a bitfield of the extras on the tile that are infrastructure.
struct startpos * map_startpos_new(struct tile *ptile)
Create a new start position at the given tile and return it.
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,...
static int index_to_map_pos_x(int mindex)
const char * dir_get_name(enum direction8 dir)
Return the debugging name of the direction.
struct tile * map_pos_to_tile(const struct civ_map *nmap, int x, int y)
Return the tile for the given cartesian (map) position.
bool is_cardinal_dir(enum direction8 dir)
Returns TRUE iff the given direction is a cardinal one.
static const bool C_CARDINAL
bool map_untrusted_dir_is_valid(enum direction8 dir)
Returns TRUE iff the given direction is a valid one.
struct tile * startpos_tile(const struct startpos *psp)
Returns the tile where this start position is located.
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Fills the start position with the nation information in the packet.
static bool is_border_tile(const struct tile *ptile, int dist)
bool is_valid_dir(enum direction8 dir)
Returns TRUE iff the given direction is a valid one.
enum direction8 dir_cw(enum direction8 dir)
Returns the next direction clock-wise.
QSet< const struct nation_type * > * startpos_raw_nations(const struct startpos *psp)
Return a the nations hash, used for the property editor.
void map_init_topology()
map_init_topology needs to be called after map.topology_id is changed.
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Return the tile for the given native position.
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
struct terrain_misc terrain_control
bool is_tiles_adjacent(const struct tile *ptile0, const struct tile *ptile1)
Are two tiles adjacent to each other.
void main_map_allocate()
Allocate main map and related global structures.
#define index_to_native_pos(pnat_x, pnat_y, mindex)
void map_init(struct civ_map *imap, bool server_side)
Put some sensible values into the map structure.
bool startpos_is_excluding(const struct startpos *psp)
Returns TRUE if the nations returned by startpos_raw_nations() are actually excluded from the nations...
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)
int map_distance(const struct tile *tile0, const struct tile *tile1)
Return Manhattan distance between two tiles.
struct tile * rand_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.
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Step from the given tile in the given direction.
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
Allow the nation to start at the start position.
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.
#define index_to_map_pos(pmap_x, pmap_y, mindex)
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.
int map_vector_to_real_distance(int dx, int dy)
Return the "real" distance for a given vector.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.