Move tools_fc_interface.[c|h] to tools/shared.
[freeciv.git] / common / movement.h
blob6651c87d4c119e47b794f87898e2ca0970f6ec5a
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__MOVEMENT_H
14 #define FC__MOVEMENT_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #include "fc_types.h"
21 #include "tile.h"
23 #define SINGLE_MOVE (terrain_control.move_fragments)
24 #define MOVE_COST_IGTER (terrain_control.igter_cost)
26 struct unit_type;
27 struct terrain;
29 enum unit_move_result {
30 MR_OK,
31 MR_DEATH,
32 MR_PAUSE,
33 MR_NO_WAR, /* Can't move here without declaring war. */
34 MR_PEACE, /* Can't move here because of a peace treaty. */
35 MR_ZOC,
36 MR_BAD_ACTIVITY,
37 MR_BAD_DESTINATION,
38 MR_BAD_MAP_POSITION,
39 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY,
40 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT,
41 MR_NO_TRANSPORTER_CAPACITY,
42 MR_TRIREME,
43 MR_CANNOT_DISEMBARK,
44 MR_NON_NATIVE_MOVE, /* Usually RMM_RELAXED road diagonally without link */
45 MR_ANIMAL_DISALLOWED,
46 MR_UNIT_STAY,
47 MR_NOT_ALLOWED
50 int utype_move_rate(const struct unit_type *utype, const struct tile *ptile,
51 const struct player *pplayer, int veteran_level,
52 int hitpoints);
53 int unit_move_rate(const struct unit *punit);
54 int utype_unknown_move_cost(const struct unit_type *utype);
56 bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit);
57 bool can_attack_non_native(const struct unit_type *utype);
58 bool can_attack_from_non_native(const struct unit_type *utype);
60 bool is_city_channel_tile(const struct unit_class *punitclass,
61 const struct tile *ptile,
62 const struct tile *pexclude);
64 bool is_native_tile(const struct unit_type *punittype,
65 const struct tile *ptile);
67 bool is_native_to_class(const struct unit_class *punitclass,
68 const struct terrain *pterrain,
69 const bv_extras *extras);
71 /****************************************************************************
72 Check if this tile is native to given unit class.
74 See is_native_to_class()
75 ****************************************************************************/
76 static inline bool is_native_tile_to_class(const struct unit_class *punitclass,
77 const struct tile *ptile)
79 return is_native_to_class(punitclass, tile_terrain(ptile),
80 tile_extras(ptile));
83 bool is_native_move(const struct unit_class *punitclass,
84 const struct tile *src_tile,
85 const struct tile *dst_tile);
86 bool is_native_near_tile(const struct civ_map *nmap,
87 const struct unit_class *uclass,
88 const struct tile *ptile);
89 bool can_exist_at_tile(const struct civ_map *nmap,
90 const struct unit_type *utype,
91 const struct tile *ptile);
92 bool can_unit_exist_at_tile(const struct civ_map *nmap,
93 const struct unit *punit, const struct tile *ptile);
94 bool can_unit_survive_at_tile(const struct civ_map *nmap,
95 const struct unit *punit,
96 const struct tile *ptile);
97 bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype,
98 const struct player *unit_owner,
99 const struct tile *src_tile,
100 const struct tile *dst_tile);
101 bool zoc_ok_move(const struct unit *punit, const struct tile *ptile);
102 bool unit_can_move_to_tile(const struct civ_map *nmap,
103 const struct unit *punit,
104 const struct tile *ptile,
105 bool igzoc,
106 bool enter_enemy_city);
107 enum unit_move_result
108 unit_move_to_tile_test(const struct civ_map *nmap,
109 const struct unit *punit,
110 enum unit_activity activity,
111 const struct tile *src_tile,
112 const struct tile *dst_tile,
113 bool igzoc,
114 struct unit *embark_to,
115 bool enter_enemy_city);
116 bool can_unit_transport(const struct unit *transporter, const struct unit *transported);
117 bool can_unit_type_transport(const struct unit_type *transporter,
118 const struct unit_class *transported);
119 bool unit_can_load(const struct unit *punit);
120 bool unit_could_load_at(const struct unit *punit, const struct tile *ptile);
122 void init_move_fragments(void);
123 const char *move_points_text_full(int mp, bool reduce, const char *prefix,
124 const char *none, bool align);
125 const char *move_points_text(int mp, bool reduce);
127 #ifdef __cplusplus
129 #endif /* __cplusplus */
131 #endif /* FC__MOVEMENT_H */