44 int base_move_rate, move_rate;
53 move_rate = base_move_rate;
57 move_rate = (move_rate * hitpoints) / utype->
hp;
67 if (move_rate < uclass->min_speed) {
110 && pterrain->movement_cost > move_cost) {
113 move_cost = pterrain->movement_cost;
143 const struct unit *punit)
151 && (ptrans ==
nullptr
182 USP_NATIVE_TILE,
false)
184 USP_LIVABLE_TILE,
false)
186 USP_LIVABLE_TILE,
false));
193 const struct tile *ptile,
194 const struct tile *pexclude)
196 struct tile_list *process_queue = tile_list_new();
206 }
else if (piter != pexclude
211 }
else if (piter != pexclude &&
nullptr !=
tile_city(piter)) {
212 tile_list_append(process_queue, piter);
219 if (found || 0 == tile_list_size(process_queue)) {
222 ptile = tile_list_front(process_queue);
223 tile_list_pop_front(process_queue);
227 tile_list_destroy(process_queue);
238 const struct tile *ptile)
268 const struct unit *punit,
269 const struct tile *ptile)
280 const struct tile *ptile)
291 const struct terrain *pterrain,
323 const struct tile *src_tile,
const struct tile *dst_tile)
386 case RMM_FAST_ALWAYS:
426 const struct tile *ptile)
453 const struct unit *punit,
454 const struct tile *ptile)
501 const struct tile *src_tile,
502 const struct tile *dst_tile,
532 const struct unit *punit,
533 const struct tile *dst_tile,
bool igzoc,
534 bool enter_enemy_city)
539 nullptr, enter_enemy_city));
567 enum unit_activity activity,
568 const struct tile *src_tile,
569 const struct tile *dst_tile,
bool igzoc,
570 struct unit *embark_to,
bool enter_enemy_city)
578 if (activity != ACTIVITY_IDLE && activity != ACTIVITY_GOTO) {
608 if (embark_to !=
nullptr) {
628 if (enter_enemy_city) {
685 const struct unit *transported)
798 const char *none,
bool align)
810 str = QStringLiteral(
"%1").arg(none ? none :
"");
813 str = QStringLiteral(
"%1%2%3").arg(
838 str += QStringLiteral(
"%1%2/%3").arg(
839 prefix, QString::number((mp %
SINGLE_MOVE) / cancel),
843 str += QStringLiteral(
"%1%2 %3/%4")
849 return qstrdup(qUtf8Printable(str));
bool BV_ISSET(const BV &bv, int bit)
#define BV_ISSET_ANY(vec)
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, enum effect_type effect_type, enum vision_layer vision_layer)
Returns the effect bonus that applies at a tile for a given unittype.
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
bool is_move_cardinal(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Returns TRUE iff the move from the position (start_x,start_y) to (end_x,end_y) is a cardinal one.
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
Return TRUE if this ocean terrain is adjacent to a safe coastline.
#define cardinal_between_iterate(nmap, tile1, tile2, between)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define ALL_DIRECTIONS_CARDINAL()
#define cardinal_between_iterate_end
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Render positive movement points as text, including fractional movement points, scaled by SINGLE_MOVE.
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Return TRUE iff a unit of the given unit type can "exist" at this location.
bool is_city_channel_tile(const struct unit_class *punitclass, const struct tile *ptile, const struct tile *pexclude)
Check for a city channel.
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
This tile is native to unit.
bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype, const struct player *unit_owner, const struct tile *src_tile, const struct tile *dst_tile, const struct civ_map *zmap)
Returns whether the unit is allowed (by ZOC) to move from src_tile to dest_tile (assumed adjacent).
int utype_unknown_move_cost(const struct unit_type *utype)
This function calculates the movement cost to unknown tiles.
bool unit_can_load(const struct unit *punit)
Return whether we can find a suitable transporter for given unit at current location.
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Return true iff transporter has ability to transport transported.
int unit_move_rate(const struct unit *punit)
This function calculates the move rate of the unit.
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Return whether we could find a suitable transporter for given unit at 'ptile'.
bool can_attack_from_non_native(const struct unit_type *utype)
This unit can attack from non-native tiles (Marines can attack from transport, ships from harbour cit...
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_enemy_city)
Returns whether the unit can move from its current tile to the destination tile.
bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
Return TRUE iff the unit can be a defender at its current location.
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
This terrain is native to unit class.
int utype_move_rate(const struct unit_type *utype, const struct tile *ptile, const struct player *pplayer, int veteran_level, int hitpoints)
This function calculates the move rate of the unit, taking into account the penalty for reduced hitpo...
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "survive" at this location.
bool is_unit_being_refueled(const struct unit *punit)
Is unit being refueled in its current position.
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Is there native tile adjacent to given tile.
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Return TRUE iff transporter type has ability to transport transported class.
bool is_native_move(const struct unit_class *punitclass, const struct tile *src_tile, const struct tile *dst_tile)
Is the move under consideration a native move? Note that this function does not check for possible mo...
void init_move_fragments()
Call whenever terrain_control.move_fragments / SINGLE_MOVE changes.
bool can_attack_non_native(const struct unit_type *utype)
This unit can attack non-native tiles (eg.
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, struct unit *embark_to, bool enter_enemy_city)
Returns whether the unit can move from its current tile to the destination tile.
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
@ MR_NO_TRANSPORTER_CAPACITY
bool player_can_invade_tile(const struct player *pplayer, const struct tile *ptile)
Return TRUE iff the player can invade a particular tile (linked with borders and diplomatic states).
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players have peace, cease-fire, or armistice.
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Check if road provides effect.
struct packet_game_info info
enum barbarian_type barbarian_type
struct player_ai ai_common
enum road_move_mode move_mode
struct extra_type_list * integrators
bv_unit_classes native_to
const struct unit_type * animal
struct unit_class::@81 cache
struct extra_type_list * native_tile_extras
enum unit_activity activity
struct unit * transporter
const struct unit_type * utype
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
#define terrain_has_flag(terr, flag)
bool tile_has_refuel_extra(const struct tile *ptile, const struct unit_type *punittype)
Check if tile contains refuel extra native for unit.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_terrain(_tile)
static const bv_extras * tile_extras(const struct tile *ptile)
#define tile_has_extra(ptile, pextra)
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Takes into account unit class flag UCF_ZOC as well as IGZOC.
bool is_my_zoc(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
Is this square controlled by the pplayer?
bool is_losing_hp(const struct unit *punit)
Does unit lose hitpoints each turn?
struct unit * is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Returns true if the tile contains an allied unit and only allied units.
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit could be loaded into the transporter if we moved there.
bool can_unit_alight_or_be_unloaded(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit can leave its current transporter without doing any other action or mo...
struct unit * is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an unit we have peace or ceasefire with on this tile?
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit can be unloaded from its current transporter.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool utype_can_do_act_when_ustate(const struct unit_type *punit_type, const action_id act_id, const enum ustate_prop prop, const bool is_there)
Return TRUE iff the unit type can do the specified (action enabler controlled) action while its unit ...
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Return TRUE iff units of the given type can do any enabler controlled action with the specified actio...
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Return veteran level properties of given unit in given veterancy level.
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define uclass_index(_c_)