Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/movement.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
movement.h
Go to the documentation of this file.
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.
7
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
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* common */
21#include "fc_types.h"
22#include "map.h"
23
24struct tile;
25
26#define SINGLE_MOVE (terrain_control.move_fragments)
27#define MOVE_COST_IGTER (terrain_control.igter_cost)
28/* packets.def MOVEFRAGS */
29#define MAX_MOVE_FRAGS 65535
30
31struct unit_type;
32struct terrain;
33
34 enum unit_move_result {
35 MR_OK,
36 MR_DEATH,
37 MR_PAUSE,
38 MR_NO_WAR, /* Can't move here without declaring war. */
39 MR_PEACE, /* Can't move here because of a peace treaty. */
40 MR_ZOC,
41 MR_BAD_ACTIVITY,
42 MR_BAD_DESTINATION,
43 MR_BAD_MAP_POSITION,
44 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY,
45 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT,
46 MR_NO_TRANSPORTER_CAPACITY,
47 MR_TRIREME,
48 MR_CANNOT_DISEMBARK,
49 MR_NON_NATIVE_MOVE, /* Usually RMM_RELAXED road diagonally without link */
50 MR_ANIMAL_DISALLOWED,
51 MR_UNIT_STAY,
52 MR_RANDOM_ONLY,
53 MR_NOT_ALLOWED
54};
55
56int utype_move_rate(const struct unit_type *utype, const struct tile *ptile,
57 const struct player *pplayer, int veteran_level,
58 int hitpoints);
59int unit_move_rate(const struct unit *punit);
60int utype_unknown_move_cost(const struct unit_type *utype);
61
62bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit);
63bool can_attack_non_native_hard_reqs(const struct unit_type *utype);
64bool can_attack_non_native(const struct unit_type *utype);
65bool can_attack_from_non_native(const struct unit_type *utype);
66
67bool is_city_channel_tile(const struct civ_map *nmap,
68 const struct unit_class *punitclass,
69 const struct tile *ptile,
70 const struct tile *pexclude);
71
72bool is_native_tile(const struct unit_type *punittype,
73 const struct tile *ptile);
74
75bool is_native_to_class(const struct unit_class *punitclass,
76 const struct terrain *pterrain,
77 const bv_extras *extras);
78
79/****************************************************************************
80 Check if this tile is native to given unit class.
81
82 See is_native_to_class()
83****************************************************************************/
84 static inline bool is_native_tile_to_class(const struct unit_class *punitclass,
85 const struct tile *ptile)
86{
87 return is_native_to_class(punitclass, tile_terrain(ptile),
88 tile_extras(ptile));
89}
90
91bool is_native_move(const struct civ_map *nmap,
92 const struct unit_class *punitclass,
93 const struct tile *src_tile,
94 const struct tile *dst_tile);
95bool is_native_near_tile(const struct civ_map *nmap,
96 const struct unit_class *uclass,
97 const struct tile *ptile);
98bool can_exist_at_tile(const struct civ_map *nmap,
99 const struct unit_type *utype,
100 const struct tile *ptile);
101bool can_unit_exist_at_tile(const struct civ_map *nmap,
102 const struct unit *punit, const struct tile *ptile);
103bool can_unit_survive_at_tile(const struct civ_map *nmap,
104 const struct unit *punit,
105 const struct tile *ptile);
106bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype,
107 const struct player *unit_owner,
108 const struct tile *src_tile,
109 const struct tile *dst_tile,
110 const struct civ_map *zmap);
111bool unit_can_move_to_tile(const struct civ_map *nmap,
112 const struct unit *punit,
113 const struct tile *ptile,
114 bool igzoc,
115 bool enter_transport,
116 bool enter_enemy_city);
117bool unit_can_teleport_to_tile(const struct civ_map *nmap,
118 const struct unit *punit,
119 const struct tile *ptile,
120 bool enter_transport,
121 bool enter_enemy_city);
122enum unit_move_result
123 unit_move_to_tile_test(const struct civ_map *nmap,
124 const struct unit *punit,
125 enum unit_activity activity,
126 const struct tile *src_tile,
127 const struct tile *dst_tile,
128 bool igzoc,
129 bool enter_transport, struct unit *embark_to,
130 bool enter_enemy_city);
131enum unit_move_result
132 unit_teleport_to_tile_test(const struct civ_map *nmap,
133 const struct unit *punit,
134 enum unit_activity activity,
135 const struct tile *src_tile,
136 const struct tile *dst_tile,
137 bool enter_transport, struct unit *embark_to,
138 bool enter_enemy_city);
139bool can_unit_transport(const struct unit *transporter, const struct unit *transported);
140bool can_unit_type_transport(const struct unit_type *transporter,
141 const struct unit_class *transported);
142bool unit_can_load(const struct unit *punit);
143bool unit_could_load_at(const struct unit *punit, const struct tile *ptile);
144
145void init_move_fragments(void);
146const char *move_points_text_full(int mp, bool reduce, const char *prefix,
147 const char *none, bool align);
148const char *move_points_text(int mp, bool reduce);
149
150#ifdef __cplusplus
151}
152#endif /* __cplusplus */
153
154#endif /* FC__MOVEMENT_H */
incite_cost
char * incite_cost
Definition comments.c:74
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
fc_types.h
map.h
move_points_text
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1015
unit_can_move_to_tile
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile, bool igzoc, bool enter_transport, bool enter_enemy_city)
Definition movement.c:572
move_points_text_full
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Definition movement.c:948
can_exist_at_tile
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:290
unit_move_to_tile_test
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:630
can_unit_exist_at_tile
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:319
is_native_tile
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:331
can_step_taken_wrt_to_zoc
bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype, const struct player *unit_owner, const struct tile *src_tile, const struct tile *dst_tile, const struct civ_map *zmap)
Definition movement.c:542
utype_unknown_move_cost
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
unit_can_load
bool unit_can_load(const struct unit *punit)
Definition movement.c:883
can_unit_transport
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:855
unit_move_rate
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
unit_could_load_at
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Definition movement.c:911
can_attack_non_native_hard_reqs
bool can_attack_non_native_hard_reqs(const struct unit_type *utype)
Definition movement.c:204
is_native_tile_to_class
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Definition movement.h:84
can_attack_from_non_native
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:227
unit_move_result
unit_move_result
Definition movement.h:34
MR_CANNOT_DISEMBARK
@ MR_CANNOT_DISEMBARK
Definition movement.h:48
MR_OK
@ MR_OK
Definition movement.h:35
MR_RANDOM_ONLY
@ MR_RANDOM_ONLY
Definition movement.h:52
MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
Definition movement.h:45
MR_TRIREME
@ MR_TRIREME
Definition movement.h:47
MR_NON_NATIVE_MOVE
@ MR_NON_NATIVE_MOVE
Definition movement.h:49
MR_BAD_MAP_POSITION
@ MR_BAD_MAP_POSITION
Definition movement.h:43
MR_BAD_ACTIVITY
@ MR_BAD_ACTIVITY
Definition movement.h:41
MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
Definition movement.h:44
MR_ANIMAL_DISALLOWED
@ MR_ANIMAL_DISALLOWED
Definition movement.h:50
MR_PEACE
@ MR_PEACE
Definition movement.h:39
MR_ZOC
@ MR_ZOC
Definition movement.h:40
MR_NOT_ALLOWED
@ MR_NOT_ALLOWED
Definition movement.h:53
MR_DEATH
@ MR_DEATH
Definition movement.h:36
MR_NO_WAR
@ MR_NO_WAR
Definition movement.h:38
MR_BAD_DESTINATION
@ MR_BAD_DESTINATION
Definition movement.h:42
MR_NO_TRANSPORTER_CAPACITY
@ MR_NO_TRANSPORTER_CAPACITY
Definition movement.h:46
MR_UNIT_STAY
@ MR_UNIT_STAY
Definition movement.h:51
MR_PAUSE
@ MR_PAUSE
Definition movement.h:37
unit_can_teleport_to_tile
bool unit_can_teleport_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile, bool enter_transport, bool enter_enemy_city)
Definition movement.c:592
unit_teleport_to_tile_test
enum unit_move_result unit_teleport_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:774
unit_can_defend_here
bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
Definition movement.c:174
is_native_move
bool is_native_move(const struct civ_map *nmap, const struct unit_class *punitclass, const struct tile *src_tile, const struct tile *dst_tile)
Definition movement.c:373
is_native_to_class
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:342
utype_move_rate
int utype_move_rate(const struct unit_type *utype, const struct tile *ptile, const struct player *pplayer, int veteran_level, int hitpoints)
Definition movement.c:47
is_city_channel_tile
bool is_city_channel_tile(const struct civ_map *nmap, const struct unit_class *punitclass, const struct tile *ptile, const struct tile *pexclude)
Definition movement.c:243
can_unit_survive_at_tile
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:491
is_native_near_tile
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:465
can_unit_type_transport
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:868
init_move_fragments
void init_move_fragments(void)
Definition movement.c:927
can_attack_non_native
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:214
civ_map
Definition map_types.h:71
player
Definition player.h:247
terrain
Definition terrain.h:182
tile
Definition tile.h:50
unit_class
Definition unittype.h:149
unit_type
Definition unittype.h:500
unit
Definition unit.h:138
veteran_level
Definition unittype.h:486
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:110
tile_extras
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:120
unit_owner
#define unit_owner(_pu)
Definition unit.h:389