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 */
80bool maybe_make_veteran(struct unit *punit, int base_chance);
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);
124 enum unit_activity *activity,
125 struct extra_type **target);
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,
154
156 void (*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);
179bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost,
180 struct unit *embark_to, bool find_embark_target,
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 */
char * incite_cost
Definition comments.c:76
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2683
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2713
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
GType type
Definition repodlgs.c:1313
unit_info_use
Definition packets.h:66
Definition city.h:317
Definition tile.h:50
Definition unit.h:140
int moves_left
Definition unit.h:152
int homecity
Definition unit.h:148
#define fc__warn_unused_result
Definition support.h:109
void unit_bombs_unit(struct unit *attacker, struct unit *defender, int *att_hp, int *def_hp, const struct action *paction)
Definition unittools.c:359
void unit_did_action(struct unit *punit)
Definition unittools.c:5065
void collect_ransom(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2643
void unit_make_contact(const struct unit *punit, struct tile *ptile, struct player *pplayer)
Definition unittools.c:5180
void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius)
Definition unittools.c:1161
bool do_airline(struct unit *punit, struct city *city2, const struct action *paction)
Definition unittools.c:3066
bool execute_orders(struct unit *punit, const bool fresh)
Definition unittools.c:4518
void update_unit_activities(struct player *pplayer)
Definition unittools.c:670
void transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
Definition unittools.c:1553
void random_movements(struct player *pplayer)
Definition unittools.c:5097
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:292
struct unit_list * get_units_seen_via_ally(const struct player *pplayer, const struct player *aplayer)
Definition unittools.c:1416
void remove_allied_visibility(struct player *pplayer, struct player *aplayer, const struct unit_list *seen_units)
Definition unittools.c:1451
void combat_veterans(struct unit *attacker, struct unit *defender, bool powerless, int att_vet, int def_vet)
Definition unittools.c:404
void resolve_unit_stacks(struct player *pplayer, struct player *aplayer, bool verbose)
Definition unittools.c:1401
void do_nuclear_explosion(const struct action *paction, const struct unit_type *act_utype, struct player *pplayer, struct tile *ptile)
Definition unittools.c:3034
void unit_set_removal_callback(struct unit *punit, void(*callback)(struct unit *punit))
Definition unittools.c:1771
void package_unit(struct unit *punit, struct packet_unit_info *packet)
Definition unittools.c:2733
void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit)
Definition unittools.c:2864
void unit_activities_cancel_all_illegal_plr(const struct player *pplayer)
Definition unittools.c:818
void finalize_unit_phase_beginning(struct player *pplayer)
Definition unittools.c:702
void execute_unit_orders(struct player *pplayer)
Definition unittools.c:680
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2877
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:2199
bool place_unit(struct unit *punit, struct player *pplayer, struct city *pcity, struct unit *ptrans, bool force)
Definition unittools.c:1713
void notify_unit_experience(struct unit *punit)
Definition unittools.c:747
void unit_activities_cancel(struct unit *punit)
Definition unittools.c:800
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:2814
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:1665
void give_allied_visibility(struct player *pplayer, struct player *aplayer)
Definition unittools.c:1475
void unit_forget_last_activity(struct unit *punit)
Definition unittools.c:1053
void unit_unset_removal_callback(struct unit *punit)
Definition unittools.c:1785
int get_unit_vision_at(const struct unit *punit, const struct tile *ptile, enum vision_layer vlayer)
Definition unittools.c:4991
bool maybe_make_veteran(struct unit *punit, int base_chance)
Definition unittools.c:219
void unit_refresh_vision(struct unit *punit)
Definition unittools.c:5004
void do_explore(struct unit *punit)
Definition unittools.c:3099
void unit_transport_load_send(struct unit *punit, struct unit *ptrans)
Definition unittools.c:3389
bool unit_can_do_action_now(const struct unit *punit)
Definition unittools.c:5032
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2139
void unit_tc_effect_refresh(struct player *pplayer)
Definition unittools.c:692
bool do_paradrop(struct unit *punit, struct tile *ptile, const struct action *paction)
Definition unittools.c:3135
void player_restore_units(struct player *pplayer)
Definition unittools.c:481
bool is_refuel_point(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition unittools.c:1530
void unit_transport_unload_send(struct unit *punit)
Definition unittools.c:3441
bool is_unit_being_refueled(const struct unit *punit)
Definition unittools.c:1521
struct unit_type * find_a_unit_type(enum unit_role_id role, enum unit_role_id role_tech)
Definition unittools.c:175
bool unit_can_be_retired(struct unit *punit)
Definition unittools.c:5080
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:1605
void unit_activities_cancel_all_illegal_tile(const struct tile *ptile)
Definition unittools.c:830
bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost, bool verbose)
Definition unittools.c:1187
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, struct extra_type **target)
Definition unittools.c:1082
void unit_activities_cancel_all_illegal_area(const struct tile *ptile)
Definition unittools.c:845
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:1632
void unit_get_goods(struct unit *punit)
Definition unittools.c:1616
void send_all_known_units(struct conn_list *dest)
Definition unittools.c:2921
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:4078
void unit_list_refresh_vision(struct unit_list *punitlist)
Definition unittools.c:5021
void kill_unit(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2266
void bounce_unit(struct unit *punit, bool verbose)
Definition unittools.c:1225
bool unit_activity_needs_target_from_client(enum unit_activity activity)
Definition unittools.c:1062