Freeciv-3.2
Loading...
Searching...
No Matches
control.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__CONTROL_H
14#define FC__CONTROL_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* common */
21#include "actions.h"
22#include "packets.h"
23#include "unitlist.h"
24
35
36/* Selecting unit from a stack without popup. */
40
41#define can_unit_do_activity_client(_punit_, _act_) \
42 can_unit_do_activity(&(wld.map), _punit_, _act_)
43#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_) \
44 can_unit_do_activity_targeted(&(wld.map), _punit_, _act_, _tgt_)
45#define can_units_do_activity_client(_punits_, _act_) \
46 can_units_do_activity(&(wld.map), _punits_, _act_)
47#define can_units_do_activity_targeted_client(_punits_, _act_, _tgt_) \
48 can_units_do_activity_targeted(&(wld.map), _punits_, _act_, _tgt_)
49
50void control_init(void);
51void control_free(void);
52void control_unit_killed(struct unit *punit);
53
54void unit_change_battlegroup(struct unit *punit, int battlegroup);
56
59extern struct extra_type *connect_tgt;
61extern int goto_last_tgt;
62extern int goto_last_sub_tgt;
64extern bool non_ai_unit_focus;
65
66bool can_unit_do_connect(struct unit *punit,
67 enum unit_activity activity,
68 struct extra_type *tgt);
69
70int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra,
71 const struct unit *punit, const struct player *pplayer, int rec);
72
73void do_move_unit(struct unit *punit, struct unit *target_unit);
74void do_unit_goto(struct tile *ptile);
75void do_unit_paradrop_to(struct unit *punit, struct tile *ptile);
76void do_unit_patrol_to(struct tile *ptile);
77void do_unit_connect(struct tile *ptile,
78 enum unit_activity activity,
79 struct extra_type *tgt);
80void do_map_click(struct tile *ptile, enum quickselect_type qtype);
81void control_mouse_cursor(struct tile *ptile);
82
83void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
85 struct extra_type *tgt,
86 int last_tgt,
90void clear_hover_state(void);
93 struct tile *dest_tile);
94void request_move_unit_direction(struct unit *punit, int dir);
97 enum unit_activity act,
98 struct extra_type *tgt);
99void request_unit_load(struct unit *pcargo, struct unit *ptransporter,
100 struct tile *ptile);
101void request_unit_unload(struct unit *pcargo);
102void request_unit_ssa_set(const struct unit *punit,
104void request_unit_autosettlers(const struct unit *punit);
108void request_unit_connect(enum unit_activity activity,
109 struct extra_type *tgt);
110void request_unit_disband(struct unit *punit);
111void request_unit_fortify(struct unit *punit);
113 action_id act_id, int sub_tgt_id);
114void request_unit_move_done(void);
115void request_unit_paradrop(struct unit_list *punits);
116void request_unit_patrol(void);
117void request_unit_pillage(struct unit *punit);
118void request_unit_sentry(struct unit *punit);
119struct unit *request_unit_unload_all(struct unit *punit);
120void request_unit_airlift(struct unit *punit, struct city *pcity);
121void request_unit_return(struct unit *punit);
122void request_unit_upgrade(struct unit *punit);
123void request_unit_convert(struct unit *punit);
124void request_units_wait(struct unit_list *punits);
125void request_unit_wakeup(struct unit *punit);
126
127#define SPECENUM_NAME unit_select_type_mode
128#define SPECENUM_VALUE0 SELTYPE_SINGLE
129#define SPECENUM_VALUE1 SELTYPE_SAME
130#define SPECENUM_VALUE2 SELTYPE_ALL
131#include "specenum_gen.h"
132
133#define SPECENUM_NAME unit_select_location_mode
134#define SPECENUM_VALUE0 SELLOC_UNITS /* Units on tile. */
135#define SPECENUM_VALUE1 SELLOC_TILE /* Tile. */
136#define SPECENUM_VALUE2 SELLOC_CONT /* Continent. */
137#define SPECENUM_VALUE3 SELLOC_LAND /* Move type: land. */
138#define SPECENUM_VALUE4 SELLOC_SEA /* Move type: sea. */
139#define SPECENUM_VALUE5 SELLOC_BOTH /* Move type: both. */
140#define SPECENUM_VALUE6 SELLOC_WORLD /* World. */
141#define SPECENUM_COUNT SELLOC_COUNT
142#include "specenum_gen.h"
143
152
153void request_unit_select(struct unit_list *punits,
156
157void request_do_action(action_id action, int actor_id,
158 int target_id, int sub_tgt, const char *name);
159void request_action_details(action_id action, int actor_id, int target_id);
160void action_confirmation(struct act_confirmation_data *data, bool confirm);
163void request_toggle_map_grid(void);
173void request_toggle_terrain(void);
174void request_toggle_coastline(void);
175void request_toggle_paths(void);
177void request_toggle_mines(void);
178void request_toggle_bases(void);
179void request_toggle_resources(void);
180void request_toggle_huts(void);
181void request_toggle_pollution(void);
182void request_toggle_cities(void);
183void request_toggle_units(void);
188
189void wakeup_sentried_units(struct tile *ptile);
190void clear_unit_orders(struct unit *punit);
191
192bool unit_is_in_focus(const struct unit *punit);
193struct unit *get_focus_unit_on_tile(const struct tile *ptile);
194struct unit *head_of_units_in_focus(void);
195struct unit_list *get_units_in_focus(void);
196int get_num_units_in_focus(void);
197
198void unit_focus_set(struct unit *punit);
200void unit_focus_add(struct unit *punit);
201void unit_focus_remove(struct unit *punit);
202void unit_focus_urgent(struct unit *punit);
203
205void unit_focus_update(void);
206
208void update_unit_pix_label(struct unit_list *punitlist);
209
210struct unit *find_visible_unit(struct tile *ptile);
211void set_units_in_combat(struct unit *pattacker, struct unit *pdefender);
212double blink_active_unit(void);
213double blink_turn_done_button(void);
214
215bool should_ask_server_for_actions(const struct unit *punit);
220
221void key_cancel_action(void);
222void key_center_capital(void);
223void key_city_full_bar_toggle(void);
224void key_city_names_toggle(void);
225void key_city_growth_toggle(void);
227void key_city_buycost_toggle(void);
230void key_terrain_toggle(void);
231void key_coastline_toggle(void);
232void key_paths_toggle(void);
233void key_irrigation_toggle(void);
234void key_mines_toggle(void);
235void key_bases_toggle(void);
236void key_resources_toggle(void);
237void key_huts_toggle(void);
238void key_pollution_toggle(void);
239void key_cities_toggle(void);
240void key_units_toggle(void);
241void key_unit_solid_bg_toggle(void);
242void key_unit_shields_toggle(void);
243void key_focus_unit_toggle(void);
244void key_fog_of_war_toggle(void);
245void key_end_turn(void);
246void key_city_outlines_toggle(void);
247void key_city_output_toggle(void);
248void key_map_grid_toggle(void);
249void key_map_borders_toggle(void);
250void key_map_native_toggle(void);
253void key_unit_airbase(void);
254void key_unit_auto_explore(void);
255void key_unit_auto_settle(void);
256void key_unit_build_city(void);
257void key_unit_build_wonder(void);
259 struct extra_type *tgt);
260void key_unit_action_select(void);
262void key_unit_clean(void);
263void key_unit_convert(void);
264void key_unit_done(void);
265void key_unit_fortify(void);
266void key_unit_fortress(void);
267void key_unit_goto(void);
268void key_unit_homecity(void);
269void key_unit_irrigate(void);
270void key_unit_cultivate(void);
271void key_unit_mine(void);
272void key_unit_plant(void);
273void key_unit_patrol(void);
274void key_unit_paradrop(void);
275void key_unit_pillage(void);
276void key_unit_road(void);
277void key_unit_sentry(void);
278void key_unit_teleport(void);
279void key_unit_trade_route(void);
280void key_unit_transform(void);
281void key_unit_unload_all(void);
282void key_unit_wait(void);
283void key_unit_wakeup_others(void);
284void key_unit_assign_battlegroup(int battlegroup, bool append);
285void key_unit_select_battlegroup(int battlegroup, bool append);
286
287void key_editor_toggle(void);
290
291void finish_city(struct tile *ptile, const char *name);
292void cancel_city(struct tile *ptile);
293
294/* don't change this unless you also put more entries in data/Freeciv */
295#define MAX_NUM_UNITS_BELOW 4
296
297extern int num_units_below;
298
299#ifdef __cplusplus
300}
301#endif /* __cplusplus */
302
303#endif /* FC__CONTROL_H */
char * incite_cost
Definition comments.c:75
double blink_turn_done_button(void)
Definition control.c:925
void key_coastline_toggle(void)
Definition control.c:3952
void key_irrigation_toggle(void)
Definition control.c:3968
void request_toggle_huts(void)
Definition control.c:2645
void key_unit_sentry(void)
Definition control.c:3756
void request_toggle_city_outlines(void)
Definition control.c:2398
void key_unit_road(void)
Definition control.c:3738
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1543
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2802
void request_toggle_resources(void)
Definition control.c:2632
void request_toggle_city_names(void)
Definition control.c:2476
void key_recall_previous_focus_unit(void)
Definition control.c:3320
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1836
void request_toggle_unit_stack_size(void)
Definition control.c:2541
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_city_output_toggle(void)
Definition control.c:3853
void request_toggle_focus_unit(void)
Definition control.c:2723
void request_toggle_city_output(void)
Definition control.c:2411
void request_unit_return(struct unit *punit)
Definition control.c:1552
void request_unit_fortify(struct unit *punit)
Definition control.c:2353
void key_unit_build_city(void)
Definition control.c:3353
void key_editor_recalculate_borders(void)
Definition control.c:4072
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1511
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2223
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity connect_activity, struct extra_type *tgt, int last_tgt, int goto_last_sub_tgt, action_id goto_last_action, enum unit_orders goto_last_order)
Definition control.c:290
enum unit_orders goto_last_order
Definition control.c:96
void request_units_wait(struct unit_list *punits)
Definition control.c:2763
void request_unit_wakeup(struct unit *punit)
Definition control.c:1600
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:396
void key_focus_unit_toggle(void)
Definition control.c:4048
void request_toggle_map_grid(void)
Definition control.c:2424
void action_decision_request(struct unit *actor_unit)
Definition control.c:1110
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2606
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1032
int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra, const struct unit *punit, const struct player *pplayer, int rec)
Definition control.c:1337
void key_unit_action_select(void)
Definition control.c:3384
void key_unit_auto_explore(void)
Definition control.c:3577
void key_cancel_action(void)
Definition control.c:3258
void request_toggle_city_buycost(void)
Definition control.c:2515
void key_unit_auto_settle(void)
Definition control.c:3590
void clear_hover_state(void)
Definition control.c:328
void request_toggle_map_native(void)
Definition control.c:2450
void request_unit_patrol(void)
Definition control.c:2319
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3375
void key_city_full_bar_toggle(void)
Definition control.c:3885
void key_bases_toggle(void)
Definition control.c:3984
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2909
void key_map_native_toggle(void)
Definition control.c:3877
void request_toggle_map_borders(void)
Definition control.c:2437
void key_resources_toggle(void)
Definition control.c:3992
void unit_focus_add(struct unit *punit)
Definition control.c:561
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1130
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3185
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:339
int goto_last_tgt
Definition control.c:94
struct extra_type * connect_tgt
Definition control.c:91
void key_unit_paradrop(void)
Definition control.c:3479
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void key_end_turn(void)
Definition control.c:3312
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_toggle_irrigation(void)
Definition control.c:2593
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2141
void request_unit_pillage(struct unit *punit)
Definition control.c:2364
void key_unit_teleport(void)
Definition control.c:3495
void request_center_focus_unit(void)
Definition control.c:2750
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:4040
void key_city_productions_toggle(void)
Definition control.c:3919
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1415
void key_unit_build_wonder(void)
Definition control.c:3363
void key_unit_plant(void)
Definition control.c:3696
void key_unit_fortress(void)
Definition control.c:3624
quickselect_type
Definition control.h:37
@ SELECT_LAND
Definition control.h:38
@ SELECT_APPEND
Definition control.h:38
@ SELECT_SEA
Definition control.h:38
@ SELECT_POPUP
Definition control.h:38
@ SELECT_FOCUS
Definition control.h:38
void key_unit_mine(void)
Definition control.c:3688
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2094
void request_toggle_fog_of_war(void)
Definition control.c:2736
void request_unit_load(struct unit *pcargo, struct unit *ptransporter, struct tile *ptile)
Definition control.c:2156
void key_unit_pillage(void)
Definition control.c:3708
void request_unit_unload(struct unit *pcargo)
Definition control.c:2194
void key_editor_toggle_fogofwar(void)
Definition control.c:4081
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2128
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2684
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:985
void key_unit_irrigate(void)
Definition control.c:3668
void request_unit_build_city(struct unit *punit)
Definition control.c:1817
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:255
void key_unit_unload_all(void)
Definition control.c:3517
void key_cities_toggle(void)
Definition control.c:4016
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3341
void key_city_outlines_toggle(void)
Definition control.c:3845
void key_unit_homecity(void)
Definition control.c:3641
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2246
cursor_hover_state
Definition control.h:25
@ HOVER_GOTO
Definition control.h:27
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_TELEPORT
Definition control.h:28
@ HOVER_ACT_SEL_TGT
Definition control.h:32
@ HOVER_NONE
Definition control.h:26
@ HOVER_CONNECT
Definition control.h:30
@ HOVER_PATROL
Definition control.h:31
@ HOVER_GOTO_SEL_TGT
Definition control.h:33
void key_unit_patrol(void)
Definition control.c:3487
void request_toggle_city_full_bar(void)
Definition control.c:2463
void request_toggle_city_growth(void)
Definition control.c:2489
void key_unit_solid_bg_toggle(void)
Definition control.c:4032
void request_toggle_unit_solid_bg(void)
Definition control.c:2697
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void key_terrain_toggle(void)
Definition control.c:3944
void key_paths_toggle(void)
Definition control.c:3960
void request_unit_sentry(struct unit *punit)
Definition control.c:2342
void key_unit_wakeup_others(void)
Definition control.c:3550
bool non_ai_unit_focus
Definition control.c:125
enum cursor_hover_state hover_state
Definition control.c:89
void key_unit_stack_size_toggle(void)
Definition control.c:3936
void key_huts_toggle(void)
Definition control.c:4000
void key_fog_of_war_toggle(void)
Definition control.c:4056
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1482
void clear_unit_orders(struct unit *punit)
Definition control.c:481
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2554
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
void key_units_toggle(void)
Definition control.c:4024
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3241
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:591
void request_toggle_bases(void)
Definition control.c:2619
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3225
void key_unit_trade_route(void)
Definition control.c:3503
void request_toggle_coastline(void)
Definition control.c:2567
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3819
void key_map_grid_toggle(void)
Definition control.c:3861
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4091
void key_pollution_toggle(void)
Definition control.c:4008
struct unit * head_of_units_in_focus(void)
Definition control.c:410
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:822
void key_city_growth_toggle(void)
Definition control.c:3902
void key_unit_action_select_tgt(void)
Definition control.c:3406
void key_city_buycost_toggle(void)
Definition control.c:3911
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3768
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1879
void key_unit_done(void)
Definition control.c:3463
void key_city_trade_routes_toggle(void)
Definition control.c:3928
void request_toggle_city_trade_routes(void)
Definition control.c:2528
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:636
void request_unit_convert(struct unit *punit)
Definition control.c:2118
void request_toggle_paths(void)
Definition control.c:2580
void request_toggle_unit_shields(void)
Definition control.c:2710
void key_city_names_toggle(void)
Definition control.c:3893
void unit_register_battlegroup(struct unit *punit)
Definition control.c:275
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1621
void unit_focus_update(void)
Definition control.c:789
void key_unit_airbase(void)
Definition control.c:3560
void key_unit_goto(void)
Definition control.c:3471
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
void key_unit_convert(void)
Definition control.c:3602
void key_unit_clean(void)
Definition control.c:3720
void key_center_capital(void)
Definition control.c:3295
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1583
void request_toggle_cities(void)
Definition control.c:2671
void key_unit_fortify(void)
Definition control.c:3612
void key_editor_toggle(void)
Definition control.c:4064
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3780
void request_unit_move_done(void)
Definition control.c:2776
void auto_center_on_focus_unit(void)
Definition control.c:434
void key_unit_cultivate(void)
Definition control.c:3676
double blink_active_unit(void)
Definition control.c:892
void unit_focus_advance(bool accept_current)
Definition control.c:688
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2502
void cancel_city(struct tile *ptile)
Definition control.c:4110
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
void request_toggle_pollution(void)
Definition control.c:2658
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3976
void do_unit_goto(struct tile *ptile)
Definition control.c:3124
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
void key_map_borders_toggle(void)
Definition control.c:3869
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit * actor_unit
Definition dialogs_g.h:55
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
int action_id
Definition fc_types.h:389
const char * name
Definition inputfile.c:127
Definition agents.h:40
Definition city.h:320
Definition tile.h:50
Definition unit.h:138
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
unit_orders
Definition unit.h:37