![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <cstdlib>#include <cstring>#include <set>#include "astring.h"#include "fcintl.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 "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 "techtools.h"#include "unittools.h"#include "autosettlers.h"#include "script_server.h"#include "unithand.h"
Include dependency graph for unithand.cpp:Go to the source code of this file.
Classes | |
| struct | ane_expl |
Macros | |
| #define | ACTION_STARTED_UNIT_CITY(action, actor, target, action_performer) |
| #define | ACTION_STARTED_UNIT_SELF(action, actor, action_performer) |
| #define | ACTION_STARTED_UNIT_UNIT(action, actor, target, action_performer) |
| #define | ACTION_STARTED_UNIT_UNITS(action, actor, target, action_performer) |
| #define | ACTION_STARTED_UNIT_TILE(action, actor, target, action_performer) |
Functions | |
| static bool | unit_activity_internal (struct unit *punit, enum unit_activity new_activity) |
| Handle request for changing activity. More... | |
| static bool | unit_activity_targeted_internal (struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target) |
| Handle request for targeted activity. More... | |
| 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, bool disturb_player, const enum action_requester requester) |
| Tell the client that the action it requested is illegal. More... | |
| static bool | city_add_unit (struct player *pplayer, struct unit *punit, struct city *pcity, const struct action *paction) |
| This function assumes that the target city is valid. More... | |
| static bool | city_build (struct player *pplayer, struct unit *punit, struct tile *ptile, const char *name, const struct action *paction) |
| 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. More... | |
| static bool | do_unit_establish_trade (struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction) |
| Handle request to establish traderoute. More... | |
| static bool | unit_do_help_build (struct player *pplayer, struct unit *punit, struct city *pcity_dest, const struct action *paction) |
| Help build the current production in a city. More... | |
| static bool | unit_bombard (struct unit *punit, struct tile *ptile, const struct action *paction) |
| This function assumes the bombard is legal. More... | |
| static bool | unit_nuke (struct player *pplayer, struct unit *punit, struct tile *def_tile, const struct action *paction) |
| Do a "regular" nuclear attack. More... | |
| static bool | unit_do_destroy_city (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction) |
| Destroy the target city. More... | |
| static bool | do_unit_change_homecity (struct unit *punit, struct city *pcity, const struct action *paction) |
| Change a unit's home city. More... | |
| static bool | do_attack (struct unit *punit, struct tile *def_tile, const struct action *paction) |
| Do a "regular" attack. More... | |
| static bool | do_unit_strike_city_production (const struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction) |
| Have the unit perform a surgical strike against the current production in the target city. More... | |
| static bool | do_unit_strike_city_building (const struct player *act_player, struct unit *act_unit, struct city *tgt_city, Impr_type_id tgt_bld_id, const struct action *paction) |
| Have the unit perform a surgical strike against a building in the target city. More... | |
| static bool | do_unit_conquer_city (struct player *act_player, struct unit *act_unit, struct city *tgt_city, struct action *paction) |
| Have the unit conquer a city. More... | |
| static bool | do_action_activity (struct unit *punit, const struct action *paction) |
| Perform an action that is an activity. More... | |
| static bool | do_action_activity_targeted (struct unit *punit, const struct action *paction, struct extra_type **new_target) |
| Perform an action that is an activity. More... | |
| void | handle_unit_type_upgrade (struct player *pplayer, Unit_type_id uti) |
| Upgrade all units of a given type. More... | |
| static bool | do_unit_upgrade (struct player *pplayer, struct unit *punit, struct city *pcity, enum action_requester ordered_by, const struct action *paction) |
| Upgrade the unit to a newer unit type. More... | |
| static bool | do_capture_units (struct player *pplayer, struct unit *punit, struct tile *pdesttile, const struct action *paction) |
| Capture all the units at pdesttile using punit. More... | |
| static void | occupy_move (unit *punit, tile *def_tile) |
| Occupying move after an action. More... | |
| static bool | do_expel_unit (struct player *pplayer, struct unit *actor, struct unit *target, const struct action *paction) |
| Expel the target unit to his owner's capital. More... | |
| static bool | do_heal_unit (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction) |
| Restore some of the target unit's hit points. More... | |
| static bool | do_unit_alight (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction) |
| Unload actor unit from target unit. More... | |
| static bool | do_unit_board (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction) |
| Have the actor unit board the target unit. More... | |
| static bool | do_unit_unload (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction) |
| Unload target unit from actor unit. More... | |
| static bool | do_disembark (struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction) |
| Disembark actor unit from target unit to target tile. More... | |
| static bool | do_unit_embark (struct player *act_player, struct unit *act_unit, struct unit *tgt_unit, const struct action *paction) |
| Have the actor unit embark the target unit. More... | |
| static bool | rel_may_become_war (const struct player *pplayer, const struct player *oplayer) |
| Returns TRUE iff the player is able to change his diplomatic relationship to the other player to war. More... | |
| 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) |
| Returns the first player that may enable the specified action if war is declared. More... | |
| 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) |
| Returns the first player that may enable the specified action if war is declared. More... | |
| static bool | does_terrain_block_action (const action_id act_id, bool is_target, struct unit *actor_unit, struct terrain *pterrain) |
| Returns TRUE iff the specified terrain type blocks the specified action. More... | |
| static bool | does_nation_block_action (const action_id act_id, bool is_target, struct unit *actor_unit, struct nation_type *pnation) |
| Returns TRUE iff the specified nation blocks the specified action. More... | |
| 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) |
| Returns an explaination why punit can't perform the specified action based on the current game state. More... | |
| 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. More... | |
| 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) |
| Explain why punit can't perform any action at all based on its current game state. More... | |
| 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 bool disturb_player) |
| Handle a query for what actions a unit may do. More... | |
| void | handle_unit_rename (player *pplayer, int unit_id, const char *name) |
| Handle request to rename a unit. More... | |
| 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. More... | |
| 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) |
| Punish a player for trying to perform an action that turned out to be illegal. More... | |
| static void | unit_query_impossible (struct connection *pc, const int actor_id, const int target_id, bool disturb_player) |
| Inform the client that something went wrong during a unit diplomat query. More... | |
| void | handle_unit_action_query (struct connection *pc, const int actor_id, const int target_id, const action_id action_type, bool disturb_player) |
| Tell the client the cost of bribing a unit, inciting a revolt, or any other parameters needed for action. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| static void | handle_unit_change_activity_real (struct player *pplayer, int unit_id, enum unit_activity activity, struct extra_type *activity_target) |
| Handle change in unit activity. More... | |
| void | handle_unit_change_activity (struct player *pplayer, int unit_id, enum unit_activity activity, int target_id) |
| Handle change in unit activity. More... | |
| static void | see_combat_unit (struct unit *punit) |
| Make sure everyone who can see combat does. More... | |
| static void | send_bombardment (const unit *pattacker, const tile *ptarget) |
| Send bombardment info to players. More... | |
| static void | send_combat (struct unit *pattacker, struct unit *pdefender, int att_veteran, int def_veteran) |
| Send combat info to players. More... | |
| static void | unit_attack_civilian_casualties (const struct unit *punit, struct city *pcity, const struct action *paction, const char *reason) |
| Reduce the city's population after an attack action. More... | |
| 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) |
| See also aiunit could_unit_move_to_tile() More... | |
| bool | unit_move_handling (struct unit *punit, struct tile *pdesttile, bool igzoc, bool move_do_not_act) |
| Will try to move to/attack the tile dest_x,dest_y. More... | |
| 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. More... | |
| static void | unit_plans_clear (struct unit *punit) |
| Delete a unit's current plans. More... | |
| 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. More... | |
| bool | unit_server_side_agent_set (struct player *pplayer, struct unit *punit, enum server_side_agent agent) |
| Change controlling server side agent. More... | |
| static void | unit_activity_dependencies (struct unit *punit, enum unit_activity old_activity, struct extra_type *old_target) |
| Update everything that needs changing when unit activity changes from old activity to new one. More... | |
| bool | unit_activity_handling (struct unit *punit, enum unit_activity new_activity) |
| Handle request for changing activity. More... | |
| bool | unit_activity_handling_targeted (struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target) |
| Handle request for targeted activity. More... | |
| void | handle_unit_orders (struct player *pplayer, const struct packet_unit_orders *packet) |
| Receives route packages. More... | |
| void | handle_worker_task (struct player *pplayer, const struct packet_worker_task *packet) |
| Handle worker task assigned to the city. More... | |
| #define ACTION_STARTED_UNIT_CITY | ( | action, | |
| actor, | |||
| target, | |||
| action_performer | |||
| ) |
| #define ACTION_STARTED_UNIT_SELF | ( | action, | |
| actor, | |||
| action_performer | |||
| ) |
| #define ACTION_STARTED_UNIT_TILE | ( | action, | |
| actor, | |||
| target, | |||
| action_performer | |||
| ) |
| #define ACTION_STARTED_UNIT_UNIT | ( | action, | |
| actor, | |||
| target, | |||
| action_performer | |||
| ) |
| #define ACTION_STARTED_UNIT_UNITS | ( | action, | |
| actor, | |||
| target, | |||
| action_performer | |||
| ) |
| 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 1046 of file unithand.cpp.
Referenced by dai_do_build_city().
|
static |
See also aiunit could_unit_move_to_tile()
Definition at line 4571 of file unithand.cpp.
Referenced by unit_move_handling().
|
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 3370 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 3425 of file unithand.cpp.
Referenced by unit_perform_action().
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 5471 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 5535 of file unithand.cpp.
Referenced by unit_perform_action().
|
static |
Do a "regular" attack.
This function assumes the attack is legal. The calling function should have already made all necessary checks.
Returns TRUE if action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.
Definition at line 3950 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 261 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 638 of file unithand.cpp.
Referenced by unit_perform_action().
|
static |
Expel the target unit to his 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 417 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 503 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 584 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 602 of file unithand.cpp.
Referenced by unit_perform_action().
|
static |
Change a unit's home city.
Returns TRUE iff the action could be done, FALSE if it couldn't.
Definition at line 3338 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 4539 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 662 of file unithand.cpp.
Referenced by unit_perform_action().
|
static |
Handle request to establish traderoute.
If pcity_dest is nullptr, 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 4899 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 4455 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 4385 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 622 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 232 of file unithand.cpp.
Referenced by unit_perform_action().
|
static |
Returns TRUE iff the specified nation blocks the specified action.
If the "action" is ACTION_ANY all actions are checked.
Definition at line 1002 of file unithand.cpp.
Referenced by action_not_enabled_reason().
|
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 957 of file unithand.cpp.
Referenced by action_not_enabled_reason().
|
static |
Returns an explaination why punit can't perform the specified action based on the current game state.
Definition at line 1046 of file unithand.cpp.
Referenced by explain_why_no_action_enabled(), and illegal_action_msg().
|
static |
Explain why punit can't perform any action at all based on its current game state.
Definition at line 1472 of file unithand.cpp.
Referenced by handle_unit_get_actions().
| void handle_unit_action_query | ( | struct connection * | pc, |
| const int | actor_id, | ||
| const int | target_id, | ||
| const action_id | action_type, | ||
| bool | disturb_player | ||
| ) |
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 2602 of file unithand.cpp.
| 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 3519 of file unithand.cpp.
|
static |
Handle change in unit activity.
Definition at line 3471 of file unithand.cpp.
Referenced by handle_unit_change_activity().
| 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 2705 of file unithand.cpp.
| 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 bool | disturb_player | ||
| ) |
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 1743 of file unithand.cpp.
| void handle_unit_orders | ( | struct player * | pplayer, |
| const struct packet_unit_orders * | packet | ||
| ) |
| void handle_unit_rename | ( | player * | pplayer, |
| int | unit_id, | ||
| const char * | name | ||
| ) |
Handle request to rename a unit.
Definition at line 1985 of file unithand.cpp.
| 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 5340 of file unithand.cpp.
Referenced by bounce_unit().
| 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 5260 of file unithand.cpp.
| void handle_unit_type_upgrade | ( | struct player * | pplayer, |
| Unit_type_id | uti | ||
| ) |
Upgrade all units of a given type.
Definition at line 161 of file unithand.cpp.
| void handle_worker_task | ( | struct player * | pplayer, |
| const struct packet_worker_task * | packet | ||
| ) |
Handle worker task assigned to the city.
Definition at line 5721 of file unithand.cpp.
|
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 2538 of file unithand.cpp.
Referenced by handle_unit_action_query().
| 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 2003 of file unithand.cpp.
Referenced by execute_orders(), handle_city_name_suggestion_req(), and illegal_action().
|
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.
| 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? |
Definition at line 2427 of file unithand.cpp.
Referenced by illegal_action().
|
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 921 of file unithand.cpp.
Referenced by action_not_enabled_reason().
|
static |
Returns the first player that may enable the specified action if war is declared.
Helper for need_war_player(). Use it in stead.
Definition at line 717 of file unithand.cpp.
Referenced by need_war_player().
Occupying move after an action.
Definition at line 368 of file unithand.cpp.
Referenced by do_attack().
|
static |
Returns TRUE iff the player is able to change his diplomatic relationship to the other player to war.
Note that the player can't declare war on someone he already is at war with.
Definition at line 695 of file unithand.cpp.
Referenced by need_war_player_hlp().
|
static |
Make sure everyone who can see combat does.
This includes a special case for attacking/defending:
Normally the player doesn't get the information about the units inside a city. However for attacking/defending the player has to know the unit of the other side. After the combat a remove_unit packet will be sent to the client to tidy up.
Note these packets must be sent out before unit_versus_unit is called, so that the original unit stats (HP) will be sent.
Definition at line 3547 of file unithand.cpp.
Referenced by do_attack(), and unit_bombard().
Send bombardment info to players.
Definition at line 3582 of file unithand.cpp.
Referenced by unit_bombard().
|
static |
Send combat info to players.
Definition at line 3619 of file unithand.cpp.
Referenced by do_attack().
|
static |
Update everything that needs changing when unit activity changes from old activity to new one.
Definition at line 5420 of file unithand.cpp.
Referenced by unit_activity_internal(), and unit_activity_targeted_internal().
| bool unit_activity_handling | ( | struct unit * | punit, |
| enum unit_activity | new_activity | ||
| ) |
Handle request for changing activity.
Definition at line 5485 of file unithand.cpp.
Referenced by adv_follow_path(), adv_unit_move(), auto_settler_setup_work(), auto_settlers_player(), bounce_unit(), create_city(), 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(), unit_activity_handling_targeted(), unit_activity_targeted_internal(), and unit_survive_autoattack().
| bool unit_activity_handling_targeted | ( | struct unit * | punit, |
| enum unit_activity | new_activity, | ||
| struct extra_type ** | new_target | ||
| ) |
Handle request for targeted activity.
Definition at line 5551 of file unithand.cpp.
Referenced by adv_follow_path(), auto_settler_setup_work(), handle_unit_change_activity_real(), and unit_activity_handling().
|
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 5512 of file unithand.cpp.
Referenced by do_action_activity(), do_action_activity_targeted(), handle_unit_server_side_agent_set(), and unit_activity_handling().
|
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 5572 of file unithand.cpp.
Referenced by do_action_activity_targeted(), and unit_activity_handling_targeted().
|
static |
Reduce the city's population after an attack action.
Definition at line 3668 of file unithand.cpp.
Referenced by do_attack(), and unit_bombard().
|
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 3691 of file unithand.cpp.
Referenced by unit_perform_action().
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 3239 of file unithand.cpp.
Referenced by do_unit_change_homecity(), and transfer_unit().
| 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 2718 of file unithand.cpp.
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().
|
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 3867 of file unithand.cpp.
Referenced by unit_perform_action().
|
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 4797 of file unithand.cpp.
Referenced by unit_perform_action().
| bool unit_move_handling | ( | struct unit * | punit, |
| struct tile * | pdesttile, | ||
| bool | igzoc, | ||
| 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.
'igzoc' means ignore ZOC rules - not necessary for igzoc units etc, but done in some special cases (moving barbarians out of initial hut). Should normally be FALSE.
'move_do_not_act' is another 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.
FIXME: This function needs a good cleaning.
Definition at line 4654 of file unithand.cpp.
Referenced by adv_unit_move(), dai_unit_attack(), dai_unit_move(), diplomat_bribe(), execute_orders(), occupy_move(), remove_city(), and unleash_barbarians().
|
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 3803 of file unithand.cpp.
Referenced by 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 2737 of file unithand.cpp.
Referenced by dai_manage_paratrooper(), diplomat_bribe(), execute_orders(), handle_unit_do_action(), handle_unit_type_upgrade(), occupy_move(), remove_city(), unit_do_action(), and unit_do_disband_trad().
|
static |
Delete a unit's current plans.
Definition at line 5324 of file unithand.cpp.
Referenced by handle_unit_server_side_agent_set().
|
static |
Inform the client that something went wrong during a unit diplomat query.
Definition at line 2588 of file unithand.cpp.
Referenced by handle_unit_action_query().
| bool unit_server_side_agent_set | ( | struct player * | pplayer, |
| struct unit * | punit, | ||
| enum server_side_agent | agent | ||
| ) |
Change controlling server side agent.
Definition at line 5386 of file unithand.cpp.
Referenced by dai_manage_settler(), and handle_unit_server_side_agent_set().