Freeciv-3.3
|
#include "astring.h"
#include "bitvector.h"
#include "fcintl.h"
#include "mem.h"
#include "shared.h"
#include "support.h"
#include "ai.h"
#include "actions.h"
#include "base.h"
#include "city.h"
#include "game.h"
#include "log.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "player.h"
#include "road.h"
#include "tech.h"
#include "traderoutes.h"
#include "unitlist.h"
#include "unit.h"
Go to the source code of this file.
Data Structures | |
struct | cargo_iter |
Macros | |
#define | CARGO_ITER(iter) ((struct cargo_iter *) (iter)) |
#define | RETURN_IS_ACTIVITY_ENABLED_UNIT_ON(paction) |
Variables | |
const Activity_type_id | tile_changing_activities [] |
enum gen_action activity_default_action | ( | enum unit_activity | act | ) |
Action that matches activity. Currently dummy placeholder.
Definition at line 2930 of file unit.c.
Referenced by adv_follow_path(), auto_worker_setup_work(), compat_load_030300(), dai_manage_military(), dai_military_findjob(), handle_unit_change_activity(), set_unit_activity_base(), set_unit_activity_road(), and sg_load_player_unit().
bool activity_requires_target | ( | enum unit_activity | activity | ) |
Return TRUE if activity requires some sort of target to be specified.
Definition at line 590 of file unit.c.
Referenced by auto_worker_setup_work(), do_action_activity(), do_action_activity_targeted(), set_unit_activity(), set_unit_activity_targeted(), total_activity(), unit_activity_handling_targeted(), unit_activity_needs_target_from_client(), unit_activity_targeted_internal(), and worker_task_is_sane().
bool are_unit_orders_equal | ( | const struct unit_order * | order1, |
const struct unit_order * | order2 | ||
) |
Checks unit orders for equality.
Definition at line 59 of file unit.c.
Referenced by send_packet_city_rally_point_100(), send_packet_unit_info_100(), and send_packet_unit_orders_100().
|
static |
Helper for transporter_for_unit() and transporter_for_unit_at()
Definition at line 1830 of file unit.c.
Referenced by transporter_for_unit(), and transporter_for_unit_at().
|
static |
Check if unit of given type would be able to transport all of transport's cargo.
Definition at line 1969 of file unit.c.
Referenced by unit_transform_result().
Return TRUE iff the unit can change homecity at its current location.
Definition at line 505 of file unit.c.
Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().
bool can_unit_change_homecity_to | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
const struct city * | pcity | ||
) |
Return TRUE iff the unit can change homecity to the given city.
Definition at line 489 of file unit.c.
Referenced by can_unit_change_homecity(), create_unit_menu(), present_unit_callback(), and unit_actions::update_actions().
Check if the unit's current activity is actually legal.
Definition at line 865 of file unit.c.
Referenced by create_city(), sg_load_players(), sg_load_players(), transform_unit(), unit_activities_cancel_all_illegal_plr(), unit_activities_cancel_all_illegal_tile(), and unit_change_homecity_handling().
bool can_unit_deboard_or_be_unloaded | ( | const struct civ_map * | nmap, |
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 move.
Definition at line 801 of file unit.c.
Referenced by unit_can_defend_here().
bool can_unit_do_activity | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
enum unit_activity | activity | ||
) |
Return TRUE iff the unit can do the given untargeted activity at its current location.
Note that some activities must be targeted; see can_unit_do_activity_targeted().
Definition at line 892 of file unit.c.
Referenced by can_units_do_activity(), dai_military_findjob(), execute_orders(), handle_unit_sscs_set(), place_partisans(), unit_activity_handling(), unit_activity_internal(), and unit_server_side_agent_set().
bool can_unit_do_activity_targeted | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
enum unit_activity | activity, | ||
struct extra_type * | target | ||
) |
Return whether the unit can do the targeted activity at its current location.
Definition at line 931 of file unit.c.
Referenced by can_unit_continue_current_activity(), can_unit_do_activity(), can_units_do_activity_targeted(), unit_activity_handling_targeted(), unit_activity_targeted_internal(), and unit_assign_specific_activity_target().
bool can_unit_do_activity_targeted_at | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
enum unit_activity | activity, | ||
struct extra_type * | target, | ||
const struct tile * | ptile | ||
) |
Return TRUE if the unit can do the targeted activity at the given location.
Definition at line 944 of file unit.c.
Referenced by can_unit_do_activity_targeted().
Return whether the unit can be put in auto-worker mode.
NOTE: we used to have "auto" mode including autoworker and auto-attack. This was bad because the two were indestinguishable even though they are very different. Now auto-attack is done differently so we just have auto-worker. If any new auto modes are introduced they should be handled separately.
Definition at line 630 of file unit.c.
Referenced by key_unit_auto_work(), mr_menu::menus_sensitive(), real_menus_update(), request_unit_autoworker(), unit_server_side_agent_set(), and unit_actions::update_actions().
Return TRUE iff the given unit can be loaded into the transporter.
Definition at line 749 of file unit.c.
Referenced by dai_unit_new_task(), transporter_for_unit(), and unit_transport_load().
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airbase special, has enough movepoints left, and has not paradropped yet this turn.
Definition at line 846 of file unit.c.
Referenced by dai_manage_paratrooper(), mr_menu::menus_sensitive(), popup_advanced_terrain_dialog(), real_menus_update(), request_unit_paradrop(), mr_menu::slot_paradrop(), and unit_actions::update_actions().
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airbase special, has enough movepoints left, and has not paradropped yet this turn.
Definition at line 830 of file unit.c.
Referenced by real_menus_update(), and request_unit_teleport().
Return TRUE iff the given unit can be unloaded from its current transporter.
This function checks everything except the legality of the position after the unloading. The caller may also want to call can_unit_exist_at_tile() to check this, unless the unit is unloading and moving at the same time.
Definition at line 776 of file unit.c.
Referenced by action_hard_reqs_actor(), actres_possible(), create_unit_menu(), present_unit_callback(), request_unit_unload(), unit_can_load(), unit_move_to_tile_test(), units_can_unload(), unit_actions::update_actions(), and wipe_unit_full().
Get the unit of the cargo iterator.
Definition at line 2649 of file unit.c.
Referenced by cargo_iter_init(), and cargo_iter_next().
Initialize the cargo iterator.
Definition at line 2701 of file unit.c.
Referenced by unit_cargo_depth().
Try to find next unit for the cargo iterator.
Definition at line 2659 of file unit.c.
Referenced by cargo_iter_init().
Return whether the iterator is still valid.
Definition at line 2693 of file unit.c.
Referenced by cargo_iter_init().
Tells whether pcargo could possibly be in ptrans, disregarding unit positions and ownership and load actions possibility, but regarding number and types of their current cargo. pcargo and ptrans must be valid unit pointers, pcargo not loaded anywhere
Definition at line 692 of file unit.c.
Referenced by api_edit_create_unit_full(), and could_unit_load().
Return TRUE iff the given unit could be loaded into the transporter if we moved there.
Definition at line 724 of file unit.c.
Referenced by actres_possible(), can_unit_load(), qtg_request_transport(), request_transport(), request_unit_load(), transporter_for_unit_at(), unit_can_load(), unit_could_load_at(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().
struct unit_order * create_unit_orders | ( | const struct civ_map * | nmap, |
int | length, | ||
const struct unit_order * | orders | ||
) |
Sanity-check unit order arrays from a packet and create a unit_order array from their contents if valid.
Definition at line 2911 of file unit.c.
Referenced by city_rally_point_receive(), and handle_unit_orders().
Free and reset the unit's goto route (punit->pgr). Only used by the server.
Definition at line 1806 of file unit.c.
Referenced by cancel_orders(), execute_orders(), handle_unit_orders(), player_restore_units(), sg_load_player_unit(), sg_load_player_unit(), sg_load_sanitycheck(), sg_load_sanitycheck(), teleport_unit_to_city(), unit_activities_cancel(), unit_activity_handling(), unit_activity_handling_targeted(), unit_move_by_data(), unit_plans_clear(), unit_virtual_destroy(), and upgrade_unit_order_targets().
Returns the speed of a unit doing an activity. This depends on the veteran level and the base move_rate of the unit (regardless of HP or effects). Usually this is just used for settlers but the value is also used for military units doing fortify/pillage activities.
The speed is multiplied by ACTIVITY_FACTOR.
Definition at line 519 of file unit.c.
Referenced by calc_activity(), get_activity_rate_this_turn(), get_turns_for_activity_at(), and goto_fill_parameter_full().
Returns the amount of work a unit does (will do) on an activity this turn. Units that have no MP do no work.
The speed is multiplied by ACTIVITY_FACTOR.
Definition at line 550 of file unit.c.
Referenced by calc_activity(), and update_unit_activity().
const char * get_activity_text | ( | enum unit_activity | activity | ) |
Return the name of the activity in a static buffer.
Definition at line 638 of file unit.c.
Referenced by concat_tile_activity_text(), contemplate_terrain_improvements(), real_unit_log(), unit_activity_astr(), usdlg_tab_append_activity(), and worker_evaluate_improvements().
Return the number of units the transporter can hold (or 0).
Definition at line 297 of file unit.c.
Referenced by actres_possible(), adv_data_phase_init(), could_unit_be_in_transport(), dai_hunter_manage(), dai_manage_barbarian_leader(), find_visible_unit(), look_for_charge(), quickselect(), request_unit_unload_all(), hud_unit_loader::show_me(), and try_summon_barbarians().
Return how many units are in the transport.
Definition at line 1820 of file unit.c.
Referenced by bounce_unit(), can_type_transport_units_cargo(), client_remove_unit(), could_unit_be_in_transport(), do_map_click(), expl_act_not_enabl(), is_unitstate_req_active(), package_short_unit(), package_unit(), hud_unit_loader::show_me(), terrain_change_bounce_single_unit(), test_unit_can_airlift_to(), throw_units_from_illegal_cities(), unit_transport_load_tp_status(), units_are_occupied(), usdlg_tab_append_units(), and wipe_unit_full().
int get_turns_for_activity_at | ( | const struct unit * | punit, |
enum unit_activity | activity, | ||
const struct tile * | ptile, | ||
struct extra_type * | tgt | ||
) |
Return the estimated number of turns for the worker unit to start and complete the activity at the given location. This assumes no other worker units are helping out, and doesn't take account of any work already done by this unit.
Definition at line 566 of file unit.c.
Referenced by worker_evaluate_improvements().
Return a mask of the extras which are actively (currently) being pillaged on the given tile.
Definition at line 1167 of file unit.c.
Referenced by actres_possible().
Returns how many hp's a unit will gain standing still on current tile.
Definition at line 2199 of file unit.c.
Referenced by dai_find_strategic_airbase(), regen_turns(), and unit_gain_hitpoints().
Is the unit capable of attacking?
Definition at line 305 of file unit.c.
Referenced by can_units_attack_at(), and unit_being_aggressive().
bool is_build_activity | ( | enum unit_activity | activity | ) |
Returns true if given activity builds an extra.
Definition at line 1596 of file unit.c.
Referenced by calc_activity(), can_unit_do_activity_targeted_at(), concat_tile_activity_text(), is_targeted_activity(), is_tile_activity(), and turns_to_activity_done().
bool is_clean_activity | ( | enum unit_activity | activity | ) |
Returns true if given activity is some kind of cleaning.
Definition at line 1612 of file unit.c.
Referenced by calc_activity(), concat_tile_activity_text(), is_targeted_activity(), is_tile_activity(), and turns_to_activity_done().
Can this unit enter peaceful borders?
Definition at line 332 of file unit.c.
Referenced by notify_illegal_armistice_units(), and remove_illegal_armistice_units().
This checks the "field unit" flag on the unit. Field units cause unhappiness (under certain governments) even when they aren't abroad.
Definition at line 438 of file unit.c.
Referenced by city_unit_unhappiness(), and resolve_city_emergency().
Does player see flag of the unit?
punit | Unit to check flag for |
pplayer | Player whose vision we're interested about, or nullptr for global observer. |
Definition at line 363 of file unit.c.
Referenced by do_attack(), fill_sprite_array(), fill_unit_sprite_array(), popup_info_text(), and tile_non_allied_unit().
Does it make sense for this unit to protect others?
Definition at line 340 of file unit.c.
Referenced by adv_worker_safe_tile(), and has_defense().
Is the unit one that is invisible on the map. A unit is invisible if it's vision layer is either V_INVIS or V_SUBSURFACE, or if it's transported by such unit.
FIXME: Should the transports recurse all the way?
Definition at line 450 of file unit.c.
Referenced by can_player_see_unit_at().
Does unit lose hitpoints each turn?
Definition at line 2265 of file unit.c.
Referenced by can_unit_do_activity_targeted_at(), can_unit_survive_at_tile(), dai_fill_unit_param(), and dai_manage_unit().
Is unit capable of enforcing martial law?
Definition at line 316 of file unit.c.
Referenced by city_support().
Does unit occupy the tile?
Definition at line 324 of file unit.c.
Referenced by unit_occupies_tile().
bool is_plr_zoc_client | ( | const struct player * | pplayer, |
const struct tile * | ptile0, | ||
const struct civ_map * | zmap | ||
) |
Is this square controlled by the pplayer? Function to be used on client side only.
Here "plr zoc" means essentially a square which is not adjacent to an enemy unit (that has a ZOC) on a terrain that has zoc rules.
Since this function is used in the client, it has to deal with some client-specific features, like FoW and the fact that the client cannot see units inside enemy cities.
Definition at line 1493 of file unit.c.
Referenced by is_my_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), and pft_fill_parameter().
bool is_plr_zoc_srv | ( | const struct player * | pplayer, |
const struct tile * | ptile0, | ||
const struct civ_map * | zmap | ||
) |
Is this square controlled by the pplayer? Function to be used on server side only.
Here "plr zoc" means essentially a square which is not adjacent to an enemy unit (that has a ZOC) on a terrain that has zoc rules.
Definition at line 1424 of file unit.c.
Referenced by is_my_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), pft_fill_parameter(), and stack_risk().
Does it make sense to use this unit for some special role?
If yes, don't waste it as cannon fodder.
Definition at line 350 of file unit.c.
Referenced by base_assess_defense_unit(), calc_civ_score(), dai_manage_unit(), get_munits(), kill_something_with(), and quickselect().
bool is_square_threatened | ( | const struct civ_map * | nmap, |
const struct player * | pplayer, | ||
const struct tile * | ptile, | ||
bool | omniscient | ||
) |
Return TRUE iff this tile is threatened from any unit within 2 tiles.
Definition at line 412 of file unit.c.
Referenced by adv_worker_safe_tile().
bool is_targeted_activity | ( | enum unit_activity | activity | ) |
Returns true if given activity requires target
Definition at line 1651 of file unit.c.
Referenced by get_turns_for_activity_at(), and tile_activity_time().
bool is_terrain_change_activity | ( | enum unit_activity | activity | ) |
Returns true if given activity changes terrain.
Definition at line 1626 of file unit.c.
Referenced by is_tile_activity().
bool is_tile_activity | ( | enum unit_activity | activity | ) |
Returns true if given activity affects tile.
Definition at line 1641 of file unit.c.
Referenced by concat_tile_activity_text().
Return whether any units on the tile are doing this activity.
Definition at line 1151 of file unit.c.
Referenced by real_menus_update(), and units_have_activity_on_tile().
void set_unit_activity | ( | struct unit * | punit, |
enum unit_activity | new_activity, | ||
enum gen_action | trigger_action | ||
) |
Assign a new untargeted task to a unit.
Definition at line 1114 of file unit.c.
Referenced by auto_worker_findwork(), check_unit_activity(), dai_auto_settler_run(), execute_orders(), sg_load_player_unit(), sg_load_player_unit(), unit_activities_cancel(), unit_activity_dependencies(), unit_activity_internal(), unit_move(), unit_restore_hitpoints(), unit_virtual_create(), update_unit_activity(), wakeup_neighbor_sentries(), and wipe_unit_full().
|
static |
Assign a new task to a unit. Doesn't account for changed_from.
Definition at line 1097 of file unit.c.
Referenced by set_unit_activity(), and set_unit_activity_targeted().
void set_unit_activity_targeted | ( | struct unit * | punit, |
enum unit_activity | new_activity, | ||
struct extra_type * | new_target, | ||
enum gen_action | trigger_action | ||
) |
assign a new targeted task to a unit.
Definition at line 1132 of file unit.c.
Referenced by set_unit_activity_base(), set_unit_activity_road(), sg_load_player_unit(), sg_load_player_unit(), and unit_activity_targeted_internal().
int stack_bribe_cost | ( | const struct tile * | ptile, |
const struct player * | briber, | ||
const struct unit * | briber_unit | ||
) |
Calculate how expensive it is to bribe entire unit stack.
ptile | Tile to bribe units from |
briber | Player that wants to bribe |
briber_unit | Unit that does the bribing |
Definition at line 2432 of file unit.c.
Referenced by diplomat_bribe_stack(), and handle_unit_action_query().
enum unit_airlift_result test_unit_can_airlift_to | ( | const struct civ_map * | nmap, |
const struct player * | restriction, | ||
const struct unit * | punit, | ||
const struct city * | pdest_city | ||
) |
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now. If pdest_city is NULL, just indicate whether it's possible for the unit to be airlifted at all from its current position. The 'restriction' parameter specifies which player's knowledge this is based on – one player can't see whether another's cities are currently able to airlift. (Clients other than global observers should only call this with a non-NULL 'restriction'.)
Definition at line 81 of file unit.c.
Referenced by actres_possible(), expl_act_not_enabl(), and get_airlift_text().
Returns one of the units, if the tile contains an allied unit and only allied units. Returns NULL if there is no units, or some of them are not allied. (ie, if your nation A is allied with B, and B is allied with C, a tile containing units from B and C will return NULL)
Definition at line 1297 of file unit.c.
Referenced by is_allied_unit_tile().
Is there an enemy unit on this tile? Returns the unit or NULL if none.
This function is likely to fail if used at the client because the client doesn't see all units. (Maybe it should be moved into the server code.)
Definition at line 1320 of file unit.c.
Referenced by is_enemy_unit_tile().
struct unit * tile_non_allied_unit | ( | const struct tile * | ptile, |
const struct player * | pplayer, | ||
bool | everyone_non_allied | ||
) |
Return one of the non-allied units on the tile, if there is any
Definition at line 1335 of file unit.c.
Referenced by is_non_allied_unit_tile(), and maybe_cancel_patrol_due_to_enemy().
Return an unit we have peace or ceasefire with on this tile, if any exist.
Definition at line 1376 of file unit.c.
Referenced by is_non_attack_unit_tile().
Return an unit belonging to any other player, if there are any on the tile.
Definition at line 1360 of file unit.c.
Referenced by dai_diplomat_bribe_nearby(), and is_other_players_unit_tile().
Find the best transporter at the given location for the unit. See also unit_can_load() to test if there will be transport might be suitable for 'pcargo'.
Definition at line 1949 of file unit.c.
Referenced by api_find_transport_unit(), player_restore_units(), request_unit_load(), try_to_save_unit(), and unit_move().
Find the best transporter at the given location for the unit. See also unit_could_load_at() to test if there will be transport might be suitable for 'pcargo'.
Definition at line 1959 of file unit.c.
Referenced by adv_unit_move(), dai_unit_attack(), dai_unit_move(), fill_parameter_part(), qtg_request_transport(), remove_city(), request_transport(), and unit_move_handling().
Append text describing the unit's current activity to the given astring.
Definition at line 1184 of file unit.c.
Referenced by create_present_supported_units_widget_list(), get_unit_info_label_text2(), units_select::paint(), popup_advanced_terrain_dialog(), redraw_unit_info_label(), unit_description(), and unit_select_dialog_popup().
Return pointer to ai data of given unit and ai type.
Definition at line 2319 of file unit.c.
Referenced by def_ai_unit_data().
An "aggressive" unit is a unit which may cause unhappiness under a Republic or Democracy. A unit is not aggressive if one or more of following is true:
Definition at line 1555 of file unit.c.
Referenced by city_unit_unhappiness(), and resolve_city_emergency().
int unit_bribe_cost | ( | const struct unit * | punit, |
const struct player * | briber, | ||
const struct unit * | briber_unit | ||
) |
Calculate how expensive it is to bribe the unit. The cost depends on the distance to the capital, the owner's treasury, and the build cost of the unit. For a damaged unit the price is reduced. For a veteran unit, it is increased.
punit | Unit to bribe |
briber | Player that wants to bribe |
briber_unit | Unit that does the bribing |
Definition at line 2344 of file unit.c.
Referenced by dai_diplomat_bribe_nearby(), diplomat_bribe_unit(), handle_unit_action_query(), popup_info_text(), and stack_bribe_cost().
Return TRUE iff this unit can add to a current city or build a new city at its current location.
Definition at line 472 of file unit.c.
Referenced by build_city_callback(), build_city_callback(), mr_menu::menus_sensitive(), real_menus_update(), mr_menu::slot_build_city(), and unit_actions::update_actions().
bool unit_can_airlift_to | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
const struct city * | pdest_city | ||
) |
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now. On the server this gives correct information; on the client it errs on the side of saying airlifting is possible even if it's not certain given player knowledge.
Definition at line 186 of file unit.c.
Referenced by goto_dialog::airlift_to(), dai_airlift(), goto_cmd_callback(), goto_dialog::item_selected(), and refresh_airlift_button().
Tests if unit can be converted to another type.
Definition at line 2072 of file unit.c.
Referenced by action_hard_reqs_actor(), real_menus_update(), unit_convert(), and units_can_convert().
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlled action.
Definition at line 383 of file unit.c.
Referenced by action_prob_self_full(), action_prob_vs_city_full(), action_prob_vs_extras_full(), action_prob_vs_stack_full(), action_prob_vs_tile_full(), action_prob_vs_unit_full(), adv_data_phase_init(), assess_danger(), caravan_parameter_init_from_unit(), compat_post_load_030100(), count_my_units(), unit_item::create_actions(), create_unit_menu(), dai_choose_help_wonder(), dai_choose_trade_route(), dai_manage_caravan(), dai_manage_unit(), disband_box::disband_clicked(), expl_act_not_enabl(), find_city_or_settler_near_tile(), get_settlers(), get_units_disband_info(), is_action_enabled_unit_on_city_full(), is_action_enabled_unit_on_extras_full(), is_action_enabled_unit_on_self_full(), is_action_enabled_unit_on_stack_full(), is_action_enabled_unit_on_tile_full(), is_action_enabled_unit_on_unit_full(), key_unit_build_wonder(), key_unit_trade_route(), need_war_player_hlp(), popup_bribe_stack_dialog(), popup_bribe_unit_dialog(), popup_disband_dialog(), popup_incite_dialog(), present_unit_callback(), real_menus_update(), request_unit_goto(), supported_unit_callback(), test_unit_can_airlift_to(), unit_do_disband_trad(), units_can_do_action(), units_contain_cityfounder(), unit_actions::update_actions(), and windfall_benefit().
Return TRUE iff this unit can do any enabler controlled action with the specified action result.
Definition at line 393 of file unit.c.
Referenced by dai_diplomat_bribe_nearby(), dai_manage_unit(), is_attack_unit(), unit_can_displace_hut(), unit_can_enter_hut(), and units_can_do_action_with_result().
Return TRUE iff this unit can do any enabler controlled action with the specified action sub result.
Definition at line 403 of file unit.c.
Referenced by unit_can_displace_hut(), and unit_can_enter_hut().
Return TRUE iff this unit can be disbanded at its current location to provide a trade route from the homecity to the target city.
Definition at line 284 of file unit.c.
Referenced by build_road_callback(), build_road_callback(), mr_menu::menus_sensitive(), real_menus_update(), and mr_menu::slot_build_road().
Return TRUE unless it is known to be impossible to disband this unit at its current position to get full shields for building a wonder.
Definition at line 258 of file unit.c.
Referenced by mr_menu::menus_sensitive(), and real_menus_update().
Returns the number of unit cargo layers within transport 'ptrans'.
Definition at line 2610 of file unit.c.
Referenced by could_unit_be_in_transport(), and pft_fill_unit_default_parameter().
Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.
Definition at line 2597 of file unit.c.
Referenced by actres_possible(), and mr_menu::find_last_unit_pos().
How many hitpoints does unit recover?
Definition at line 2220 of file unit.c.
Referenced by dai_manage_hitpoint_recovery(), and unit_restore_hitpoints().
Return TRUE iff the unit is following client-side orders.
Definition at line 202 of file unit.c.
Referenced by api_edit_unit_movepoints(), auto_workers_player(), base_transporter_for_unit(), clear_unit_orders(), dai_manage_unit(), dai_unit_new_task(), do_move_unit(), execute_orders(), execute_unit_orders(), fill_unit_sprite_array(), find_best_focus_candidate(), handle_unit_orders(), is_possible_base_fuel(), mapdeco_set_gotoroute(), pf_get_move_scope(), pf_transport_check(), fc_client::popup_tile_info(), unit_activities_cancel(), unit_drawn_with_city_outline(), unit_focus_advance(), unit_focus_update(), unit_move(), upgrade_unit_order_targets(), and wakeup_neighbor_sentries().
Check if unit with given id is still alive. Use this before using old unit pointers when unit might have died.
Definition at line 2290 of file unit.c.
Referenced by action_auto_perf_unit_do(), action_success_actor_consume(), action_success_pay_mp(), action_success_target_pay_mp(), check_units_single_tile(), city_create_unit(), diplomat_bribe_stack(), diplomat_bribe_unit(), do_attack(), do_capture_units(), do_wipe_units(), occupy_move(), random_movements(), spy_attack(), unit_change_owner(), unit_do_disband_trad(), unit_enter_hut(), unit_move(), unit_move_consequences(), and upkeep_kill_unit().
Is a cityfounder unit?
Definition at line 2718 of file unit.c.
Referenced by auto_worker_findwork(), auto_workers_player(), citymap_turn_init(), dai_auto_settler_run(), dai_fill_unit_param(), dai_manage_unit(), dai_war_desire(), end_turn(), and unit_drawn_with_city_outline().
Return TRUE if this is a valid unit pointer but does not correspond to any unit that exists in the game.
NB: A return value of FALSE implies that either the pointer is NULL or that the unit exists in the game.
Definition at line 2307 of file unit.c.
Referenced by tile_virtual_destroy().
Return the nationality of the unit.
Definition at line 1274 of file unit.c.
Referenced by city_add_unit(), city_build(), do_heal_unit(), get_unit_info_label_text2(), package_unit(), player_clear(), popup_info_text(), sg_save_player_units(), and unit_description().
Is there an occupying unit on this tile?
Intended for both client and server; assumes that hiding units are not sent to client. First check tile for known and seen.
Called by city_can_work_tile().
Definition at line 1397 of file unit.c.
Referenced by base_city_can_work_tile().
bool unit_order_list_is_sane | ( | const struct civ_map * | nmap, |
int | length, | ||
const struct unit_order * | orders | ||
) |
Returns TRUE iff the unit order array is sane.
Definition at line 2726 of file unit.c.
Referenced by create_unit_orders(), sg_load_sanitycheck(), and sg_load_sanitycheck().
Returns the amount of movement points successfully performing the specified action will consume in the actor unit.
Definition at line 2172 of file unit.c.
Referenced by action_success_pay_mp(), adv_unit_move(), dai_action_value_unit_vs_city(), and dai_unit_move().
Attach ai data to unit
Definition at line 2327 of file unit.c.
Referenced by dai_unit_close(), and dai_unit_init().
int unit_shield_value | ( | const struct unit * | punit, |
const struct unit_type * | punittype, | ||
const struct action * | paction | ||
) |
Returns how many shields the unit (type) is worth.
punit | the unit. Can be NULL if punittype is set. |
punittype | the unit's type. Can be NULL iff punit is set. |
paction | the action the unit does when valued. |
Definition at line 214 of file unit.c.
Referenced by city_gold_worth(), unit_do_help_build(), and unit_upgrade_price().
Set the tile location of the unit. Tile can be NULL (for transported units).
Definition at line 1284 of file unit.c.
Referenced by api_find_transport_unit(), calculate_city_clusters(), contemplate_new_city(), contemplate_terrain_improvements(), dai_find_strategic_airbase(), do_move_unit(), find_best_city_placement(), get_virtual_defense_power(), sg_load_player_unit(), sg_load_player_unit(), texai_unit_info_recv(), texai_unit_moved_recv(), unit_move_by_data(), unit_virtual_create(), unit_virtual_prepare(), unpackage_short_unit(), and unpackage_unit().
enum unit_upgrade_result unit_transform_result | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
const struct unit_type * | to_unittype | ||
) |
Tests if something prevents punit from being transformed to to_unittype where it is now, presuming its current position is valid.
FIXME: The transport stack may still fail unit_transport_check() in result.
Definition at line 1993 of file unit.c.
Referenced by api_methods_unit_transform_problem(), unit_can_convert(), unit_upgrade_test(), and ur_transform_unit().
Returns the list of cargo units.
Definition at line 2528 of file unit.c.
Referenced by bounce_unit(), cargo_iter_init(), cargo_iter_next(), client_remove_unit(), handle_unit_remove(), player_clear(), terrain_change_bounce_single_unit(), throw_units_from_illegal_cities(), usdlg_tab_append_units(), and wipe_unit_full().
Returns whether 'pcargo' in 'ptrans' is a valid transport. Note that 'pcargo' can already be (but doesn't need) loaded into 'ptrans'.
It may fail if one of the cargo unit has the same type of one of the transporter unit or if one of the cargo unit can transport one of the transporters.
Definition at line 2556 of file unit.c.
Referenced by could_unit_be_in_transport().
|
inlinestatic |
Helper for unit_transport_check().
Definition at line 2540 of file unit.c.
Referenced by unit_transport_check().
Returns the number of unit transport layers which carry unit 'pcargo'.
Definition at line 2628 of file unit.c.
Referenced by base_transporter_for_unit(), could_unit_be_in_transport(), and pf_transport_check().
Returns the transporter of the unit or NULL if it is not transported.
Definition at line 2518 of file unit.c.
Referenced by action_hard_reqs_actor(), actres_possible(), assess_danger_unit(), can_unit_deboard_or_be_unloaded(), can_unit_move_to_tile_with_notify(), can_unit_unload(), compare_units(), create_unit_menu(), dai_hunter_try_launch(), dai_manage_units(), dai_military_attack_barbarian(), explain_why_no_action_enabled(), find_something_to_kill(), handle_unit_packet_common(), handle_unit_remove(), illegal_action_msg(), is_hiding_unit(), package_short_unit(), package_unit(), pft_fill_unit_default_parameter(), place_unit(), present_unit_callback(), request_unit_unload(), request_unit_unload_all(), server_remove_unit_full(), sg_load_sanitycheck(), sg_load_sanitycheck(), sg_save_player_units(), throw_units_from_illegal_cities(), unit_can_defend_here(), unit_list_compare(), unit_move(), unit_move_to_tile_test(), unit_transport_unload(), unit_transport_unload_send(), units_can_unload(), unit_actions::update_actions(), usdlg_get_unit_descr(), and wipe_unit_full().
Load pcargo onto ptrans. Returns TRUE on success.
Definition at line 2447 of file unit.c.
Referenced by dai_military_attack_barbarian(), handle_unit_packet_common(), sg_load_player_units_transport(), sg_load_player_units_transport(), unit_transport_load_send(), and unit_transport_load_tp_status().
Unload pcargo from ptrans. Returns TRUE on success.
Definition at line 2467 of file unit.c.
Referenced by client_remove_unit(), do_unit_board(), do_unit_embark(), do_unit_load(), handle_unit_packet_common(), handle_unit_remove(), player_clear(), server_remove_unit_full(), unit_move(), unit_transport_unload_send(), unit_virtual_destroy(), and wipe_unit_full().
Returns TRUE iff the unit is transported.
Definition at line 2502 of file unit.c.
Referenced by action_hard_reqs_actor(), actres_possible(), api_edit_unit_move(), api_edit_unit_teleport(), assess_danger_unit(), can_player_see_unit(), can_unit_do_activity_targeted_at(), can_unit_load(), check_units_single_tile(), dai_caravan_goto(), dai_gothere(), dai_hunter_try_launch(), dai_is_unit_tired_waiting_boat(), dai_manage_units(), dai_military_attack_barbarian(), dai_unit_new_task(), do_attack(), do_move_unit(), do_paradrop(), do_unit_board(), do_unit_embark(), do_unit_load(), editor_grab_tool(), expl_act_not_enabl(), fill_unit_sprite_array(), find_visible_unit(), get_units_seen_via_ally(), handle_unit_packet_common(), is_hiding_unit(), is_unit_being_refueled(), package_short_unit(), package_unit(), server_remove_unit(), unit_attack_all_at_tile_result(), unit_attack_any_at_tile_result(), unit_can_load(), unit_gain_hitpoints(), unit_move(), unit_move_by_data(), unit_move_to_tile_test(), unit_transport_unload(), unit_virtual_destroy(), units_can_unload(), unit_actions::update_actions(), usdlg_data_new(), wakeup_neighbor_sentries(), and wipe_unit().
Does unit lose hitpoints each turn?
Definition at line 2277 of file unit.c.
Referenced by dai_choose_attacker_air().
Takes into account unit class flag UCF_ZOC as well as IGZOC
Definition at line 1541 of file unit.c.
Referenced by can_step_taken_wrt_to_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), and pft_fill_parameter().
enum unit_upgrade_result unit_upgrade_info | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
char * | buf, | ||
size_t | bufsz | ||
) |
Find the result of trying to upgrade the unit, and a message that most callers can use directly.
Definition at line 2088 of file unit.c.
Referenced by get_units_upgrade_info(), and popup_unit_upgrade_dlg().
enum unit_upgrade_result unit_upgrade_test | ( | const struct civ_map * | nmap, |
const struct unit * | punit, | ||
bool | is_free | ||
) |
Tests if the unit could be updated. Returns UU_OK if is this is possible.
is_free should be set if the unit upgrade is "free" (e.g., Leonardo's). Otherwise money is needed and the unit must be in an owned city.
Note that this function is strongly tied to unittools.c:transform_unit().
Definition at line 2025 of file unit.c.
Referenced by actres_possible(), api_methods_unit_can_upgrade(), do_upgrade_effects(), expl_act_not_enabl(), get_units_upgrade_info(), handle_unit_type_upgrade(), unit_upgrade_info(), units_can_upgrade(), and unit_actions::update_actions().
Append a line of text describing the unit's upkeep to the astring.
NB: In the client it is assumed that this information is only available for units owned by the client's player; the caller must check this.
Definition at line 1260 of file unit.c.
Referenced by unit_description().
struct unit * unit_virtual_create | ( | struct player * | pplayer, |
struct city * | pcity, | ||
const struct unit_type * | punittype, | ||
int | veteran_level | ||
) |
Create a virtual unit skeleton. pcity can be nullptr, but then you need to set tile and homecity yourself.
Definition at line 1661 of file unit.c.
Referenced by api_find_transport_unit(), calculate_city_clusters(), contemplate_new_city(), contemplate_terrain_improvements(), dai_choose_attacker_air(), dai_choose_defender_versus(), dai_choose_diplomat_offensive(), dai_choose_paratrooper(), dai_find_strategic_airbase(), dai_unit_consider_bodyguard(), dai_wonder_city_distance(), decrease_unit_hp_smooth(), edit_buffer_copy(), editor_unit_virtual_create(), eval_hunter_want(), find_best_city_placement(), get_virtual_defense_power(), military_advisor_choose_build(), move_unit_map_canvas(), send_rally_tile(), sg_load_player_units(), sg_load_player_units(), sha_unit_new(), texai_city_worker_task_select(), texai_unit_info_recv(), unit_virtual_prepare(), unpackage_short_unit(), and unpackage_unit().
Free the memory used by virtual unit. By the time this function is called, you should already have unregistered it everywhere.
Definition at line 1766 of file unit.c.
Referenced by animations_free(), api_edit_create_unit_full(), api_find_transport_unit(), battle_animation(), calculate_city_clusters(), contemplate_new_city(), contemplate_terrain_improvements(), create_city_virtual(), create_unit_full(), dai_choose_attacker_air(), dai_choose_defender_versus(), dai_choose_diplomat_offensive(), dai_choose_paratrooper(), dai_find_strategic_airbase(), dai_unit_consider_bodyguard(), dai_wonder_city_distance(), eval_hunter_want(), find_best_city_placement(), game_remove_unit(), get_virtual_defense_power(), handle_investigate_started(), handle_unit_info(), handle_unit_short_info(), military_advisor_choose_build(), movement_animation(), send_rally_tile(), sg_load_player_units(), sg_load_player_units(), texai_city_worker_task_select(), texai_unit_destruction_recv(), tile_virtual_destroy(), and unit_change_owner().
const Activity_type_id tile_changing_activities[] |