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

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
road.h File Reference
`#include "specenum_gen.h"`
`#include "speclist.h"`

Go to the source code of this file.

## Data Structures

struct | road_type

## Macros

#define | SPECENUM_NAME road_flag_id
#define | SPECENUM_VALUE0 RF_RIVER
#define | SPECENUM_VALUE0NAME N_("River")
#define | SPECENUM_VALUE1 RF_UNRESTRICTED_INFRA
#define | SPECENUM_VALUE1NAME N_("UnrestrictedInfra")
#define | SPECENUM_VALUE2 RF_JUMP_FROM
#define | SPECENUM_VALUE2NAME N_("JumpFrom")
#define | SPECENUM_VALUE3 RF_JUMP_TO
#define | SPECENUM_VALUE3NAME N_("JumpTo")
#define | SPECENUM_COUNT RF_COUNT
#define | SPECENUM_BITVECTOR bv_road_flags
#define | SPECENUM_NAME road_move_mode
#define | SPECENUM_VALUE0 RMM_CARDINAL
#define | SPECENUM_VALUE0NAME "Cardinal"
#define | SPECENUM_VALUE1 RMM_RELAXED
#define | SPECENUM_VALUE1NAME "Relaxed"
#define | SPECENUM_VALUE2 RMM_FAST_ALWAYS
#define | SPECENUM_VALUE2NAME "FastAlways"
#define | SPECENUM_NAME road_gui_type
#define | SPECENUM_VALUE0 ROAD_GUI_ROAD
#define | SPECENUM_VALUE0NAME "Road"
#define | SPECENUM_VALUE1 ROAD_GUI_RAILROAD
#define | SPECENUM_VALUE1NAME "Railroad"
#define | SPECENUM_VALUE2 ROAD_GUI_MAGLEV
#define | SPECENUM_VALUE2NAME "Maglev"
#define | SPECENUM_VALUE3 ROAD_GUI_OTHER
#define | SPECENUM_VALUE3NAME "Other"
#define | SPECLIST_TAG road_type
#define | SPECLIST_TYPE struct road_type
#define | road_type_list_iterate(roadlist, proad) TYPED_LIST_ITERATE(struct road_type, roadlist, proad)
#define | road_type_list_iterate_end LIST_ITERATE_END
#define | ROAD_NONE (-1)
#define | road_deps_iterate(_reqs, _dep)
#define | road_deps_iterate_end

## Functions

Road_type_id | road_count (void)
Road_type_id | road_number (const struct road_type *proad)
struct road_type * | road_by_number (Road_type_id id)
struct extra_type * | road_extra_get (const struct road_type *proad)
enum road_compat | road_compat_special (const struct road_type *proad)
struct road_type * | road_by_compat_special (enum road_compat compat)
struct road_type * | road_by_gui_type (enum road_gui_type gui_type)
int | count_road_near_tile (struct civ_map *nmap, const struct tile *ptile, const struct road_type *proad)
int | count_river_near_tile (struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver)
int | count_river_type_tile_card (struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
int | count_river_type_near_tile (struct civ_map *nmap, const struct tile *ptile, const struct extra_type *priver, bool percentage)
bool | road_has_flag (const struct road_type *proad, enum road_flag_id flag)
bool | is_road_flag_card_near (const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
bool | is_road_flag_near_tile (const struct civ_map *nmap, const struct tile *ptile, enum road_flag_id flag)
bool | road_can_be_built (const struct road_type *proad, const struct tile *ptile)
bool | can_build_road (const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
bool | player_can_build_road (const struct civ_map *nmap, const struct road_type *proad, const struct player *pplayer, const struct tile *ptile)
bool | is_native_tile_to_road (const struct road_type *proad, const struct tile *ptile)
bool | is_cardinal_only_road (const struct extra_type *pextra)
bool | road_provides_move_bonus (const struct road_type *proad)
int | compare_road_move_cost (const struct extra_type *const *p, const struct extra_type *const *q)
void | road_type_init (struct extra_type *pextra, int idx)
void | road_integrators_cache_init (void)
void | road_types_free (void)

## Macro Definition Documentation

## ◆ road_deps_iterate

#define road_deps_iterate | ( |  | _reqs,
|  |  | _dep
| ) |  |

Value:
{ \
requirement_vector_iterate(_reqs, preq) { \
if (preq->source.kind == VUT_EXTRA \
&& preq->present \
&& is_extra_caused_by(preq->source.value.extra, EC_ROAD)) { \
struct road_type *_dep = extra_road_get(preq->source.value.extra);
incite_cost
char * incite_cost
Definition comments.c:74
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:203
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:191
road_type
Definition road.h:71

Definition at line 155 of file road.h.

## ◆ road_deps_iterate_end

#define road_deps_iterate_end

Value:
} \
} requirement_vector_iterate_end; \
}
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94

Definition at line 164 of file road.h.

## ◆ ROAD_NONE

#define ROAD_NONE (-1)

Definition at line 94 of file road.h.

## ◆ road_type_list_iterate

#define road_type_list_iterate | ( |  | roadlist,
|  |  | proad
| ) |  | TYPED_LIST_ITERATE(struct road_type, roadlist, proad)

Definition at line 65 of file road.h.

## ◆ road_type_list_iterate_end

#define road_type_list_iterate_end LIST_ITERATE_END

Definition at line 67 of file road.h.

## ◆ SPECENUM_BITVECTOR

#define SPECENUM_BITVECTOR bv_road_flags

Definition at line 33 of file road.h.

## ◆ SPECENUM_COUNT

#define SPECENUM_COUNT RF_COUNT

Definition at line 32 of file road.h.

## ◆ SPECENUM_NAME [1/3]

#define SPECENUM_NAME road_flag_id

Definition at line 21 of file road.h.

## ◆ SPECENUM_NAME [2/3]

#define SPECENUM_NAME road_move_mode

Definition at line 21 of file road.h.

## ◆ SPECENUM_NAME [3/3]

#define SPECENUM_NAME road_gui_type

Definition at line 21 of file road.h.

## ◆ SPECENUM_VALUE0 [1/3]

#define SPECENUM_VALUE0 RF_RIVER

Definition at line 22 of file road.h.

## ◆ SPECENUM_VALUE0 [2/3]

#define SPECENUM_VALUE0 RMM_CARDINAL

Definition at line 22 of file road.h.

## ◆ SPECENUM_VALUE0 [3/3]

#define SPECENUM_VALUE0 ROAD_GUI_ROAD

Definition at line 22 of file road.h.

## ◆ SPECENUM_VALUE0NAME [1/3]

#define SPECENUM_VALUE0NAME N_("River")

Definition at line 25 of file road.h.

## ◆ SPECENUM_VALUE0NAME [2/3]

#define SPECENUM_VALUE0NAME "Cardinal"

Definition at line 25 of file road.h.

## ◆ SPECENUM_VALUE0NAME [3/3]

#define SPECENUM_VALUE0NAME "Road"

Definition at line 25 of file road.h.

## ◆ SPECENUM_VALUE1 [1/3]

#define SPECENUM_VALUE1 RF_UNRESTRICTED_INFRA

Definition at line 26 of file road.h.

## ◆ SPECENUM_VALUE1 [2/3]

#define SPECENUM_VALUE1 RMM_RELAXED

Definition at line 26 of file road.h.

## ◆ SPECENUM_VALUE1 [3/3]

#define SPECENUM_VALUE1 ROAD_GUI_RAILROAD

Definition at line 26 of file road.h.

## ◆ SPECENUM_VALUE1NAME [1/3]

#define SPECENUM_VALUE1NAME N_("UnrestrictedInfra")

Definition at line 27 of file road.h.

## ◆ SPECENUM_VALUE1NAME [2/3]

#define SPECENUM_VALUE1NAME "Relaxed"

Definition at line 27 of file road.h.

## ◆ SPECENUM_VALUE1NAME [3/3]

#define SPECENUM_VALUE1NAME "Railroad"

Definition at line 27 of file road.h.

## ◆ SPECENUM_VALUE2 [1/3]

#define SPECENUM_VALUE2 RF_JUMP_FROM

Definition at line 28 of file road.h.

## ◆ SPECENUM_VALUE2 [2/3]

#define SPECENUM_VALUE2 RMM_FAST_ALWAYS

Definition at line 28 of file road.h.

## ◆ SPECENUM_VALUE2 [3/3]

#define SPECENUM_VALUE2 ROAD_GUI_MAGLEV

Definition at line 28 of file road.h.

## ◆ SPECENUM_VALUE2NAME [1/3]

#define SPECENUM_VALUE2NAME N_("JumpFrom")

Definition at line 29 of file road.h.

## ◆ SPECENUM_VALUE2NAME [2/3]

#define SPECENUM_VALUE2NAME "FastAlways"

Definition at line 29 of file road.h.

## ◆ SPECENUM_VALUE2NAME [3/3]

#define SPECENUM_VALUE2NAME "Maglev"

Definition at line 29 of file road.h.

## ◆ SPECENUM_VALUE3 [1/2]

#define SPECENUM_VALUE3 RF_JUMP_TO

Definition at line 30 of file road.h.

## ◆ SPECENUM_VALUE3 [2/2]

#define SPECENUM_VALUE3 ROAD_GUI_OTHER

Definition at line 30 of file road.h.

## ◆ SPECENUM_VALUE3NAME [1/2]

#define SPECENUM_VALUE3NAME N_("JumpTo")

Definition at line 31 of file road.h.

## ◆ SPECENUM_VALUE3NAME [2/2]

#define SPECENUM_VALUE3NAME "Other"

Definition at line 31 of file road.h.

## ◆ SPECLIST_TAG

#define SPECLIST_TAG road_type

Definition at line 61 of file road.h.

## ◆ SPECLIST_TYPE

#define SPECLIST_TYPE struct road_type

Definition at line 62 of file road.h.

## Function Documentation

## ◆ can_build_road()

bool can_build_road | ( | const struct civ_map * | nmap,
|  | struct road_type * | proad,
|  | const struct unit * | punit,
|  | const struct tile * | ptile
| ) |  |

Tells if unit can build road on tile.

Definition at line 301 of file road.c.

Referenced by actres_possible(), can_units_do_any_road(), check_recursive_road_connect(), and unit_actions::update_actions().

## ◆ compare_road_move_cost()

int compare_road_move_cost | ( | const struct extra_type *const * | p,
|  | const struct extra_type *const * | q
| ) |  |

This function is passed to road_type_list_sort() to sort a list of roads in ascending move_cost (faster roads first).

Definition at line 75 of file road.c.

Referenced by road_integrators_cache_init().

## ◆ count_river_near_tile()

int count_river_near_tile | ( | struct civ_map * | nmap,
|  | const struct tile * | ptile,
|  | const struct extra_type * | priver
| ) |  |

Count tiles with any river near the tile.

Definition at line 340 of file road.c.

Referenced by is_terrain_ecologically_wet(), make_river(), and make_rivers().

## ◆ 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
| ) |  |

Count tiles with river of specific type near the tile.

Definition at line 389 of file road.c.

Referenced by island_river_suitability().

## ◆ 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
| ) |  |

Count tiles with river of specific type cardinally adjacent to the tile.

Definition at line 362 of file road.c.

Referenced by island_river_mouth_suitability(), island_river_suitability(), river_test_adjacent_river(), and river_test_rivergrid().

## ◆ count_road_near_tile()

int count_road_near_tile | ( | struct civ_map * | nmap,
|  | const struct tile * | ptile,
|  | const struct road_type * | proad
| ) |  |

Count tiles with specified road near the tile. Can be called with NULL road.

Definition at line 319 of file road.c.

## ◆ is_cardinal_only_road()

bool is_cardinal_only_road | ( | const struct extra_type * | pextra | ) |

Is extra cardinal only road.

Definition at line 489 of file road.c.

Referenced by are_road_reqs_fulfilled(), fair_map_island_new(), fill_road_corner_sprites(), and fill_road_sprite_array().

## ◆ is_native_tile_to_road()

bool is_native_tile_to_road | ( | const struct road_type * | proad,
|  | const struct tile * | ptile
| ) |  |

Is tile native to road?

Definition at line 466 of file road.c.

## ◆ 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
| ) |  |

Returns TRUE iff any cardinally adjacent tile contains a road with the given flag (does not check ptile itself).

Definition at line 425 of file road.c.

Referenced by is_roadflag_req_active().

## ◆ 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
| ) |  |

Returns TRUE iff any adjacent tile contains a road with the given flag (does not check ptile itself).

Definition at line 446 of file road.c.

Referenced by is_roadflag_req_active().

## ◆ 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
| ) |  |

Tells if player can build road to tile with suitable unit.

Definition at line 286 of file road.c.

Referenced by check_recursive_road_connect().

## ◆ road_by_compat_special()

struct road_type * road_by_compat_special | ( | enum road_compat | compat | ) |

Return road type represented by given compatibility special, or NULL if special does not represent road type at all.

Definition at line 160 of file road.c.

Referenced by sg_load_player_unit(), sg_special_set_bv(), and sg_special_set_dbv().

## ◆ road_by_gui_type()

struct road_type * road_by_gui_type | ( | enum road_gui_type | gui_type | ) |

Return road type represented by given gui_type, or NULL if it does not represent road type at all.

Definition at line 180 of file road.c.

Referenced by connect_maglev_callback(), connect_maglev_callback(), connect_rail_callback(), connect_rail_callback(), connect_road_callback(), connect_road_callback(), create_units_order_widgets(), mr_menu::menus_sensitive(), real_menus_update(), mr_menu::slot_conn_maglev(), mr_menu::slot_conn_rail(), mr_menu::slot_conn_road(), and unit_order_callback().

## ◆ road_by_number()

struct road_type * road_by_number | ( | Road_type_id | id | ) |

Return road type of given id.

Definition at line 58 of file road.c.

Referenced by handle_ruleset_road(), set_unit_activity_road(), and sg_load_player_unit().

## ◆ road_can_be_built()

bool road_can_be_built | ( | const struct road_type * | proad,
|  | const struct tile * | ptile
| ) |  |

Tells if road can build to tile if all other requirements are met.

Definition at line 200 of file road.c.

Referenced by get_tile_value().

## ◆ road_compat_special()

enum road_compat road_compat_special | ( | const struct road_type * | proad | ) |

Return tile special that used to represent this road type.

Definition at line 151 of file road.c.

Referenced by real_menus_update(), and road_by_compat_special().

## ◆ road_count()

Road_type_id road_count | ( | void |  | ) |

Return the number of road_types.

Definition at line 50 of file road.c.

Referenced by editor_tool_is_usable(), extviewer_view_cell_toggled(), and tab_misc::refresh_stats().

## ◆ road_extra_get()

struct extra_type * road_extra_get | ( | const struct road_type * | proad | ) |

Return extra that road is.

Definition at line 42 of file road.c.

Referenced by adv_workers_road_bonus(), are_road_reqs_fulfilled(), can_build_road(), connect_maglev_callback(), connect_maglev_callback(), connect_rail_callback(), connect_rail_callback(), connect_road_callback(), connect_road_callback(), create_units_order_widgets(), is_native_tile_to_road(), mr_menu::menus_sensitive(), player_can_build_road(), real_menus_update(), road_can_be_built(), set_unit_activity_road(), sg_load_player_unit(), sg_roads_set_bv(), sg_roads_set_dbv(), sg_special_set_bv(), sg_special_set_dbv(), mr_menu::slot_conn_maglev(), mr_menu::slot_conn_rail(), mr_menu::slot_conn_road(), tile_has_road(), unit_order_callback(), and worker_evaluate_improvements().

## ◆ road_has_flag()

bool road_has_flag | ( | const struct road_type * | proad,
|  | enum road_flag_id | flag
| ) |  |

Check if road provides effect

Definition at line 416 of file road.c.

Referenced by evaluate_city_name_priority(), extra_type_found(), helptext_extra(), is_native_move(), is_native_tile_to_extra(), is_native_tile_to_road(), is_road_flag_card_near(), is_road_flag_near_tile(), is_roadflag_req_active(), move_type_from_extra(), ocean_to_land_fix_rivers(), remove_tiny_islands(), river_types_init(), save_terrain_ruleset(), tile_has_river(), tile_has_road_flag(), and tile_move_cost_ptrs().

## ◆ road_integrators_cache_init()

void road_integrators_cache_init | ( | void |  | ) |

Initialize the road integrators cache

Definition at line 111 of file road.c.

Referenced by handle_rulesets_ready(), and load_rulesetdir().

## ◆ road_number()

Road_type_id road_number | ( | const struct road_type * | proad | ) |

Return the road id.

Definition at line 32 of file road.c.

Referenced by adv_workers_road_bonus(), extviewer_refresh_widgets(), load_ruleset_terrain(), objbind_get_value_from_object(), objbind_pack_modified_value(), propval_as_string(), road_integrators_cache_init(), sanity_check_ruleset_data(), send_ruleset_roads(), and sg_load_player_unit().

## ◆ road_provides_move_bonus()

bool road_provides_move_bonus | ( | const struct road_type * | proad | ) |

Does road type provide move bonus

Definition at line 505 of file road.c.

Referenced by helptext_extra(), set_unit_class_caches(), texai_tile_worker_task_select(), and worker_evaluate_improvements().

## ◆ road_type_init()

void road_type_init | ( | struct extra_type * | pextra,
|  | int | idx
| ) |  |

Initialize road_type structures.

Definition at line 93 of file road.c.

Referenced by handle_ruleset_extra(), and load_terrain_names().

## ◆ road_types_free()

void road_types_free | ( | void |  | ) |

Free the memory associated with road types

Definition at line 134 of file road.c.

Referenced by extras_free().