webperimental: killstack decides stack protects.
[freeciv.git] / server / unithand.h
blob8b9e55afe4031f1c07a0f0448e2a1f0c0478ad07
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__UNITHAND_H
14 #define FC__UNITHAND_H
16 #include "unit.h"
18 #include "hand_gen.h"
20 /* A category of reasons why an action isn't enabled. */
21 enum ane_kind {
22 /* Explanation: wrong actor unit. */
23 ANEK_ACTOR_UNIT,
24 /* Explanation: no action target. */
25 ANEK_MISSING_TARGET,
26 /* Explanation: the action is redundant vs this target. */
27 ANEK_BAD_TARGET,
28 /* Explanation: bad actor terrain. */
29 ANEK_BAD_TERRAIN_ACT,
30 /* Explanation: bad target terrain. */
31 ANEK_BAD_TERRAIN_TGT,
32 /* Explanation: being transported. */
33 ANEK_IS_TRANSPORTED,
34 /* Explanation: not being transported. */
35 ANEK_IS_NOT_TRANSPORTED,
36 /* Explanation: transports a cargo unit. */
37 ANEK_IS_TRANSPORTING,
38 /* Explanation: doesn't transport a cargo unit. */
39 ANEK_IS_NOT_TRANSPORTING,
40 /* Explanation: actor unit has a home city. */
41 ANEK_ACTOR_HAS_HOME_CITY,
42 /* Explanation: actor unit has no a home city. */
43 ANEK_ACTOR_HAS_NO_HOME_CITY,
44 /* Explanation: must declare war first. */
45 ANEK_NO_WAR,
46 /* Explanation: can't be done to domestic targets. */
47 ANEK_DOMESTIC,
48 /* Explanation: can't be done to foreign targets. */
49 ANEK_FOREIGN,
50 /* Explanation: this nation can't act. */
51 ANEK_NATION_ACT,
52 /* Explanation: this nation can't be targeted. */
53 ANEK_NATION_TGT,
54 /* Explanation: not enough MP left. */
55 ANEK_LOW_MP,
56 /* Explanation: can't be done to city centers. */
57 ANEK_IS_CITY_CENTER,
58 /* Explanation: can't be done to non city centers. */
59 ANEK_IS_NOT_CITY_CENTER,
60 /* Explanation: can't be done to claimed target tiles. */
61 ANEK_TGT_IS_CLAIMED,
62 /* Explanation: can't be done to unclaimed target tiles. */
63 ANEK_TGT_IS_UNCLAIMED,
64 /* Explanation: can't be done because target is too near. */
65 ANEK_DISTANCE_NEAR,
66 /* Explanation: can't be done because target is too far away. */
67 ANEK_DISTANCE_FAR,
68 /* Explanation: can't be done to targets that far from the coast line. */
69 ANEK_TRIREME_MOVE,
70 /* Explanation: can't be done because the actor can't exit its
71 * transport. */
72 ANEK_DISEMBARK_ACT,
73 /* Explanation: actor can't reach unit at target. */
74 ANEK_TGT_UNREACHABLE,
75 /* Explanation: the action is disabled in this scenario. */
76 ANEK_SCENARIO_DISABLED,
77 /* Explanation: too close to a city. */
78 ANEK_CITY_TOO_CLOSE_TGT,
79 /* Explanation: the target city is too big. */
80 ANEK_CITY_TOO_BIG,
81 /* Explanation: the target city's population limit banned the action. */
82 ANEK_CITY_POP_LIMIT,
83 /* Explanation: the specified city don't have the needed capacity. */
84 ANEK_CITY_NO_CAPACITY,
85 /* Explanation: the target tile is unknown. */
86 ANEK_TGT_TILE_UNKNOWN,
87 /* Explanation: the action is blocked by another action. */
88 ANEK_ACTION_BLOCKS,
89 /* Explanation not detected. */
90 ANEK_UNKNOWN,
93 void unit_activity_handling(struct unit *punit,
94 enum unit_activity new_activity);
95 void unit_activity_handling_targeted(struct unit *punit,
96 enum unit_activity new_activity,
97 struct extra_type **new_target);
98 void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity,
99 bool rehome);
101 bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
102 bool igzoc, bool move_diplomat_city,
103 struct unit *embark_to);
105 bool unit_perform_action(struct player *pplayer,
106 const int actor_id,
107 const int target_id,
108 const int value,
109 const char *name,
110 const enum gen_action action_type,
111 const enum action_requester requester);
113 void illegal_action_msg(struct player *pplayer,
114 const enum event_type event,
115 struct unit *actor,
116 const int stopped_action,
117 const struct tile *target_tile,
118 const struct city *target_city,
119 const struct unit *target_unit);
121 enum ane_kind action_not_enabled_reason(struct unit *punit,
122 enum gen_action action_id,
123 const struct tile *target_tile,
124 const struct city *target_city,
125 const struct unit *target_unit);
127 #endif /* FC__UNITHAND_H */