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)
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
18 #endif /* __cplusplus */
23 #define SINGLE_MOVE (terrain_control.move_fragments)
24 #define MOVE_COST_IGTER (terrain_control.igter_cost)
29 enum unit_move_result
{
33 MR_NO_WAR
, /* Can't move here without declaring war. */
34 MR_PEACE
, /* Can't move here because of a peace treaty. */
39 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
,
40 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
,
41 MR_NO_TRANSPORTER_CAPACITY
,
44 MR_NON_NATIVE_MOVE
, /* Usually RMM_RELAXED road diagonally without link */
50 int utype_move_rate(const struct unit_type
*utype
, const struct tile
*ptile
,
51 const struct player
*pplayer
, int veteran_level
,
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
),
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
,
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
,
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
);
129 #endif /* __cplusplus */
131 #endif /* FC__MOVEMENT_H */