Freeciv-3.2
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);
127
128/* creation/deletion/upgrading */
129void transform_unit(struct unit *punit, const struct unit_type *to_unit,
130 int vet_loss);
131struct unit *create_unit(struct player *pplayer, struct tile *ptile,
132 const struct unit_type *punittype,
133 int veteran_level, int homecity_id, int moves_left);
134struct unit *create_unit_full(struct player *pplayer, struct tile *ptile,
135 const struct unit_type *punittype, int veteran_level,
136 int homecity_id, int moves_left, int hp_left,
137 struct unit *ptrans);
138struct unit *unit_virtual_prepare(struct player *pplayer, struct tile *ptile,
139 const struct unit_type *type,
140 int veteran_level, int homecity_id,
141 int moves_left, int hp_left);
142bool place_unit(struct unit *punit, struct player *pplayer,
143 struct city *pcity, struct unit *ptrans, bool force);
144void wipe_unit(struct unit *punit, enum unit_loss_reason reason,
145 struct player *killer);
146void kill_unit(struct unit *pkiller, struct unit *punit, bool vet);
147void collect_ransom(struct unit *pkiller, struct unit *punit, bool vet);
148
149struct unit *unit_change_owner(struct unit *punit, struct player *pplayer,
152
154 void (*callback)(struct unit *punit));
156
157/* Sending to client */
158void package_unit(struct unit *punit, struct packet_unit_info *packet);
159void package_short_unit(struct unit *punit,
160 struct packet_unit_short_info *packet,
161 enum unit_info_use packet_use, int info_city_id);
162void send_unit_info(struct conn_list *dest, struct unit *punit);
163void send_all_known_units(struct conn_list *dest);
164void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit);
165
166/* doing a unit activity */
167void do_nuclear_explosion(const struct action *paction,
168 const struct unit_type *act_utype,
169 struct player *pplayer, struct tile *ptile);
170bool do_airline(struct unit *punit, struct city *city2,
171 const struct action *paction);
172void do_explore(struct unit *punit);
173bool do_paradrop(struct unit *punit, struct tile *ptile,
174 const struct action *paction);
175void unit_transport_load_send(struct unit *punit, struct unit *ptrans);
177bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost,
178 struct unit *embark_to, bool find_embark_target,
180 bool enter_hut, bool frighten_hut);
181bool execute_orders(struct unit *punit, const bool fresh);
182
183bool unit_can_do_action_now(const struct unit *punit);
184void unit_did_action(struct unit *punit);
185
186bool unit_can_be_retired(struct unit *punit);
187
188void unit_activities_cancel(struct unit *punit);
189void unit_activities_cancel_all_illegal_plr(const struct player *pplayer);
190void unit_activities_cancel_all_illegal_tile(const struct tile *ptile);
191void unit_activities_cancel_all_illegal_area(const struct tile *ptile);
192
193void unit_get_goods(struct unit *punit);
194
195#endif /* FC__UNITTOOLS_H */
char * incite_cost
Definition comments.c:75
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2658
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2688
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
GType type
Definition repodlgs.c:1313
unit_info_use
Definition packets.h:66
Definition city.h:320
Definition tile.h:50
Definition unit.h:138
int moves_left
Definition unit.h:150
int homecity
Definition unit.h:146
#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:355
void unit_did_action(struct unit *punit)
Definition unittools.c:4901
void collect_ransom(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2494
void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius)
Definition unittools.c:1157
bool do_airline(struct unit *punit, struct city *city2, const struct action *paction)
Definition unittools.c:2911
bool execute_orders(struct unit *punit, const bool fresh)
Definition unittools.c:4354
void update_unit_activities(struct player *pplayer)
Definition unittools.c:666
void transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
Definition unittools.c:1545
void random_movements(struct player *pplayer)
Definition unittools.c:4933
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:288
struct unit_list * get_units_seen_via_ally(const struct player *pplayer, const struct player *aplayer)
Definition unittools.c:1409
void remove_allied_visibility(struct player *pplayer, struct player *aplayer, const struct unit_list *seen_units)
Definition unittools.c:1444
void combat_veterans(struct unit *attacker, struct unit *defender, bool powerless, int att_vet, int def_vet)
Definition unittools.c:400
void resolve_unit_stacks(struct player *pplayer, struct player *aplayer, bool verbose)
Definition unittools.c:1394
void do_nuclear_explosion(const struct action *paction, const struct unit_type *act_utype, struct player *pplayer, struct tile *ptile)
Definition unittools.c:2879
void unit_set_removal_callback(struct unit *punit, void(*callback)(struct unit *punit))
Definition unittools.c:1763
void package_unit(struct unit *punit, struct packet_unit_info *packet)
Definition unittools.c:2584
void unit_goes_out_of_sight(struct player *pplayer, struct unit *punit)
Definition unittools.c:2709
void unit_activities_cancel_all_illegal_plr(const struct player *pplayer)
Definition unittools.c:814
void finalize_unit_phase_beginning(struct player *pplayer)
Definition unittools.c:698
void execute_unit_orders(struct player *pplayer)
Definition unittools.c:676
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2722
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:2191
bool place_unit(struct unit *punit, struct player *pplayer, struct city *pcity, struct unit *ptrans, bool force)
Definition unittools.c:1705
void notify_unit_experience(struct unit *punit)
Definition unittools.c:743
void unit_activities_cancel(struct unit *punit)
Definition unittools.c:796
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:2665
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:1657
void give_allied_visibility(struct player *pplayer, struct player *aplayer)
Definition unittools.c:1468
void unit_forget_last_activity(struct unit *punit)
Definition unittools.c:1049
void unit_unset_removal_callback(struct unit *punit)
Definition unittools.c:1777
int get_unit_vision_at(const struct unit *punit, const struct tile *ptile, enum vision_layer vlayer)
Definition unittools.c:4827
bool maybe_make_veteran(struct unit *punit, int base_chance)
Definition unittools.c:219
void unit_refresh_vision(struct unit *punit)
Definition unittools.c:4840
void do_explore(struct unit *punit)
Definition unittools.c:2944
void unit_transport_load_send(struct unit *punit, struct unit *ptrans)
Definition unittools.c:3229
bool unit_can_do_action_now(const struct unit *punit)
Definition unittools.c:4868
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2131
void unit_tc_effect_refresh(struct player *pplayer)
Definition unittools.c:688
bool do_paradrop(struct unit *punit, struct tile *ptile, const struct action *paction)
Definition unittools.c:2980
void player_restore_units(struct player *pplayer)
Definition unittools.c:477
bool is_refuel_point(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition unittools.c:1523
void unit_transport_unload_send(struct unit *punit)
Definition unittools.c:3281
bool is_unit_being_refueled(const struct unit *punit)
Definition unittools.c:1514
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:4916
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:1597
void unit_activities_cancel_all_illegal_tile(const struct tile *ptile)
Definition unittools.c:826
bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost, bool verbose)
Definition unittools.c:1183
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, struct extra_type **target)
Definition unittools.c:1078
void unit_activities_cancel_all_illegal_area(const struct tile *ptile)
Definition unittools.c:841
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:1624
void unit_get_goods(struct unit *punit)
Definition unittools.c:1608
void send_all_known_units(struct conn_list *dest)
Definition unittools.c:2766
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:3918
void unit_list_refresh_vision(struct unit_list *punitlist)
Definition unittools.c:4857
void kill_unit(struct unit *pkiller, struct unit *punit, bool vet)
Definition unittools.c:2258
void bounce_unit(struct unit *punit, bool verbose)
Definition unittools.c:1221
bool unit_activity_needs_target_from_client(enum unit_activity activity)
Definition unittools.c:1058