Freeciv-3.2
Loading...
Searching...
No Matches
Functions
road.c File Reference
#include "extras.h"
#include "fc_types.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "name_translation.h"
#include "unittype.h"
#include "road.h"

Go to the source code of this file.

Functions

Road_type_id road_number (const struct road_type *proad)
 
struct extra_typeroad_extra_get (const struct road_type *proad)
 
Road_type_id road_count (void)
 
struct road_typeroad_by_number (Road_type_id id)
 
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)
 
enum road_compat road_compat_special (const struct road_type *proad)
 
struct road_typeroad_by_compat_special (enum road_compat compat)
 
struct road_typeroad_by_gui_type (enum road_gui_type gui_type)
 
bool road_can_be_built (const struct road_type *proad, const struct tile *ptile)
 
static bool are_road_reqs_fulfilled (const struct civ_map *nmap, const struct road_type *proad, const struct player *pplayer, 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 can_build_road (const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
 
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 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)
 

Function Documentation

◆ are_road_reqs_fulfilled()

static bool are_road_reqs_fulfilled ( const struct civ_map nmap,
const struct road_type proad,
const struct player pplayer,
const struct unit punit,
const struct tile ptile 
)
static

Tells if player and optionally unit have road building requirements fulfilled.

Definition at line 224 of file road.c.

Referenced by can_build_road(), and player_can_build_road().

◆ 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 295 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 334 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 383 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 356 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 313 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 483 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 460 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 419 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 440 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 280 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)

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

◆ road_has_flag()

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

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

◆ road_provides_move_bonus()

bool road_provides_move_bonus ( const struct road_type proad)

Does road type provide move bonus

Definition at line 499 of file road.c.

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

◆ 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().