Do not build gtk3.22-client by default
[freeciv.git] / server / unittools.h
blobd4b1f7fba8dca5e204de0909d1919fe9e59da029
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__UNITTOOLS_H
14 #define FC__UNITTOOLS_H
16 #include "fc_types.h"
18 #include "packets.h" /* enum unit_info_use */
19 #include "unitlist.h"
21 #define SPECENUM_NAME unit_loss_reason
22 #define SPECENUM_VALUE0 ULR_KILLED
23 #define SPECENUM_VALUE0NAME "killed"
24 #define SPECENUM_VALUE1 ULR_RETIRED
25 #define SPECENUM_VALUE1NAME "retired"
26 #define SPECENUM_VALUE2 ULR_DISBANDED
27 #define SPECENUM_VALUE2NAME "disbanded"
28 #define SPECENUM_VALUE3 ULR_BARB_UNLEASH
29 #define SPECENUM_VALUE3NAME "barb_unleash"
30 #define SPECENUM_VALUE4 ULR_CITY_LOST
31 #define SPECENUM_VALUE4NAME "city_lost"
32 #define SPECENUM_VALUE5 ULR_STARVED
33 #define SPECENUM_VALUE5NAME "starved"
34 #define SPECENUM_VALUE6 ULR_SOLD
35 #define SPECENUM_VALUE6NAME "sold"
36 #define SPECENUM_VALUE7 ULR_USED
37 #define SPECENUM_VALUE7NAME "used"
38 #define SPECENUM_VALUE8 ULR_EXECUTED
39 #define SPECENUM_VALUE8NAME "executed"
40 #define SPECENUM_VALUE9 ULR_ELIMINATED
41 #define SPECENUM_VALUE9NAME "eliminated"
42 #define SPECENUM_VALUE10 ULR_EDITOR
43 #define SPECENUM_VALUE10NAME "editor"
44 #define SPECENUM_VALUE11 ULR_NONNATIVE_TERR
45 #define SPECENUM_VALUE11NAME "nonnative_terr"
46 #define SPECENUM_VALUE12 ULR_PLAYER_DIED
47 #define SPECENUM_VALUE12NAME "player_died"
48 #define SPECENUM_VALUE13 ULR_ARMISTICE
49 #define SPECENUM_VALUE13NAME "armistice"
50 #define SPECENUM_VALUE14 ULR_SDI
51 #define SPECENUM_VALUE14NAME "sdi"
52 #define SPECENUM_VALUE15 ULR_DETONATED
53 #define SPECENUM_VALUE15NAME "detonated"
54 #define SPECENUM_VALUE16 ULR_MISSILE
55 #define SPECENUM_VALUE16NAME "missile"
56 #define SPECENUM_VALUE17 ULR_NUKE
57 #define SPECENUM_VALUE17NAME "nuke"
58 #define SPECENUM_VALUE18 ULR_HP_LOSS
59 #define SPECENUM_VALUE18NAME "hp_loss"
60 #define SPECENUM_VALUE19 ULR_FUEL
61 #define SPECENUM_VALUE19NAME "fuel"
62 #define SPECENUM_VALUE20 ULR_STACK_CONFLICT
63 #define SPECENUM_VALUE20NAME "stack_conflict"
64 #define SPECENUM_VALUE21 ULR_BRIBED
65 #define SPECENUM_VALUE21NAME "bribed"
66 #define SPECENUM_VALUE22 ULR_CAPTURED
67 #define SPECENUM_VALUE22NAME "captured"
68 #define SPECENUM_VALUE23 ULR_CAUGHT
69 #define SPECENUM_VALUE23NAME "caught"
70 #define SPECENUM_VALUE24 ULR_TRANSPORT_LOST
71 #define SPECENUM_VALUE24NAME "transport_lost"
72 #include "specenum_gen.h"
74 /* battle related */
75 struct unit_type *find_a_unit_type(enum unit_role_id role,
76 enum unit_role_id role_tech);
77 bool maybe_make_veteran(struct unit *punit);
78 void notify_unit_experience(struct unit *punit);
79 void unit_versus_unit(struct unit *attacker, struct unit *defender,
80 bool bombard, int *att_hp, int *def_hp);
81 void combat_veterans(struct unit *attacker, struct unit *defender);
83 /* move check related */
84 bool is_unit_being_refueled(const struct unit *punit);
85 bool is_airunit_refuel_point(const struct tile *ptile,
86 const struct player *pplayer,
87 const struct unit *punit);
89 /* turn update related */
90 void player_restore_units(struct player *pplayer);
91 void update_unit_activities(struct player *pplayer);
92 void execute_unit_orders(struct player *pplayer);
93 void finalize_unit_phase_beginning(struct player *pplayer);
95 /* various */
96 void place_partisans(struct tile *pcenter, struct player *powner,
97 int count, int sq_radius);
98 bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost,
99 bool verbose);
100 void resolve_unit_stacks(struct player *pplayer, struct player *aplayer,
101 bool verbose);
102 struct unit_list *get_units_seen_via_ally(const struct player *pplayer,
103 const struct player *aplayer);
104 void remove_allied_visibility(struct player *pplayer, struct player *aplayer,
105 const struct unit_list *seen_units);
106 void give_allied_visibility(struct player *pplayer, struct player *aplayer);
107 int get_unit_vision_at(struct unit *punit, struct tile *ptile,
108 enum vision_layer vlayer);
109 void unit_refresh_vision(struct unit *punit);
110 void unit_list_refresh_vision(struct unit_list *punitlist);
111 void bounce_unit(struct unit *punit, bool verbose);
112 bool unit_activity_needs_target_from_client(enum unit_activity activity);
113 void unit_assign_specific_activity_target(struct unit *punit,
114 enum unit_activity *activity,
115 struct extra_type **target);
116 void unit_forget_last_activity(struct unit *punit);
118 /* creation/deletion/upgrading */
119 void transform_unit(struct unit *punit, struct unit_type *to_unit,
120 bool has_to_pay);
121 struct unit *create_unit(struct player *pplayer, struct tile *ptile,
122 struct unit_type *punittype,
123 int veteran_level, int homecity_id, int moves_left);
124 struct unit *create_unit_full(struct player *pplayer, struct tile *ptile,
125 struct unit_type *punittype, int veteran_level,
126 int homecity_id, int moves_left, int hp_left,
127 struct unit *ptrans);
128 void wipe_unit(struct unit *punit, enum unit_loss_reason reason,
129 struct player *killer);
130 void kill_unit(struct unit *pkiller, struct unit *punit, bool vet);
132 struct unit *unit_change_owner(struct unit *punit, struct player *pplayer,
133 int homecity, enum unit_loss_reason reason)
134 fc__warn_unused_result;
136 /* sending to client */
137 void package_unit(struct unit *punit, struct packet_unit_info *packet);
138 void package_short_unit(struct unit *punit,
139 struct packet_unit_short_info *packet,
140 enum unit_info_use packet_use, int info_city_id);
141 void send_unit_info(struct conn_list *dest, struct unit *punit);
142 void send_all_known_units(struct conn_list *dest);
143 void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit);
145 /* doing a unit activity */
146 void do_nuclear_explosion(struct player *pplayer, struct tile *ptile);
147 bool do_airline(struct unit *punit, struct city *city2);
148 void do_explore(struct unit *punit);
149 bool do_paradrop(struct unit *punit, struct tile *ptile);
150 void unit_transport_load_send(struct unit *punit, struct unit *ptrans);
151 void unit_transport_unload_send(struct unit *punit);
152 bool unit_move(struct unit *punit, struct tile *ptile, int move_cost,
153 struct unit *embark_to);
154 bool execute_orders(struct unit *punit, const bool fresh);
156 bool unit_can_do_action_now(const struct unit *punit);
157 void unit_did_action(struct unit *punit);
159 bool unit_can_be_retired(struct unit *punit);
161 #endif /* FC__UNITTOOLS_H */