Freeciv-3.3: /fast/freeciv/nightly/main/common/road.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
road.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__ROAD_H
14#define FC__ROAD_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* Used in the network protocol. */
21#define SPECENUM_NAME road_flag_id
22#define SPECENUM_VALUE0 RF_RIVER
23/* TRANS: this and following strings are 'road flags', which may rarely
24 * be presented to the player in ruleset help text */
25#define SPECENUM_VALUE0NAME N_("River")
26#define SPECENUM_VALUE1 RF_UNRESTRICTED_INFRA
27#define SPECENUM_VALUE1NAME N_("UnrestrictedInfra")
28#define SPECENUM_VALUE2 RF_JUMP_FROM
29#define SPECENUM_VALUE2NAME N_("JumpFrom")
30#define SPECENUM_VALUE3 RF_JUMP_TO
31#define SPECENUM_VALUE3NAME N_("JumpTo")
32#define SPECENUM_COUNT RF_COUNT
33#define SPECENUM_BITVECTOR bv_road_flags
34#include "specenum_gen.h"
35
36/* Used in the network protocol. */
37#define SPECENUM_NAME road_move_mode
38#define SPECENUM_VALUE0 RMM_CARDINAL
39#define SPECENUM_VALUE0NAME "Cardinal"
40#define SPECENUM_VALUE1 RMM_RELAXED
41#define SPECENUM_VALUE1NAME "Relaxed"
42#define SPECENUM_VALUE2 RMM_FAST_ALWAYS
43#define SPECENUM_VALUE2NAME "FastAlways"
44#include "specenum_gen.h"
45
46/* Used in the network protocol. */
47#define SPECENUM_NAME road_gui_type
48#define SPECENUM_VALUE0 ROAD_GUI_ROAD
49#define SPECENUM_VALUE0NAME "Road"
50#define SPECENUM_VALUE1 ROAD_GUI_RAILROAD
51#define SPECENUM_VALUE1NAME "Railroad"
52#define SPECENUM_VALUE2 ROAD_GUI_MAGLEV
53#define SPECENUM_VALUE2NAME "Maglev"
54#define SPECENUM_VALUE3 ROAD_GUI_OTHER
55#define SPECENUM_VALUE3NAME "Other"
56#include "specenum_gen.h"
57
58struct road_type;
59
60/* get 'struct road_type_list' and related functions: */
61#define SPECLIST_TAG road_type
62#define SPECLIST_TYPE struct road_type
63#include "speclist.h"
64
65#define road_type_list_iterate(roadlist, proad) \
66 TYPED_LIST_ITERATE(struct road_type, roadlist, proad)
67#define road_type_list_iterate_end LIST_ITERATE_END
68
69struct extra_type;
70
71 struct road_type {
72 int id;
73
74 int move_cost;
75 enum road_move_mode move_mode;
76 int tile_incr_const[O_LAST];
77 int tile_incr[O_LAST];
78 int tile_bonus[O_LAST];
79 enum road_compat compat;
80 enum road_gui_type gui_type;
81
82 struct requirement_vector first_reqs;
83
84 bv_max_extras integrates;
85 bv_road_flags flags;
86
87 /* Same information as in integrates, but iterating through this list is much
88 * faster than through all road types to check for compatible roads. */
89 struct extra_type_list *integrators;
90
91 struct extra_type *self;
92};
93
94#define ROAD_NONE (-1)
95
96/* General road type accessor functions. */
97 Road_type_id road_count(void);
98 Road_type_id road_number(const struct road_type *proad);
99
100struct road_type *road_by_number(Road_type_id id);
101struct extra_type *road_extra_get(const struct road_type *proad);
102
103enum road_compat road_compat_special(const struct road_type *proad);
104struct road_type *road_by_compat_special(enum road_compat compat);
105
106struct road_type *road_by_gui_type(enum road_gui_type gui_type);
107
108int count_road_near_tile(struct civ_map *nmap, const struct tile *ptile,
109 const struct road_type *proad);
110int count_river_near_tile(struct civ_map *nmap,
111 const struct tile *ptile,
112 const struct extra_type *priver);
113int count_river_type_tile_card(struct civ_map *nmap,
114 const struct tile *ptile,
115 const struct extra_type *priver,
116 bool percentage);
117int count_river_type_near_tile(struct civ_map *nmap,
118 const struct tile *ptile,
119 const struct extra_type *priver,
120 bool percentage);
121
122/* Functions to operate on a road flag. */
123bool road_has_flag(const struct road_type *proad, enum road_flag_id flag);
124bool is_road_flag_card_near(const struct civ_map *nmap, const struct tile *ptile,
125 enum road_flag_id flag);
126bool is_road_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile,
127 enum road_flag_id flag);
128
129bool road_can_be_built(const struct road_type *proad, const struct tile *ptile);
130bool can_build_road(const struct civ_map *nmap,
131 struct road_type *proad,
132 const struct unit *punit,
133 const struct tile *ptile);
134bool player_can_build_road(const struct civ_map *nmap,
135 const struct road_type *proad,
136 const struct player *pplayer,
137 const struct tile *ptile);
138
139bool is_native_tile_to_road(const struct road_type *proad,
140 const struct tile *ptile);
141
142bool is_cardinal_only_road(const struct extra_type *pextra);
143
144bool road_provides_move_bonus(const struct road_type *proad);
145
146/* Sorting */
147int compare_road_move_cost(const struct extra_type *const *p,
148 const struct extra_type *const *q);
149
150/* Initialization and iteration */
151void road_type_init(struct extra_type *pextra, int idx);
152void road_integrators_cache_init(void);
153void road_types_free(void);
154
155#define road_deps_iterate(_reqs, _dep) \
156{ \
157 requirement_vector_iterate(_reqs, preq) { \
158 if (preq->source.kind == VUT_EXTRA \
159 && preq->present \
160 && is_extra_caused_by(preq->source.value.extra, EC_ROAD)) { \
161 struct road_type *_dep = extra_road_get(preq->source.value.extra);
162
163
164#define road_deps_iterate_end \
165 } \
166 } requirement_vector_iterate_end; \
167}
168
169#ifdef __cplusplus
170}
171#endif /* __cplusplus */
172
173#endif /* FC__ROAD_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
Road_type_id
int Road_type_id
Definition fc_types.h:388
road_compat
road_compat
Definition fc_types.h:1233
O_LAST
@ O_LAST
Definition fc_types.h:101
road_count
Road_type_id road_count(void)
Definition road.c:50
can_build_road
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:301
road_extra_get
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
road_number
Road_type_id road_number(const struct road_type *proad)
Definition road.c:32
road_has_flag
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:416
is_cardinal_only_road
bool is_cardinal_only_road(const struct extra_type *pextra)
Definition road.c:489
road_integrators_cache_init
void road_integrators_cache_init(void)
Definition road.c:111
road_compat_special
enum road_compat road_compat_special(const struct road_type *proad)
Definition road.c:151
is_road_flag_near_tile
bool is_road_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
Definition road.c:446
road_provides_move_bonus
bool road_provides_move_bonus(const struct road_type *proad)
Definition road.c:505
road_types_free
void road_types_free(void)
Definition road.c:134
count_river_type_tile_card
int count_river_type_tile_card(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
Definition road.c:362
road_by_number
struct road_type * road_by_number(Road_type_id id)
Definition road.c:58
road_type_init
void road_type_init(struct extra_type *pextra, int idx)
Definition road.c:93
is_native_tile_to_road
bool is_native_tile_to_road(const struct road_type *proad, const struct tile *ptile)
Definition road.c:466
compare_road_move_cost
int compare_road_move_cost(const struct extra_type *const *p, const struct extra_type *const *q)
Definition road.c:75
road_by_compat_special
struct road_type * road_by_compat_special(enum road_compat compat)
Definition road.c:160
road_can_be_built
bool road_can_be_built(const struct road_type *proad, const struct tile *ptile)
Definition road.c:200
count_river_type_near_tile
int count_river_type_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
Definition road.c:389
count_river_near_tile
int count_river_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver)
Definition road.c:340
player_can_build_road
bool player_can_build_road(const struct civ_map *nmap, const struct road_type *proad, const struct player *pplayer, const struct tile *ptile)
Definition road.c:286
road_by_gui_type
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
is_road_flag_card_near
bool is_road_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
Definition road.c:425
count_road_near_tile
int count_road_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct road_type *proad)
Definition road.c:319
compat
static struct compatibility compat[]
Definition savecompat.c:112
specenum_gen.h
speclist.h
civ_map
Definition map_types.h:71
extra_type
Definition extras.h:88
player
Definition player.h:249
road_type
Definition road.h:71
road_type::self
struct extra_type * self
Definition road.h:91
road_type::gui_type
enum road_gui_type gui_type
Definition road.h:80
road_type::first_reqs
struct requirement_vector first_reqs
Definition road.h:82
road_type::move_mode
enum road_move_mode move_mode
Definition road.h:75
road_type::id
int id
Definition road.h:72
road_type::integrators
struct extra_type_list * integrators
Definition road.h:89
road_type::tile_bonus
int tile_bonus[O_LAST]
Definition road.h:78
road_type::tile_incr_const
int tile_incr_const[O_LAST]
Definition road.h:76
road_type::tile_incr
int tile_incr[O_LAST]
Definition road.h:77
road_type::flags
bv_road_flags flags
Definition road.h:85
road_type::move_cost
int move_cost
Definition road.h:74
road_type::compat
enum road_compat compat
Definition road.h:79
road_type::integrates
bv_max_extras integrates
Definition road.h:84
tile
Definition tile.h:50
unit
Definition unit.h:140