Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / movement.h
blob6e4b02b21d040c4147d423933b53ab13ce8e4172
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_NOT_ALLOWED
49 int utype_move_rate(const struct unit_type *utype, const struct tile *ptile,
50 const struct player *pplayer, int veteran_level,
51 int hitpoints);
52 int unit_move_rate(const struct unit *punit);
53 int utype_unknown_move_cost(const struct unit_type *utype);
55 bool unit_can_defend_here(const struct unit *punit);
56 bool can_attack_non_native(const struct unit_type *utype);
57 bool can_attack_from_non_native(const struct unit_type *utype);
59 bool is_city_channel_tile(const struct unit_class *punitclass,
60 const struct tile *ptile,
61 const struct tile *pexclude);
63 bool is_native_tile(const struct unit_type *punittype,
64 const struct tile *ptile);
66 bool is_native_to_class(const struct unit_class *punitclass,
67 const struct terrain *pterrain,
68 const bv_extras *extras);
70 /****************************************************************************
71 Check if this tile is native to given unit class.
73 See is_native_to_class()
74 ****************************************************************************/
75 static inline bool is_native_tile_to_class(const struct unit_class *punitclass,
76 const struct tile *ptile)
78 return is_native_to_class(punitclass, tile_terrain(ptile),
79 tile_extras(ptile));
82 bool is_native_move(const struct unit_class *punitclass,
83 const struct tile *src_tile,
84 const struct tile *dst_tile);
85 bool is_native_near_tile(const struct unit_class *uclass, const struct tile *ptile);
86 bool can_exist_at_tile(const struct unit_type *utype,
87 const struct tile *ptile);
88 bool can_unit_exist_at_tile(const struct unit *punit, const struct tile *ptile);
89 bool can_unit_survive_at_tile(const struct unit *punit,
90 const struct tile *ptile);
91 bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype,
92 const struct player *unit_owner,
93 const struct tile *src_tile,
94 const struct tile *dst_tile);
95 bool zoc_ok_move(const struct unit *punit, const struct tile *ptile);
96 bool unit_can_move_to_tile(const struct unit *punit,
97 const struct tile *ptile,
98 bool igzoc,
99 bool enter_enemy_city);
100 enum unit_move_result
101 unit_move_to_tile_test(const struct unit *punit,
102 enum unit_activity activity,
103 const struct tile *src_tile,
104 const struct tile *dst_tile,
105 bool igzoc,
106 struct unit *embark_to,
107 bool enter_enemy_city);
108 bool can_unit_transport(const struct unit *transporter, const struct unit *transported);
109 bool can_unit_type_transport(const struct unit_type *transporter,
110 const struct unit_class *transported);
111 bool unit_can_load(const struct unit *punit);
112 bool unit_could_load_at(const struct unit *punit, const struct tile *ptile);
114 void init_move_fragments(void);
115 const char *move_points_text_full(int mp, bool reduce, const char *prefix,
116 const char *none, bool align);
117 const char *move_points_text(int mp, bool reduce);
119 #ifdef __cplusplus
121 #endif /* __cplusplus */
123 #endif /* FC__MOVEMENT_H */