Freeciv-3.3: /fast/freeciv/nightly/main/server/unittools.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
unittools.h
Go to the documentation of this file.
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.
7
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
15
16/* common */
17#include "fc_types.h"
18#include "packets.h" /* enum unit_info_use */
19#include "unitlist.h"
20
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/* Upkeep other than one of the above ones */
37#define SPECENUM_VALUE7 ULR_UPKEEP
38#define SPECENUM_VALUE7NAME "upkeep"
39#define SPECENUM_VALUE8 ULR_USED
40#define SPECENUM_VALUE8NAME "used"
41#define SPECENUM_VALUE9 ULR_EXECUTED
42#define SPECENUM_VALUE9NAME "executed"
43#define SPECENUM_VALUE10 ULR_ELIMINATED
44#define SPECENUM_VALUE10NAME "eliminated"
45#define SPECENUM_VALUE11 ULR_EDITOR
46#define SPECENUM_VALUE11NAME "editor"
47#define SPECENUM_VALUE12 ULR_NONNATIVE_TERR
48#define SPECENUM_VALUE12NAME "nonnative_terr"
49#define SPECENUM_VALUE13 ULR_PLAYER_DIED
50#define SPECENUM_VALUE13NAME "player_died"
51#define SPECENUM_VALUE14 ULR_ARMISTICE
52#define SPECENUM_VALUE14NAME "armistice"
53#define SPECENUM_VALUE15 ULR_SDI
54#define SPECENUM_VALUE15NAME "sdi"
55#define SPECENUM_VALUE16 ULR_DETONATED
56#define SPECENUM_VALUE16NAME "detonated"
57#define SPECENUM_VALUE17 ULR_MISSILE
58#define SPECENUM_VALUE17NAME "missile"
59#define SPECENUM_VALUE18 ULR_NUKE
60#define SPECENUM_VALUE18NAME "nuke"
61#define SPECENUM_VALUE19 ULR_HP_LOSS
62#define SPECENUM_VALUE19NAME "hp_loss"
63#define SPECENUM_VALUE20 ULR_FUEL
64#define SPECENUM_VALUE20NAME "fuel"
65#define SPECENUM_VALUE21 ULR_STACK_CONFLICT
66#define SPECENUM_VALUE21NAME "stack_conflict"
67#define SPECENUM_VALUE22 ULR_BRIBED
68#define SPECENUM_VALUE22NAME "bribed"
69#define SPECENUM_VALUE23 ULR_CAPTURED
70#define SPECENUM_VALUE23NAME "captured"
71#define SPECENUM_VALUE24 ULR_CAUGHT
72#define SPECENUM_VALUE24NAME "caught"
73#define SPECENUM_VALUE25 ULR_TRANSPORT_LOST
74#define SPECENUM_VALUE25NAME "transport_lost"
75#include "specenum_gen.h"
76
77/* battle related */
78struct unit_type *find_a_unit_type(enum unit_role_id role,
79 enum unit_role_id role_tech);
80bool maybe_make_veteran(struct unit *punit, int base_chance);
81void notify_unit_experience(struct unit *punit);
82bool unit_versus_unit(struct unit *attacker, struct unit *defender,
83 int *att_hp, int *def_hp, int *att_vet, int *def_vet,
84 const struct action *paction);
85void unit_bombs_unit(struct unit *attacker, struct unit *defender,
86 int *att_hp, int *def_hp,
87 const struct action *paction);
88void combat_veterans(struct unit *attacker, struct unit *defender,
89 bool powerless, int att_vet, int def_vet);
90
91/* Move check related */
92bool is_unit_being_refueled(const struct unit *punit);
93bool is_refuel_point(const struct tile *ptile,
94 const struct player *pplayer,
95 const struct unit *punit);
96
97/* Turn update related */
98void player_restore_units(struct player *pplayer);
99void update_unit_activities(struct player *pplayer);
100void random_movements(struct player *pplayer);
101void execute_unit_orders(struct player *pplayer);
102void unit_tc_effect_refresh(struct player *pplayer);
103void finalize_unit_phase_beginning(struct player *pplayer);
104
105/* Various */
106void place_partisans(struct tile *pcenter, struct player *powner,
107 int count, int sq_radius);
108bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost,
109 bool verbose);
110void resolve_unit_stacks(struct player *pplayer, struct player *aplayer,
111 bool verbose);
112struct unit_list *get_units_seen_via_ally(const struct player *pplayer,
113 const struct player *aplayer);
114void remove_allied_visibility(struct player *pplayer, struct player *aplayer,
115 const struct unit_list *seen_units);
116void give_allied_visibility(struct player *pplayer, struct player *aplayer);
117int get_unit_vision_at(const struct unit *punit, const struct tile *ptile,
118 enum vision_layer vlayer);
119void unit_refresh_vision(struct unit *punit);
120void unit_list_refresh_vision(struct unit_list *punitlist);
121void bounce_unit(struct unit *punit, bool verbose);
122bool unit_activity_needs_target_from_client(enum unit_activity activity);
123void unit_assign_specific_activity_target(struct unit *punit,
124 enum unit_activity *activity,
125 struct extra_type **target);
126void unit_forget_last_activity(struct unit *punit);
127void unit_make_contact(const struct unit *punit,
128 struct tile *ptile, struct player *pplayer);
129
130/* creation/deletion/upgrading */
131void transform_unit(struct unit *punit, const struct unit_type *to_unit,
132 int vet_loss);
133struct unit *create_unit(struct player *pplayer, struct tile *ptile,
134 const struct unit_type *punittype,
135 int veteran_level, int homecity_id, int moves_left);
136struct unit *create_unit_full(struct player *pplayer, struct tile *ptile,
137 const struct unit_type *punittype, int veteran_level,
138 int homecity_id, int moves_left, int hp_left,
139 struct unit *ptrans);
140struct unit *unit_virtual_prepare(struct player *pplayer, struct tile *ptile,
141 const struct unit_type *type,
142 int veteran_level, int homecity_id,
143 int moves_left, int hp_left);
144bool place_unit(struct unit *punit, struct player *pplayer,
145 struct city *pcity, struct unit *ptrans, bool force);
146void wipe_unit(struct unit *punit, enum unit_loss_reason reason,
147 struct player *killer);
148void kill_unit(struct unit *pkiller, struct unit *punit, bool vet);
149void collect_ransom(struct unit *pkiller, struct unit *punit, bool vet);
150
151struct unit *unit_change_owner(struct unit *punit, struct player *pplayer,
152 int homecity, enum unit_loss_reason reason)
153 fc__warn_unused_result;
154
155void unit_set_removal_callback(struct unit *punit,
156 void (*callback)(struct unit *punit));
157void unit_unset_removal_callback(struct unit *punit);
158
159/* Sending to client */
160void package_unit(struct unit *punit, struct packet_unit_info *packet);
161void package_short_unit(struct unit *punit,
162 struct packet_unit_short_info *packet,
163 enum unit_info_use packet_use, int info_city_id);
164void send_unit_info(struct conn_list *dest, struct unit *punit);
165void send_all_known_units(struct conn_list *dest);
166void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit);
167
168/* doing a unit activity */
169void do_nuclear_explosion(const struct action *paction,
170 const struct unit_type *act_utype,
171 struct player *pplayer, struct tile *ptile);
172bool do_airline(struct unit *punit, struct city *city2,
173 const struct action *paction);
174void do_explore(struct unit *punit);
175bool do_paradrop(struct unit *punit, struct tile *ptile,
176 const struct action *paction);
177void unit_transport_load_send(struct unit *punit, struct unit *ptrans);
178void unit_transport_unload_send(struct unit *punit);
179bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost,
180 struct unit *embark_to, bool find_embark_target,
181 bool conquer_city_allowed, bool conquer_extras_allowed,
182 bool enter_hut, bool frighten_hut);
183bool execute_orders(struct unit *punit, const bool fresh);
184
185bool unit_can_do_action_now(const struct unit *punit);
186void unit_did_action(struct unit *punit);
187
188bool unit_can_be_retired(struct unit *punit);
189
190void unit_activities_cancel(struct unit *punit);
191void unit_activities_cancel_all_illegal_plr(const struct player *pplayer);
192void unit_activities_cancel_all_illegal_tile(const struct tile *ptile);
193void unit_activities_cancel_all_illegal_area(const struct tile *ptile);
194
195void unit_get_goods(struct unit *punit);
196
197#endif /* FC__UNITTOOLS_H */
incite_cost
char * incite_cost
Definition comments.c:74
enter_hut
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2665
frighten_hut
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2695
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
fc_types.h
type
GType type
Definition repodlgs.c:1313
packets.h
unit_info_use
unit_info_use
Definition packets.h:66
specenum_gen.h
action
Definition actions.h:106
callback
Definition gui_main.c:2405
city
Definition city.h:320
extra_type
Definition extras.h:88
packet_unit_info
Definition packets_gen.h:637
packet_unit_short_info
Definition packets_gen.h:678
player
Definition player.h:249
tile
Definition tile.h:50
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::moves_left
int moves_left
Definition unit.h:152
unit::homecity
int homecity
Definition unit.h:148
veteran_level
Definition unittype.h:493
fc__warn_unused_result
#define fc__warn_unused_result
Definition support.h:109
unitlist.h
unit_bombs_unit
void unit_bombs_unit(struct unit *attacker, struct unit *defender, int *att_hp, int *def_hp, const struct action *paction)
Definition unittools.c:356
unit_did_action
void unit_did_action(struct unit *punit)
Definition unittools.c:5062
collect_ransom
void collect_ransom(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2644
unit_make_contact
void unit_make_contact(const struct unit *punit, struct tile *ptile, struct player *pplayer)
Definition unittools.c:5177
place_partisans
void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius)
Definition unittools.c:1162
do_airline
bool do_airline(struct unit *punit, struct city *city2, const struct action *paction)
Definition unittools.c:3067
execute_orders
bool execute_orders(struct unit *punit, const bool fresh)
Definition unittools.c:4515
update_unit_activities
void update_unit_activities(struct player *pplayer)
Definition unittools.c:667
transform_unit
void transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
Definition unittools.c:1554
random_movements
void random_movements(struct player *pplayer)
Definition unittools.c:5094
unit_versus_unit
bool unit_versus_unit(struct unit *attacker, struct unit *defender, int *att_hp, int *def_hp, int *att_vet, int *def_vet, const struct action *paction)
Definition unittools.c:289
get_units_seen_via_ally
struct unit_list * get_units_seen_via_ally(const struct player *pplayer, const struct player *aplayer)
Definition unittools.c:1417
remove_allied_visibility
void remove_allied_visibility(struct player *pplayer, struct player *aplayer, const struct unit_list *seen_units)
Definition unittools.c:1452
combat_veterans
void combat_veterans(struct unit *attacker, struct unit *defender, bool powerless, int att_vet, int def_vet)
Definition unittools.c:401
resolve_unit_stacks
void resolve_unit_stacks(struct player *pplayer, struct player *aplayer, bool verbose)
Definition unittools.c:1402
do_nuclear_explosion
void do_nuclear_explosion(const struct action *paction, const struct unit_type *act_utype, struct player *pplayer, struct tile *ptile)
Definition unittools.c:3035
unit_set_removal_callback
void unit_set_removal_callback(struct unit *punit, void(*callback)(struct unit *punit))
Definition unittools.c:1772
package_unit
void package_unit(struct unit *punit, struct packet_unit_info *packet)
Definition unittools.c:2734
unit_goes_out_of_sight
void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit)
Definition unittools.c:2865
unit_activities_cancel_all_illegal_plr
void unit_activities_cancel_all_illegal_plr(const struct player *pplayer)
Definition unittools.c:819
finalize_unit_phase_beginning
void finalize_unit_phase_beginning(struct player *pplayer)
Definition unittools.c:699
execute_unit_orders
void execute_unit_orders(struct player *pplayer)
Definition unittools.c:677
send_unit_info
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2878
unit_change_owner
struct unit * unit_change_owner(struct unit *punit, struct player *pplayer, int homecity, enum unit_loss_reason reason) fc__warn_unused_result
Definition unittools.c:2200
place_unit
bool place_unit(struct unit *punit, struct player *pplayer, struct city *pcity, struct unit *ptrans, bool force)
Definition unittools.c:1714
notify_unit_experience
void notify_unit_experience(struct unit *punit)
Definition unittools.c:744
unit_activities_cancel
void unit_activities_cancel(struct unit *punit)
Definition unittools.c:801
package_short_unit
void package_short_unit(struct unit *punit, struct packet_unit_short_info *packet, enum unit_info_use packet_use, int info_city_id)
Definition unittools.c:2815
unit_virtual_prepare
struct unit * unit_virtual_prepare(struct player *pplayer, struct tile *ptile, const struct unit_type *type, int veteran_level, int homecity_id, int moves_left, int hp_left)
Definition unittools.c:1666
give_allied_visibility
void give_allied_visibility(struct player *pplayer, struct player *aplayer)
Definition unittools.c:1476
unit_forget_last_activity
void unit_forget_last_activity(struct unit *punit)
Definition unittools.c:1054
unit_unset_removal_callback
void unit_unset_removal_callback(struct unit *punit)
Definition unittools.c:1786
get_unit_vision_at
int get_unit_vision_at(const struct unit *punit, const struct tile *ptile, enum vision_layer vlayer)
Definition unittools.c:4988
maybe_make_veteran
bool maybe_make_veteran(struct unit *punit, int base_chance)
Definition unittools.c:219
unit_refresh_vision
void unit_refresh_vision(struct unit *punit)
Definition unittools.c:5001
do_explore
void do_explore(struct unit *punit)
Definition unittools.c:3100
unit_transport_load_send
void unit_transport_load_send(struct unit *punit, struct unit *ptrans)
Definition unittools.c:3386
unit_can_do_action_now
bool unit_can_do_action_now(const struct unit *punit)
Definition unittools.c:5029
wipe_unit
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2140
unit_tc_effect_refresh
void unit_tc_effect_refresh(struct player *pplayer)
Definition unittools.c:689
do_paradrop
bool do_paradrop(struct unit *punit, struct tile *ptile, const struct action *paction)
Definition unittools.c:3136
player_restore_units
void player_restore_units(struct player *pplayer)
Definition unittools.c:478
is_refuel_point
bool is_refuel_point(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition unittools.c:1531
unit_transport_unload_send
void unit_transport_unload_send(struct unit *punit)
Definition unittools.c:3438
is_unit_being_refueled
bool is_unit_being_refueled(const struct unit *punit)
Definition unittools.c:1522
find_a_unit_type
struct unit_type * find_a_unit_type(enum unit_role_id role, enum unit_role_id role_tech)
Definition unittools.c:175
unit_can_be_retired
bool unit_can_be_retired(struct unit *punit)
Definition unittools.c:5077
create_unit
struct unit * create_unit(struct player *pplayer, struct tile *ptile, const struct unit_type *punittype, int veteran_level, int homecity_id, int moves_left)
Definition unittools.c:1606
unit_activities_cancel_all_illegal_tile
void unit_activities_cancel_all_illegal_tile(const struct tile *ptile)
Definition unittools.c:831
teleport_unit_to_city
bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost, bool verbose)
Definition unittools.c:1188
unit_assign_specific_activity_target
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, struct extra_type **target)
Definition unittools.c:1083
unit_activities_cancel_all_illegal_area
void unit_activities_cancel_all_illegal_area(const struct tile *ptile)
Definition unittools.c:846
create_unit_full
struct unit * create_unit_full(struct player *pplayer, struct tile *ptile, const struct unit_type *punittype, int veteran_level, int homecity_id, int moves_left, int hp_left, struct unit *ptrans)
Definition unittools.c:1633
unit_get_goods
void unit_get_goods(struct unit *punit)
Definition unittools.c:1617
send_all_known_units
void send_all_known_units(struct conn_list *dest)
Definition unittools.c:2922
unit_move
bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, struct unit *embark_to, bool find_embark_target, bool conquer_city_allowed, bool conquer_extras_allowed, bool enter_hut, bool frighten_hut)
Definition unittools.c:4075
unit_list_refresh_vision
void unit_list_refresh_vision(struct unit_list *punitlist)
Definition unittools.c:5018
kill_unit
void kill_unit(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2267
bounce_unit
void bounce_unit(struct unit *punit, bool verbose)
Definition unittools.c:1226
unit_activity_needs_target_from_client
bool unit_activity_needs_target_from_client(enum unit_activity activity)
Definition unittools.c:1063