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
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****************************************************************************/
80static 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);
114unit_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);
123unit_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 */
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
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
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
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Definition movement.c:906
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:275
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
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:304
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:316
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
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
bool unit_can_load(const struct unit *punit)
Definition movement.c:841
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:813
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Definition movement.c:869
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Definition movement.h:80
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:215
unit_move_result
Definition movement.h:32
@ MR_CANNOT_DISEMBARK
Definition movement.h:46
@ MR_OK
Definition movement.h:33
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
Definition movement.h:43
@ MR_TRIREME
Definition movement.h:45
@ MR_NON_NATIVE_MOVE
Definition movement.h:47
@ MR_BAD_MAP_POSITION
Definition movement.h:41
@ MR_BAD_ACTIVITY
Definition movement.h:39
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_CITY
Definition movement.h:42
@ MR_ANIMAL_DISALLOWED
Definition movement.h:48
@ MR_PEACE
Definition movement.h:37
@ MR_ZOC
Definition movement.h:38
@ MR_NOT_ALLOWED
Definition movement.h:50
@ MR_DEATH
Definition movement.h:34
@ MR_NO_WAR
Definition movement.h:36
@ MR_BAD_DESTINATION
Definition movement.h:40
@ MR_NO_TRANSPORTER_CAPACITY
Definition movement.h:44
@ MR_UNIT_STAY
Definition movement.h:49
@ MR_PAUSE
Definition movement.h:35
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
bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
Definition movement.c:175
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
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:327
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
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
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:476
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:450
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:826
void init_move_fragments(void)
Definition movement.c:885
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:202
Definition tile.h:49
Definition unit.h:138
#define tile_terrain(_tile)
Definition tile.h:109
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:119
#define unit_owner(_pu)
Definition unit.h:394