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)
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 ***********************************************************************/
18 #endif /* __cplusplus */
20 /* Used in the network protocol. */
21 #define SPECENUM_NAME road_flag_id
22 #define SPECENUM_VALUE0 RF_REQUIRES_BRIDGE
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_("RequiresBridge")
26 #define SPECENUM_VALUE1 RF_PREVENTS_OTHER_ROADS
27 #define SPECENUM_VALUE1NAME N_("PreventsOtherRoads")
28 #define SPECENUM_VALUE2 RF_RIVER
29 #define SPECENUM_VALUE2NAME N_("River")
30 #define SPECENUM_VALUE3 RF_UNRESTRICTED_INFRA
31 #define SPECENUM_VALUE3NAME N_("UnrestrictedInfra")
32 #define SPECENUM_VALUE4 RF_JUMP_FROM
33 #define SPECENUM_VALUE4NAME N_("JumpFrom")
34 #define SPECENUM_VALUE5 RF_JUMP_TO
35 #define SPECENUM_VALUE5NAME N_("JumpTo")
36 #define SPECENUM_COUNT RF_COUNT
37 #define SPECENUM_BITVECTOR bv_road_flags
38 #include "specenum_gen.h"
40 /* Used in the network protocol. */
41 #define SPECENUM_NAME road_move_mode
42 #define SPECENUM_VALUE0 RMM_CARDINAL
43 #define SPECENUM_VALUE0NAME "Cardinal"
44 #define SPECENUM_VALUE1 RMM_RELAXED
45 #define SPECENUM_VALUE1NAME "Relaxed"
46 #define SPECENUM_VALUE2 RMM_FAST_ALWAYS
47 #define SPECENUM_VALUE2NAME "FastAlways"
48 #include "specenum_gen.h"
52 /* get 'struct road_type_list' and related functions: */
53 #define SPECLIST_TAG road_type
54 #define SPECLIST_TYPE struct road_type
57 #define road_type_list_iterate(roadlist, proad) \
58 TYPED_LIST_ITERATE(struct road_type, roadlist, proad)
59 #define road_type_list_iterate_end LIST_ITERATE_END
67 enum road_move_mode move_mode
;
68 int tile_incr_const
[O_LAST
];
69 int tile_incr
[O_LAST
];
70 int tile_bonus
[O_LAST
];
71 enum road_compat compat
;
73 struct requirement_vector first_reqs
;
78 /* Same information as in integrates, but iterating through this list is much
79 * faster than through all road types to check for compatible roads. */
80 struct extra_type_list
*integrators
;
82 struct extra_type
*self
;
85 #define ROAD_NONE (-1)
87 /* General road type accessor functions. */
88 Road_type_id
road_count(void);
89 Road_type_id
road_index(const struct road_type
*proad
);
90 Road_type_id
road_number(const struct road_type
*proad
);
92 struct road_type
*road_by_number(Road_type_id id
);
93 struct extra_type
*road_extra_get(const struct road_type
*proad
);
95 enum road_compat
road_compat_special(const struct road_type
*proad
);
96 struct road_type
*road_by_compat_special(enum road_compat compat
);
98 int count_road_near_tile(const struct tile
*ptile
, const struct road_type
*proad
);
99 int count_river_near_tile(const struct tile
*ptile
,
100 const struct extra_type
*priver
);
101 int count_river_type_tile_card(const struct tile
*ptile
,
102 const struct extra_type
*priver
,
104 int count_river_type_near_tile(const struct tile
*ptile
,
105 const struct extra_type
*priver
,
108 /* Functions to operate on a road flag. */
109 bool road_has_flag(const struct road_type
*proad
, enum road_flag_id flag
);
110 bool is_road_flag_card_near(const struct tile
*ptile
,
111 enum road_flag_id flag
);
112 bool is_road_flag_near_tile(const struct tile
*ptile
,
113 enum road_flag_id flag
);
115 bool road_can_be_built(const struct road_type
*proad
, const struct tile
*ptile
);
116 bool can_build_road_base(const struct road_type
*proad
,
117 const struct player
*pplayer
,
118 const struct tile
*ptile
);
119 bool can_build_road(struct road_type
*proad
,
120 const struct unit
*punit
,
121 const struct tile
*ptile
);
122 bool player_can_build_road(const struct road_type
*proad
,
123 const struct player
*pplayer
,
124 const struct tile
*ptile
);
126 bool is_native_tile_to_road(const struct road_type
*proad
,
127 const struct tile
*ptile
);
129 bool is_cardinal_only_road(const struct extra_type
*pextra
);
131 bool road_provides_move_bonus(const struct road_type
*proad
);
134 int compare_road_move_cost(const struct extra_type
*const *p
,
135 const struct extra_type
*const *q
);
137 /* Initialization and iteration */
138 void road_type_init(struct extra_type
*pextra
, int idx
);
139 void road_integrators_cache_init(void);
140 void road_types_free(void);
142 #define road_deps_iterate(_reqs, _dep) \
144 requirement_vector_iterate(_reqs, preq) { \
145 if (preq->source.kind == VUT_EXTRA \
147 && is_extra_caused_by(preq->source.value.extra, EC_ROAD)) { \
148 struct road_type *_dep = extra_road_get(preq->source.value.extra);
151 #define road_deps_iterate_end \
153 } requirement_vector_iterate_end; \
158 #endif /* __cplusplus */
160 #endif /* FC__ROAD_H */