Freeciv-3.3: /fast/freeciv/nightly/main/server/unithand.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
unithand.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "lua.h"`
`#include "astring.h"`
`#include "fcintl.h"`
`#include "mem.h"`
`#include "rand.h"`
`#include "shared.h"`
`#include "actions.h"`
`#include "ai.h"`
`#include "city.h"`
`#include "combat.h"`
`#include "events.h"`
`#include "featured_text.h"`
`#include "game.h"`
`#include "log.h"`
`#include "map.h"`
`#include "movement.h"`
`#include "packets.h"`
`#include "player.h"`
`#include "research.h"`
`#include "specialist.h"`
`#include "traderoutes.h"`
`#include "unit.h"`
`#include "unitlist.h"`
`#include "luascript_types.h"`
`#include "actiontools.h"`
`#include "barbarian.h"`
`#include "citizenshand.h"`
`#include "citytools.h"`
`#include "cityturn.h"`
`#include "diplomats.h"`
`#include "maphand.h"`
`#include "notify.h"`
`#include "plrhand.h"`
`#include "sanitycheck.h"`
`#include "spacerace.h"`
`#include "srv_main.h"`
`#include "techtools.h"`
`#include "unittools.h"`
`#include "autoexplorer.h"`
`#include "autoworkers.h"`
`#include "script_server.h"`
`#include "unithand.h"`

Go to the source code of this file.

## Data Structures

struct | ane_expl

## Macros

#define | ACTION_PERFORM_UNIT_CITY(action, actor, target, action_performer)
#define | ACTION_PERFORM_UNIT_SELF(action, actor, action_performer)
#define | ACTION_PERFORM_UNIT_UNIT(action, actor, target, action_performer)
#define | ACTION_PERFORM_UNIT_UNITS(action, actor, target, action_performer)
#define | ACTION_PERFORM_UNIT_TILE(action, actor, target, action_performer)
#define | ACTION_PERFORM_UNIT_EXTRAS(action, actor, target, action_performer)
#define | ACTION_PERFORM_UNIT_ANY(paction, actor, target_city, target_unit, target_tile, action_performer)

## Functions

static bool | unit_activity_internal (struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
static bool | unit_activity_targeted_internal (struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target, enum gen_action trigger_action)
static void | illegal_action (struct player *pplayer, struct unit *actor, action_id stopped_action, struct player *tgt_player, struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, int request_kind, const enum action_requester requester)
static bool | city_add_unit (struct player *pplayer, struct unit *punit, struct city *pcity, const struct action *paction)
static bool | city_build (struct player *pplayer, struct unit *punit, struct tile *ptile, const char *name, const struct action *paction)
static bool | do_unit_establish_trade (struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction)
static bool | unit_do_help_build (struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction)
static bool | unit_do_regular_move (struct player *actor_player, struct unit *actor_unit, struct tile *target_tile, const struct action *paction)
static bool | unit_bombard (struct unit *punit, struct tile *ptile, const struct action *paction)
static bool | unit_nuke (struct player *pplayer, struct unit *punit, struct tile *def_tile, const struct action *paction)
static bool | unit_do_destroy_city (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
static bool | do_unit_change_homecity (struct unit *punit, struct city *pcity, const struct action *paction)
static bool | do_attack (struct unit *actor_unit, struct tile *target_tile, const struct action *paction)
static bool | do_unit_strike_city_production (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
static bool | do_unit_strike_city_building (struct player *act_player, struct unit *act_unit, struct city *tgt_city, Impr_type_id tgt_bld_id, const struct action *paction)
static bool | do_unit_conquer_city (struct player *act_player, struct unit *act_unit, struct city *tgt_city, struct action *paction)
static bool | do_action_activity (struct unit *punit, const struct action *paction)
static bool | do_action_activity_targeted (struct unit *punit, const struct action *paction, struct extra_type **new_target)
static bool | non_allied_not_listed_at (const struct player *pplayer, const int *list, int n, const struct tile *ptile)
void | handle_unit_type_upgrade (struct player *pplayer, Unit_type_id uti)
static bool | do_unit_upgrade (struct player *pplayer, struct unit *punit, struct city *pcity, enum action_requester ordered_by, const struct action *paction)
static bool | do_capture_units (struct player *pplayer, struct unit *punit, struct tile *pdesttile, const struct action *paction)
static bool | occupy_move (struct tile *def_tile, struct unit *punit, const struct action *paction)
static bool | do_wipe_units (struct unit *punit, struct tile *pdesttile, const struct action *paction)
static bool | do_expel_unit (struct player *pplayer, struct unit *actor, struct unit *target, const struct action *paction)
static bool | do_conquer_extras (struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
static bool | do_heal_unit (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_unit_deboard (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_unit_board (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_unit_load (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_unit_unload (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_disembark (struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
static bool | do_unit_hut (struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
static bool | do_unit_embark (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction)
static bool | do_unit_make_homeless (struct unit *punit, const struct action *paction)
static bool | rel_may_become_war (const struct player *pplayer, const struct player *oplayer)
static bool | need_war_enabler (const struct unit_type *actor_utype, const struct action *paction, struct player *player1, struct player *player2, bool act_if_diplrel_kind(const struct unit_type *, const action_id, const int, const bool))
static struct player * | need_war_player_hlp (const struct unit *actor, const action_id act, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
static struct player * | need_war_player (const struct unit *actor, const action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
static bool | tile_has_units_not_allied_to_but_seen_by (const struct tile *ptile, const struct player *pplayer)
static bool | does_terrain_block_action (const action_id act_id, bool is_target, struct unit *actor_unit, struct terrain *pterrain)
static bool | does_nation_block_action (const action_id act_id, bool is_target, struct unit *actor_unit, struct nation_type *pnation)
static struct ane_expl * | expl_act_not_enabl (struct unit *punit, const action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
enum ane_kind | action_not_enabled_reason (struct unit *punit, action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
static void | explain_why_no_action_enabled (struct unit *punit, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
void | handle_unit_get_actions (struct connection *pc, const int actor_unit_id, const int target_unit_id_client, const int target_tile_id, const int target_extra_id_client, const int request_kind)
void | illegal_action_msg (struct player *pplayer, const enum event_type event, struct unit *actor, const action_id stopped_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
static bool | illegal_action_pay_price (struct player *pplayer, bool information_revealed, struct unit *act_unit, struct action *stopped_action, struct player *tgt_player, struct tile *tgt_tile, const enum action_requester requester)
static void | unit_query_impossible (struct connection *pc, const int actor_id, const int target_id, int request_kind)
void | handle_unit_action_query (struct connection *pc, const int actor_id, const int target_id, const action_id action_type, int request_kind)
void | handle_unit_do_action (struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
void | unit_do_action (struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
bool | unit_perform_action (struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
void | unit_change_homecity_handling (struct unit *punit, struct city *new_pcity, bool rehome)
static void | handle_unit_change_activity_real (struct player *pplayer, int unit_id, enum unit_activity activity, struct extra_type *activity_target, enum gen_action trigger_action)
void | handle_unit_change_activity (struct player *pplayer, int unit_id, enum unit_activity activity, int target_id)
static void | see_combat (struct unit *pattacker, struct unit *pdefender)
static void | send_combat (struct unit *pattacker, struct unit *pdefender, int att_veteran, int def_veteran, int bombard)
static void | unit_attack_civilian_casualties (const struct unit *punit, struct city *pcity, const struct action *paction, const char *reason)
static const char * | unit_veteran_level_string (const struct unit *punit)
static const char * | unit_achieved_rank_string (const struct unit *punit)
static const char * | unit_tired_attack_string (const struct unit *punit)
static const char * | unit_firepower_if_not_one (int firepower)
static bool | can_unit_move_to_tile_with_notify (struct unit *punit, struct tile *dest_tile, bool igzoc, struct unit *embark_to, bool enter_enemy_city)
bool | unit_move_handling (struct unit *punit, struct tile *pdesttile, bool move_do_not_act)
void | handle_unit_sscs_set (struct player *pplayer, int unit_id, enum unit_ss_data_type type, int value)
static void | unit_plans_clear (struct unit *punit)
void | handle_unit_server_side_agent_set (struct player *pplayer, int unit_id, enum server_side_agent agent)
bool | unit_server_side_agent_set (struct player *pplayer, struct unit *punit, enum server_side_agent agent)
static void | unit_activity_dependencies (struct unit *punit, enum unit_activity old_activity, struct extra_type *old_target)
bool | unit_activity_handling (struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
bool | unit_activity_handling_targeted (struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target, enum gen_action trigger_action)
void | handle_unit_orders (struct player *pplayer, const struct packet_unit_orders *packet)
void | handle_worker_task (struct player *pplayer, const struct packet_worker_task *packet)

## Macro Definition Documentation

## ◆ ACTION_PERFORM_UNIT_ANY

#define ACTION_PERFORM_UNIT_ANY | ( |  | paction,
|  |  | actor,
|  |  | target_city,
|  |  | target_unit,
|  |  | target_tile,
|  |  | action_performer
| ) |  |

Value:
switch (action_get_target_kind(paction)) { \
case ATK_CITY: \
ACTION_PERFORM_UNIT_CITY(paction->id, actor, target_city, \
action_performer); \
break; \
case ATK_UNIT: \
ACTION_PERFORM_UNIT_UNIT(paction->id, actor, target_unit, \
action_performer); \
break; \
case ATK_UNITS: \
ACTION_PERFORM_UNIT_UNITS(paction->id, actor, target_tile, \
action_performer); \
break; \
case ATK_TILE: \
ACTION_PERFORM_UNIT_TILE(paction->id, actor, target_tile, \
action_performer); \
break; \
case ATK_EXTRAS: \
ACTION_PERFORM_UNIT_EXTRAS(paction->id, actor, target_tile, \
action_performer); \
break; \
case ATK_SELF: \
ACTION_PERFORM_UNIT_SELF(paction->id, actor, TRUE); \
break; \
case ATK_COUNT: \
fc_assert(action_get_target_kind(paction) != ATK_COUNT); \
break; \
}
action_get_target_kind
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1073
incite_cost
char * incite_cost
Definition comments.c:74
target_unit
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
actor
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
target_tile
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
target_city
struct unit struct city * target_city
Definition dialogs_g.h:56
TRUE
#define TRUE
Definition support.h:46

## ◆ ACTION_PERFORM_UNIT_CITY

#define ACTION_PERFORM_UNIT_CITY | ( |  | action,
|  |  | actor,
|  |  | target,
|  |  | action_performer
| ) |  |

Value:
if (pcity \
&& is_action_enabled_unit_on_city(nmap, action_type, \
actor_unit, pcity)) { \
bool success; \
script_server_signal_emit("action_started_unit_city", \
action_by_number(action), actor, target); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
if (!target || !city_exist(target_id)) { \
/* Target city was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
} \
script_server_signal_emit("action_finished_unit_city", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL, \
city_exist(target_id) ? target : NULL); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
pcity ? city_owner(pcity) : NULL, NULL, pcity, NULL, \
TRUE, requester); \
}
is_action_enabled_unit_on_city
bool is_action_enabled_unit_on_city(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
Definition actions.c:3044
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
city_exist
bool city_exist(int id)
Definition city.c:3560
city_owner
#define city_owner(_pcity_)
Definition city.h:563
actor_unit
struct unit * actor_unit
Definition dialogs_g.h:55
action
Definition actions.h:106
FALSE
#define FALSE
Definition support.h:47
unit_is_alive
bool unit_is_alive(int id)
Definition unit.c:2286

## ◆ ACTION_PERFORM_UNIT_EXTRAS

#define ACTION_PERFORM_UNIT_EXTRAS | ( |  | action,
|  |  | actor,
|  |  | target,
|  |  | action_performer
| ) |  |

Value:
if (target_tile \
&& is_action_enabled_unit_on_extras(nmap, action_type, \
actor_unit, target_tile, \
target_extra)) { \
bool success; \
script_server_signal_emit("action_started_unit_extras", \
action_by_number(action), actor, target); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
} \
script_server_signal_emit("action_finished_unit_extras", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL, \
target); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
target_tile ? target_tile->extras_owner : NULL, \
target_tile, NULL, NULL, \
TRUE, requester); \
}
is_action_enabled_unit_on_extras
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3362
target_extra
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57

## ◆ ACTION_PERFORM_UNIT_SELF

#define ACTION_PERFORM_UNIT_SELF | ( |  | action,
|  |  | actor,
|  |  | action_performer
| ) |  |

Value:
if (actor_unit \
&& is_action_enabled_unit_on_self(action_type, actor_unit)) { \
bool success; \
script_server_signal_emit("action_started_unit_self", \
action_by_number(action), actor); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
} \
script_server_signal_emit("action_finished_unit_self", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
unit_owner(actor_unit), NULL, NULL, actor_unit, \
TRUE, requester); \
}
is_action_enabled_unit_on_self
bool is_action_enabled_unit_on_self(const action_id wanted_action, const struct unit *actor_unit)
Definition actions.c:3434
unit_owner
#define unit_owner(_pu)
Definition unit.h:396

## ◆ ACTION_PERFORM_UNIT_TILE

#define ACTION_PERFORM_UNIT_TILE | ( |  | action,
|  |  | actor,
|  |  | target,
|  |  | action_performer
| ) |  |

Value:
if (target_tile \
&& is_action_enabled_unit_on_tile(nmap, action_type, \
actor_unit, target_tile, \
target_extra)) { \
bool success; \
script_server_signal_emit("action_started_unit_tile", \
action_by_number(action), actor, target); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
} \
script_server_signal_emit("action_finished_unit_tile", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL, \
target); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
target_tile ? tile_owner(target_tile) : NULL, \
target_tile, NULL, NULL, \
TRUE, requester); \
}
is_action_enabled_unit_on_tile
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3285
tile_owner
#define tile_owner(_tile)
Definition tile.h:97

## ◆ ACTION_PERFORM_UNIT_UNIT

#define ACTION_PERFORM_UNIT_UNIT | ( |  | action,
|  |  | actor,
|  |  | target,
|  |  | action_performer
| ) |  |

Value:
if (punit \
&& is_action_enabled_unit_on_unit(nmap, action_type, actor_unit, punit)) { \
bool success; \
script_server_signal_emit("action_started_unit_unit", \
action_by_number(action), actor, target); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
if (!target || !unit_is_alive(target_id)) { \
/* Target unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
action_success_target_pay_mp(paction, target_id, punit); \
} \
script_server_signal_emit("action_finished_unit_unit", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL, \
unit_is_alive(target_id) ? target : NULL); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
punit ? unit_owner(punit) : NULL, NULL, NULL, punit, \
TRUE, requester); \
}
is_action_enabled_unit_on_unit
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Definition actions.c:3121
punit
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

## ◆ ACTION_PERFORM_UNIT_UNITS

#define ACTION_PERFORM_UNIT_UNITS | ( |  | action,
|  |  | actor,
|  |  | target,
|  |  | action_performer
| ) |  |

Value:
if (target_tile \
&& is_action_enabled_unit_on_stack(nmap, action_type, \
actor_unit, target_tile)) { \
bool success; \
script_server_signal_emit("action_started_unit_units", \
action_by_number(action), actor, target); \
if (!actor || !unit_is_alive(actor_id)) { \
/* Actor unit was destroyed during pre action Lua. */ \
return FALSE; \
} \
success = action_performer; \
if (success) { \
action_success_actor_price(paction, actor_id, actor); \
} \
script_server_signal_emit("action_finished_unit_units", \
action_by_number(action), success, \
unit_is_alive(actor_id) ? actor : NULL, \
target); \
return success; \
} else { \
illegal_action(pplayer, actor_unit, action_type, \
NULL, target_tile, NULL, NULL, \
TRUE, requester); \
}
is_action_enabled_unit_on_stack
bool is_action_enabled_unit_on_stack(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile)
Definition actions.c:3209

## Function Documentation

## ◆ action_not_enabled_reason()

enum ane_kind action_not_enabled_reason | ( | struct unit * | punit,
|  | action_id | act_id,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

Give the reason kind why an action isn't enabled.

Definition at line 1929 of file unithand.c.

Referenced by dai_do_build_city().

## ◆ can_unit_move_to_tile_with_notify()

static bool can_unit_move_to_tile_with_notify | ( | struct unit * | punit,
|  | struct tile * | dest_tile,
|  | bool | igzoc,
|  | struct unit * | embark_to,
|  | bool | enter_enemy_city
| ) |  |

static

See also aiunit could_unit_move_to_tile()

Definition at line 5560 of file unithand.c.

Referenced by unit_move_handling().

## ◆ city_add_unit()

static bool city_add_unit | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

static

This function assumes that the target city is valid. It should only be called after checking that the unit legally can join the target city.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4166 of file unithand.c.

Referenced by unit_perform_action().

## ◆ city_build()

static bool city_build | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct tile * | ptile,
|  | const char * | name,
|  | const struct action * | paction
| ) |  |

static

This function assumes a certain level of consistency checking: There is no city under punit->(x, y), and that location is a valid one on which to build a city. It should only be called after a call to a function like test_unit_add_or_build_city, which does the checking.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4228 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_action_activity()

static bool do_action_activity | ( | struct unit * | punit,
|  | const struct action * | paction
| ) |  |

static

Perform an action that is an activity.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 6589 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_action_activity_targeted()

static bool do_action_activity_targeted | ( | struct unit * | punit,
|  | const struct action * | paction,
|  | struct extra_type ** | new_target
| ) |  |

static

Perform an action that is an activity.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 6657 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_attack()

static bool do_attack | ( | struct unit * | punit,
|  | struct tile * | def_tile,
|  | const struct action * | paction
| ) |  |

static

Do a "regular" attack.

This function assumes the attack is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4904 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_capture_units()

static bool do_capture_units | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct tile * | pdesttile,
|  | const struct action * | paction
| ) |  |

static

Capture all the units at pdesttile using punit.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 316 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_conquer_extras()

static bool do_conquer_extras | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct tile * | tgt_tile,
|  | const struct action * | paction
| ) |  |

static

Claim all ownable extras at tgt_tile.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 693 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_disembark()

static bool do_disembark | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct tile * | tgt_tile,
|  | const struct action * | paction
| ) |  |

static

Disembark actor unit from target unit to target tile.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 911 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_expel_unit()

static bool do_expel_unit | ( | struct player * | pplayer,
|  | struct unit * | actor,
|  | struct unit * | target,
|  | const struct action * | paction
| ) |  |

static

Expel the target unit to its owner's capital.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 603 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_heal_unit()

static bool do_heal_unit | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Restore some of the target unit's hit points.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 732 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_board()

static bool do_unit_board | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Have the actor unit board the target unit.

Assumes that all checks for action legality has been done.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 850 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_change_homecity()

static bool do_unit_change_homecity | ( | struct unit * | punit,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

static

Change a unit's home city.

Returns TRUE iff the action could be done, FALSE if it couldn't.

Definition at line 4132 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_conquer_city()

static bool do_unit_conquer_city | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | struct action * | paction
| ) |  |

static

Have the unit conquer a city.

This function assumes the attack is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5522 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_deboard()

static bool do_unit_deboard | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Unload actor unit from target unit.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 831 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_embark()

static bool do_unit_embark | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Have the actor unit embark the target unit.

Assumes that all checks for action legality has been done.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 969 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_establish_trade()

static bool do_unit_establish_trade | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct city * | pcity_dest,
|  | const struct action * | paction
| ) |  |

static

Handle request to establish trade route. If pcity_dest is NULL, assumes that unit is inside target city.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5977 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_hut()

static bool do_unit_hut | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct tile * | tgt_tile,
|  | const struct action * | paction
| ) |  |

static

Enter a hut at the target tile.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 939 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_load()

static bool do_unit_load | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Load the target unit into the actor unit.

Assumes that all checks for action legality has been done.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 873 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_make_homeless()

static bool do_unit_make_homeless | ( | struct unit * | punit,
|  | const struct action * | paction
| ) |  |

static

Deletes a unit's home city making it unhomed.

Returns TRUE iff the action could be done, FALSE if it couldn't.

Definition at line 1006 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_strike_city_building()

static bool do_unit_strike_city_building | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | Impr_type_id | tgt_bld_id,
|  | const struct action * | paction
| ) |  |

static

Have the unit perform a surgical strike against a building in the target city.

This function assumes the attack is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5403 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_strike_city_production()

static bool do_unit_strike_city_production | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

static

Have the unit perform a surgical strike against the current production in the target city.

This function assumes the attack is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5316 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_unload()

static bool do_unit_unload | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct unit * | tgt_unit,
|  | const struct action * | paction
| ) |  |

static

Unload target unit from actor unit.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 894 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_unit_upgrade()

static bool do_unit_upgrade | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct city * | pcity,
|  | enum action_requester | ordered_by,
|  | const struct action * | paction
| ) |  |

static

Upgrade the unit to a newer unit type.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 257 of file unithand.c.

Referenced by unit_perform_action().

## ◆ do_wipe_units()

static bool do_wipe_units | ( | struct unit * | punit,
|  | struct tile * | pdesttile,
|  | const struct action * | paction
| ) |  |

static

Wipe all units at target tile.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 550 of file unithand.c.

Referenced by unit_perform_action().

## ◆ does_nation_block_action()

static bool does_nation_block_action | ( | const action_id | act_id,
|  | bool | is_target,
|  | struct unit * | actor_unit,
|  | struct nation_type * | pnation
| ) |  |

static

Returns TRUE iff the specified nation blocks the specified action.

If the "action" is ACTION_ANY all actions are checked.

Definition at line 1403 of file unithand.c.

Referenced by does_nation_block_action(), and expl_act_not_enabl().

## ◆ does_terrain_block_action()

static bool does_terrain_block_action | ( | const action_id | act_id,
|  | bool | is_target,
|  | struct unit * | actor_unit,
|  | struct terrain * | pterrain
| ) |  |

static

Returns TRUE iff the specified terrain type blocks the specified action.

If the "action" is ACTION_ANY all actions are checked.

Definition at line 1361 of file unithand.c.

Referenced by does_terrain_block_action(), and expl_act_not_enabl().

## ◆ expl_act_not_enabl()

static struct ane_expl * expl_act_not_enabl | ( | struct unit * | punit,
|  | const action_id | act_id,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

static

Returns an explanation why punit can't perform the specified action based on the current game state.

Definition at line 1445 of file unithand.c.

Referenced by action_not_enabled_reason(), explain_why_no_action_enabled(), and illegal_action_msg().

## ◆ explain_why_no_action_enabled()

static void explain_why_no_action_enabled | ( | struct unit * | punit,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

static

Explain why punit can't perform any action at all based on its current game state.

Definition at line 1949 of file unithand.c.

Referenced by handle_unit_get_actions().

## ◆ handle_unit_action_query()

void handle_unit_action_query | ( | struct connection * | pc,
|  | const int | actor_id,
|  | const int | target_id,
|  | const action_id | action_type,
|  | int | request_kind
| ) |  |

Tell the client the cost of bribing a unit, inciting a revolt, or any other parameters needed for action.

Only send result back to the requesting connection, not all connections for that player.

Definition at line 3177 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_change_activity()

void handle_unit_change_activity | ( | struct player * | pplayer,
|  | int | unit_id,
|  | enum unit_activity | activity,
|  | int | target_id
| ) |  |

Handle change in unit activity.

Definition at line 4328 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_change_activity_real()

static void handle_unit_change_activity_real | ( | struct player * | pplayer,
|  | int | unit_id,
|  | enum unit_activity | activity,
|  | struct extra_type * | activity_target,
|  | enum gen_action | trigger_action
| ) |  |

static

Handle change in unit activity.

Definition at line 4277 of file unithand.c.

Referenced by handle_unit_change_activity().

## ◆ handle_unit_do_action()

void handle_unit_do_action | ( | struct player * | pplayer,
|  | const int | actor_id,
|  | const int | target_id,
|  | const int | sub_tgt_id,
|  | const char * | name,
|  | const action_id | action_type
| ) |  |

Handle a request to do an action.

action_type must be a valid action.

Definition at line 3291 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_get_actions()

void handle_unit_get_actions | ( | struct connection * | pc,
|  | const int | actor_unit_id,
|  | const int | target_unit_id_client,
|  | const int | target_tile_id,
|  | const int | target_extra_id_client,
|  | const int | request_kind
| ) |  |

Handle a query for what actions a unit may do.

MUST always send a reply so the client can move on in the queue. This includes when the client give invalid input. That the acting unit died before the server received a request for what actions it could do should not stop the client from processing the next unit in the queue.

Definition at line 2244 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_orders()

void handle_unit_orders | ( | struct player * | pplayer,
|  | const struct packet_unit_orders * | packet
| ) |  |

Receives route packages.

Definition at line 6743 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_server_side_agent_set()

void handle_unit_server_side_agent_set | ( | struct player * | pplayer,
|  | int | unit_id,
|  | enum server_side_agent | agent
| ) |  |

Handle request to change controlling server side agent.

Definition at line 6454 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_sscs_set()

void handle_unit_sscs_set | ( | struct player * | pplayer,
|  | int | unit_id,
|  | enum unit_ss_data_type | type,
|  | int | value
| ) |  |

Change various unit server side client state.

The server keeps various unit state that is owned by the client. The only consequence this state has for the game is how the client reacts to it. The state may be server side because the server writes to it or simply to have it end up in the save game.

Definition at line 6347 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_unit_type_upgrade()

void handle_unit_type_upgrade | ( | struct player * | pplayer,
|  | Unit_type_id | uti
| ) |  |

Upgrade all units of a given type.

Definition at line 187 of file unithand.c.

Referenced by server_handle_packet().

## ◆ handle_worker_task()

void handle_worker_task | ( | struct player * | pplayer,
|  | const struct packet_worker_task * | packet
| ) |  |

Handle worker task assigned to the city

Definition at line 6852 of file unithand.c.

Referenced by client_handle_packet(), and server_handle_packet().

## ◆ illegal_action()

static void illegal_action | ( | struct player * | pplayer,
|  | struct unit * | actor,
|  | action_id | stopped_action_id,
|  | struct player * | tgt_player,
|  | struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit,
|  | int | request_kind,
|  | const enum action_requester | requester
| ) |  |

static

Tell the client that the action it requested is illegal. This can be caused by the player (and therefore the client) not knowing that some condition of an action no longer is true.

Definition at line 3101 of file unithand.c.

Referenced by handle_unit_action_query().

## ◆ illegal_action_msg()

void illegal_action_msg | ( | struct player * | pplayer,
|  | const enum event_type | event,
|  | struct unit * | actor,
|  | const action_id | stopped_action,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

Try to explain to the player why an action is illegal.

Event type should be E_BAD_COMMAND if the player should know that the action is illegal or E_UNIT_ILLEGAL_ACTION if new information potentially is being revealed to the player.

Definition at line 2508 of file unithand.c.

Referenced by execute_orders(), handle_city_name_suggestion_req(), and illegal_action().

## ◆ illegal_action_pay_price()

static bool illegal_action_pay_price | ( | struct player * | pplayer,
|  | bool | information_revealed,
|  | struct unit * | act_unit,
|  | struct action * | stopped_action,
|  | struct player * | tgt_player,
|  | struct tile * | tgt_tile,
|  | const enum action_requester | requester
| ) |  |

static

Punish a player for trying to perform an action that turned out to be illegal. The punishment, if any at all, is specified by the ruleset.

Parameters

  pplayer | the player to punish.
  information_revealed | if finding out that the action is illegal reveals new information.
  act_unit | the actor unit performing the action.
  stopped_action | the illegal action.
  tgt_player | the owner of the intended target of the action.
  tgt_tile | the tile of the target of the action.
  requester | who ordered the action performed?

Returns
  TRUE iff player was punished for trying to do the illegal action.

Definition at line 2984 of file unithand.c.

Referenced by illegal_action().

## ◆ need_war_enabler()

static bool need_war_enabler | ( | const struct unit_type * | actor_utype,
|  | const struct action * | paction,
|  | struct player * | player1,
|  | struct player * | player2,
|  | bool | act_if_diplrel_kindconst struct unit_type *, const action_id, const int, const bool
| ) |  |

static

Returns TRUE iff player1 declaring war on player2 is possible and would result in a unit of the specified type belonging to player1 going from being unable to do the specified action to player2 to being able to perform it.

Definition at line 1045 of file unithand.c.

Referenced by need_war_player_hlp().

## ◆ need_war_player()

static struct player * need_war_player | ( | const struct unit * | actor,
|  | const action_id | act_id,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

static

Returns the first player that may enable the specified action if war is declared. If the specified action is ACTION_ANY the first player that may enable any action at all if war is declared will be returned.

Definition at line 1307 of file unithand.c.

Referenced by expl_act_not_enabl().

## ◆ need_war_player_hlp()

static struct player * need_war_player_hlp | ( | const struct unit * | actor,
|  | const action_id | act,
|  | const struct tile * | target_tile,
|  | const struct city * | target_city,
|  | const struct unit * | target_unit
| ) |  |

static

Returns the first player that may enable the specified action if war is declared.

Helper for need_war_player(). Use it instead.

Definition at line 1086 of file unithand.c.

Referenced by need_war_player().

## ◆ non_allied_not_listed_at()

static bool non_allied_not_listed_at | ( | const struct player * | pplayer,
|  | const int * | list,
|  | int | n,
|  | const struct tile * | ptile
| ) |  |

inlinestatic

Helper function for do_capture_units(). Tells if ptile contains a unit not allied to pplayer whose id is not on the list.

Definition at line 287 of file unithand.c.

Referenced by do_capture_units().

## ◆ occupy_move()

static bool occupy_move | ( | struct tile * | def_tile,
|  | struct unit * | punit,
|  | const struct action * | paction
| ) |  |

static

Occupying move after an action.

Definition at line 505 of file unithand.c.

Referenced by do_attack(), and do_wipe_units().

## ◆ rel_may_become_war()

static bool rel_may_become_war | ( | const struct player * | pplayer,
|  | const struct player * | oplayer
| ) |  |

static

Returns TRUE iff the player is able to change their diplomatic relationship to the other player to war.

Note that the player can't declare war on someone they already are at war with.

Definition at line 1021 of file unithand.c.

Referenced by need_war_enabler(), and need_war_player_hlp().

## ◆ see_combat()

static void see_combat | ( | struct unit * | pattacker,
|  | struct unit * | pdefender
| ) |  |

static

Make sure everyone who can see combat does.

Definition at line 4390 of file unithand.c.

Referenced by do_attack(), and unit_bombard().

## ◆ send_combat()

static void send_combat | ( | struct unit * | pattacker,
|  | struct unit * | pdefender,
|  | int | att_veteran,
|  | int | def_veteran,
|  | int | bombard
| ) |  |

static

Send combat info to players.

Definition at line 4449 of file unithand.c.

Referenced by do_attack(), and unit_bombard().

## ◆ tile_has_units_not_allied_to_but_seen_by()

static bool tile_has_units_not_allied_to_but_seen_by | ( | const struct tile * | ptile,
|  | const struct player * | pplayer
| ) |  |

static

Returns TRUE iff the specified tile has a unit seen by and not allied to the specified player.

Definition at line 1343 of file unithand.c.

Referenced by expl_act_not_enabl().

## ◆ unit_achieved_rank_string()

static const char * unit_achieved_rank_string | ( | const struct unit * | punit | ) |

static

Get string of when unit gets upgraded to new veteran level. N.B.: The returned string is static, so every call to this function overwrites the previous.

Definition at line 4840 of file unithand.c.

Referenced by do_attack().

## ◆ unit_activity_dependencies()

static void unit_activity_dependencies | ( | struct unit * | punit,
|  | enum unit_activity | old_activity,
|  | struct extra_type * | old_target
| ) |  |

static

Update everything that needs changing when unit activity changes from old activity to new one.

Definition at line 6540 of file unithand.c.

Referenced by unit_activity_internal(), and unit_activity_targeted_internal().

## ◆ unit_activity_handling()

bool unit_activity_handling | ( | struct unit * | punit,
|  | enum unit_activity | new_activity,
|  | enum gen_action | trigger_action
| ) |  |

Handle request for changing activity.

Definition at line 6603 of file unithand.c.

Referenced by adv_follow_path(), adv_unit_move(), auto_worker_setup_work(), auto_workers_player(), dai_auto_settler_cont(), dai_diplomat_city(), dai_do_build_city(), dai_manage_airunit(), dai_manage_barbarian_leader(), dai_manage_military(), dai_military_attack(), dai_military_findjob(), dai_unit_attack(), dai_unit_bodyguard_move(), dai_unit_move(), dai_unit_new_task(), do_explore(), handle_unit_orders(), player_restore_units(), remove_city(), terrain_change_bounce_single_unit(), unit_activity_handling_targeted(), unit_activity_targeted_internal(), and unit_survive_autoattack().

## ◆ unit_activity_handling_targeted()

bool unit_activity_handling_targeted | ( | struct unit * | punit,
|  | enum unit_activity | new_activity,
|  | struct extra_type ** | new_target,
|  | enum gen_action | trigger_action
| ) |  |

Handle request for targeted activity.

Definition at line 6675 of file unithand.c.

Referenced by adv_follow_path(), auto_worker_setup_work(), handle_unit_change_activity_real(), and unit_activity_handling().

## ◆ unit_activity_internal()

static bool unit_activity_internal | ( | struct unit * | punit,
|  | enum unit_activity | new_activity,
|  | enum gen_action | trigger_action
| ) |  |

static

Handle request for changing activity.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 6633 of file unithand.c.

Referenced by do_action_activity(), do_action_activity_targeted(), handle_unit_server_side_agent_set(), handle_unit_sscs_set(), and unit_activity_handling().

## ◆ unit_activity_targeted_internal()

static bool unit_activity_targeted_internal | ( | struct unit * | punit,
|  | enum unit_activity | new_activity,
|  | struct extra_type ** | new_target,
|  | enum gen_action | trigger_action
| ) |  |

static

Handle request for targeted activity.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 6698 of file unithand.c.

Referenced by do_action_activity_targeted(), and unit_activity_handling_targeted().

## ◆ unit_attack_civilian_casualties()

static void unit_attack_civilian_casualties | ( | const struct unit * | punit,
|  | struct city * | pcity,
|  | const struct action * | paction,
|  | const char * | reason
| ) |  |

static

Reduce the city's population after an attack action.

Definition at line 4494 of file unithand.c.

Referenced by do_attack(), and unit_bombard().

## ◆ unit_bombard()

static bool unit_bombard | ( | struct unit * | punit,
|  | struct tile * | ptile,
|  | const struct action * | paction
| ) |  |

static

This function assumes the bombard is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4544 of file unithand.c.

Referenced by unit_perform_action().

## ◆ unit_change_homecity_handling()

void unit_change_homecity_handling | ( | struct unit * | punit,
|  | struct city * | new_pcity,
|  | bool | rehome
| ) |  |

Transfer a unit from one city (and possibly player) to another. If 'rehome' is not set, only change the player which owns the unit (the new owner is new_pcity's owner). Otherwise the new unit will be given a homecity, even if it was homeless before. This new homecity must be valid for this unit.

Definition at line 4030 of file unithand.c.

Referenced by do_unit_change_homecity(), do_unit_make_homeless(), and transfer_unit().

## ◆ unit_do_action()

void unit_do_action | ( | struct player * | pplayer,
|  | const int | actor_id,
|  | const int | target_id,
|  | const int | sub_tgt_id,
|  | const char * | name,
|  | const action_id | action_type
| ) |  |

Handle unit action

action_type must be a valid action.

Definition at line 3307 of file unithand.c.

Referenced by adv_unit_move(), dai_airlift(), dai_caravan_goto(), dai_diplomat_bribe_nearby(), dai_diplomat_city(), dai_do_build_city(), dai_hunter_try_launch(), dai_unit_attack(), dai_unit_make_homecity(), dai_unit_move(), dai_upgrade_units(), and unleash_barbarians().

## ◆ unit_do_destroy_city()

static bool unit_do_destroy_city | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

static

Destroy the target city.

This function assumes the destruction is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4731 of file unithand.c.

Referenced by unit_perform_action().

## ◆ unit_do_help_build()

static bool unit_do_help_build | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct city * | pcity_dest,
|  | const struct action * | paction
| ) |  |

static

Help build the current production in a city.

The amount of shields used to build the unit added to the city's shield stock for the current production is determined by the Unit_Shield_Value_Pct effect.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5862 of file unithand.c.

Referenced by unit_perform_action().

## ◆ unit_do_regular_move()

static bool unit_do_regular_move | ( | struct player * | actor_player,
|  | struct unit * | actor_unit,
|  | struct tile * | target_tile,
|  | const struct action * | paction
| ) |  |

static

Moves the unit from one tile to another.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 5631 of file unithand.c.

Referenced by unit_perform_action().

## ◆ unit_firepower_if_not_one()

static const char * unit_firepower_if_not_one | ( | int | firepower | ) |

static

Get string of unit's firepower text, i.e. "FP:2 " If firepower is equal to one, then an empty string is returned so as to shorten the text output. N.B.: The returned string is static, so every call to this function overwrites the previous.

Definition at line 4879 of file unithand.c.

Referenced by do_attack().

## ◆ unit_move_handling()

bool unit_move_handling | ( | struct unit * | punit,
|  | struct tile * | pdesttile,
|  | bool | move_do_not_act
| ) |  |

Will try to move to/attack the tile dest_x,dest_y. Returns TRUE if this was done, FALSE if it wasn't for some reason. Even if this returns TRUE, the unit may have died upon arrival to new tile.

'move_do_not_act' is a special case which should normally be FALSE. If TRUE any enabler controlled actions punit can perform to pdesttile it self or something located at it will be ignored. If FALSE the system will check if punit can perform any enabler controlled action to pdesttile. If it can the player will be asked to choose what to do. If it can't and punit is unable to move (or perform another non enabler controlled action) to pdesttile the game will try to explain why.

Definition at line 5669 of file unithand.c.

Referenced by execute_orders().

## ◆ unit_nuke()

static bool unit_nuke | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct tile * | def_tile,
|  | const struct action * | paction
| ) |  |

static

Do a "regular" nuclear attack.

Can be stopped by an EFT_NUKE_PROOF (SDI defended) city.

This function assumes the attack is legal. The calling function should have already made all necessary checks.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 4661 of file unithand.c.

Referenced by unit_perform_action().

## ◆ unit_perform_action()

bool unit_perform_action | ( | struct player * | pplayer,
|  | const int | actor_id,
|  | const int | target_id,
|  | const int | sub_tgt_id_incoming,
|  | const char * | name,
|  | const action_id | action_type,
|  | const enum action_requester | requester
| ) |  |

Execute a request to perform an action and let the caller know if it was performed or not.

The action must be a valid action.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 3327 of file unithand.c.

Referenced by api_edit_perform_action_unit_vs_city(), api_edit_perform_action_unit_vs_city_impr(), api_edit_perform_action_unit_vs_city_tech(), api_edit_perform_action_unit_vs_self(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), api_edit_perform_action_unit_vs_unit(), dai_manage_paratrooper(), execute_orders(), handle_unit_do_action(), handle_unit_type_upgrade(), random_movements(), unit_do_action(), unit_do_disband_trad(), and unit_move_handling().

## ◆ unit_plans_clear()

static void unit_plans_clear | ( | struct unit * | punit | ) |

static

Delete a unit's current plans.

Definition at line 6438 of file unithand.c.

Referenced by handle_unit_server_side_agent_set().

## ◆ unit_query_impossible()

static void unit_query_impossible | ( | struct connection * | pc,
|  | const int | actor_id,
|  | const int | target_id,
|  | int | request_kind
| ) |  |

static

Inform the client that something went wrong during a unit diplomat query

Definition at line 3158 of file unithand.c.

Referenced by handle_unit_action_query().

## ◆ unit_server_side_agent_set()

bool unit_server_side_agent_set | ( | struct player * | pplayer,
|  | struct unit * | punit,
|  | enum server_side_agent | agent
| ) |  |

Change controlling server side agent.

Returns
  TRUE iff the server side agent was changed.

Definition at line 6503 of file unithand.c.

Referenced by dai_manage_settler(), and handle_unit_server_side_agent_set().

## ◆ unit_tired_attack_string()

static const char * unit_tired_attack_string | ( | const struct unit * | punit | ) |

static

Get string of unit's attack would be a tired attack or not. N.B.: The returned string is static, so every call to this function overwrites the previous.

Definition at line 4857 of file unithand.c.

Referenced by do_attack().

## ◆ unit_veteran_level_string()

static const char * unit_veteran_level_string | ( | const struct unit * | punit | ) |

static

Get a text of a unit's vet level. N.B.: The returned string is static, so every call to this function overwrites the previous.

Definition at line 4819 of file unithand.c.

Referenced by do_attack(), and unit_achieved_rank_string().