Freeciv-3.2
Loading...
Searching...
No Matches
control.c
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
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20#include "bitvector.h"
21#include "fcintl.h"
22#include "log.h"
23#include "mem.h"
24#include "timing.h"
25
26/* common */
27#include "combat.h"
28#include "game.h"
29#include "map.h"
30#include "movement.h"
31#include "unitlist.h"
32
33/* common/aicore */
34#include "path_finding.h"
35
36/* client/include */
37#include "chatline_g.h"
38#include "citydlg_g.h"
39#include "dialogs_g.h"
40#include "gui_main_g.h"
41#include "mapctrl_g.h"
42#include "mapview_g.h"
43#include "menu_g.h"
44
45/* client */
46#include "audio.h"
47#include "client_main.h"
48#include "climap.h"
49#include "climisc.h"
50#include "editor.h"
51#include "goto.h"
52#include "options.h"
53#include "overview_common.h"
54#include "tilespec.h"
55#include "update_queue.h"
56
57#include "control.h"
58
59
64
65/* Ways to disband a unit. Sorted by preference. Starts with the worst. */
66/* TODO: Should other actions that consumes the unit be considered?
67 * Join City may be an appealing alternative. Perhaps it should be a
68 * user configurable client option? */
74
75/* gui-dep code may adjust depending on tile size etc: */
77
78/* current_focus points to the current unit(s) in focus */
79static struct unit_list *current_focus = NULL;
80
81/* The previously focused unit(s). Focus can generally be recalled
82 * with keypad 5 (or the equivalent). */
83static struct unit_list *previous_focus = NULL;
84
85/* The priority unit(s) for unit_focus_advance(). */
86static struct unit_list *urgent_focus_queue = NULL;
87
88/* These should be set via set_hover_state() */
92
96enum unit_orders goto_last_order; /* Last order for goto */
97
98static struct tile *hover_tile = NULL;
99static struct unit_list *battlegroups[MAX_NUM_BATTLEGROUPS];
100
101/* Current moving unit. */
102static struct unit *punit_moving = NULL;
103
104/* units involved in current combat */
105static struct unit *punit_attacking = NULL;
106static struct unit *punit_defending = NULL;
107
108/* The ID of the unit that currently is in the action selection process.
109 *
110 * The action selection process begins when the client asks the server what
111 * actions a unit can take. It ends when the last follow up question is
112 * answered.
113 *
114 * No common client code using client supports more than one action
115 * selection process at once. The interface between the common client code
116 * and the clients would have to change before that could happen. (See
117 * action_selection_actor_unit() etc)
118 */
120
121/*
122 * This variable is TRUE iff a NON-AI controlled unit was focused this
123 * turn.
124 */
126
127static void do_unit_teleport_to(struct unit *punit, struct tile *ptile);
128
129/*************************************************************************/
130
131static struct unit *quickselect(struct tile *ptile,
133
134/**********************************************************************/
137void control_init(void)
138{
139 int i;
140
144
145 for (i = 0; i < MAX_NUM_BATTLEGROUPS; i++) {
147 }
149}
150
151/**********************************************************************/
173
174/**********************************************************************/
177struct unit_list *get_units_in_focus(void)
178{
179 return current_focus;
180}
181
182/**********************************************************************/
186{
188}
189
190/**********************************************************************/
203
204/**********************************************************************/
211
212/**********************************************************************/
215static void focus_units_changed(void)
216{
218 menus_update();
219 /* Notify the GUI */
221}
222
223/**********************************************************************/
246
247/**********************************************************************/
250void unit_change_battlegroup(struct unit *punit, int battlegroup)
251{
253 battlegroup = BATTLEGROUP_NONE;
254 }
255
256 if (punit->battlegroup != battlegroup) {
257 if (battlegroup != BATTLEGROUP_NONE) {
258 unit_list_append(battlegroups[battlegroup], punit);
259 }
262 }
263 punit->battlegroup = battlegroup;
264 }
265}
266
267/**********************************************************************/
278
279/**********************************************************************/
285void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
286 enum unit_activity activity,
287 struct extra_type *tgt,
288 int last_tgt,
289 int last_sub_tgt,
291 enum unit_orders order)
292{
294 || state == HOVER_NONE);
295 fc_assert_ret(state == HOVER_CONNECT || activity == ACTIVITY_LAST);
296 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
297 || order == ORDER_LAST);
298 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
299 || action == ACTION_NONE);
300
302 && (state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT))) {
303 /* Exit goto unless this is a switch between goto states */
305 }
306
307 hover_state = state;
308 connect_activity = activity;
309 if (tgt) {
310 connect_tgt = tgt;
311 } else {
313 }
314 goto_last_order = order;
318}
319
320/**********************************************************************/
329
330/**********************************************************************/
335{
337 /* The player is interested in getting a pop up for a mere
338 * arrival. */
341}
342
343/**********************************************************************/
348{
349 /* OK as long as no other unit already asked and aren't done yet. */
352}
353
354/**********************************************************************/
362{
365
366 /* Only one action selection dialog at a time is supported. */
368 "Unit %d started action selection before unit %d was done",
371
373 punit->id,
378}
379
380/**********************************************************************/
383bool unit_is_in_focus(const struct unit *punit)
384{
386}
387
388/**********************************************************************/
391struct unit *get_focus_unit_on_tile(const struct tile *ptile)
392{
394 if (unit_tile(punit) == ptile) {
395 return punit;
396 }
398
399 return NULL;
400}
401
402/**********************************************************************/
406{
407 return unit_list_get(current_focus, 0);
408}
409
410/**********************************************************************/
414{
415 struct unit *punit;
416
418 return unit_tile(punit);
419 } else if (get_num_units_in_focus() > 0) {
421 } else {
422 return NULL;
423 }
424}
425
426/**********************************************************************/
430{
432
436 }
437}
438
439/**********************************************************************/
458
459/**********************************************************************/
462static void current_focus_remove(struct unit *punit)
463{
464 /* Close the action selection dialog if the actor unit lose focus. */
467 }
468
471}
472
473/**********************************************************************/
477{
478 if (!punit) {
479 return;
480 }
481
487 } else if (unit_has_orders(punit)) {
488 /* Clear the focus unit's orders. */
490 }
491}
492
493/**********************************************************************/
502{
503 bool focus_changed = FALSE;
504
505 if (NULL != punit
506 && NULL != client.conn.playing
508 /* Callers should make sure this never happens. */
509 return;
510 }
511
512 /* FIXME: this won't work quite right; for instance activating a
513 * battlegroup twice in a row will store the focus erronously. The only
514 * solution would be a set_units_focus() */
515 if (!(get_num_units_in_focus() == 1
516 && punit == head_of_units_in_focus())) {
519 }
520
521 /* Close the action selection dialog if the actor unit lose focus. */
525 }
527
528 /* Redraw the old focus unit (to fix blinking or remove the selection
529 * circle). */
534
535 if (!can_client_change_view()) {
536 /* This function can be called to set the focus to NULL when
537 * disconnecting. In this case we don't want any other actions! */
538 fc_assert(punit == NULL);
539 return;
540 }
541
542 if (NULL != punit) {
545 }
546
547 if (focus_changed) {
550 }
551}
552
553/**********************************************************************/
557{
558 if (NULL != punit
559 && NULL != client.conn.playing
561 /* Callers should make sure this never happens. */
562 return;
563 }
564
565 if (NULL == punit || !can_client_change_view()) {
566 return;
567 }
568
569 if (unit_is_in_focus(punit)) {
570 return;
571 }
572
573 if (hover_state != HOVER_NONE) {
574 /* Can't continue with current goto if set of focus units
575 * change. Cancel it. */
577 }
578
581}
582
583/**********************************************************************/
587{
588 if (NULL != punit
589 && NULL != client.conn.playing
591 /* Callers should make sure this never happens. */
592 return;
593 }
594
595 if (NULL == punit || !can_client_change_view()) {
596 return;
597 }
598
599 if (!unit_is_in_focus(punit)) {
600 return;
601 }
602
603 if (hover_state != HOVER_NONE) {
604 /* Can't continue with current goto if set of focus units
605 * change. Cancel it. */
607 }
608
610 if (get_num_units_in_focus() > 0) {
612 } else {
614 }
615}
616
617/**********************************************************************/
627
628/**********************************************************************/
634{
635 struct tile *ptile = get_center_tile_mapcanvas();
636
637 if (!get_focus_unit_on_tile(ptile)) {
639
640 if (pfirst) {
641 ptile = unit_tile(pfirst);
642 }
643 }
644
652 && (punit->moves_left > 0 || unit_type_get(punit)->move_rate == 0)
653 && !punit->done_moving
655 return punit;
656 }
659
660 return NULL;
661}
662
663/**********************************************************************/
671{
672 struct unit *candidate = NULL;
674
675 if (NULL == client.conn.playing
679 return;
680 }
681
683
685 /*
686 * Is the unit which just lost focus a non-AI unit? If yes this
687 * enables the auto end turn.
688 */
689 if (punit->ssa_controller == SSA_NONE) {
691 break;
692 }
694
696 /* Try top of the urgent list. */
697 struct tile *focus_tile = (get_num_units_in_focus() > 0
699 : NULL);
700
704 /* This isn't an action decision needed because of an
705 * ORDER_ACTION_MOVE located in the middle of an order. */
707 /* We have assigned new orders to this unit since, remove it. */
709 } else if (NULL == focus_tile
710 || focus_tile == unit_tile(punit)) {
711 /* Use the first one found */
713 break;
714 } else if (NULL == candidate) {
716 }
718
719 if (NULL != candidate) {
721
722 /* Autocenter on Wakeup, regardless of the local option
723 * "auto_center_on_unit". */
726 }
727 }
728 }
729
730 if (NULL == candidate) {
732
733 if (!candidate) {
734 /* Try for "waiting" units. */
738 }
741
742 if (!candidate) {
743 /* Accept current focus unit as last resort. */
745 }
746 }
747 }
748
750
751 /*
752 * Handle auto-turn-done mode: If a unit was in focus (did move),
753 * but now none are (no more to move) and there was at least one
754 * non-AI unit this turn which was focused, then fake a Turn Done
755 * keypress.
756 */
759 && get_num_units_in_focus() == 0
761 key_end_turn();
762 }
763}
764
765/**********************************************************************/
772{
774 return;
775 }
776
779
780 /* An actor unit is asking the player what to do. Don't change the
781 * focus. */
782 return;
783 }
784
785 /* iterate zero times for no units in focus,
786 * otherwise quit for any of the conditions. */
791 && punit->moves_left > 0
792 && !punit->done_moving
794 return;
795 }
797
799}
800
801/**********************************************************************/
804struct unit *find_visible_unit(struct tile *ptile)
805{
806 struct unit *panyowned = NULL, *panyother = NULL, *ptptother = NULL;
807
808 /* If no units here, return nothing. */
809 if (unit_list_size(ptile->units) == 0) {
810 return NULL;
811 }
812
813 /* If a unit is attacking we should show that on top */
815 unit_list_iterate(ptile->units, punit) {
816 if (punit == punit_attacking) {
817 return punit;
818 }
820 }
821
822 /* If a unit is defending we should show that on top */
824 unit_list_iterate(ptile->units, punit) {
825 if (punit == punit_defending) {
826 return punit;
827 }
829 }
830
831 /* If the unit in focus is at this tile, show that on top */
833 if (punit != punit_moving && unit_tile(punit) == ptile) {
834 return punit;
835 }
837
838 /* If a city is here, return nothing (unit hidden by city). */
839 if (tile_city(ptile)) {
840 return NULL;
841 }
842
843 /* Iterate through the units to find the best one we prioritize this way:
844 1: owned transporter.
845 2: any owned unit
846 3: any transporter
847 4: any unit
848 (always return first in stack). */
851 if (!unit_transported(punit)) {
853 return punit;
854 } else if (!panyowned) {
856 }
857 }
858 } else if (!ptptother && !unit_transported(punit)) {
861 } else if (!panyother) {
863 }
864 }
866
868}
869
870/**********************************************************************/
875{
876 static struct timer *blink_timer = NULL;
878
879 if (get_num_units_in_focus() > 0) {
882
883 /* If we lag, we don't try to catch up. Instead we just start a
884 * new blink_time on every update. */
886 blink_timer != NULL ? NULL : "blink");
888
890 /* We used to unqueue here, but that's inherently risky
891 * for a function run from a timer - the UI can be in any
892 * inconsistent state. */
895 }
896
898 }
899
900 return blink_time;
901}
902
903/**********************************************************************/
908{
909 static struct timer *blink_timer = NULL;
910 const double blink_time = 0.5; /* half-second blink interval */
911
912 if (NULL != client.conn.playing
917 int is_waiting = 0, is_moving = 0;
918 bool blocking_mode;
919 struct option *opt;
920
922 if (opt != NULL) {
924 } else {
926 }
927
928 players_iterate_alive(pplayer) {
929 if ((pplayer->is_connected || blocking_mode)
930 && is_player_phase(pplayer, game.info.phase)) {
931 if (pplayer->phase_done) {
932 is_waiting++;
933 } else {
934 is_moving++;
935 }
936 }
938
939 if (is_moving == 1 && is_waiting > 0) {
940 update_turn_done_button(FALSE); /* stress the slow player! */
941 }
943 blink_timer != NULL ? NULL : "blink");
945 }
947 }
948
949 return blink_time;
950}
951
952/**********************************************************************/
967void update_unit_pix_label(struct unit_list *punitlist)
968{
969 int i;
970
971 /* Check for any change in the unit's state. This assumes that a unit's
972 * orders cannot be changed directly but must be removed and then reset. */
974 && C_S_OVER != client_state()) {
975 /* There used to be a complicated and bug-prone check here to see if
976 * the unit had actually changed. This was misguided since the stacked
977 * units (below) are redrawn in any case. Unless we write a general
978 * system for unit updates here we might as well just redraw it every
979 * time. */
980 struct unit *punit = unit_list_get(punitlist, 0);
981
982 set_unit_icon(-1, punit);
983
984 i = 0; /* index into unit_below_canvas */
986 if (aunit != punit) {
987 if (i < num_units_below) {
989 }
990 i++;
991 }
992 }
994
995 if (i > num_units_below) {
997 } else {
999 for (; i < num_units_below; i++) {
1001 }
1002 }
1003 } else {
1004 for (i = -1; i < num_units_below; i++) {
1006 }
1008 }
1009}
1010
1011/**********************************************************************/
1015{
1018
1021 /* If one of the units is the focus unit, make sure hidden-focus is
1022 * disabled. We don't just do this as a check later because then
1023 * with a blinking unit it would just disappear again right after the
1024 * battle. */
1026 }
1027}
1028
1029/**********************************************************************/
1034{
1035 /* IDENTITY_NUMBER_ZERO is accepted for cases where the unit is gone
1036 * without a trace. */
1040 "Decision taken for %d but selection is for %d.",
1042
1043 /* Stop objecting to allowing the next unit to ask. */
1045
1046 /* Clean up any client specific assumptions. */
1048}
1049
1050/**********************************************************************/
1055{
1057 /* Have the server record that a decision no longer is wanted. */
1060 }
1061}
1062
1063/**********************************************************************/
1067{
1068 struct unit *old;
1069
1071
1072 /* Go to the next unit in focus that needs a decision. */
1074 if (old != funit && should_ask_server_for_actions(funit)) {
1076 return;
1077 }
1079}
1080
1081/**********************************************************************/
1085{
1088
1090 /* Getting feed back may be urgent. A unit standing next to an enemy
1091 * could be killed while waiting. */
1093 } else if (can_client_issue_orders()
1095 /* No need to wait. The actor unit is in focus. No other actor unit
1096 * is currently asking about action selection. */
1098 }
1099}
1100
1101/**********************************************************************/
1105 action_id act_id, int sub_tgt_id)
1106{
1107 struct unit_list *punits = get_units_in_focus();
1108
1109 fc_assert_ret(act_id == ACTION_NONE
1111
1112 if (unit_list_size(punits) == 0) {
1113 return;
1114 }
1115
1117 /* An action has been specified. */
1119
1121 if (!unit_can_do_action(punit, act_id)) {
1122 /* This unit can't perform the action specified in the last
1123 * order. */
1124
1125 struct astring astr = ASTRING_INIT;
1126
1128 action_id_get_role(act_id),
1129 TRUE)) {
1130 /* ...but other units can perform it. */
1131
1133 /* TRANS: Only Nuclear or ICBM can do Explode
1134 * Nuclear. */
1135 _("Only %s can do %s."),
1136 astr_str(&astr),
1138
1139 astr_free(&astr);
1140 } else {
1142 /* TRANS: Spy can't do Explode Nuclear. */
1143 _("%s can't do %s."),
1146 }
1147
1148 return;
1149 }
1151 }
1152
1155 NO_TARGET, sub_tgt_id, act_id, last_order);
1160 } else {
1162 /* Adding a long range action in the middle isn't handled yet */
1165 }
1166}
1167
1168/**********************************************************************/
1171static bool can_units_attack_at(struct unit_list *punits,
1172 const struct tile *ptile)
1173{
1176 && can_unit_attack_tile(punit, NULL, ptile)) {
1177 return TRUE;
1178 }
1180
1181 return FALSE;
1182}
1183
1184/**********************************************************************/
1189void control_mouse_cursor(struct tile *ptile)
1190{
1191 struct unit *punit = NULL;
1192 struct city *pcity = NULL;
1193 struct unit_list *active_units = get_units_in_focus();
1195
1197 return;
1198 }
1199
1200 if (C_S_RUNNING != client_state()) {
1202 return;
1203 }
1204
1205 if (is_server_busy()) {
1206 /* Server will not accept any commands. */
1208 return;
1209 }
1210
1211 if (!ptile) {
1212 if (hover_tile) {
1213 /* hover_tile is the tile that was previously under the mouse cursor. */
1214 ptile = hover_tile;
1215 } else {
1217 return;
1218 }
1219 } else {
1220 hover_tile = ptile;
1221 }
1222
1223 punit = find_visible_unit(ptile);
1224 pcity = ptile ? tile_city(ptile) : NULL;
1225
1226 switch (hover_state) {
1227 case HOVER_NONE:
1228 if (NULL != punit
1229 && unit_owner(punit) == client_player()) {
1230 /* Set mouse cursor to select a unit. */
1232 } else if (NULL != pcity
1234 /* Set mouse cursor to select a city. */
1236 } else {
1237 /* Set default mouse cursor, because nothing selectable found. */
1238 }
1239 break;
1240 case HOVER_GOTO:
1241 /* Determine if the goto is valid, invalid, nuke or will attack. */
1242 if (is_valid_goto_destination(ptile)) {
1245 /* Goto results in nuclear attack. */
1247 } else if (can_units_attack_at(active_units, ptile)) {
1248 /* Goto results in military attack. */
1250 } else if (is_enemy_city_tile(ptile, client.conn.playing)) {
1251 /* Goto results in attack of enemy city. */
1253 } else {
1255 }
1256 } else {
1258 }
1259 break;
1260 case HOVER_PATROL:
1261 if (is_valid_goto_destination(ptile)) {
1263 } else {
1265 }
1266 break;
1267 case HOVER_CONNECT:
1268 if (is_valid_goto_destination(ptile)) {
1270 } else {
1272 }
1273 break;
1274 case HOVER_TELEPORT:
1275 /* FIXME: check for invalid tiles. */
1277 break;
1278 case HOVER_PARADROP:
1279 /* FIXME: check for invalid tiles. */
1281 break;
1282 case HOVER_ACT_SEL_TGT:
1283 case HOVER_GOTO_SEL_TGT:
1284 /* Select a tile to target / find targets on. */
1286 break;
1287 };
1288
1290}
1291
1292/**********************************************************************/
1295static bool is_activity_on_tile(struct tile *ptile,
1296 enum unit_activity activity)
1297{
1298 unit_list_iterate(ptile->units, punit) {
1299 if (punit->activity == activity) {
1300 return TRUE;
1301 }
1303
1304 return FALSE;
1305}
1306
1307/**********************************************************************/
1312 const struct extra_type *pextra,
1313 const struct unit *punit,
1314 const struct player *pplayer, int rec)
1315{
1316 int activity_mc = 0;
1317 struct terrain *pterrain = tile_terrain(ptile);
1318 const struct civ_map *nmap = &(wld.map);
1319
1320 if (rec > MAX_EXTRA_TYPES) {
1321 return -1;
1322 }
1323
1324 if (!is_extra_caused_by(pextra, EC_ROAD)) {
1325 return -1;
1326 }
1327
1328 extra_deps_iterate(&(pextra->reqs), pdep) {
1329 if (!tile_has_extra(ptile, pdep)) {
1330 int single_mc;
1331
1333 pplayer, rec + 1);
1334
1335 if (single_mc < 0) {
1336 return -1;
1337 }
1338
1340 }
1342
1343 /* Can build road after that? */
1344 if (punit != NULL) {
1345 if (!can_build_road(nmap, extra_road_get(pextra), punit, ptile)) {
1346 return -1;
1347 }
1348 } else if (pplayer != NULL) {
1350 pplayer, ptile)) {
1351 return -1;
1352 }
1353 }
1354
1355 tile_add_extra(ptile, pextra);
1356
1358
1359 return activity_mc;
1360}
1361
1362/*******************************************************************/
1366static bool can_be_irrigated(const struct tile *ptile,
1367 const struct unit *punit)
1368{
1369 struct terrain* pterrain = tile_terrain(ptile);
1370 struct universal for_unit = { .kind = VUT_UTYPE,
1371 .value.utype = unit_type_get(punit)};
1372 struct universal for_tile = { .kind = VUT_TERRAIN,
1373 .value.terrain = tile_terrain(ptile)};
1374
1375 if (T_UNKNOWN == pterrain) {
1376 return FALSE;
1377 }
1378
1380 &for_unit, &for_tile);
1381}
1382
1383/**********************************************************************/
1390 enum unit_activity activity,
1391 struct extra_type *tgt)
1392{
1393 struct tile *ptile = unit_tile(punit);
1394 struct road_type *proad = NULL;
1395 const struct req_context unit_ctxt = {
1396 .unit = punit,
1397 .unittype = unit_type_get(punit),
1398 };
1399
1400 /* HACK: This code duplicates that in
1401 * can_unit_do_activity_targeted_at(). The general logic here is that
1402 * the connect is allowed if both:
1403 * (1) the unit can do that activity type, in general
1404 * (2) either
1405 * (a) the activity has already been completed at this tile
1406 * (b) it can be done by the unit at this tile. */
1407 switch (activity) {
1408 case ACTIVITY_GEN_ROAD:
1409 {
1410 struct tile *vtile;
1411 int build_time;
1412
1414
1415 proad = extra_road_get(tgt);
1416
1417 if (tile_has_road(ptile, proad)) {
1418 /* This tile has road, can unit build road to other tiles too? */
1420 }
1421
1422 /* To start connect, unit must be able to build road to this
1423 * particular tile. */
1424 vtile = tile_virtual_new(ptile);
1425 build_time = check_recursive_road_connect(vtile, tgt, punit, NULL, 0);
1427
1428 return build_time >= 0;
1429 }
1430
1431 case ACTIVITY_IRRIGATE:
1432 /* Special case for irrigation: only irrigate to make S_IRRIGATION,
1433 * never to transform tiles. */
1435 return FALSE;
1436 }
1437 if (tile_has_extra(ptile, tgt)) {
1439 }
1440
1441 return can_be_irrigated(ptile, punit)
1442 && can_build_extra(tgt, punit, ptile)
1443 && !is_activity_on_tile(ptile,
1445 default:
1446 break;
1447 }
1448
1449 return FALSE;
1450}
1451
1452/**********************************************************************/
1457 struct extra_type *tgt)
1458{
1459 struct unit_list *punits = get_units_in_focus();
1460
1461 if (!can_units_do_connect(punits, activity, tgt)) {
1462 return;
1463 }
1464
1465 if (hover_state != HOVER_CONNECT || connect_activity != activity
1466 || (connect_tgt != tgt
1467 && (activity == ACTIVITY_GEN_ROAD
1468 || activity == ACTIVITY_IRRIGATE))) {
1470 activity, tgt, NO_TARGET, NO_TARGET,
1476 } else {
1479 }
1480}
1481
1482/**********************************************************************/
1486{
1487 struct tile *ptile = unit_tile(punit);
1488 struct unit *plast = NULL;
1489
1490 if (get_transporter_capacity(punit) == 0) {
1492 _("Only transporter units can be unloaded."));
1493 return NULL;
1494 }
1495
1496 unit_list_iterate(ptile->units, pcargo) {
1499
1500 if (pcargo->activity == ACTIVITY_SENTRY) {
1502 USSDT_SENTRY, 0);
1503 }
1504
1505 if (unit_owner(pcargo) == unit_owner(punit)) {
1506 plast = pcargo;
1507 }
1508 }
1510
1511 return plast;
1512}
1513
1514/**********************************************************************/
1517void request_unit_airlift(struct unit *punit, struct city *pcity)
1518{
1519 request_do_action(ACTION_AIRLIFT, punit->id, pcity->id, 0, "");
1520}
1521
1522/**********************************************************************/
1527{
1528 struct pf_path *path;
1529
1530 if ((path = path_to_nearest_allied_city(punit))) {
1531 int turns = pf_path_last_position(path)->turn;
1532 int max_hp = unit_type_get(punit)->hp;
1533
1534 if (punit->hp + turns *
1536 - (max_hp * unit_class_get(punit)->hp_loss_pct / 100))
1537 < max_hp) {
1538 struct unit_order order;
1539
1541 order.dir = DIR8_ORIGIN;
1542 order.activity = ACTIVITY_SENTRY;
1543 order.target = NO_TARGET;
1544 order.sub_target = NO_TARGET;
1545 order.action = ACTION_NONE;
1546 send_goto_path(punit, path, &order);
1547 } else {
1548 send_goto_path(punit, path, NULL);
1549 }
1550 pf_path_destroy(path);
1551 }
1552}
1553
1554/**********************************************************************/
1557void wakeup_sentried_units(struct tile *ptile)
1558{
1559 if (!can_client_issue_orders()) {
1560 return;
1561 }
1562 unit_list_iterate(ptile->units, punit) {
1566 }
1567 }
1569}
1570
1571/**********************************************************************/
1578
1579/**************************************************************************
1580 Defines specific hash tables needed for request_unit_select().
1581**************************************************************************/
1582#define SPECHASH_TAG unit_type
1583#define SPECHASH_IKEY_TYPE struct unit_type *
1584#define SPECHASH_IDATA_TYPE void *
1585#include "spechash.h"
1586
1587#define SPECHASH_TAG continent
1588#define SPECHASH_INT_KEY_TYPE
1589#define SPECHASH_IDATA_TYPE void *
1590#include "spechash.h"
1591
1592/**********************************************************************/
1595void request_unit_select(struct unit_list *punits,
1598{
1599 const struct player *pplayer;
1600 const struct tile *ptile;
1601 struct unit *punit_first;
1602 struct tile_hash *tile_table;
1603 struct unit_type_hash *type_table;
1604 struct continent_hash *cont_table;
1605
1607 || unit_list_size(punits) < 1) {
1608 return;
1609 }
1610
1612
1613 if (seltype == SELTYPE_SINGLE) {
1615 return;
1616 }
1617
1618 pplayer = unit_owner(punit_first);
1622
1624 if (seltype == SELTYPE_SAME) {
1626 }
1627
1628 ptile = unit_tile(punit);
1629 if (selloc == SELLOC_TILE) {
1631 } else if (selloc == SELLOC_CONT) {
1633 }
1635
1636 if (selloc == SELLOC_TILE) {
1639 if (unit_owner(punit) != pplayer) {
1640 continue;
1641 }
1642 if (seltype == SELTYPE_SAME
1644 continue;
1645 }
1649 } else {
1650 unit_list_iterate(pplayer->units, punit) {
1651 ptile = unit_tile(punit);
1652 if ((seltype == SELTYPE_SAME
1654 || (selloc == SELLOC_CONT
1656 NULL))) {
1657 continue;
1658 }
1659
1662 }
1663
1667}
1668
1669/**********************************************************************/
1674 char *buf, size_t bufsize)
1675{
1676 fc_assert(buf != NULL || bufsize == 0);
1677
1678 if (bufsize > 0) {
1679 buf[0] = '\0';
1680 }
1681
1682 if (act == ACTION_JOIN_CITY) {
1683 if (bufsize > 0) {
1684 fc_snprintf(buf, bufsize, _("Joining a city uses the unit"));
1685 }
1686
1687 return TRUE;
1688 }
1689
1690 return FALSE;
1691}
1692
1693/**********************************************************************/
1705 int target_id, int sub_tgt, const char *name)
1706{
1707 char buf[400];
1708
1709 if (action_requires_confirmation(action, buf, sizeof(buf))) {
1710 struct act_confirmation_data *data = fc_malloc(sizeof(struct act_confirmation_data));
1711
1712 data->act = action;
1713 data->actor = actor_id;
1714 data->target = target_id;
1715 data->tgt_sub = sub_tgt;
1716
1717 if (name != NULL) {
1718 data->name = fc_strdup(name);
1719 } else {
1720 data->name = NULL;
1721 }
1722
1724 } else {
1725 struct unit *actor_unit = game_unit_by_number(actor_id);
1726
1727 /* Giving an order takes back control. */
1729
1731 actor_id, target_id, sub_tgt, name,
1732 action);
1733 }
1734}
1735
1736/**********************************************************************/
1741{
1742 if (confirm) {
1743 struct unit *actor_unit = game_unit_by_number(data->actor);
1744
1745 if (actor_unit != NULL) {
1746 /* Giving an order takes back control. */
1748
1750 data->actor,
1751 data->target,
1752 data->tgt_sub,
1753 data->name,
1754 data->act);
1755 }
1756 }
1757
1758 if (data->name != NULL) {
1759 free(data->name);
1760 }
1761
1762 free(data);
1763}
1764
1765/**********************************************************************/
1773 int target_id)
1774{
1776 actor_id, target_id, action,
1777 /* Users that need the answer in the
1778 * background should send the packet them
1779 * self. At least for now. */
1781}
1782
1783/**********************************************************************/
1792{
1793 struct city *pcity;
1794
1795 if ((pcity = tile_city(unit_tile(punit)))) {
1796 /* Try to join the city. */
1797 request_do_action(ACTION_JOIN_CITY, punit->id, pcity->id, 0, "");
1798 } else {
1799 /* The reply will trigger a dialog to name the new city. */
1801 }
1802}
1803
1804/**********************************************************************/
1811 struct tile *dest_tile)
1812{
1813 struct packet_unit_orders p;
1814 int dir;
1815
1817
1818 if (dir == -1) {
1819 /* The unit isn't located next to the destination tile. */
1820 return;
1821 }
1822
1823 memset(&p, 0, sizeof(p));
1824
1825 p.repeat = FALSE;
1826 p.vigilant = FALSE;
1827
1828 p.unit_id = punit->id;
1831
1832 p.length = 1;
1833 p.orders[0].order = ORDER_MOVE;
1834 p.orders[0].dir = dir;
1836 p.orders[0].target = NO_TARGET;
1838 p.orders[0].action = ACTION_NONE;
1839
1842}
1843
1844/**********************************************************************/
1854{
1855 struct packet_unit_orders p;
1856 struct tile *dest_tile;
1857
1858 /* Catches attempts to move off map */
1859 dest_tile = mapstep(&(wld.map), unit_tile(punit), dir);
1860 if (!dest_tile) {
1861 return;
1862 }
1863
1864 if (!can_unit_exist_at_tile(&(wld.map), punit, dest_tile)) {
1865 if (request_transport(punit, dest_tile)) {
1866 return;
1867 }
1868 }
1869
1870 /* The goto system isn't used to send the order because that would
1871 * prevent direction movement from overriding it.
1872 * Example of a situation when overriding the goto system is useful:
1873 * The goto system creates a longer path to make a move legal. The player
1874 * wishes to order the illegal move so the server will explain why the
1875 * short move is illegal. */
1876
1877 memset(&p, 0, sizeof(p));
1878
1879 p.repeat = FALSE;
1880 p.vigilant = FALSE;
1881
1882 p.unit_id = punit->id;
1884 p.dest_tile = tile_index(dest_tile);
1885
1886 p.length = 1;
1889 p.orders[0].dir = dir;
1891 p.orders[0].target = NO_TARGET;
1893 p.orders[0].action = ACTION_NONE;
1894
1897}
1898
1899/**********************************************************************/
1907
1908/**********************************************************************/
1913 enum unit_activity act,
1914 struct extra_type *tgt)
1915{
1916 if (!can_client_issue_orders()) {
1917 return;
1918 }
1919
1920 /* Callers rely on this to take back control from server side agents. */
1922
1923 if (tgt == NULL) {
1925 } else {
1927 }
1928}
1929
1930/**********************************************************************/
1934{
1935 struct client_disband_unit_data *data = p;
1936
1937 free(data);
1938}
1939
1940/**********************************************************************/
1943static void do_disband_alternative(void *p)
1944{
1945 struct unit *punit;
1946 struct city *pcity;
1947 struct tile *ptile;
1948 int last_request_id_used;
1949 struct client_disband_unit_data *next;
1950 struct client_disband_unit_data *data = p;
1951 int act;
1952
1954
1955 /* Fetch the unit to get rid of. */
1957
1958 if (punit == NULL) {
1959 /* Success! It is gone. */
1960 return;
1961 }
1962
1963 if (data->alt == -1) {
1964 /* All alternatives have been tried. */
1966 /* TRANS: Unable to get rid of Leader. */
1967 _("Unable to get rid of %s."),
1969 return;
1970 }
1971
1972 act = disband_unit_alternatives[data->alt];
1973
1974 /* Prepare the data for the next try in case this try fails. */
1975 next = fc_malloc(sizeof(struct client_disband_unit_data));
1976 next->unit_id = data->unit_id;
1977 next->alt = data->alt - 1;
1978
1979 /* Latest request ID before trying to send a request. */
1980 last_request_id_used = client.conn.client.last_request_id_used;
1981
1982 /* Send a request to the server unless it is known to be pointless. */
1983 switch (action_id_get_target_kind(act)) {
1984 case ATK_CITY:
1985 if ((pcity = tile_city(unit_tile(punit)))
1987 request_do_action(act, punit->id, pcity->id, 0, "");
1988 }
1989 break;
1990 case ATK_UNIT:
1992 request_do_action(act, punit->id, punit->id, 0, "");
1993 }
1994 break;
1995 case ATK_UNITS:
1996 if ((ptile = unit_tile(punit))
1998 request_do_action(act, punit->id, ptile->index, 0, "");
1999 }
2000 break;
2001 case ATK_TILE:
2002 if ((ptile = unit_tile(punit))
2004 request_do_action(act, punit->id, ptile->index, 0, "");
2005 }
2006 break;
2007 case ATK_EXTRAS:
2008 if ((ptile = unit_tile(punit))
2010 ptile, NULL))) {
2011 request_do_action(act, punit->id, ptile->index, 0, "");
2012 }
2013 break;
2014 case ATK_SELF:
2016 request_do_action(act, punit->id, punit->id, 0, "");
2017 }
2018 break;
2019 case ATK_COUNT:
2021 break;
2022 }
2023
2024 if (last_request_id_used != client.conn.client.last_request_id_used) {
2025 /* A request was sent. */
2026
2027 /* Check if it worked. Move on if it didn't. */
2032 } else {
2033 /* No request was sent. */
2034
2035 /* Move on. */
2037
2038 /* Won't be freed by anyone else. */
2040 }
2041}
2042
2043/**********************************************************************/
2047{
2048 struct client_disband_unit_data *data;
2049
2050 /* Set up disband data. Start at the end of the array. */
2051 data = fc_malloc(sizeof(struct client_disband_unit_data));
2052 data->unit_id = punit->id;
2053 data->alt = 2;
2054
2055 /* Begin. */
2057
2058 /* Won't be freed by anyone else. */
2060}
2061
2062/**********************************************************************/
2066{
2067 struct city *pcity = tile_city(unit_tile(punit));
2068
2069 if (pcity) {
2070 request_do_action(ACTION_HOME_CITY, punit->id, pcity->id, 0, "");
2071 }
2072}
2073
2074/**********************************************************************/
2078{
2079 struct city *pcity = tile_city(unit_tile(punit));
2080
2081 if (pcity) {
2083 }
2084}
2085
2086/**********************************************************************/
2093
2094/**********************************************************************/
2101{
2102 if (punit) {
2104 agent);
2105 }
2106}
2107
2108/**********************************************************************/
2113{
2116 } else if (punit) {
2118 _("Only settler units can be put into auto mode."));
2119 }
2120}
2121
2122/**********************************************************************/
2128 struct tile *ptile)
2129{
2130 if (!ptrans) {
2132 }
2133
2134 if (ptrans
2138 same_pos(unit_tile(pcargo), ptile)
2141 enum gen_action act_id = action_id(paction);
2142
2144 ptrans))) {
2145 /* Try the first action that may be legal. */
2146 /* Implement something like do_disband_alternative() if a ruleset
2147 * appears where this isn't good enough. */
2148 request_do_action(act_id, pcargo->id, ptrans->id, 0, "");
2149 break;
2150 }
2152
2153 /* Sentry the unit. */
2154 /* FIXME: Should not sentry if above loading fails (transport moved away,
2155 * or filled already in server side) */
2157 USSDT_SENTRY, 1);
2158 }
2159}
2160
2161/**********************************************************************/
2166{
2168
2170 && ptrans != NULL
2175 pcargo->id, ptrans->id, 0, "");
2176 } else {
2178 ptrans->id, pcargo->id, 0, "");
2179 }
2180
2182 && pcargo->activity == ACTIVITY_SENTRY) {
2183 /* Activate the unit. */
2185 USSDT_SENTRY, 0);
2186 }
2187 }
2188}
2189
2190/**********************************************************************/
2195{
2196 struct city *target_city;
2197
2198 if (!((target_city = tile_city(unit_tile(punit))))) {
2199 return;
2200 }
2201
2202 if (action == ACTION_TRADE_ROUTE) {
2204 target_city->id, 0, "");
2205 } else if (action == ACTION_HELP_WONDER) {
2207 target_city->id, 0, "");
2208 } else {
2209 log_error("request_unit_caravan_action() Bad action (%d)", action);
2210 }
2211}
2212
2213/**********************************************************************/
2217void request_unit_paradrop(struct unit_list *punits)
2218{
2219 bool can = FALSE;
2220 struct tile *offender = NULL;
2221
2222 if (unit_list_size(punits) == 0) {
2223 return;
2224 }
2226 if (can_unit_paradrop(&(wld.map), punit)) {
2227 can = TRUE;
2228 break;
2229 }
2230 if (!offender) { /* Take first offender tile/unit */
2232 }
2234 if (can) {
2236 ftc_client,
2237 /* TRANS: paradrop target tile. */
2238 _("Click on a tile to paradrop to it."));
2239
2243 } else {
2245 _("Only paratrooper units can do this."));
2246 }
2247}
2248
2249/**********************************************************************/
2253static void request_unit_teleport(struct unit_list *punits)
2254{
2255 bool can = FALSE;
2256 struct tile *offender = NULL;
2257
2258 if (unit_list_size(punits) == 0) {
2259 return;
2260 }
2261
2263 if (can_unit_teleport(&(wld.map), punit)) {
2264 can = TRUE;
2265 break;
2266 }
2267 if (!offender) { /* Take first offender tile/unit */
2269 }
2271
2272 if (can) {
2274 ftc_client,
2275 /* TRANS: teleport target tile. */
2276 _("Click on a tile to teleport to it."));
2277
2281 } else {
2283 _("Only teleporting units can do this."));
2284 }
2285}
2286
2287/**********************************************************************/
2291{
2292 struct unit_list *punits = get_units_in_focus();
2293
2294 if (unit_list_size(punits) == 0) {
2295 return;
2296 }
2297
2298 if (hover_state != HOVER_PATROL) {
2304 } else {
2307 }
2308}
2309
2310/**********************************************************************/
2320
2321/**********************************************************************/
2331
2332/**********************************************************************/
2336{
2337 if (!game.info.pillage_select) {
2338 /* Leave choice up to the server */
2340 } else {
2342 int count = 0;
2343
2347 potential)) {
2349 count++;
2350 }
2352
2353 if (count > 1) {
2355 } else {
2356 /* Should be only one choice... */
2358
2359 if (target != NULL) {
2361 }
2362 }
2363 }
2364}
2365
2366/**********************************************************************/
2378
2379/**********************************************************************/
2391
2392/**********************************************************************/
2396{
2397 if (!can_client_change_view()) {
2398 return;
2399 }
2400
2403}
2404
2405/**********************************************************************/
2409{
2410 if (!can_client_change_view()) {
2411 return;
2412 }
2413
2416}
2417
2418/**********************************************************************/
2422{
2423 if (!can_client_change_view()) {
2424 return;
2425 }
2426
2429}
2430
2431/**********************************************************************/
2435{
2436 if (!can_client_change_view()) {
2437 return;
2438 }
2439
2442}
2443
2444/**********************************************************************/
2448{
2449 if (!can_client_change_view()) {
2450 return;
2451 }
2452
2455}
2456
2457/**********************************************************************/
2461{
2462 if (!can_client_change_view()) {
2463 return;
2464 }
2465
2468}
2469
2470/**********************************************************************/
2474{
2475 if (!can_client_change_view()) {
2476 return;
2477 }
2478
2481}
2482
2483/**********************************************************************/
2487{
2488 if (!can_client_change_view()) {
2489 return;
2490 }
2491
2494}
2495
2496/**********************************************************************/
2500{
2501 if (!can_client_change_view()) {
2502 return;
2503 }
2504
2507}
2508
2509/**********************************************************************/
2513{
2514 if (!can_client_change_view()) {
2515 return;
2516 }
2517
2520}
2521
2522/**********************************************************************/
2526{
2527 if (!can_client_change_view()) {
2528 return;
2529 }
2530
2533}
2534
2535/**********************************************************************/
2539{
2540 if (!can_client_change_view()) {
2541 return;
2542 }
2543
2546}
2547
2548/**********************************************************************/
2552{
2553 if (!can_client_change_view()) {
2554 return;
2555 }
2556
2559}
2560
2561/**********************************************************************/
2565{
2566 if (!can_client_change_view()) {
2567 return;
2568 }
2569
2572}
2573
2574/**********************************************************************/
2578{
2579 if (!can_client_change_view()) {
2580 return;
2581 }
2582
2585}
2586
2587/**********************************************************************/
2591{
2592 if (!can_client_change_view()) {
2593 return;
2594 }
2595
2598}
2599
2600/**********************************************************************/
2604{
2605 if (!can_client_change_view()) {
2606 return;
2607 }
2608
2611}
2612
2613/**********************************************************************/
2617{
2618 if (!can_client_change_view()) {
2619 return;
2620 }
2621
2624}
2625
2626/**********************************************************************/
2630{
2631 if (!can_client_change_view()) {
2632 return;
2633 }
2634
2637}
2638
2639/**********************************************************************/
2643{
2644 if (!can_client_change_view()) {
2645 return;
2646 }
2647
2650}
2651
2652/**********************************************************************/
2656{
2657 if (!can_client_change_view()) {
2658 return;
2659 }
2660
2663}
2664
2665/**********************************************************************/
2669{
2670 if (!can_client_change_view()) {
2671 return;
2672 }
2673
2676}
2677
2678/**********************************************************************/
2682{
2683 if (!can_client_change_view()) {
2684 return;
2685 }
2686
2689}
2690
2691/**********************************************************************/
2695{
2696 if (!can_client_change_view()) {
2697 return;
2698 }
2699
2702}
2703
2704/**********************************************************************/
2708{
2709 if (!can_client_change_view()) {
2710 return;
2711 }
2712
2716}
2717
2718/**********************************************************************/
2722{
2723 struct tile *ptile = find_a_focus_unit_tile_to_center_on();
2724
2725 if (ptile) {
2726 center_tile_mapcanvas(ptile);
2727 }
2728}
2729
2730/**********************************************************************/
2734void request_units_wait(struct unit_list *punits)
2735{
2739 if (punits == get_units_in_focus()) {
2741 }
2742}
2743
2744/**********************************************************************/
2748{
2749 if (get_num_units_in_focus() > 0) {
2752 /* If any of the focused units are busy, keep all of them
2753 * in focus; another tap of the key will dismiss them */
2754 if (punit->activity != ACTIVITY_IDLE) {
2756 }
2762 if (new_status == FOCUS_DONE) {
2764 }
2765 }
2766}
2767
2768/**********************************************************************/
2774{
2775 struct tile *src_tile = unit_tile(punit);
2779
2782
2783 if (!was_teleported
2785 && !unit_transported(punit)) {
2787 unit_type_get(punit)->sound_move_alt,
2788 NULL);
2789 }
2790
2798 || (punit->ssa_controller == SSA_NONE))
2801 }
2802
2803 if (hover_state != HOVER_NONE && in_focus) {
2804 /* Cancel current goto/patrol/connect/nuke command. */
2807 }
2808
2809 unit_list_remove(src_tile->units, punit);
2810
2811 if (!unit_transported(punit)) {
2812 /* Mark the unit as moving unit, then find_visible_unit() won't return
2813 * it. It is especially useful to don't draw many times the unit when
2814 * refreshing the canvas. */
2816
2817 /* We have to refresh the tile before moving. This will draw
2818 * the tile without the unit (because it was unlinked above). */
2820
2822 && punit->ssa_controller != SSA_NONE) {
2823 /* Dont animate automatic units */
2824 } else if (do_animation) {
2825 int dx, dy;
2826
2827 /* For the duration of the animation the unit exists at neither
2828 * tile. */
2829 map_distance_vector(&dx, &dy, src_tile, dst_tile);
2830 move_unit_map_canvas(punit, src_tile, dx, dy);
2831 }
2832 }
2833
2836
2837 if (!unit_transported(punit)) {
2838 /* For find_visible_unit(), see above. */
2840
2842 }
2843
2844 /* With the "full" city bar we have to update the city bar when units move
2845 * into or out of a city. For foreign cities this is handled separately,
2846 * via the occupied field of the short-city packet. */
2847 if (NULL != tile_city(src_tile)
2850 }
2851 if (NULL != tile_city(dst_tile)
2854 }
2855
2856 if (in_focus) {
2857 menus_update();
2858 }
2859}
2860
2861/**********************************************************************/
2865static void do_unit_act_sel_vs(struct tile *ptile)
2866{
2869 /* Have the server record that an action decision is wanted for
2870 * this unit against this tile. */
2872 USSDT_QUEUE, tile_index(ptile));
2873 }
2875}
2876
2877/**********************************************************************/
2880void do_map_click(struct tile *ptile, enum quickselect_type qtype)
2881{
2882 struct city *pcity = tile_city(ptile);
2883 struct unit_list *punits = get_units_in_focus();
2884 bool maybe_goto = FALSE;
2885
2886 if (hover_state != HOVER_NONE) {
2887 switch (hover_state) {
2888 case HOVER_NONE:
2889 break;
2890 case HOVER_GOTO:
2891 do_unit_goto(ptile);
2892 break;
2893 case HOVER_TELEPORT:
2895 do_unit_teleport_to(punit, ptile);
2897 break;
2898 case HOVER_PARADROP:
2900 do_unit_paradrop_to(punit, ptile);
2902 break;
2903 case HOVER_CONNECT:
2905 break;
2906 case HOVER_PATROL:
2907 do_unit_patrol_to(ptile);
2908 break;
2909 case HOVER_ACT_SEL_TGT:
2910 do_unit_act_sel_vs(ptile);
2911 break;
2912 case HOVER_GOTO_SEL_TGT:
2914 do_unit_goto(ptile);
2915 break;
2916 }
2917
2920 } else if (qtype != SELECT_POPUP && qtype != SELECT_APPEND) {
2921 /* Bypass stack or city popup if quickselect is specified. */
2922 struct unit *qunit = quickselect(ptile, qtype);
2923
2924 if (qunit) {
2927 }
2928 } else if (NULL != pcity
2930 /* Otherwise use popups. */
2931 popup_city_dialog(pcity);
2932 } else if (unit_list_size(ptile->units) == 0
2933 && NULL == pcity
2934 && get_num_units_in_focus() > 0) {
2936 } else if (unit_list_size(ptile->units) == 1
2938 struct unit *punit = unit_list_get(ptile->units, 0);
2939
2943 if (qtype == SELECT_APPEND) {
2945 } else {
2947 }
2948 }
2949 } else if (pcity) {
2950 /* Don't hide the unit in the city. */
2952 }
2953 } else if (unit_list_size(ptile->units) > 0) {
2954 /* The stack list is always popped up, even if it includes enemy units.
2955 * If the server doesn't want the player to know about them it shouldn't
2956 * tell them! The previous behavior would only pop up the stack if you
2957 * owned a unit on the tile. This gave cheating clients an advantage,
2958 * and also showed you allied units if (and only if) you had a unit on
2959 * the tile (inconsistent). */
2961 }
2962
2963 /* See mapctrl_common.c */
2967}
2968
2969/**********************************************************************/
2974static struct unit *quickselect(struct tile *ptile,
2976{
2977 int listsize = unit_list_size(ptile->units);
2978 struct unit *panytransporter = NULL,
2982
2984
2985 if (qtype == SELECT_FOCUS) {
2986 return head_of_units_in_focus();
2987 }
2988
2989 if (listsize == 0) {
2990 return NULL;
2991 } else if (listsize == 1) {
2992 struct unit *punit = unit_list_get(ptile->units, 0);
2993 return (unit_owner(punit) == client.conn.playing) ? punit : NULL;
2994 }
2995
2996 /* Quickselect priorities. Units with moves left
2997 * before exhausted. Focus unit is excluded.
2998 *
2999 * SEA: Transporter
3000 * Sea unit
3001 * Any unit
3002 *
3003 * LAND: Military land unit
3004 * Non-combatant
3005 * Sea unit
3006 * Any unit
3007 */
3008
3009 unit_list_iterate(ptile->units, punit) {
3011 continue;
3012 }
3013 if (qtype == SELECT_SEA) {
3014 /* Transporter. */
3016 if (punit->moves_left > 0) {
3017 return punit;
3018 } else if (!panytransporter) {
3020 }
3021 }
3022 /* Any sea, pref. moves left. */
3024 if (punit->moves_left > 0) {
3025 if (!panymovesea) {
3027 }
3028 } else if (!panysea) {
3029 panysea = punit;
3030 }
3031 }
3032 } else if (qtype == SELECT_LAND) {
3034 if (punit->moves_left > 0) {
3035 if (!is_special_unit(punit)) {
3036 return punit;
3037 } else if (!panymoveland) {
3039 }
3040 } else if (!panyland) {
3041 panyland = punit;
3042 }
3043 }
3045 if (punit->moves_left > 0) {
3047 } else {
3048 panysea = punit;
3049 }
3050 }
3051 }
3052 if (punit->moves_left > 0 && !panymoveunit) {
3054 }
3055 if (!panyunit) {
3056 panyunit = punit;
3057 }
3059
3060 if (qtype == SELECT_SEA) {
3061 if (panytransporter) {
3062 return panytransporter;
3063 } else if (panymovesea) {
3064 return panymovesea;
3065 } else if (panysea) {
3066 return panysea;
3067 } else if (panymoveunit) {
3068 return panymoveunit;
3069 } else if (panyunit) {
3070 return panyunit;
3071 }
3072 }
3073 else if (qtype == SELECT_LAND) {
3074 if (panymoveland) {
3075 return panymoveland;
3076 } else if (panyland) {
3077 return panyland;
3078 } else if (panymovesea) {
3079 return panymovesea;
3080 } else if (panysea) {
3081 return panysea;
3082 } else if (panymoveunit) {
3083 return panymoveunit;
3084 } else if (panyunit) {
3085 return panyunit;
3086 }
3087 }
3088 return NULL;
3089}
3090
3091/**********************************************************************/
3095void do_unit_goto(struct tile *ptile)
3096{
3100
3103 return;
3104 }
3105
3106 if (is_valid_goto_draw_line(ptile)) {
3108 } else {
3110 _("Didn't find a route to the destination!"));
3111 }
3112}
3113
3114/**********************************************************************/
3117static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
3118{
3119 struct action *teleport_action = NULL;
3120
3121 action_iterate(act_id) {
3122 struct action *paction = action_by_number(act_id);
3123
3125 /* Not relevant. */
3126 continue;
3127 }
3128
3131 tile_city(ptile), NULL,
3132 ptile, NULL))) {
3133 if (teleport_action == NULL) {
3134 /* This is the first possible teleport action. */
3136 } else {
3137 /* More than one teleport action may be possible. The user must
3138 * choose. Have the server record that an action decision is wanted
3139 * for this unit so the dialog will be brought up. */
3141 USSDT_QUEUE, tile_index(ptile));
3142 return;
3143 }
3144 }
3146
3147 if (teleport_action != NULL) {
3149 tile_index(ptile), 0 , "");
3150 }
3151}
3152
3153/**********************************************************************/
3156void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
3157{
3158 struct action *paradrop_action = NULL;
3159
3160 action_iterate(act_id) {
3161 struct action *paction = action_by_number(act_id);
3162
3165 /* Not relevant. */
3166 continue;
3167 }
3168
3171 tile_city(ptile), NULL,
3172 ptile, NULL))) {
3173 if (paradrop_action == NULL) {
3174 /* This is the first possible paradrop action. */
3176 } else {
3177 /* More than one paradrop action may be possible. The user must
3178 * choose. Have the server record that an action decision is wanted
3179 * for this unit so the dialog will be brought up. */
3181 USSDT_QUEUE, tile_index(ptile));
3182 return;
3183 }
3184 }
3186
3187 if (paradrop_action != NULL) {
3189 tile_index(ptile), 0 , "");
3190 }
3191}
3192
3193/**********************************************************************/
3196void do_unit_patrol_to(struct tile *ptile)
3197{
3198 if (is_valid_goto_draw_line(ptile)
3201 } else {
3203 _("Didn't find a route to the destination!"));
3204 }
3205
3207}
3208
3209/**********************************************************************/
3212void do_unit_connect(struct tile *ptile,
3213 enum unit_activity activity,
3214 struct extra_type *tgt)
3215{
3216 if (is_valid_goto_draw_line(ptile)) {
3217 send_connect_route(activity, tgt);
3218 } else {
3220 _("Didn't find a route to the destination!"));
3221 }
3222
3224}
3225
3226/**********************************************************************/
3230{
3231 struct unit_list *punits = get_units_in_focus();
3233
3234 switch (hover_state) {
3235 case HOVER_GOTO_SEL_TGT:
3239 break;
3240 case HOVER_GOTO:
3241 case HOVER_PATROL:
3242 case HOVER_CONNECT:
3243 if (goto_pop_waypoint()) {
3244 break;
3245 }
3246 fc__fallthrough; /* else fall through: */
3247 case HOVER_TELEPORT:
3248 case HOVER_PARADROP:
3249 case HOVER_ACT_SEL_TGT:
3252
3256 break;
3257 case HOVER_NONE:
3258 break;
3259 };
3260}
3261
3262/**********************************************************************/
3267{
3269
3270 if (capital) {
3271 /* Center on the tile, and pop up the crosshair overlay. */
3274 } else {
3276 _("Oh my! You seem to have no capital!"));
3277 }
3278}
3279
3280/**********************************************************************/
3284{
3286}
3287
3288/**********************************************************************/
3292{
3293 int i = 0;
3294
3295 /* Could use unit_list_copy here instead. Just having safe genlists
3296 * wouldn't be sufficient since we don't want to skip units already
3297 * removed from focus... */
3299 if (i == 0) {
3301 } else {
3303 }
3304 i++;
3306}
3307
3308/**********************************************************************/
3320
3321/**********************************************************************/
3330
3331/**********************************************************************/
3342
3343/**********************************************************************/
3347 struct extra_type *tgt)
3348{
3349 request_unit_connect(activity, tgt);
3350}
3351
3352/**********************************************************************/
3356{
3357 struct tile *ptile;
3358
3361 && (ptile = unit_tile(punit))) {
3362 /* Have the server record that an action decision is wanted for this
3363 * unit. */
3365 USSDT_QUEUE, tile_index(ptile));
3366 }
3368}
3369
3370/**********************************************************************/
3378{
3379 struct unit_list *punits = get_units_in_focus();
3380
3382 /* The 2nd key press means that the actor should target its own
3383 * tile. */
3385
3386 /* Target tile selected. Clean up hover state. */
3389
3390 return;
3391 } else if (hover_state == HOVER_GOTO_SEL_TGT) {
3393
3394 /* We don't support long range actions in the middle of orders yet so
3395 * send it at once. */
3397
3398 /* Target tile selected. Clean up hover state. */
3401
3402 return;
3403 } else if (hover_state == HOVER_GOTO
3406
3408 ftc_client,
3409 /* TRANS: Perform action inside a goto. */
3410 _("Click on a tile to do %s against it."),
3412
3417
3418 return;
3419 }
3420
3422 ftc_client,
3423 /* TRANS: "Do..." action selection dialog target. */
3424 _("Click on a tile to act against it. "
3425 "Press 'd' again to act against own tile."));
3426
3429}
3430
3431/**********************************************************************/
3435{
3437}
3438
3439/**********************************************************************/
3443{
3445}
3446
3447/**********************************************************************/
3454
3455/**********************************************************************/
3459{
3461}
3462
3463/**********************************************************************/
3470
3471/**********************************************************************/
3475{
3477 /* TODO: Is falling back on ACTION_MARKETPLACE if not able to establish
3478 * a trade route trade a good idea or an unplecant surprice? */
3481 }
3483}
3484
3485/**********************************************************************/
3489{
3490 struct unit *pnext_focus = NULL, *plast;
3491
3495 }
3497
3498 if (pnext_focus) {
3500 /* Unfocus the ships, and advance the focus to the last unloaded unit.
3501 * If there is no unit unloaded (which shouldn't happen, but could if
3502 * the caller doesn't check if the transporter is loaded), the we
3503 * don't do anything. */
3507 }
3508}
3509
3510/**********************************************************************/
3517
3518/**********************************************************************/
3527
3528/**********************************************************************/
3544
3545/**********************************************************************/
3556
3557/**********************************************************************/
3569
3570/**********************************************************************/
3579
3580/**********************************************************************/
3591
3592/**********************************************************************/
3608
3609/**********************************************************************/
3618
3619/**********************************************************************/
3622static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
3623{
3626 cause,
3628 punit);
3629
3632 }
3634}
3635
3636/**********************************************************************/
3643
3644/**********************************************************************/
3655
3656/**********************************************************************/
3660{
3662}
3663
3664/**********************************************************************/
3675
3676/**********************************************************************/
3687
3688/**********************************************************************/
3705
3706/**********************************************************************/
3723
3724/**********************************************************************/
3735
3736/**********************************************************************/
3747
3748/**********************************************************************/
3751void key_unit_assign_battlegroup(int battlegroup, bool append)
3752{
3754 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3755 if (!append) {
3757 if (!unit_is_in_focus(punit)) {
3763 unit_list_remove(battlegroups[battlegroup], punit);
3764 }
3766 }
3768 if (punit->battlegroup != battlegroup) {
3769 if (punit->battlegroup >= 0
3772 }
3773 punit->battlegroup = battlegroup;
3776 battlegroup);
3777 unit_list_append(battlegroups[battlegroup], punit);
3779 }
3781 unit_list_iterate(battlegroups[battlegroup], punit) {
3784 }
3785}
3786
3787/**********************************************************************/
3790void key_unit_select_battlegroup(int battlegroup, bool append)
3791{
3793 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3794 int i = 0;
3795
3796 if (unit_list_size(battlegroups[battlegroup]) == 0 && !append) {
3798 return;
3799 }
3800
3801 /* FIXME: this is very inefficient and can be improved. */
3802 unit_list_iterate(battlegroups[battlegroup], punit) {
3803 if (i == 0 && !append) {
3805 } else {
3807 }
3808 i++;
3810 }
3811}
3812
3813/**********************************************************************/
3820
3821/**********************************************************************/
3828
3829/**********************************************************************/
3833{
3835}
3836
3837/**********************************************************************/
3844
3845/**********************************************************************/
3852
3853/**********************************************************************/
3860
3861/**********************************************************************/
3868
3869/**********************************************************************/
3877
3878/**********************************************************************/
3886
3887/**********************************************************************/
3894
3895/**********************************************************************/
3903
3904/**********************************************************************/
3911
3912/**********************************************************************/
3916{
3918}
3919
3920/**********************************************************************/
3924{
3926}
3927
3928/**********************************************************************/
3932{
3934}
3935
3936/**********************************************************************/
3943
3944/**********************************************************************/
3948{
3950}
3951
3952/**********************************************************************/
3956{
3958}
3959
3960/**********************************************************************/
3964{
3966}
3967
3968/**********************************************************************/
3972{
3974}
3975
3976/**********************************************************************/
3980{
3982}
3983
3984/**********************************************************************/
3988{
3990}
3991
3992/**********************************************************************/
3996{
3998}
3999
4000/**********************************************************************/
4007
4008/**********************************************************************/
4015
4016/**********************************************************************/
4023
4024/**********************************************************************/
4031
4032/**********************************************************************/
4039
4040/**********************************************************************/
4047
4048/**********************************************************************/
4058
4059/**********************************************************************/
4062void finish_city(struct tile *ptile, const char *name)
4063{
4064 unit_list_iterate(ptile->units, punit) {
4066 /* Unit will disappear only in case city building still success.
4067 * Cancel city building status just in case something has changed
4068 * to prevent city building in the meanwhile and unit will remain
4069 * alive. */
4072 0, name);
4073 }
4075}
4076
4077/**********************************************************************/
4081void cancel_city(struct tile *ptile)
4082{
4083 unit_list_iterate(ptile->units, punit) {
4086}
const char * action_name_translation(const struct action *action)
Definition actions.c:1982
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2002
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Definition actions.c:5497
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5823
struct act_prob action_prob_unit_vs_tgt(const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Definition actions.c:5519
struct act_prob action_prob_vs_city(const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Definition actions.c:4981
struct act_prob action_prob_vs_unit(const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Definition actions.c:5065
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:5342
struct act_prob action_prob_vs_stack(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:5258
struct act_prob action_prob_vs_extras(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:5426
bool action_id_exists(const action_id act_id)
Definition actions.c:1820
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:927
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:479
static struct action * action_by_number(action_id act_id)
Definition actions.h:633
#define action_has_result(_act_, _res_)
Definition actions.h:429
#define action_id_get_role(act_id)
Definition actions.h:694
#define action_by_result_iterate_end
Definition actions.h:483
#define action_iterate_end
Definition actions.h:463
#define action_id(_act_)
Definition actions.h:659
#define action_iterate(_act_)
Definition actions.h:459
#define action_id_get_target_kind(act_id)
Definition actions.h:650
#define action_id_has_result_safe(act_id, result)
Definition actions.h:663
#define ACTION_NONE
Definition actions.h:309
void astr_free(struct astring *astr)
Definition astring.c:153
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_play_sound(const char *const tag, const char *const alt_tag, const char *const alt_tag2)
Definition audio.c:528
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Definition base.c:139
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:726
void popup_city_dialog(struct city *pcity)
int client_player_number(void)
void send_turn_done(void)
struct civclient client
enum client_states client_state(void)
bool can_client_issue_orders(void)
bool client_has_player(void)
bool is_server_busy(void)
bool can_client_change_view(void)
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
@ C_S_OVER
Definition client_main.h:48
enum direction8 gui_to_map_dir(enum direction8 gui_dir)
Definition climap.c:59
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1081
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1230
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:311
char * incite_cost
Definition comments.c:74
double blink_turn_done_button(void)
Definition control.c:907
void key_coastline_toggle(void)
Definition control.c:3923
void key_irrigation_toggle(void)
Definition control.c:3939
void request_toggle_huts(void)
Definition control.c:2616
void key_unit_sentry(void)
Definition control.c:3727
void request_toggle_city_outlines(void)
Definition control.c:2369
void key_unit_road(void)
Definition control.c:3709
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1517
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2773
void request_toggle_resources(void)
Definition control.c:2603
void request_toggle_city_names(void)
Definition control.c:2447
void key_recall_previous_focus_unit(void)
Definition control.c:3291
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1810
void request_toggle_unit_stack_size(void)
Definition control.c:2512
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:383
void key_city_output_toggle(void)
Definition control.c:3824
void request_toggle_focus_unit(void)
Definition control.c:2694
void request_toggle_city_output(void)
Definition control.c:2382
void request_unit_return(struct unit *punit)
Definition control.c:1526
void request_unit_fortify(struct unit *punit)
Definition control.c:2324
void key_unit_build_city(void)
Definition control.c:3324
void key_editor_recalculate_borders(void)
Definition control.c:4043
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1485
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2194
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1033
enum unit_orders goto_last_order
Definition control.c:96
void request_units_wait(struct unit_list *punits)
Definition control.c:2734
void request_unit_wakeup(struct unit *punit)
Definition control.c:1574
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:391
void key_focus_unit_toggle(void)
Definition control.c:4019
void request_toggle_map_grid(void)
Definition control.c:2395
void action_decision_request(struct unit *actor_unit)
Definition control.c:1084
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2577
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1014
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:1311
void key_unit_action_select(void)
Definition control.c:3355
void key_unit_auto_explore(void)
Definition control.c:3548
static int action_selection_in_progress_for
Definition control.c:119
static void do_disband_alternative(void *p)
Definition control.c:1943
void key_cancel_action(void)
Definition control.c:3229
void request_toggle_city_buycost(void)
Definition control.c:2486
void key_unit_auto_settle(void)
Definition control.c:3561
void clear_hover_state(void)
Definition control.c:323
void request_toggle_map_native(void)
Definition control.c:2421
void request_unit_patrol(void)
Definition control.c:2290
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3346
void key_city_full_bar_toggle(void)
Definition control.c:3856
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2127
void key_bases_toggle(void)
Definition control.c:3955
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2880
static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
Definition control.c:3622
void key_map_native_toggle(void)
Definition control.c:3848
void request_toggle_map_borders(void)
Definition control.c:2408
void key_resources_toggle(void)
Definition control.c:3963
static void request_unit_teleport(struct unit_list *punits)
Definition control.c:2253
static struct unit * punit_attacking
Definition control.c:105
void unit_focus_add(struct unit *punit)
Definition control.c:556
void unit_focus_set(struct unit *punit)
Definition control.c:501
static void do_unit_act_sel_vs(struct tile *ptile)
Definition control.c:2865
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1104
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3156
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:334
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:3450
static bool can_units_attack_at(struct unit_list *punits, const struct tile *ptile)
Definition control.c:1171
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:1704
void key_end_turn(void)
Definition control.c:3283
void request_unit_disband(struct unit *punit)
Definition control.c:2046
void request_toggle_irrigation(void)
Definition control.c:2564
static struct unit_list * current_focus
Definition control.c:79
static struct unit_list * previous_focus
Definition control.c:83
void unit_focus_advance(void)
Definition control.c:670
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2112
void request_unit_pillage(struct unit *punit)
Definition control.c:2335
void key_unit_teleport(void)
Definition control.c:3466
void request_center_focus_unit(void)
Definition control.c:2721
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:4011
void key_city_productions_toggle(void)
Definition control.c:3890
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1389
void key_unit_build_wonder(void)
Definition control.c:3334
void key_unit_plant(void)
Definition control.c:3667
void key_unit_fortress(void)
Definition control.c:3595
void key_unit_mine(void)
Definition control.c:3659
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2065
void request_toggle_fog_of_war(void)
Definition control.c:2707
void key_unit_pillage(void)
Definition control.c:3679
void request_unit_unload(struct unit *pcargo)
Definition control.c:2165
void key_editor_toggle_fogofwar(void)
Definition control.c:4052
static void client_disband_unit_data_destroy(void *p)
Definition control.c:1933
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2099
static struct unit * find_best_focus_candidate(bool accept_current)
Definition control.c:633
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1772
static struct unit * quickselect(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2974
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2655
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1912
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:967
void key_unit_irrigate(void)
Definition control.c:3639
void request_unit_build_city(struct unit *punit)
Definition control.c:1791
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:250
static struct unit_list * urgent_focus_queue
Definition control.c:86
void key_unit_unload_all(void)
Definition control.c:3488
void key_cities_toggle(void)
Definition control.c:3987
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3312
void key_city_outlines_toggle(void)
Definition control.c:3816
void key_unit_homecity(void)
Definition control.c:3612
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2217
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:285
static int disband_unit_alternatives[3]
Definition control.c:69
void key_unit_patrol(void)
Definition control.c:3458
void request_toggle_city_full_bar(void)
Definition control.c:2434
void request_toggle_city_growth(void)
Definition control.c:2460
void key_unit_solid_bg_toggle(void)
Definition control.c:4003
void request_toggle_unit_solid_bg(void)
Definition control.c:2668
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1740
void key_terrain_toggle(void)
Definition control.c:3915
void key_paths_toggle(void)
Definition control.c:3931
void request_unit_sentry(struct unit *punit)
Definition control.c:2313
void key_unit_wakeup_others(void)
Definition control.c:3521
bool non_ai_unit_focus
Definition control.c:125
static struct unit * punit_defending
Definition control.c:106
static struct tile * find_a_focus_unit_tile_to_center_on(void)
Definition control.c:413
enum cursor_hover_state hover_state
Definition control.c:89
void key_unit_stack_size_toggle(void)
Definition control.c:3907
static void store_previous_focus(void)
Definition control.c:194
void key_huts_toggle(void)
Definition control.c:3971
void key_fog_of_war_toggle(void)
Definition control.c:4027
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1456
void clear_unit_orders(struct unit *punit)
Definition control.c:476
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2525
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1054
void key_unit_wait(void)
Definition control.c:3513
void key_units_toggle(void)
Definition control.c:3995
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3212
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:586
void request_toggle_bases(void)
Definition control.c:2590
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3196
void key_unit_trade_route(void)
Definition control.c:3474
void request_toggle_coastline(void)
Definition control.c:2538
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3790
void key_map_grid_toggle(void)
Definition control.c:3832
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4062
static struct unit * punit_moving
Definition control.c:102
void key_pollution_toggle(void)
Definition control.c:3979
struct unit * head_of_units_in_focus(void)
Definition control.c:405
static bool is_activity_on_tile(struct tile *ptile, enum unit_activity activity)
Definition control.c:1295
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:804
static bool can_be_irrigated(const struct tile *ptile, const struct unit *punit)
Definition control.c:1366
void key_city_growth_toggle(void)
Definition control.c:3873
void key_unit_action_select_tgt(void)
Definition control.c:3377
static struct unit_list * battlegroups[MAX_NUM_BATTLEGROUPS]
Definition control.c:99
void key_city_buycost_toggle(void)
Definition control.c:3882
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3739
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1853
static void current_focus_append(struct unit *punit)
Definition control.c:442
void key_unit_done(void)
Definition control.c:3434
static void current_focus_remove(struct unit *punit)
Definition control.c:462
static struct tile * hover_tile
Definition control.c:98
void key_city_trade_routes_toggle(void)
Definition control.c:3899
static void focus_units_changed(void)
Definition control.c:215
void request_toggle_city_trade_routes(void)
Definition control.c:2499
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:620
void request_unit_convert(struct unit *punit)
Definition control.c:2089
void request_toggle_paths(void)
Definition control.c:2551
void request_toggle_unit_shields(void)
Definition control.c:2681
void key_city_names_toggle(void)
Definition control.c:3864
void unit_register_battlegroup(struct unit *punit)
Definition control.c:270
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1595
static bool action_requires_confirmation(action_id act, char *buf, size_t bufsize)
Definition control.c:1673
void unit_focus_update(void)
Definition control.c:771
void key_unit_airbase(void)
Definition control.c:3531
void key_unit_goto(void)
Definition control.c:3442
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
void key_unit_convert(void)
Definition control.c:3573
void key_unit_clean(void)
Definition control.c:3691
void key_center_capital(void)
Definition control.c:3266
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1557
void request_toggle_cities(void)
Definition control.c:2642
void key_unit_fortify(void)
Definition control.c:3583
void key_editor_toggle(void)
Definition control.c:4035
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3751
void request_unit_move_done(void)
Definition control.c:2747
void auto_center_on_focus_unit(void)
Definition control.c:429
void key_unit_cultivate(void)
Definition control.c:3647
double blink_active_unit(void)
Definition control.c:874
void request_unit_upgrade(struct unit *punit)
Definition control.c:2077
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2473
void cancel_city(struct tile *ptile)
Definition control.c:4081
static void ask_server_for_actions(struct unit *punit)
Definition control.c:361
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1903
void request_toggle_pollution(void)
Definition control.c:2629
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3947
static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
Definition control.c:3117
void do_unit_goto(struct tile *ptile)
Definition control.c:3095
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1066
static bool can_ask_server_for_actions(void)
Definition control.c:347
void key_map_borders_toggle(void)
Definition control.c:3840
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:43
#define MAX_NUM_UNITS_BELOW
Definition control.h:295
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
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
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
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 action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
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 * target_city
Definition dialogs_g.h:56
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Definition effects.c:1070
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:790
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:533
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_deps_iterate(_reqs, _dep)
Definition extras.h:371
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_deps_iterate_end
Definition extras.h:379
#define EXTRA_NONE
Definition extras.h:85
#define extra_road_get(_e_)
Definition extras.h:191
#define NO_TARGET
Definition fc_types.h:357
@ RPT_POSSIBLE
Definition fc_types.h:703
#define DIR8_ORIGIN
Definition fc_types.h:460
int action_id
Definition fc_types.h:392
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:705
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
void exit_goto_state(void)
Definition goto.c:1022
bool goto_is_active(void)
Definition goto.c:1059
struct pf_path * path_to_nearest_allied_city(struct unit *punit)
Definition goto.c:1982
void send_patrol_route(void)
Definition goto.c:1647
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1338
bool goto_add_waypoint(void)
Definition goto.c:487
bool goto_pop_waypoint(void)
Definition goto.c:524
void send_connect_route(enum unit_activity activity, struct extra_type *tgt)
Definition goto.c:1713
void goto_unit_killed(struct unit *punit)
Definition goto.c:1040
void free_client_goto(void)
Definition goto.c:162
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1001
void send_goto_route(void)
Definition goto.c:1869
bool is_valid_goto_destination(const struct tile *ptile)
Definition goto.c:179
void request_orders_cleared(struct unit *punit)
Definition goto.c:1363
void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *final_order)
Definition goto.c:1530
int action_selection_actor_unit(void)
void action_selection_close(void)
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:538
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
void request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.c:1607
void real_focus_units_changed(void)
Definition gui_main.c:2171
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2148
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2118
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
void update_turn_done_button(bool do_restore)
Definition mapview.c:76
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:643
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
bool request_transport(struct unit *cargo, struct tile *ptile)
enum cursor_type mouse_cursor_type
Definition gui_mouse.c:46
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_error(message,...)
Definition log.h:103
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1347
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:931
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:940
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Definition map.c:371
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1073
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:367
#define iterate_outward_end
Definition map.h:371
bool keyboardless_goto_button_down
void cancel_tile_hiliting(void)
bool keyboardless_goto_active
struct tile * keyboardless_goto_start_tile
void update_map_canvas_visible(void)
struct tile * get_center_tile_mapcanvas(void)
void move_unit_map_canvas(struct unit *punit, struct tile *src_tile, int dx, int dy)
void center_tile_mapcanvas(const struct tile *ptile)
void update_city_description(struct city *pcity)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile)
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
void menus_update(void)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:319
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:491
const struct option_set * server_optset
Definition options.c:4019
bool option_bool_get(const struct option *poption)
Definition options.c:796
struct client_options gui_options
Definition options.c:71
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:430
void refresh_overview_canvas(void)
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_change_activity(struct connection *pc, int unit_id, enum unit_activity activity, int target)
int dsend_packet_unit_do_action(struct connection *pc, int actor_id, int target_id, int sub_tgt_id, const char *name, action_id action_type)
int send_packet_unit_orders(struct connection *pc, const struct packet_unit_orders *packet)
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_unit_server_side_agent_set(struct connection *pc, int unit_id, enum server_side_agent agent)
int send_packet_edit_recalculate_borders(struct connection *pc)
int dsend_packet_unit_action_query(struct connection *pc, int actor_id, int target_id, action_id action_type, int request_kind)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
int dsend_packet_edit_toggle_fogofwar(struct connection *pc, int player)
int dsend_packet_unit_sscs_set(struct connection *pc, int unit_id, enum unit_ss_data_type type, int value)
int dsend_packet_edit_mode(struct connection *pc, bool state)
const struct pf_position * pf_path_last_position(const struct pf_path *path)
void pf_path_destroy(struct pf_path *path)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1133
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
#define players_iterate_alive_end
Definition player.h:547
#define players_iterate_alive(_pplayer)
Definition player.h:542
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
bool player_can_build_road(const struct civ_map *nmap, const struct road_type *proad, const struct player *pplayer, const struct tile *ptile)
Definition road.c:280
#define FC_INFINITY
Definition shared.h:36
Definition agents.h:40
Definition city.h:320
int id
Definition city.h:326
enum capital_type capital
Definition city.h:328
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
bool draw_native
Definition options.h:215
bool enable_cursor_changes
Definition options.h:173
bool auto_turn_done
Definition options.h:164
bool draw_specials
Definition options.h:207
bool draw_city_output
Definition options.h:194
bool draw_city_names
Definition options.h:196
bool draw_city_productions
Definition options.h:198
int smooth_move_unit_msec
Definition options.h:151
bool draw_mines
Definition options.h:205
bool draw_borders
Definition options.h:214
bool draw_fortress_airbase
Definition options.h:206
bool draw_city_buycost
Definition options.h:199
bool draw_unit_stack_size
Definition options.h:218
bool draw_irrigation
Definition options.h:204
bool draw_terrain
Definition options.h:201
bool draw_units
Definition options.h:211
bool auto_center_on_automated
Definition options.h:156
bool draw_fog_of_war
Definition options.h:213
bool draw_city_trade_routes
Definition options.h:200
bool unit_selection_clears_orders
Definition options.h:175
bool draw_unit_shields
Definition options.h:217
bool draw_cities
Definition options.h:210
bool draw_map_grid
Definition options.h:195
bool draw_city_growth
Definition options.h:197
bool draw_focus_unit
Definition options.h:212
bool draw_paths
Definition options.h:203
bool draw_city_outlines
Definition options.h:193
bool draw_coastline
Definition options.h:202
bool popup_actor_arrival
Definition options.h:168
bool draw_full_citybar
Definition options.h:216
bool draw_pollution
Definition options.h:209
bool auto_center_on_unit
Definition options.h:155
bool solid_color_behind_units
Definition options.h:149
bool popup_last_move_to_allied
Definition options.h:170
bool keyboardless_goto
Definition options.h:172
struct player * playing
Definition connection.h:151
struct connection::@58::@63 client
int last_request_id_used
Definition connection.h:187
struct requirement_vector reqs
Definition extras.h:106
struct unit_order orders[MAX_LEN_ROUTE]
struct unit_list * units
Definition player.h:280
bool is_alive
Definition player.h:266
bool phase_done
Definition player.h:261
enum unit_activity activity
const struct unit * unit
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
Definition timing.c:81
enum unit_activity activity
Definition unit.h:94
enum unit_orders order
Definition unit.h:93
int action
Definition unit.h:100
enum direction8 dir
Definition unit.h:102
int target
Definition unit.h:97
int sub_target
Definition unit.h:98
Definition unit.h:138
enum action_decision action_decision_want
Definition unit.h:202
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int id
Definition unit.h:145
int hp
Definition unit.h:151
bool asking_city_name
Definition unit.h:225
bool done_moving
Definition unit.h:181
struct tile * action_decision_tile
Definition unit.h:203
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
enum universals_n kind
Definition fc_types.h:903
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:119
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:699
#define T_UNKNOWN
Definition terrain.h:57
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Definition tile.c:955
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1033
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Definition tile.c:844
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:981
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define tile_hash_iterate(hash, ptile)
Definition tile.h:82
#define tile_terrain(_tile)
Definition tile.h:110
#define tile_hash_iterate_end
Definition tile.h:84
#define tile_continent(_tile)
Definition tile.h:92
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
double get_focus_unit_toggle_timeout(const struct tileset *t)
Definition tilespec.c:6523
void toggle_focus_unit_state(struct tileset *t)
Definition tilespec.c:6555
void focus_unit_in_combat(struct tileset *t)
Definition tilespec.c:6544
cursor_type
Definition tilespec.h:287
@ CURSOR_TELEPORT
Definition tilespec.h:291
@ CURSOR_GOTO
Definition tilespec.h:288
@ CURSOR_INVALID
Definition tilespec.h:294
@ CURSOR_PATROL
Definition tilespec.h:289
@ CURSOR_WAIT
Definition tilespec.h:298
@ CURSOR_SELECT
Definition tilespec.h:293
@ CURSOR_DEFAULT
Definition tilespec.h:300
@ CURSOR_PARADROP
Definition tilespec.h:290
@ CURSOR_NUKE
Definition tilespec.h:292
@ CURSOR_ATTACK
Definition tilespec.h:295
void timer_start(struct timer *t)
Definition timing.c:264
double timer_read_seconds(struct timer *t)
Definition timing.c:384
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
Definition timing.c:180
@ TIMER_ACTIVE
Definition timing.h:46
@ TIMER_USER
Definition timing.h:42
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1779
bool is_attack_unit(const struct unit *punit)
Definition unit.c:307
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2437
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:696
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:602
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:361
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:803
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:299
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:819
bool is_special_unit(const struct unit *punit)
Definition unit.c:352
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1252
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2421
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:748
bool unit_has_orders(const struct unit *punit)
Definition unit.c:205
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1908
#define unit_tile(_pu)
Definition unit.h:390
unit_focus_status
Definition unit.h:52
@ FOCUS_AVAIL
Definition unit.h:53
@ FOCUS_DONE
Definition unit.h:53
@ FOCUS_WAIT
Definition unit.h:53
#define BATTLEGROUP_NONE
Definition unit.h:190
unit_orders
Definition unit.h:37
@ ORDER_ACTION_MOVE
Definition unit.h:45
@ ORDER_ACTIVITY
Definition unit.h:41
@ ORDER_MOVE
Definition unit.h:39
@ ORDER_LAST
Definition unit.h:49
@ ORDER_PERFORM_ACTION
Definition unit.h:47
#define unit_owner(_pu)
Definition unit.h:389
#define MAX_NUM_BATTLEGROUPS
Definition unit.h:189
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:425
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_both_iterate_end
Definition unitlist.h:37
#define unit_list_both_iterate(unitlist, plink, punit)
Definition unitlist.h:34
#define unit_list_iterate_safe_end
Definition unitlist.h:61
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Definition unittype.c:1551
bool utype_may_act_at_all(const struct unit_type *putype)
Definition unittype.c:359
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2498
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
bool role_units_translations(struct astring *astr, int flag, bool alts)
Definition unittype.c:1668
void update_queue_connect_processing_finished_full(int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)