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_number(const struct road_type
*proad
);
91 struct road_type
*road_by_number(Road_type_id id
);
92 struct extra_type
*road_extra_get(const struct road_type
*proad
);
94 enum road_compat
road_compat_special(const struct road_type
*proad
);
95 struct road_type
*road_by_compat_special(enum road_compat compat
);
97 int count_road_near_tile(const struct tile
*ptile
, const struct road_type
*proad
);
98 int count_river_near_tile(const struct tile
*ptile
,
99 const struct extra_type
*priver
);
100 int count_river_type_tile_card(const struct tile
*ptile
,
101 const struct extra_type
*priver
,
103 int count_river_type_near_tile(const struct tile
*ptile
,
104 const struct extra_type
*priver
,
107 /* Functions to operate on a road flag. */
108 bool road_has_flag(const struct road_type
*proad
, enum road_flag_id flag
);
109 bool is_road_flag_card_near(const struct tile
*ptile
,
110 enum road_flag_id flag
);
111 bool is_road_flag_near_tile(const struct tile
*ptile
,
112 enum road_flag_id flag
);
114 bool road_can_be_built(const struct road_type
*proad
, const struct tile
*ptile
);
115 bool can_build_road_base(const struct road_type
*proad
,
116 const struct player
*pplayer
,
117 const struct tile
*ptile
);
118 bool can_build_road(struct road_type
*proad
,
119 const struct unit
*punit
,
120 const struct tile
*ptile
);
121 bool player_can_build_road(const struct road_type
*proad
,
122 const struct player
*pplayer
,
123 const struct tile
*ptile
);
125 bool is_native_tile_to_road(const struct road_type
*proad
,
126 const struct tile
*ptile
);
128 bool is_cardinal_only_road(const struct extra_type
*pextra
);
130 bool road_provides_move_bonus(const struct road_type
*proad
);
133 int compare_road_move_cost(const struct extra_type
*const *p
,
134 const struct extra_type
*const *q
);
136 /* Initialization and iteration */
137 void road_type_init(struct extra_type
*pextra
, int idx
);
138 void road_integrators_cache_init(void);
139 void road_types_free(void);
141 #define road_deps_iterate(_reqs, _dep) \
143 requirement_vector_iterate(_reqs, preq) { \
144 if (preq->source.kind == VUT_EXTRA \
146 && is_extra_caused_by(preq->source.value.extra, EC_ROAD)) { \
147 struct road_type *_dep = extra_road_get(preq->source.value.extra);
150 #define road_deps_iterate_end \
152 } requirement_vector_iterate_end; \
157 #endif /* __cplusplus */
159 #endif /* FC__ROAD_H */