Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/movement.h Source File

Freeciv-3.1

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#include "fc_types.h"
21#include "map.h"
22#include "tile.h"
23
24#define SINGLE_MOVE (terrain_control.move_fragments)
25#define MOVE_COST_IGTER (terrain_control.igter_cost)
26/* packets.def MOVEFRAGS */
27#define MAX_MOVE_FRAGS 65535
28
29struct unit_type;
30struct terrain;
31
32 enum unit_move_result {
33 MR_OK,
34 MR_DEATH,
35 MR_PAUSE,
36 MR_NO_WAR, /* Can't move here without declaring war. */
37 MR_PEACE, /* Can't move here because of a peace treaty. */
38 MR_ZOC,
39 MR_BAD_ACTIVITY,
40 MR_BAD_DESTINATION,
41 MR_BAD_MAP_POSITION,
42 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY,
43 MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT,
44 MR_NO_TRANSPORTER_CAPACITY,
45 MR_TRIREME,
46 MR_CANNOT_DISEMBARK,
47 MR_NON_NATIVE_MOVE, /* Usually RMM_RELAXED road diagonally without link */
48 MR_ANIMAL_DISALLOWED,
49 MR_UNIT_STAY,
50 MR_NOT_ALLOWED
51};
52
53int utype_move_rate(const struct unit_type *utype, const struct tile *ptile,
54 const struct player *pplayer, int veteran_level,
55 int hitpoints);
56int unit_move_rate(const struct unit *punit);
57int utype_unknown_move_cost(const struct unit_type *utype);
58
59bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit);
60bool can_attack_non_native(const struct unit_type *utype);
61bool can_attack_from_non_native(const struct unit_type *utype);
62
63bool is_city_channel_tile(const struct civ_map *nmap,
64 const struct unit_class *punitclass,
65 const struct tile *ptile,
66 const struct tile *pexclude);
67
68bool is_native_tile(const struct unit_type *punittype,
69 const struct tile *ptile);
70
71bool is_native_to_class(const struct unit_class *punitclass,
72 const struct terrain *pterrain,
73 const bv_extras *extras);
74
75/****************************************************************************
76 Check if this tile is native to given unit class.
77
78 See is_native_to_class()
79****************************************************************************/
80 static inline bool is_native_tile_to_class(const struct unit_class *punitclass,
81 const struct tile *ptile)
82{
83 return is_native_to_class(punitclass, tile_terrain(ptile),
84 tile_extras(ptile));
85}
86
87bool is_native_move(const struct civ_map *nmap,
88 const struct unit_class *punitclass,
89 const struct tile *src_tile,
90 const struct tile *dst_tile);
91bool is_native_near_tile(const struct civ_map *nmap,
92 const struct unit_class *uclass,
93 const struct tile *ptile);
94bool can_exist_at_tile(const struct civ_map *nmap,
95 const struct unit_type *utype,
96 const struct tile *ptile);
97bool can_unit_exist_at_tile(const struct civ_map *nmap,
98 const struct unit *punit, const struct tile *ptile);
99bool can_unit_survive_at_tile(const struct civ_map *nmap,
100 const struct unit *punit,
101 const struct tile *ptile);
102bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype,
103 const struct player *unit_owner,
104 const struct tile *src_tile,
105 const struct tile *dst_tile,
106 const struct civ_map *zmap);
107bool unit_can_move_to_tile(const struct civ_map *nmap,
108 const struct unit *punit,
109 const struct tile *ptile,
110 bool igzoc,
111 bool enter_transport,
112 bool enter_enemy_city);
113enum unit_move_result
114 unit_move_to_tile_test(const struct civ_map *nmap,
115 const struct unit *punit,
116 enum unit_activity activity,
117 const struct tile *src_tile,
118 const struct tile *dst_tile,
119 bool igzoc,
120 bool enter_transport, struct unit *embark_to,
121 bool enter_enemy_city);
122enum unit_move_result
123 unit_teleport_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 enter_transport, struct unit *embark_to,
129 bool enter_enemy_city);
130bool can_unit_transport(const struct unit *transporter, const struct unit *transported);
131bool can_unit_type_transport(const struct unit_type *transporter,
132 const struct unit_class *transported);
133bool unit_can_load(const struct unit *punit);
134bool unit_could_load_at(const struct unit *punit, const struct tile *ptile);
135
136void init_move_fragments(void);
137const char *move_points_text_full(int mp, bool reduce, const char *prefix,
138 const char *none, bool align);
139const char *move_points_text(int mp, bool reduce);
140
141#ifdef __cplusplus
142}
143#endif /* __cplusplus */
144
145#endif /* FC__MOVEMENT_H */
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:73
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:973
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:557
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:906
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:275
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:595
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:304
is_native_tile
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:316
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:527
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:841
can_unit_transport
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:813
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:869
is_native_tile_to_class
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Definition movement.h:80
can_attack_from_non_native
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:215
unit_move_result
unit_move_result
Definition movement.h:32
MR_CANNOT_DISEMBARK
@ MR_CANNOT_DISEMBARK
Definition movement.h:46
MR_OK
@ MR_OK
Definition movement.h:33
MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
Definition movement.h:43
MR_TRIREME
@ MR_TRIREME
Definition movement.h:45
MR_NON_NATIVE_MOVE
@ MR_NON_NATIVE_MOVE
Definition movement.h:47
MR_BAD_MAP_POSITION
@ MR_BAD_MAP_POSITION
Definition movement.h:41
MR_BAD_ACTIVITY
@ MR_BAD_ACTIVITY
Definition movement.h:39
MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
Definition movement.h:42
MR_ANIMAL_DISALLOWED
@ MR_ANIMAL_DISALLOWED
Definition movement.h:48
MR_PEACE
@ MR_PEACE
Definition movement.h:37
MR_ZOC
@ MR_ZOC
Definition movement.h:38
MR_NOT_ALLOWED
@ MR_NOT_ALLOWED
Definition movement.h:50
MR_DEATH
@ MR_DEATH
Definition movement.h:34
MR_NO_WAR
@ MR_NO_WAR
Definition movement.h:36
MR_BAD_DESTINATION
@ MR_BAD_DESTINATION
Definition movement.h:40
MR_NO_TRANSPORTER_CAPACITY
@ MR_NO_TRANSPORTER_CAPACITY
Definition movement.h:44
MR_UNIT_STAY
@ MR_UNIT_STAY
Definition movement.h:49
MR_PAUSE
@ MR_PAUSE
Definition movement.h:35
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:732
unit_can_defend_here
bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
Definition movement.c:175
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:358
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:327
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:228
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:476
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:450
can_unit_type_transport
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:826
init_move_fragments
void init_move_fragments(void)
Definition movement.c:885
can_attack_non_native
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:202
civ_map
Definition map_types.h:71
player
Definition player.h:249
terrain
Definition terrain.h:176
tile
Definition tile.h:49
unit_class
Definition unittype.h:136
unit_type
Definition unittype.h:481
unit
Definition unit.h:138
veteran_level
Definition unittype.h:467
tile.h
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:109
tile_extras
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:119
unit_owner
#define unit_owner(_pu)
Definition unit.h:387