Freeciv-3.2
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
71struct road_type {
72 int id;
73
81
83
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. */
90
92};
93
94#define ROAD_NONE (-1)
95
96/* General road type accessor functions. */
99
101struct extra_type *road_extra_get(const struct road_type *proad);
102
105
107
108int count_road_near_tile(struct civ_map *nmap, const struct tile *ptile,
109 const struct road_type *proad);
111 const struct tile *ptile,
112 const struct extra_type *priver);
114 const struct tile *ptile,
115 const struct extra_type *priver,
116 bool percentage);
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);
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 */
char * incite_cost
Definition comments.c:75
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
int Road_type_id
Definition fc_types.h:384
road_compat
Definition fc_types.h:1253
@ O_LAST
Definition fc_types.h:101
Road_type_id road_count(void)
Definition road.c:50
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
struct extra_type * road_extra_get(const struct road_type *proad)
Definition road.c:42
Road_type_id road_number(const struct road_type *proad)
Definition road.c:32
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:410
bool is_cardinal_only_road(const struct extra_type *pextra)
Definition road.c:483
void road_integrators_cache_init(void)
Definition road.c:111
enum road_compat road_compat_special(const struct road_type *proad)
Definition road.c:151
bool is_road_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
Definition road.c:440
bool road_provides_move_bonus(const struct road_type *proad)
Definition road.c:499
void road_types_free(void)
Definition road.c:134
int count_river_type_tile_card(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
Definition road.c:356
struct road_type * road_by_number(Road_type_id id)
Definition road.c:58
void road_type_init(struct extra_type *pextra, int idx)
Definition road.c:93
bool is_native_tile_to_road(const struct road_type *proad, const struct tile *ptile)
Definition road.c:460
int compare_road_move_cost(const struct extra_type *const *p, const struct extra_type *const *q)
Definition road.c:75
struct road_type * road_by_compat_special(enum road_compat compat)
Definition road.c:160
bool road_can_be_built(const struct road_type *proad, const struct tile *ptile)
Definition road.c:200
int count_river_type_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
Definition road.c:383
int count_river_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver)
Definition road.c:334
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:280
struct road_type * road_by_gui_type(enum road_gui_type gui_type)
Definition road.c:180
bool is_road_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
Definition road.c:419
int count_road_near_tile(struct civ_map *nmap, const struct tile *ptile, const struct road_type *proad)
Definition road.c:313
static struct compatibility compat[]
Definition savecompat.c:105
struct extra_type * self
Definition road.h:91
enum road_gui_type gui_type
Definition road.h:80
struct requirement_vector first_reqs
Definition road.h:82
enum road_move_mode move_mode
Definition road.h:75
int id
Definition road.h:72
struct extra_type_list * integrators
Definition road.h:89
int tile_bonus[O_LAST]
Definition road.h:78
int tile_incr_const[O_LAST]
Definition road.h:76
int tile_incr[O_LAST]
Definition road.h:77
bv_road_flags flags
Definition road.h:85
int move_cost
Definition road.h:74
enum road_compat compat
Definition road.h:79
bv_max_extras integrates
Definition road.h:84
Definition tile.h:50
Definition unit.h:138