Freeciv-3.1
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
34
35/* Selecting unit from a stack without popup. */
39
40#define can_unit_do_activity_client(_punit_, _act_) \
41 can_unit_do_activity(&(wld.map), _punit_, _act_)
42#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_) \
43 can_unit_do_activity_targeted(&(wld.map), _punit_, _act_, _tgt_)
44#define can_units_do_activity_client(_punits_, _act_) \
45 can_units_do_activity(&(wld.map), _punits_, _act_)
46#define can_units_do_activity_targeted_client(_punits_, _act_, _tgt_) \
47 can_units_do_activity_targeted(&(wld.map), _punits_, _act_, _tgt_)
48
49void control_init(void);
50void control_free(void);
51void control_unit_killed(struct unit *punit);
52
53void unit_change_battlegroup(struct unit *punit, int battlegroup);
55
57extern enum unit_activity connect_activity;
58extern struct extra_type *connect_tgt;
60extern int goto_last_tgt;
61extern int goto_last_sub_tgt;
63extern bool non_ai_unit_focus;
64
65bool can_unit_do_connect(struct unit *punit,
66 enum unit_activity activity,
67 struct extra_type *tgt);
68
69int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra,
70 const struct unit *punit, const struct player *pplayer, int rec);
71
72void do_move_unit(struct unit *punit, struct unit *target_unit);
73void do_unit_goto(struct tile *ptile);
74void do_unit_paradrop_to(struct unit *punit, struct tile *ptile);
75void do_unit_patrol_to(struct tile *ptile);
76void do_unit_connect(struct tile *ptile,
77 enum unit_activity activity,
78 struct extra_type *tgt);
79void do_map_click(struct tile *ptile, enum quickselect_type qtype);
80void control_mouse_cursor(struct tile *ptile);
81
82void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
83 enum unit_activity connect_activity,
84 struct extra_type *tgt,
85 int last_tgt,
89void clear_hover_state(void);
92 struct tile *dest_tile);
93void request_move_unit_direction(struct unit *punit, int dir);
94void request_new_unit_activity(struct unit *punit, enum unit_activity act);
96 enum unit_activity act,
97 struct extra_type *tgt);
98void request_unit_load(struct unit *pcargo, struct unit *ptransporter,
99 struct tile *ptile);
100void request_unit_unload(struct unit *pcargo);
101void request_unit_ssa_set(const struct unit *punit,
102 enum server_side_agent agent);
103void request_unit_autosettlers(const struct unit *punit);
107void request_unit_connect(enum unit_activity activity,
108 struct extra_type *tgt);
109void request_unit_disband(struct unit *punit);
110void request_unit_fortify(struct unit *punit);
111void request_unit_goto(enum unit_orders last_order,
112 action_id act_id, int sub_tgt_id);
113void request_unit_move_done(void);
114void request_unit_paradrop(struct unit_list *punits);
115void request_unit_patrol(void);
116void request_unit_pillage(struct unit *punit);
117void request_unit_sentry(struct unit *punit);
118struct unit *request_unit_unload_all(struct unit *punit);
119void request_unit_airlift(struct unit *punit, struct city *pcity);
120void request_unit_return(struct unit *punit);
121void request_unit_upgrade(struct unit *punit);
122void request_unit_convert(struct unit *punit);
123void request_units_wait(struct unit_list *punits);
124void request_unit_wakeup(struct unit *punit);
125
126#define SPECENUM_NAME unit_select_type_mode
127#define SPECENUM_VALUE0 SELTYPE_SINGLE
128#define SPECENUM_VALUE1 SELTYPE_SAME
129#define SPECENUM_VALUE2 SELTYPE_ALL
130#include "specenum_gen.h"
131
132#define SPECENUM_NAME unit_select_location_mode
133#define SPECENUM_VALUE0 SELLOC_UNITS /* Units on tile. */
134#define SPECENUM_VALUE1 SELLOC_TILE /* Tile. */
135#define SPECENUM_VALUE2 SELLOC_CONT /* Continent. */
136#define SPECENUM_VALUE3 SELLOC_LAND /* Move type: land. */
137#define SPECENUM_VALUE4 SELLOC_SEA /* Move type: sea. */
138#define SPECENUM_VALUE5 SELLOC_BOTH /* Move type: both. */
139#define SPECENUM_VALUE6 SELLOC_WORLD /* World. */
140#define SPECENUM_COUNT SELLOC_COUNT
141#include "specenum_gen.h"
142
143void request_unit_select(struct unit_list *punits,
144 enum unit_select_type_mode seltype,
145 enum unit_select_location_mode selloc);
146
147void request_do_action(action_id action, int actor_id,
148 int target_id, int sub_tgt, const char *name);
149void request_action_details(action_id action, int actor_id, int target_id);
152void request_toggle_map_grid(void);
162void request_toggle_terrain(void);
163void request_toggle_coastline(void);
166void request_toggle_mines(void);
167void request_toggle_bases(void);
168void request_toggle_resources(void);
169void request_toggle_huts(void);
170void request_toggle_pollution(void);
171void request_toggle_cities(void);
172void request_toggle_units(void);
177
178void wakeup_sentried_units(struct tile *ptile);
179void clear_unit_orders(struct unit *punit);
180
181bool unit_is_in_focus(const struct unit *punit);
182struct unit *get_focus_unit_on_tile(const struct tile *ptile);
183struct unit *head_of_units_in_focus(void);
184struct unit_list *get_units_in_focus(void);
185int get_num_units_in_focus(void);
186
187void unit_focus_set(struct unit *punit);
189void unit_focus_add(struct unit *punit);
190void unit_focus_remove(struct unit *punit);
191void unit_focus_urgent(struct unit *punit);
192
193void unit_focus_advance(bool accept_current);
194void unit_focus_update(void);
195
197void update_unit_pix_label(struct unit_list *punitlist);
198
199struct unit *find_visible_unit(struct tile *ptile);
200void set_units_in_combat(struct unit *pattacker, struct unit *pdefender);
201double blink_active_unit(void);
202double blink_turn_done_button(void);
203
204bool should_ask_server_for_actions(const struct unit *punit);
205void action_selection_no_longer_in_progress(const int old_actor_id);
206void action_decision_clear_want(const int old_actor_id);
207void action_selection_next_in_focus(const int old_actor_id);
209
210void key_cancel_action(void);
211void key_center_capital(void);
212void key_city_full_bar_toggle(void);
213void key_city_names_toggle(void);
214void key_city_growth_toggle(void);
216void key_city_buycost_toggle(void);
219void key_terrain_toggle(void);
220void key_coastline_toggle(void);
221void key_roads_rails_toggle(void);
222void key_irrigation_toggle(void);
223void key_mines_toggle(void);
224void key_bases_toggle(void);
225void key_resources_toggle(void);
226void key_huts_toggle(void);
227void key_pollution_toggle(void);
228void key_cities_toggle(void);
229void key_units_toggle(void);
230void key_unit_solid_bg_toggle(void);
231void key_unit_shields_toggle(void);
232void key_focus_unit_toggle(void);
233void key_fog_of_war_toggle(void);
234void key_end_turn(void);
235void key_city_outlines_toggle(void);
236void key_city_output_toggle(void);
237void key_map_grid_toggle(void);
238void key_map_borders_toggle(void);
239void key_map_native_toggle(void);
241void key_unit_move(enum direction8 gui_dir);
242void key_unit_airbase(void);
243void key_unit_auto_explore(void);
244void key_unit_auto_settle(void);
245void key_unit_build_city(void);
246void key_unit_build_wonder(void);
247void key_unit_connect(enum unit_activity activity,
248 struct extra_type *tgt);
249void key_unit_action_select(void);
251void key_unit_clean(void);
252void key_unit_convert(void);
253void key_unit_done(void);
254void key_unit_fallout(void);
255void key_unit_fortify(void);
256void key_unit_fortress(void);
257void key_unit_goto(void);
258void key_unit_homecity(void);
259void key_unit_irrigate(void);
260void key_unit_cultivate(void);
261void key_unit_mine(void);
262void key_unit_plant(void);
263void key_unit_patrol(void);
264void key_unit_paradrop(void);
265void key_unit_pillage(void);
266void key_unit_pollution(void);
267void key_unit_road(void);
268void key_unit_sentry(void);
269void key_unit_trade_route(void);
270void key_unit_transform(void);
271void key_unit_unload_all(void);
272void key_unit_wait(void);
273void key_unit_wakeup_others(void);
274void key_unit_assign_battlegroup(int battlegroup, bool append);
275void key_unit_select_battlegroup(int battlegroup, bool append);
276
277void key_editor_toggle(void);
280
281void finish_city(struct tile *ptile, const char *name);
282void cancel_city(struct tile *ptile);
283
284/* don't change this unless you also put more entries in data/Freeciv */
285#define MAX_NUM_UNITS_BELOW 4
286
287extern int num_units_below;
288
289#ifdef __cplusplus
290}
291#endif /* __cplusplus */
292
293#endif /* FC__CONTROL_H */
double blink_turn_done_button(void)
Definition control.c:925
void key_coastline_toggle(void)
Definition control.c:3830
void key_irrigation_toggle(void)
Definition control.c:3846
void request_toggle_huts(void)
Definition control.c:2532
void key_unit_sentry(void)
Definition control.c:3634
void request_toggle_city_outlines(void)
Definition control.c:2285
void key_unit_road(void)
Definition control.c:3616
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1538
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2689
void request_toggle_resources(void)
Definition control.c:2519
void request_toggle_city_names(void)
Definition control.c:2363
void key_recall_previous_focus_unit(void)
Definition control.c:3161
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1759
void request_toggle_unit_stack_size(void)
Definition control.c:2428
void key_unit_pollution(void)
Definition control.c:3608
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:389
void key_city_output_toggle(void)
Definition control.c:3731
void request_toggle_focus_unit(void)
Definition control.c:2610
void request_toggle_city_output(void)
Definition control.c:2298
void request_unit_return(struct unit *punit)
Definition control.c:1547
void request_unit_fortify(struct unit *punit)
Definition control.c:2240
void key_unit_build_city(void)
Definition control.c:3194
void key_editor_recalculate_borders(void)
Definition control.c:3950
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1506
void key_roads_rails_toggle(void)
Definition control.c:3838
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2148
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1050
void request_toggle_roads_rails(void)
Definition control.c:2467
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:2650
void request_unit_wakeup(struct unit *punit)
Definition control.c:1595
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:397
void key_focus_unit_toggle(void)
Definition control.c:3926
void request_toggle_map_grid(void)
Definition control.c:2311
void action_decision_request(struct unit *actor_unit)
Definition control.c:1109
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2493
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1031
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:1332
void key_unit_action_select(void)
Definition control.c:3225
void key_unit_auto_explore(void)
Definition control.c:3410
void key_cancel_action(void)
Definition control.c:3100
void request_toggle_city_buycost(void)
Definition control.c:2402
void key_unit_auto_settle(void)
Definition control.c:3423
void clear_hover_state(void)
Definition control.c:328
void request_toggle_map_native(void)
Definition control.c:2337
void request_unit_patrol(void)
Definition control.c:2206
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3216
void key_city_full_bar_toggle(void)
Definition control.c:3763
void key_bases_toggle(void)
Definition control.c:3862
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2795
void key_map_native_toggle(void)
Definition control.c:3755
void request_toggle_map_borders(void)
Definition control.c:2324
void key_resources_toggle(void)
Definition control.c:3870
void unit_focus_add(struct unit *punit)
Definition control.c:562
void unit_focus_set(struct unit *punit)
Definition control.c:507
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1129
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3027
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:3320
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:1701
void key_end_turn(void)
Definition control.c:3153
void request_unit_disband(struct unit *punit)
Definition control.c:2002
void request_toggle_irrigation(void)
Definition control.c:2480
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2068
void request_unit_pillage(struct unit *punit)
Definition control.c:2251
void request_center_focus_unit(void)
Definition control.c:2637
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:3918
void key_city_productions_toggle(void)
Definition control.c:3797
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1410
void key_unit_build_wonder(void)
Definition control.c:3204
void key_unit_plant(void)
Definition control.c:3556
void key_unit_fortress(void)
Definition control.c:3465
quickselect_type
Definition control.h:36
@ SELECT_LAND
Definition control.h:37
@ SELECT_APPEND
Definition control.h:37
@ SELECT_SEA
Definition control.h:37
@ SELECT_POPUP
Definition control.h:37
@ SELECT_FOCUS
Definition control.h:37
void key_unit_mine(void)
Definition control.c:3548
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2021
void request_toggle_fog_of_war(void)
Definition control.c:2623
void request_unit_load(struct unit *pcargo, struct unit *ptransporter, struct tile *ptile)
Definition control.c:2083
void key_unit_pillage(void)
Definition control.c:3568
void request_unit_unload(struct unit *pcargo)
Definition control.c:2119
void key_editor_toggle_fogofwar(void)
Definition control.c:3959
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2055
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1721
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2571
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1863
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:984
void key_unit_irrigate(void)
Definition control.c:3528
void request_unit_build_city(struct unit *punit)
Definition control.c:1740
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:255
void key_unit_unload_all(void)
Definition control.c:3350
void key_cities_toggle(void)
Definition control.c:3894
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3182
void key_city_outlines_toggle(void)
Definition control.c:3723
void key_unit_homecity(void)
Definition control.c:3482
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2171
cursor_hover_state
Definition control.h:25
@ HOVER_GOTO
Definition control.h:27
@ HOVER_PARADROP
Definition control.h:28
@ HOVER_ACT_SEL_TGT
Definition control.h:31
@ HOVER_NONE
Definition control.h:26
@ HOVER_CONNECT
Definition control.h:29
@ HOVER_PATROL
Definition control.h:30
@ HOVER_GOTO_SEL_TGT
Definition control.h:32
void key_unit_patrol(void)
Definition control.c:3328
void request_toggle_city_full_bar(void)
Definition control.c:2350
void request_toggle_city_growth(void)
Definition control.c:2376
void key_unit_solid_bg_toggle(void)
Definition control.c:3910
void request_toggle_unit_solid_bg(void)
Definition control.c:2584
void key_terrain_toggle(void)
Definition control.c:3822
void request_unit_sentry(struct unit *punit)
Definition control.c:2229
void key_unit_wakeup_others(void)
Definition control.c:3383
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:3814
void key_huts_toggle(void)
Definition control.c:3878
void key_fog_of_war_toggle(void)
Definition control.c:3934
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1477
void clear_unit_orders(struct unit *punit)
Definition control.c:482
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2441
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1079
void key_unit_wait(void)
Definition control.c:3375
void key_units_toggle(void)
Definition control.c:3902
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3083
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:592
void request_toggle_bases(void)
Definition control.c:2506
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3067
void key_unit_trade_route(void)
Definition control.c:3336
void request_toggle_coastline(void)
Definition control.c:2454
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3697
void key_map_grid_toggle(void)
Definition control.c:3739
void finish_city(struct tile *ptile, const char *name)
Definition control.c:3969
void key_pollution_toggle(void)
Definition control.c:3886
struct unit * head_of_units_in_focus(void)
Definition control.c:411
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:823
void key_city_growth_toggle(void)
Definition control.c:3780
void key_unit_action_select_tgt(void)
Definition control.c:3247
void key_unit_fallout(void)
Definition control.c:3445
void key_city_buycost_toggle(void)
Definition control.c:3789
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3646
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1803
void key_unit_done(void)
Definition control.c:3304
void key_city_trade_routes_toggle(void)
Definition control.c:3806
void request_toggle_city_trade_routes(void)
Definition control.c:2415
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:637
void request_unit_convert(struct unit *punit)
Definition control.c:2045
void request_toggle_unit_shields(void)
Definition control.c:2597
void key_city_names_toggle(void)
Definition control.c:3771
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:1616
void unit_focus_update(void)
Definition control.c:790
void key_unit_airbase(void)
Definition control.c:3393
void key_unit_goto(void)
Definition control.c:3312
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1214
void key_unit_convert(void)
Definition control.c:3435
void key_unit_clean(void)
Definition control.c:3580
void key_center_capital(void)
Definition control.c:3136
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1578
void request_toggle_cities(void)
Definition control.c:2558
void key_unit_fortify(void)
Definition control.c:3453
void key_editor_toggle(void)
Definition control.c:3942
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3658
void request_unit_move_done(void)
Definition control.c:2663
void auto_center_on_focus_unit(void)
Definition control.c:435
void key_unit_cultivate(void)
Definition control.c:3536
double blink_active_unit(void)
Definition control.c:893
void unit_focus_advance(bool accept_current)
Definition control.c:689
void request_unit_upgrade(struct unit *punit)
Definition control.c:2033
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2389
void cancel_city(struct tile *ptile)
Definition control.c:3988
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1854
void request_toggle_pollution(void)
Definition control.c:2545
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3854
void do_unit_goto(struct tile *ptile)
Definition control.c:3005
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1091
void key_map_borders_toggle(void)
Definition control.c:3747
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
struct unit * actor_unit
Definition dialogs_g.h:54
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:73
int action_id
Definition fc_types.h:359
const char * name
Definition inputfile.c:127
Definition agents.h:40
Definition city.h:309
Definition tile.h:49
Definition unit.h:138
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
unit_orders
Definition unit.h:37