Freeciv-3.3
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/**********************************************************************/
251
252/**********************************************************************/
255void unit_change_battlegroup(struct unit *punit, int battlegroup)
256{
258 battlegroup = BATTLEGROUP_NONE;
259 }
260
261 if (punit->battlegroup != battlegroup) {
262 if (battlegroup != BATTLEGROUP_NONE) {
263 unit_list_append(battlegroups[battlegroup], punit);
264 }
267 }
268 punit->battlegroup = battlegroup;
269 }
270}
271
272/**********************************************************************/
283
284/**********************************************************************/
290void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
291 enum unit_activity activity,
292 struct extra_type *tgt,
293 int last_tgt,
294 int last_sub_tgt,
296 enum unit_orders order)
297{
299 || state == HOVER_NONE);
300 fc_assert_ret(state == HOVER_CONNECT || activity == ACTIVITY_LAST);
301 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
302 || order == ORDER_LAST);
303 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
304 || action == ACTION_NONE);
305
307 && (state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT))) {
308 /* Exit goto unless this is a switch between goto states */
310 }
311
312 hover_state = state;
313 connect_activity = activity;
314 if (tgt) {
315 connect_tgt = tgt;
316 } else {
318 }
319 goto_last_order = order;
323}
324
325/**********************************************************************/
334
335/**********************************************************************/
340{
342 /* The player is interested in getting a pop up for a mere
343 * arrival. */
346}
347
348/**********************************************************************/
353{
354 /* OK as long as no other unit already asked and aren't done yet. */
357}
358
359/**********************************************************************/
367{
370
371 /* Only one action selection dialog at a time is supported. */
373 "Unit %d started action selection before unit %d was done",
376
378 punit->id,
383}
384
385/**********************************************************************/
388bool unit_is_in_focus(const struct unit *punit)
389{
391}
392
393/**********************************************************************/
396struct unit *get_focus_unit_on_tile(const struct tile *ptile)
397{
399 if (unit_tile(punit) == ptile) {
400 return punit;
401 }
403
404 return NULL;
405}
406
407/**********************************************************************/
411{
412 return unit_list_get(current_focus, 0);
413}
414
415/**********************************************************************/
419{
420 struct unit *punit;
421
423 return unit_tile(punit);
424 } else if (get_num_units_in_focus() > 0) {
426 } else {
427 return NULL;
428 }
429}
430
431/**********************************************************************/
435{
437
441 }
442}
443
444/**********************************************************************/
463
464/**********************************************************************/
467static void current_focus_remove(struct unit *punit)
468{
469 /* Close the action selection dialog if the actor unit lose focus. */
472 }
473
476}
477
478/**********************************************************************/
482{
483 if (!punit) {
484 return;
485 }
486
492 } else if (unit_has_orders(punit)) {
493 /* Clear the focus unit's orders. */
495 }
496}
497
498/**********************************************************************/
507{
508 bool focus_changed = FALSE;
509
510 if (NULL != punit
511 && NULL != client.conn.playing
513 /* Callers should make sure this never happens. */
514 return;
515 }
516
517 /* FIXME: This won't work quite right; for instance activating a
518 * battlegroup twice in a row will store the focus erroneously. The only
519 * solution would be a set_units_focus() */
520 if (!(get_num_units_in_focus() == 1
521 && punit == head_of_units_in_focus())) {
524 }
525
526 /* Close the action selection dialog if the actor unit lose focus. */
530 }
532
533 /* Redraw the old focus unit (to fix blinking or remove the selection
534 * circle). */
539
540 if (!can_client_change_view()) {
541 /* This function can be called to set the focus to NULL when
542 * disconnecting. In this case we don't want any other actions! */
543 fc_assert(punit == NULL);
544 return;
545 }
546
547 if (NULL != punit) {
550 }
551
552 if (focus_changed) {
555 }
556}
557
558/**********************************************************************/
562{
563 if (NULL != punit
564 && NULL != client.conn.playing
566 /* Callers should make sure this never happens. */
567 return;
568 }
569
570 if (NULL == punit || !can_client_change_view()) {
571 return;
572 }
573
574 if (unit_is_in_focus(punit)) {
575 return;
576 }
577
578 if (hover_state != HOVER_NONE) {
579 /* Can't continue with current goto if set of focus units
580 * change. Cancel it. */
582 }
583
586}
587
588/**********************************************************************/
592{
593 bool keep_in_focus = FALSE;
594
595 if (NULL != punit
596 && NULL != client.conn.playing
598 /* Callers should make sure this never happens. */
599 return;
600 }
601
602 if (NULL == punit || !can_client_change_view()) {
603 return;
604 }
605
606 if (!unit_is_in_focus(punit)) {
607 return;
608 }
609
610 if (hover_state != HOVER_NONE) {
611 /* Can't continue with current goto if set of focus units
612 * change. Cancel it. */
614 }
615
616 if (get_num_units_in_focus() == 1) {
618
619 if (unit_is_in_focus(punit)) {
620 /* Unit was restored to focus (there was no other units to focus to) */
622 }
623 }
624
625 if (!keep_in_focus) {
627 if (get_num_units_in_focus() > 0) {
629 }
630 }
631}
632
633/**********************************************************************/
643
644/**********************************************************************/
650{
651 struct tile *ptile = get_center_tile_mapcanvas();
652
653 if (!get_focus_unit_on_tile(ptile)) {
655
656 if (pfirst) {
657 ptile = unit_tile(pfirst);
658 }
659 }
660
668 && (punit->moves_left > 0 || unit_type_get(punit)->move_rate == 0)
669 && !punit->done_moving
671 return punit;
672 }
675
676 return NULL;
677}
678
679/**********************************************************************/
689{
690 struct unit *candidate = NULL;
692
693 if (NULL == client.conn.playing
697 return;
698 }
699
701
703 /*
704 * Is the unit which just lost focus a non-AI unit? If yes this
705 * enables the auto end turn.
706 */
707 if (punit->ssa_controller == SSA_NONE) {
709 break;
710 }
712
714 /* Try top of the urgent list. */
715 struct tile *focus_tile = (get_num_units_in_focus() > 0
717 : NULL);
718
722 /* This isn't an action decision needed because of an
723 * ORDER_ACTION_MOVE located in the middle of an order. */
725 /* We have assigned new orders to this unit since, remove it. */
727 } else if (NULL == focus_tile
728 || focus_tile == unit_tile(punit)) {
729 /* Use the first one found */
731 break;
732 } else if (NULL == candidate) {
734 }
736
737 if (NULL != candidate) {
739
740 /* Autocenter on Wakeup, regardless of the local option
741 * "auto_center_on_unit". */
744 }
745 }
746 }
747
748 if (NULL == candidate) {
750
751 if (!candidate) {
752 /* Try for "waiting" units. */
756 }
759
760 if (!candidate && accept_current) {
761 /* Accept current focus unit as last resort. */
763 }
764 }
765 }
766
768
769 /*
770 * Handle auto-turn-done mode: If a unit was in focus (did move),
771 * but now none are (no more to move) and there was at least one
772 * non-AI unit this turn which was focused, then fake a Turn Done
773 * keypress.
774 */
777 && get_num_units_in_focus() == 0
779 key_end_turn();
780 }
781}
782
783/**********************************************************************/
790{
792 return;
793 }
794
797
798 /* An actor unit is asking the player what to do. Don't change the
799 * focus. */
800 return;
801 }
802
803 /* iterate zero times for no units in focus,
804 * otherwise quit for any of the conditions. */
809 && punit->moves_left > 0
810 && !punit->done_moving
812 return;
813 }
815
817}
818
819/**********************************************************************/
822struct unit *find_visible_unit(struct tile *ptile)
823{
824 struct unit *panyowned = NULL, *panyother = NULL, *ptptother = NULL;
825
826 /* If no units here, return nothing. */
827 if (unit_list_size(ptile->units) == 0) {
828 return NULL;
829 }
830
831 /* If a unit is attacking we should show that on top */
833 unit_list_iterate(ptile->units, punit) {
834 if (punit == punit_attacking) {
835 return punit;
836 }
838 }
839
840 /* If a unit is defending we should show that on top */
842 unit_list_iterate(ptile->units, punit) {
843 if (punit == punit_defending) {
844 return punit;
845 }
847 }
848
849 /* If the unit in focus is at this tile, show that on top */
851 if (punit != punit_moving && unit_tile(punit) == ptile) {
852 return punit;
853 }
855
856 /* If a city is here, return nothing (unit hidden by city). */
857 if (tile_city(ptile)) {
858 return NULL;
859 }
860
861 /* Iterate through the units to find the best one we prioritize this way:
862 1: owned transporter.
863 2: any owned unit
864 3: any transporter
865 4: any unit
866 (always return first in stack). */
869 if (!unit_transported(punit)) {
871 return punit;
872 } else if (!panyowned) {
874 }
875 }
876 } else if (!ptptother && !unit_transported(punit)) {
879 } else if (!panyother) {
881 }
882 }
884
886}
887
888/**********************************************************************/
893{
894 static struct timer *blink_timer = NULL;
896
897 if (get_num_units_in_focus() > 0) {
900
901 /* If we lag, we don't try to catch up. Instead we just start a
902 * new blink_time on every update. */
904 blink_timer != NULL ? NULL : "blink");
906
908 /* We used to unqueue here, but that's inherently risky
909 * for a function run from a timer - the UI can be in any
910 * inconsistent state. */
913 }
914
916 }
917
918 return blink_time;
919}
920
921/**********************************************************************/
926{
927 static struct timer *blink_timer = NULL;
928 const double blink_time = 0.5; /* half-second blink interval */
929
930 if (NULL != client.conn.playing
935 int is_waiting = 0, is_moving = 0;
936 bool blocking_mode;
937 struct option *opt;
938
940 if (opt != NULL) {
942 } else {
944 }
945
946 players_iterate_alive(pplayer) {
947 if ((pplayer->is_connected || blocking_mode)
948 && is_player_phase(pplayer, game.info.phase)) {
949 if (pplayer->phase_done) {
950 is_waiting++;
951 } else {
952 is_moving++;
953 }
954 }
956
957 if (is_moving == 1 && is_waiting > 0) {
958 update_turn_done_button(FALSE); /* stress the slow player! */
959 }
961 blink_timer != NULL ? NULL : "blink");
963 }
965 }
966
967 return blink_time;
968}
969
970/**********************************************************************/
985void update_unit_pix_label(struct unit_list *punitlist)
986{
987 int i;
988
989 /* Check for any change in the unit's state. This assumes that a unit's
990 * orders cannot be changed directly but must be removed and then reset. */
992 && C_S_OVER != client_state()) {
993 /* There used to be a complicated and bug-prone check here to see if
994 * the unit had actually changed. This was misguided since the stacked
995 * units (below) are redrawn in any case. Unless we write a general
996 * system for unit updates here we might as well just redraw it every
997 * time. */
998 struct unit *punit = unit_list_get(punitlist, 0);
999
1000 set_unit_icon(-1, punit);
1001
1002 i = 0; /* index into unit_below_canvas */
1004 if (aunit != punit) {
1005 if (i < num_units_below) {
1007 }
1008 i++;
1009 }
1010 }
1012
1013 if (i > num_units_below) {
1015 } else {
1017 for (; i < num_units_below; i++) {
1019 }
1020 }
1021 } else {
1022 for (i = -1; i < num_units_below; i++) {
1024 }
1026 }
1027}
1028
1029/**********************************************************************/
1033{
1036
1039 /* If one of the units is the focus unit, make sure hidden-focus is
1040 * disabled. We don't just do this as a check later because then
1041 * with a blinking unit it would just disappear again right after the
1042 * battle. */
1044 }
1045}
1046
1047/**********************************************************************/
1052{
1053 struct unit *old_actor_unit;
1054
1055 /* IDENTITY_NUMBER_ZERO is accepted for cases where the unit is gone
1056 * without a trace. */
1060 "Decision taken for %d but selection is for %d.",
1062
1064 if (old_actor_unit != NULL
1065 && old_actor_unit->client.act_prob_cache != NULL) {
1066 FC_FREE(old_actor_unit->client.act_prob_cache);
1067 }
1068
1069 /* Stop objecting to allowing the next unit to ask. */
1071
1072 /* Clean up any client specific assumptions. */
1074}
1075
1076/**********************************************************************/
1081{
1083 /* Have the server record that a decision no longer is wanted. */
1086 }
1087}
1088
1089/**********************************************************************/
1093{
1094 struct unit *old;
1095
1097
1098 /* Go to the next unit in focus that needs a decision. */
1102 return;
1103 }
1105}
1106
1107/**********************************************************************/
1111{
1114
1116 /* Getting feed back may be urgent. A unit standing next to an enemy
1117 * could be killed while waiting. */
1119 } else if (can_client_issue_orders()
1121 /* No need to wait. The actor unit is in focus. No other actor unit
1122 * is currently asking about action selection. */
1124 }
1125}
1126
1127/**********************************************************************/
1131 action_id act_id, int sub_tgt_id)
1132{
1133 struct unit_list *punits = get_units_in_focus();
1134
1135 fc_assert_ret(act_id == ACTION_NONE
1137
1138 if (unit_list_size(punits) == 0) {
1139 return;
1140 }
1141
1143 /* An action has been specified. */
1145
1147 if (!unit_can_do_action(punit, act_id)) {
1148 /* This unit can't perform the action specified in the last
1149 * order. */
1150
1151 struct astring astr = ASTRING_INIT;
1152
1154 action_id_get_role(act_id),
1155 TRUE)) {
1156 /* ...but other units can perform it. */
1157
1159 /* TRANS: Only Nuclear or ICBM can do Explode
1160 * Nuclear. */
1161 _("Only %s can do %s."),
1162 astr_str(&astr),
1164
1165 astr_free(&astr);
1166 } else {
1168 /* TRANS: Spy can't do Explode Nuclear. */
1169 _("%s can't do %s."),
1172 }
1173
1174 return;
1175 }
1177 }
1178
1181 NO_TARGET, sub_tgt_id, act_id, last_order);
1186 } else {
1188 /* Adding a long range action in the middle isn't handled yet */
1191 }
1192}
1193
1194/**********************************************************************/
1197static bool can_units_attack_at(struct unit_list *punits,
1198 const struct tile *ptile)
1199{
1202 && can_unit_attack_tile(punit, NULL, ptile)) {
1203 return TRUE;
1204 }
1206
1207 return FALSE;
1208}
1209
1210/**********************************************************************/
1215void control_mouse_cursor(struct tile *ptile)
1216{
1217 struct unit *punit = NULL;
1218 struct city *pcity = NULL;
1219 struct unit_list *active_units = get_units_in_focus();
1221
1223 return;
1224 }
1225
1226 if (C_S_RUNNING != client_state()) {
1228 return;
1229 }
1230
1231 if (is_server_busy()) {
1232 /* Server will not accept any commands. */
1234 return;
1235 }
1236
1237 if (!ptile) {
1238 if (hover_tile) {
1239 /* hover_tile is the tile that was previously under the mouse cursor. */
1240 ptile = hover_tile;
1241 } else {
1243 return;
1244 }
1245 } else {
1246 hover_tile = ptile;
1247 }
1248
1249 punit = find_visible_unit(ptile);
1250 pcity = ptile ? tile_city(ptile) : NULL;
1251
1252 switch (hover_state) {
1253 case HOVER_NONE:
1254 if (NULL != punit
1255 && unit_owner(punit) == client_player()) {
1256 /* Set mouse cursor to select a unit. */
1258 } else if (NULL != pcity
1260 /* Set mouse cursor to select a city. */
1262 } else {
1263 /* Set default mouse cursor, because nothing selectable found. */
1264 }
1265 break;
1266 case HOVER_GOTO:
1267 /* Determine if the goto is valid, invalid, nuke or will attack. */
1268 if (is_valid_goto_destination(ptile)) {
1271 /* Goto results in nuclear attack. */
1273 } else if (can_units_attack_at(active_units, ptile)) {
1274 /* Goto results in military attack. */
1276 } else if (is_enemy_city_tile(ptile, client.conn.playing)) {
1277 /* Goto results in attack of enemy city. */
1279 } else {
1281 }
1282 } else {
1284 }
1285 break;
1286 case HOVER_PATROL:
1287 if (is_valid_goto_destination(ptile)) {
1289 } else {
1291 }
1292 break;
1293 case HOVER_CONNECT:
1294 if (is_valid_goto_destination(ptile)) {
1296 } else {
1298 }
1299 break;
1300 case HOVER_TELEPORT:
1301 /* FIXME: check for invalid tiles. */
1303 break;
1304 case HOVER_PARADROP:
1305 /* FIXME: check for invalid tiles. */
1307 break;
1308 case HOVER_ACT_SEL_TGT:
1309 case HOVER_GOTO_SEL_TGT:
1310 /* Select a tile to target / find targets on. */
1312 break;
1313 };
1314
1316}
1317
1318/**********************************************************************/
1321static bool is_activity_on_tile(struct tile *ptile,
1322 enum unit_activity activity)
1323{
1324 unit_list_iterate(ptile->units, punit) {
1325 if (punit->activity == activity) {
1326 return TRUE;
1327 }
1329
1330 return FALSE;
1331}
1332
1333/**********************************************************************/
1338 const struct extra_type *pextra,
1339 const struct unit *punit,
1340 const struct player *pplayer, int rec)
1341{
1342 int activity_mc = 0;
1343 struct terrain *pterrain = tile_terrain(ptile);
1344 const struct civ_map *nmap = &(wld.map);
1345
1346 if (rec > MAX_EXTRA_TYPES) {
1347 return -1;
1348 }
1349
1350 if (!is_extra_caused_by(pextra, EC_ROAD)) {
1351 return -1;
1352 }
1353
1354 extra_deps_iterate(&(pextra->reqs), pdep) {
1355 if (!tile_has_extra(ptile, pdep)) {
1356 int single_mc;
1357
1359 pplayer, rec + 1);
1360
1361 if (single_mc < 0) {
1362 return -1;
1363 }
1364
1366 }
1368
1369 /* Can build road after that? */
1370 if (punit != NULL) {
1371 if (!can_build_road(nmap, extra_road_get(pextra), punit, ptile)) {
1372 return -1;
1373 }
1374 } else if (pplayer != NULL) {
1376 pplayer, ptile)) {
1377 return -1;
1378 }
1379 }
1380
1381 tile_add_extra(ptile, pextra);
1382
1384
1385 return activity_mc;
1386}
1387
1388/*******************************************************************/
1392static bool can_be_irrigated(const struct tile *ptile,
1393 const struct unit *punit)
1394{
1395 struct terrain* pterrain = tile_terrain(ptile);
1396 struct universal for_unit = { .kind = VUT_UTYPE,
1397 .value.utype = unit_type_get(punit)};
1398 struct universal for_tile = { .kind = VUT_TERRAIN,
1399 .value.terrain = tile_terrain(ptile)};
1400
1401 if (T_UNKNOWN == pterrain) {
1402 return FALSE;
1403 }
1404
1406 &for_unit, &for_tile);
1407}
1408
1409/**********************************************************************/
1416 enum unit_activity activity,
1417 struct extra_type *tgt)
1418{
1419 struct tile *ptile = unit_tile(punit);
1420 struct road_type *proad = NULL;
1421 const struct req_context unit_ctxt = {
1422 .unit = punit,
1423 .unittype = unit_type_get(punit),
1424 };
1425
1426 /* HACK: This code duplicates that in
1427 * can_unit_do_activity_targeted_at(). The general logic here is that
1428 * the connect is allowed if both:
1429 * (1) the unit can do that activity type, in general
1430 * (2) either
1431 * (a) the activity has already been completed at this tile
1432 * (b) it can be done by the unit at this tile. */
1433 switch (activity) {
1434 case ACTIVITY_GEN_ROAD:
1435 {
1436 struct tile *vtile;
1437 int build_time;
1438
1440
1441 proad = extra_road_get(tgt);
1442
1443 if (tile_has_road(ptile, proad)) {
1444 /* This tile has road, can unit build road to other tiles too? */
1446 }
1447
1448 /* To start connect, unit must be able to build road to this
1449 * particular tile. */
1450 vtile = tile_virtual_new(ptile);
1451 build_time = check_recursive_road_connect(vtile, tgt, punit, NULL, 0);
1453
1454 return build_time >= 0;
1455 }
1456
1457 case ACTIVITY_IRRIGATE:
1458 /* Special case for irrigation: only irrigate to make S_IRRIGATION,
1459 * never to transform tiles. */
1461 return FALSE;
1462 }
1463 if (tile_has_extra(ptile, tgt)) {
1465 }
1466
1467 return can_be_irrigated(ptile, punit)
1468 && can_build_extra(tgt, punit, ptile)
1469 && !is_activity_on_tile(ptile,
1471 default:
1472 break;
1473 }
1474
1475 return FALSE;
1476}
1477
1478/**********************************************************************/
1483 struct extra_type *tgt)
1484{
1485 struct unit_list *punits = get_units_in_focus();
1486
1487 if (!can_units_do_connect(punits, activity, tgt)) {
1488 return;
1489 }
1490
1491 if (hover_state != HOVER_CONNECT || connect_activity != activity
1492 || (connect_tgt != tgt
1493 && (activity == ACTIVITY_GEN_ROAD
1494 || activity == ACTIVITY_IRRIGATE))) {
1496 activity, tgt, NO_TARGET, NO_TARGET,
1502 } else {
1505 }
1506}
1507
1508/**********************************************************************/
1512{
1513 struct tile *ptile = unit_tile(punit);
1514 struct unit *plast = NULL;
1515
1516 if (get_transporter_capacity(punit) == 0) {
1518 _("Only transporter units can be unloaded."));
1519 return NULL;
1520 }
1521
1522 unit_list_iterate(ptile->units, pcargo) {
1525
1526 if (pcargo->activity == ACTIVITY_SENTRY) {
1528 USSDT_SENTRY, 0);
1529 }
1530
1531 if (unit_owner(pcargo) == unit_owner(punit)) {
1532 plast = pcargo;
1533 }
1534 }
1536
1537 return plast;
1538}
1539
1540/**********************************************************************/
1544{
1546}
1547
1548/**********************************************************************/
1553{
1554 struct pf_path *path;
1555
1556 if ((path = path_to_nearest_allied_city(punit))) {
1557 int turns = pf_path_last_position(path)->turn;
1558 int max_hp = unit_type_get(punit)->hp;
1559
1560 if (punit->hp + turns *
1562 - (max_hp * unit_class_get(punit)->hp_loss_pct / 100))
1563 < max_hp) {
1564 struct unit_order order;
1565
1567 order.dir = DIR8_ORIGIN;
1568 order.activity = ACTIVITY_SENTRY;
1569 order.target = NO_TARGET;
1570 order.sub_target = NO_TARGET;
1571 order.action = ACTION_NONE;
1572 send_goto_path(punit, path, &order);
1573 } else {
1574 send_goto_path(punit, path, NULL);
1575 }
1576 pf_path_destroy(path);
1577 }
1578}
1579
1580/**********************************************************************/
1583void wakeup_sentried_units(struct tile *ptile)
1584{
1585 if (!can_client_issue_orders()) {
1586 return;
1587 }
1588 unit_list_iterate(ptile->units, punit) {
1592 }
1593 }
1595}
1596
1597/**********************************************************************/
1604
1605/**************************************************************************
1606 Defines specific hash tables needed for request_unit_select().
1607**************************************************************************/
1608#define SPECHASH_TAG unit_type
1609#define SPECHASH_IKEY_TYPE struct unit_type *
1610#define SPECHASH_IDATA_TYPE void *
1611#include "spechash.h"
1612
1613#define SPECHASH_TAG continent
1614#define SPECHASH_INT_KEY_TYPE
1615#define SPECHASH_IDATA_TYPE void *
1616#include "spechash.h"
1617
1618/**********************************************************************/
1621void request_unit_select(struct unit_list *punits,
1624{
1625 const struct player *pplayer;
1626 const struct tile *ptile;
1627 struct unit *punit_first;
1628 struct tile_hash *tile_table;
1629 struct unit_type_hash *type_table;
1630 struct continent_hash *cont_table;
1631
1633 || unit_list_size(punits) < 1) {
1634 return;
1635 }
1636
1638
1639 if (seltype == SELTYPE_SINGLE) {
1641 return;
1642 }
1643
1644 pplayer = unit_owner(punit_first);
1648
1650 if (seltype == SELTYPE_SAME) {
1652 }
1653
1654 ptile = unit_tile(punit);
1655 if (selloc == SELLOC_TILE) {
1657 } else if (selloc == SELLOC_CONT) {
1659 }
1661
1662 if (selloc == SELLOC_TILE) {
1665 if (unit_owner(punit) != pplayer) {
1666 continue;
1667 }
1668 if (seltype == SELTYPE_SAME
1670 continue;
1671 }
1675 } else {
1676 unit_list_iterate(pplayer->units, punit) {
1677 ptile = unit_tile(punit);
1678 if ((seltype == SELTYPE_SAME
1680 || (selloc == SELLOC_CONT
1682 NULL))) {
1683 continue;
1684 }
1685
1688 }
1689
1693}
1694
1695/**********************************************************************/
1700 char *buf, size_t bufsize)
1701{
1702 fc_assert(buf != NULL || bufsize == 0);
1703
1704 if (bufsize > 0) {
1705 buf[0] = '\0';
1706 }
1707
1708 if (act == ACTION_JOIN_CITY) {
1709 if (bufsize > 0) {
1710 fc_snprintf(buf, bufsize, _("Joining a city uses the unit"));
1711 }
1712
1713 return TRUE;
1714 }
1715
1716 return FALSE;
1717}
1718
1719/**********************************************************************/
1731 int target_id, int sub_tgt, const char *name)
1732{
1733 char buf[400];
1734
1735 if (action_requires_confirmation(action, buf, sizeof(buf))) {
1736 struct act_confirmation_data *data = fc_malloc(sizeof(struct act_confirmation_data));
1737
1738 data->act = action;
1739 data->actor = actor_id;
1740 data->target = target_id;
1741 data->tgt_sub = sub_tgt;
1742
1743 if (name != NULL) {
1744 data->name = fc_strdup(name);
1745 } else {
1746 data->name = NULL;
1747 }
1748
1750 } else {
1751 struct unit *actor_unit = game_unit_by_number(actor_id);
1752
1753 /* Giving an order takes back control. */
1755
1757 actor_id, target_id, sub_tgt, name,
1758 action);
1759 }
1760}
1761
1762/**********************************************************************/
1767{
1768 if (confirm) {
1769 struct unit *actor_unit = game_unit_by_number(data->actor);
1770
1771 if (actor_unit != NULL) {
1772 /* Giving an order takes back control. */
1774
1776 data->actor,
1777 data->target,
1778 data->tgt_sub,
1779 data->name,
1780 data->act);
1781 }
1782 }
1783
1784 if (data->name != NULL) {
1785 free(data->name);
1786 }
1787
1788 free(data);
1789}
1790
1791/**********************************************************************/
1799 int target_id)
1800{
1802 actor_id, target_id, action,
1803 /* Users that need the answer in the
1804 * background should send the packet them
1805 * self. At least for now. */
1807}
1808
1809/**********************************************************************/
1818{
1819 struct city *pcity;
1820
1821 if ((pcity = tile_city(unit_tile(punit)))) {
1822 /* Try to join the city. */
1824 } else {
1825 /* The reply will trigger a dialog to name the new city. */
1827 }
1828}
1829
1830/**********************************************************************/
1837 struct tile *dest_tile)
1838{
1839 struct packet_unit_orders p;
1840 int dir;
1841
1843
1844 if (dir == -1) {
1845 /* The unit isn't located next to the destination tile. */
1846 return;
1847 }
1848
1849 memset(&p, 0, sizeof(p));
1850
1851 p.repeat = FALSE;
1852 p.vigilant = FALSE;
1853
1854 p.unit_id = punit->id;
1857
1858 p.length = 1;
1859 p.orders[0].order = ORDER_MOVE;
1860 p.orders[0].dir = dir;
1862 p.orders[0].target = NO_TARGET;
1864 p.orders[0].action = ACTION_NONE;
1865
1868}
1869
1870/**********************************************************************/
1880{
1881 struct packet_unit_orders p;
1882 struct tile *dest_tile;
1883
1884 /* Catches attempts to move off map */
1885 dest_tile = mapstep(&(wld.map), unit_tile(punit), dir);
1886 if (!dest_tile) {
1887 return;
1888 }
1889
1890 if (!can_unit_exist_at_tile(&(wld.map), punit, dest_tile)) {
1891 if (request_transport(punit, dest_tile)) {
1892 return;
1893 }
1894 }
1895
1896 /* The goto system isn't used to send the order because that would
1897 * prevent direction movement from overriding it.
1898 * Example of a situation when overriding the goto system is useful:
1899 * The goto system creates a longer path to make a move legal. The player
1900 * wishes to order the illegal move so the server will explain why the
1901 * short move is illegal. */
1902
1903 memset(&p, 0, sizeof(p));
1904
1905 p.repeat = FALSE;
1906 p.vigilant = FALSE;
1907
1908 p.unit_id = punit->id;
1910 p.dest_tile = tile_index(dest_tile);
1911
1912 p.length = 1;
1915 p.orders[0].dir = dir;
1917 p.orders[0].target = NO_TARGET;
1919 p.orders[0].action = ACTION_NONE;
1920
1923}
1924
1925/**********************************************************************/
1933
1934/**********************************************************************/
1939 enum unit_activity act,
1940 struct extra_type *tgt)
1941{
1942 if (!can_client_issue_orders()) {
1943 return;
1944 }
1945
1946 /* Callers rely on this to take back control from server side agents. */
1948
1949 if (tgt == NULL) {
1951 } else {
1953 }
1954}
1955
1956/**********************************************************************/
1960{
1961 struct client_disband_unit_data *data = p;
1962
1963 free(data);
1964}
1965
1966/**********************************************************************/
1969static void do_disband_alternative(void *p)
1970{
1971 struct unit *punit;
1972 struct city *pcity;
1973 struct tile *ptile;
1974 int last_request_id_used;
1975 struct client_disband_unit_data *next;
1976 struct client_disband_unit_data *data = p;
1977 int act;
1978 const struct civ_map *nmap = &(wld.map);
1979
1981
1982 /* Fetch the unit to get rid of. */
1984
1985 if (punit == NULL) {
1986 /* Success! It is gone. */
1987 return;
1988 }
1989
1990 if (data->alt == -1) {
1991 /* All alternatives have been tried. */
1993 /* TRANS: Unable to get rid of Leader. */
1994 _("Unable to get rid of %s."),
1996 return;
1997 }
1998
1999 act = disband_unit_alternatives[data->alt];
2000
2001 /* Prepare the data for the next try in case this try fails. */
2002 next = fc_malloc(sizeof(struct client_disband_unit_data));
2003 next->unit_id = data->unit_id;
2004 next->alt = data->alt - 1;
2005
2006 /* Latest request ID before trying to send a request. */
2007 last_request_id_used = client.conn.client.last_request_id_used;
2008
2009 /* Send a request to the server unless it is known to be pointless. */
2010 switch (action_id_get_target_kind(act)) {
2011 case ATK_CITY:
2012 if ((pcity = tile_city(unit_tile(punit)))
2014 act, pcity))) {
2015 request_do_action(act, punit->id, pcity->id, 0, "");
2016 }
2017 break;
2018 case ATK_UNIT:
2020 request_do_action(act, punit->id, punit->id, 0, "");
2021 }
2022 break;
2023 case ATK_STACK:
2024 if ((ptile = unit_tile(punit))
2026 request_do_action(act, punit->id, ptile->index, 0, "");
2027 }
2028 break;
2029 case ATK_TILE:
2030 if ((ptile = unit_tile(punit))
2032 ptile, NULL))) {
2033 request_do_action(act, punit->id, ptile->index, 0, "");
2034 }
2035 break;
2036 case ATK_EXTRAS:
2037 if ((ptile = unit_tile(punit))
2039 ptile, NULL))) {
2040 request_do_action(act, punit->id, ptile->index, 0, "");
2041 }
2042 break;
2043 case ATK_SELF:
2045 request_do_action(act, punit->id, punit->id, 0, "");
2046 }
2047 break;
2048 case ATK_COUNT:
2050 break;
2051 }
2052
2053 if (last_request_id_used != client.conn.client.last_request_id_used) {
2054 /* A request was sent. */
2055
2056 /* Check if it worked. Move on if it didn't. */
2061 } else {
2062 /* No request was sent. */
2063
2064 /* Move on. */
2066
2067 /* Won't be freed by anyone else. */
2069 }
2070}
2071
2072/**********************************************************************/
2076{
2077 struct client_disband_unit_data *data;
2078
2079 /* Set up disband data. Start at the end of the array. */
2080 data = fc_malloc(sizeof(struct client_disband_unit_data));
2081 data->unit_id = punit->id;
2082 data->alt = 2;
2083
2084 /* Begin. */
2086
2087 /* Won't be freed by anyone else. */
2089}
2090
2091/**********************************************************************/
2095{
2096 struct city *pcity = tile_city(unit_tile(punit));
2097
2098 if (pcity) {
2100 }
2101}
2102
2103/**********************************************************************/
2107{
2108 struct city *pcity = tile_city(unit_tile(punit));
2109
2110 if (pcity) {
2112 }
2113}
2114
2115/**********************************************************************/
2122
2123/**********************************************************************/
2130{
2131 if (punit) {
2133 agent);
2134 }
2135}
2136
2137/**********************************************************************/
2142{
2145 } else if (punit) {
2147 _("Only worker units can be put into auto working mode."));
2148 }
2149}
2150
2151/**********************************************************************/
2157 struct tile *ptile)
2158{
2159 if (!ptrans) {
2161 }
2162
2163 if (ptrans
2167 same_pos(unit_tile(pcargo), ptile)
2170 enum gen_action act_id = action_id(paction);
2171
2173 ptrans))) {
2174 /* Try the first action that may be legal. */
2175 /* Implement something like do_disband_alternative() if a ruleset
2176 * appears where this isn't good enough. */
2177 request_do_action(act_id, pcargo->id, ptrans->id, 0, "");
2178 break;
2179 }
2181
2182 /* Sentry the unit. */
2183 /* FIXME: Should not sentry if above loading fails (transport moved away,
2184 * or filled already in server side) */
2186 USSDT_SENTRY, 1);
2187 }
2188}
2189
2190/**********************************************************************/
2195{
2197
2199 && ptrans != NULL
2204 pcargo->id, ptrans->id, 0, "");
2205 } else {
2207 ptrans->id, pcargo->id, 0, "");
2208 }
2209
2211 && pcargo->activity == ACTIVITY_SENTRY) {
2212 /* Activate the unit. */
2214 USSDT_SENTRY, 0);
2215 }
2216 }
2217}
2218
2219/**********************************************************************/
2224{
2225 struct city *target_city;
2226
2227 if (!((target_city = tile_city(unit_tile(punit))))) {
2228 return;
2229 }
2230
2231 if (action == ACTION_TRADE_ROUTE) {
2233 target_city->id, 0, "");
2234 } else if (action == ACTION_HELP_WONDER) {
2236 target_city->id, 0, "");
2237 } else {
2238 log_error("request_unit_caravan_action() Bad action (%d)", action);
2239 }
2240}
2241
2242/**********************************************************************/
2246void request_unit_paradrop(struct unit_list *punits)
2247{
2248 bool can = FALSE;
2249 struct tile *offender = NULL;
2250
2251 if (unit_list_size(punits) == 0) {
2252 return;
2253 }
2255 if (can_unit_paradrop(&(wld.map), punit)) {
2256 can = TRUE;
2257 break;
2258 }
2259 if (!offender) { /* Take first offender tile/unit */
2261 }
2263 if (can) {
2265 ftc_client,
2266 /* TRANS: paradrop target tile. */
2267 _("Click on a tile to paradrop to it."));
2268
2272 } else {
2274 _("Only paratrooper units can do this."));
2275 }
2276}
2277
2278/**********************************************************************/
2282static void request_unit_teleport(struct unit_list *punits)
2283{
2284 bool can = FALSE;
2285 struct tile *offender = NULL;
2286
2287 if (unit_list_size(punits) == 0) {
2288 return;
2289 }
2290
2292 if (can_unit_teleport(&(wld.map), punit)) {
2293 can = TRUE;
2294 break;
2295 }
2296 if (!offender) { /* Take first offender tile/unit */
2298 }
2300
2301 if (can) {
2303 ftc_client,
2304 /* TRANS: teleport target tile. */
2305 _("Click on a tile to teleport to it."));
2306
2310 } else {
2312 _("Only teleporting units can do this."));
2313 }
2314}
2315
2316/**********************************************************************/
2320{
2321 struct unit_list *punits = get_units_in_focus();
2322
2323 if (unit_list_size(punits) == 0) {
2324 return;
2325 }
2326
2327 if (hover_state != HOVER_PATROL) {
2333 } else {
2336 }
2337}
2338
2339/**********************************************************************/
2349
2350/**********************************************************************/
2360
2361/**********************************************************************/
2365{
2366 if (!game.info.pillage_select) {
2367 /* Leave choice up to the server */
2369 } else {
2371 int count = 0;
2372
2376 potential)) {
2378 count++;
2379 }
2381
2382 if (count > 1) {
2384 } else {
2385 /* Should be only one choice... */
2387
2388 if (target != NULL) {
2390 }
2391 }
2392 }
2393}
2394
2395/**********************************************************************/
2407
2408/**********************************************************************/
2420
2421/**********************************************************************/
2425{
2426 if (!can_client_change_view()) {
2427 return;
2428 }
2429
2432}
2433
2434/**********************************************************************/
2438{
2439 if (!can_client_change_view()) {
2440 return;
2441 }
2442
2445}
2446
2447/**********************************************************************/
2451{
2452 if (!can_client_change_view()) {
2453 return;
2454 }
2455
2458}
2459
2460/**********************************************************************/
2464{
2465 if (!can_client_change_view()) {
2466 return;
2467 }
2468
2471}
2472
2473/**********************************************************************/
2477{
2478 if (!can_client_change_view()) {
2479 return;
2480 }
2481
2484}
2485
2486/**********************************************************************/
2490{
2491 if (!can_client_change_view()) {
2492 return;
2493 }
2494
2497}
2498
2499/**********************************************************************/
2503{
2504 if (!can_client_change_view()) {
2505 return;
2506 }
2507
2510}
2511
2512/**********************************************************************/
2516{
2517 if (!can_client_change_view()) {
2518 return;
2519 }
2520
2523}
2524
2525/**********************************************************************/
2529{
2530 if (!can_client_change_view()) {
2531 return;
2532 }
2533
2536}
2537
2538/**********************************************************************/
2542{
2543 if (!can_client_change_view()) {
2544 return;
2545 }
2546
2549}
2550
2551/**********************************************************************/
2555{
2556 if (!can_client_change_view()) {
2557 return;
2558 }
2559
2562}
2563
2564/**********************************************************************/
2568{
2569 if (!can_client_change_view()) {
2570 return;
2571 }
2572
2575}
2576
2577/**********************************************************************/
2581{
2582 if (!can_client_change_view()) {
2583 return;
2584 }
2585
2588}
2589
2590/**********************************************************************/
2594{
2595 if (!can_client_change_view()) {
2596 return;
2597 }
2598
2601}
2602
2603/**********************************************************************/
2607{
2608 if (!can_client_change_view()) {
2609 return;
2610 }
2611
2614}
2615
2616/**********************************************************************/
2620{
2621 if (!can_client_change_view()) {
2622 return;
2623 }
2624
2627}
2628
2629/**********************************************************************/
2633{
2634 if (!can_client_change_view()) {
2635 return;
2636 }
2637
2640}
2641
2642/**********************************************************************/
2646{
2647 if (!can_client_change_view()) {
2648 return;
2649 }
2650
2653}
2654
2655/**********************************************************************/
2659{
2660 if (!can_client_change_view()) {
2661 return;
2662 }
2663
2666}
2667
2668/**********************************************************************/
2672{
2673 if (!can_client_change_view()) {
2674 return;
2675 }
2676
2679}
2680
2681/**********************************************************************/
2685{
2686 if (!can_client_change_view()) {
2687 return;
2688 }
2689
2692}
2693
2694/**********************************************************************/
2698{
2699 if (!can_client_change_view()) {
2700 return;
2701 }
2702
2705}
2706
2707/**********************************************************************/
2711{
2712 if (!can_client_change_view()) {
2713 return;
2714 }
2715
2718}
2719
2720/**********************************************************************/
2724{
2725 if (!can_client_change_view()) {
2726 return;
2727 }
2728
2731}
2732
2733/**********************************************************************/
2737{
2738 if (!can_client_change_view()) {
2739 return;
2740 }
2741
2745}
2746
2747/**********************************************************************/
2751{
2752 struct tile *ptile = find_a_focus_unit_tile_to_center_on();
2753
2754 if (ptile) {
2755 center_tile_mapcanvas(ptile);
2756 }
2757}
2758
2759/**********************************************************************/
2763void request_units_wait(struct unit_list *punits)
2764{
2768 if (punits == get_units_in_focus()) {
2770 }
2771}
2772
2773/**********************************************************************/
2777{
2778 if (get_num_units_in_focus() > 0) {
2781 /* If any of the focused units are busy, keep all of them
2782 * in focus; another tap of the key will dismiss them */
2783 if (punit->activity != ACTIVITY_IDLE) {
2785 }
2791 if (new_status == FOCUS_DONE) {
2793 }
2794 }
2795}
2796
2797/**********************************************************************/
2803{
2804 struct tile *src_tile = unit_tile(punit);
2808
2811
2812 if (!was_teleported
2814 && !unit_transported(punit)) {
2816 unit_type_get(punit)->sound_move_alt,
2817 NULL);
2818 }
2819
2827 || (punit->ssa_controller == SSA_NONE))
2830 }
2831
2832 if (hover_state != HOVER_NONE && in_focus) {
2833 /* Cancel current goto/patrol/connect/nuke command. */
2836 }
2837
2838 unit_list_remove(src_tile->units, punit);
2839
2840 if (!unit_transported(punit)) {
2841 /* Mark the unit as moving unit, then find_visible_unit() won't return
2842 * it. It is especially useful to don't draw many times the unit when
2843 * refreshing the canvas. */
2845
2846 /* We have to refresh the tile before moving. This will draw
2847 * the tile without the unit (because it was unlinked above). */
2849
2851 && punit->ssa_controller != SSA_NONE) {
2852 /* Dont animate automatic units */
2853 } else if (do_animation) {
2854 int dx, dy;
2855
2856 /* For the duration of the animation the unit exists at neither
2857 * tile. */
2858 map_distance_vector(&dx, &dy, src_tile, dst_tile);
2859 move_unit_map_canvas(punit, src_tile, dx, dy);
2860 }
2861 }
2862
2865
2866 if (!unit_transported(punit)) {
2867 /* For find_visible_unit(), see above. */
2869
2871 }
2872
2873 /* With the "full" city bar we have to update the city bar when units move
2874 * into or out of a city. For foreign cities this is handled separately,
2875 * via the occupied field of the short-city packet. */
2876 if (NULL != tile_city(src_tile)
2879 }
2880 if (NULL != tile_city(dst_tile)
2883 }
2884
2885 if (in_focus) {
2886 menus_update();
2887 }
2888}
2889
2890/**********************************************************************/
2894static void do_unit_act_sel_vs(struct tile *ptile)
2895{
2898 /* Have the server record that an action decision is wanted for
2899 * this unit against this tile. */
2901 USSDT_QUEUE, tile_index(ptile));
2902 }
2904}
2905
2906/**********************************************************************/
2909void do_map_click(struct tile *ptile, enum quickselect_type qtype)
2910{
2911 struct city *pcity = tile_city(ptile);
2912 struct unit_list *punits = get_units_in_focus();
2913 bool maybe_goto = FALSE;
2914
2915 if (hover_state != HOVER_NONE) {
2916 switch (hover_state) {
2917 case HOVER_NONE:
2918 break;
2919 case HOVER_GOTO:
2920 do_unit_goto(ptile);
2921 break;
2922 case HOVER_TELEPORT:
2924 do_unit_teleport_to(punit, ptile);
2926 break;
2927 case HOVER_PARADROP:
2929 do_unit_paradrop_to(punit, ptile);
2931 break;
2932 case HOVER_CONNECT:
2934 break;
2935 case HOVER_PATROL:
2936 do_unit_patrol_to(ptile);
2937 break;
2938 case HOVER_ACT_SEL_TGT:
2939 do_unit_act_sel_vs(ptile);
2940 break;
2941 case HOVER_GOTO_SEL_TGT:
2943 do_unit_goto(ptile);
2944 break;
2945 }
2946
2949 } else if (qtype != SELECT_POPUP && qtype != SELECT_APPEND) {
2950 /* Bypass stack or city popup if quickselect is specified. */
2951 struct unit *qunit = quickselect(ptile, qtype);
2952
2953 if (qunit) {
2956 }
2957 } else if (NULL != pcity
2959 /* Otherwise use popups. */
2961 } else if (unit_list_size(ptile->units) == 0
2962 && NULL == pcity
2963 && get_num_units_in_focus() > 0) {
2965 } else if (unit_list_size(ptile->units) == 1
2967 struct unit *punit = unit_list_get(ptile->units, 0);
2968
2972 if (qtype == SELECT_APPEND) {
2974 } else {
2976 }
2977 }
2978 } else if (pcity) {
2979 /* Don't hide the unit in the city. */
2981 }
2982 } else if (unit_list_size(ptile->units) > 0) {
2983 /* The stack list is always popped up, even if it includes enemy units.
2984 * If the server doesn't want the player to know about them it shouldn't
2985 * tell them! The previous behavior would only pop up the stack if you
2986 * owned a unit on the tile. This gave cheating clients an advantage,
2987 * and also showed you allied units if (and only if) you had a unit on
2988 * the tile (inconsistent). */
2990 }
2991
2992 /* See mapctrl_common.c */
2996}
2997
2998/**********************************************************************/
3003static struct unit *quickselect(struct tile *ptile,
3005{
3006 int listsize = unit_list_size(ptile->units);
3007 struct unit *panytransporter = NULL,
3011
3013
3014 if (qtype == SELECT_FOCUS) {
3015 return head_of_units_in_focus();
3016 }
3017
3018 if (listsize == 0) {
3019 return NULL;
3020 } else if (listsize == 1) {
3021 struct unit *punit = unit_list_get(ptile->units, 0);
3022 return (unit_owner(punit) == client.conn.playing) ? punit : NULL;
3023 }
3024
3025 /* Quickselect priorities. Units with moves left
3026 * before exhausted. Focus unit is excluded.
3027 *
3028 * SEA: Transporter
3029 * Sea unit
3030 * Any unit
3031 *
3032 * LAND: Military land unit
3033 * Non-combatant
3034 * Sea unit
3035 * Any unit
3036 */
3037
3038 unit_list_iterate(ptile->units, punit) {
3040 continue;
3041 }
3042 if (qtype == SELECT_SEA) {
3043 /* Transporter. */
3045 if (punit->moves_left > 0) {
3046 return punit;
3047 } else if (!panytransporter) {
3049 }
3050 }
3051 /* Any sea, pref. moves left. */
3053 if (punit->moves_left > 0) {
3054 if (!panymovesea) {
3056 }
3057 } else if (!panysea) {
3058 panysea = punit;
3059 }
3060 }
3061 } else if (qtype == SELECT_LAND) {
3063 if (punit->moves_left > 0) {
3064 if (!is_special_unit(punit)) {
3065 return punit;
3066 } else if (!panymoveland) {
3068 }
3069 } else if (!panyland) {
3070 panyland = punit;
3071 }
3072 }
3074 if (punit->moves_left > 0) {
3076 } else {
3077 panysea = punit;
3078 }
3079 }
3080 }
3081 if (punit->moves_left > 0 && !panymoveunit) {
3083 }
3084 if (!panyunit) {
3085 panyunit = punit;
3086 }
3088
3089 if (qtype == SELECT_SEA) {
3090 if (panytransporter) {
3091 return panytransporter;
3092 } else if (panymovesea) {
3093 return panymovesea;
3094 } else if (panysea) {
3095 return panysea;
3096 } else if (panymoveunit) {
3097 return panymoveunit;
3098 } else if (panyunit) {
3099 return panyunit;
3100 }
3101 }
3102 else if (qtype == SELECT_LAND) {
3103 if (panymoveland) {
3104 return panymoveland;
3105 } else if (panyland) {
3106 return panyland;
3107 } else if (panymovesea) {
3108 return panymovesea;
3109 } else if (panysea) {
3110 return panysea;
3111 } else if (panymoveunit) {
3112 return panymoveunit;
3113 } else if (panyunit) {
3114 return panyunit;
3115 }
3116 }
3117 return NULL;
3118}
3119
3120/**********************************************************************/
3124void do_unit_goto(struct tile *ptile)
3125{
3129
3132 return;
3133 }
3134
3135 if (is_valid_goto_draw_line(ptile)) {
3137 } else {
3139 _("Didn't find a route to the destination!"));
3140 }
3141}
3142
3143/**********************************************************************/
3146static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
3147{
3148 struct action *teleport_action = NULL;
3149
3150 action_iterate(act_id) {
3151 struct action *paction = action_by_number(act_id);
3152
3154 /* Not relevant. */
3155 continue;
3156 }
3157
3160 tile_city(ptile), NULL,
3161 ptile, NULL))) {
3162 if (teleport_action == NULL) {
3163 /* This is the first possible teleport action. */
3165 } else {
3166 /* More than one teleport action may be possible. The user must
3167 * choose. Have the server record that an action decision is wanted
3168 * for this unit so the dialog will be brought up. */
3170 USSDT_QUEUE, tile_index(ptile));
3171 return;
3172 }
3173 }
3175
3176 if (teleport_action != NULL) {
3178 tile_index(ptile), 0 , "");
3179 }
3180}
3181
3182/**********************************************************************/
3185void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
3186{
3187 struct action *paradrop_action = NULL;
3188
3189 action_iterate(act_id) {
3190 struct action *paction = action_by_number(act_id);
3191
3194 /* Not relevant. */
3195 continue;
3196 }
3197
3200 tile_city(ptile), NULL,
3201 ptile, NULL))) {
3202 if (paradrop_action == NULL) {
3203 /* This is the first possible paradrop action. */
3205 } else {
3206 /* More than one paradrop action may be possible. The user must
3207 * choose. Have the server record that an action decision is wanted
3208 * for this unit so the dialog will be brought up. */
3210 USSDT_QUEUE, tile_index(ptile));
3211 return;
3212 }
3213 }
3215
3216 if (paradrop_action != NULL) {
3218 tile_index(ptile), 0 , "");
3219 }
3220}
3221
3222/**********************************************************************/
3225void do_unit_patrol_to(struct tile *ptile)
3226{
3227 if (is_valid_goto_draw_line(ptile)
3230 } else {
3232 _("Didn't find a route to the destination!"));
3233 }
3234
3236}
3237
3238/**********************************************************************/
3241void do_unit_connect(struct tile *ptile,
3242 enum unit_activity activity,
3243 struct extra_type *tgt)
3244{
3245 if (is_valid_goto_draw_line(ptile)) {
3246 send_connect_route(activity, tgt);
3247 } else {
3249 _("Didn't find a route to the destination!"));
3250 }
3251
3253}
3254
3255/**********************************************************************/
3259{
3260 struct unit_list *punits = get_units_in_focus();
3262
3263 switch (hover_state) {
3264 case HOVER_GOTO_SEL_TGT:
3268 break;
3269 case HOVER_GOTO:
3270 case HOVER_PATROL:
3271 case HOVER_CONNECT:
3272 if (goto_pop_waypoint()) {
3273 break;
3274 }
3275 fc__fallthrough; /* else fall through: */
3276 case HOVER_TELEPORT:
3277 case HOVER_PARADROP:
3278 case HOVER_ACT_SEL_TGT:
3281
3285 break;
3286 case HOVER_NONE:
3287 break;
3288 };
3289}
3290
3291/**********************************************************************/
3296{
3298
3299 if (capital) {
3300 /* Center on the tile, and pop up the crosshair overlay. */
3303 } else {
3305 _("Oh my! You seem to have no capital!"));
3306 }
3307}
3308
3309/**********************************************************************/
3313{
3315}
3316
3317/**********************************************************************/
3321{
3322 int i = 0;
3323
3324 /* Could use unit_list_copy here instead. Just having safe genlists
3325 * wouldn't be sufficient since we don't want to skip units already
3326 * removed from focus... */
3328 if (i == 0) {
3330 } else {
3332 }
3333 i++;
3335}
3336
3337/**********************************************************************/
3349
3350/**********************************************************************/
3359
3360/**********************************************************************/
3371
3372/**********************************************************************/
3376 struct extra_type *tgt)
3377{
3378 request_unit_connect(activity, tgt);
3379}
3380
3381/**********************************************************************/
3385{
3386 struct tile *ptile;
3387
3390 && (ptile = unit_tile(punit))) {
3391 /* Have the server record that an action decision is wanted for this
3392 * unit. */
3394 USSDT_QUEUE, tile_index(ptile));
3395 }
3397}
3398
3399/**********************************************************************/
3407{
3408 struct unit_list *punits = get_units_in_focus();
3409
3411 /* The 2nd key press means that the actor should target its own
3412 * tile. */
3414
3415 /* Target tile selected. Clean up hover state. */
3418
3419 return;
3420 } else if (hover_state == HOVER_GOTO_SEL_TGT) {
3422
3423 /* We don't support long range actions in the middle of orders yet so
3424 * send it at once. */
3426
3427 /* Target tile selected. Clean up hover state. */
3430
3431 return;
3432 } else if (hover_state == HOVER_GOTO
3435
3437 ftc_client,
3438 /* TRANS: Perform action inside a goto. */
3439 _("Click on a tile to do %s against it."),
3441
3446
3447 return;
3448 }
3449
3451 ftc_client,
3452 /* TRANS: "Do..." action selection dialog target. */
3453 _("Click on a tile to act against it. "
3454 "Press 'd' again to act against own tile."));
3455
3458}
3459
3460/**********************************************************************/
3464{
3466}
3467
3468/**********************************************************************/
3472{
3474}
3475
3476/**********************************************************************/
3483
3484/**********************************************************************/
3488{
3490}
3491
3492/**********************************************************************/
3499
3500/**********************************************************************/
3504{
3506 /* TODO: Is falling back on ACTION_MARKETPLACE if not able to establish
3507 * a trade route trade a good idea or an unplecant surprice? */
3510 }
3512}
3513
3514/**********************************************************************/
3518{
3519 struct unit *pnext_focus = NULL, *plast;
3520
3524 }
3526
3527 if (pnext_focus) {
3529 /* Unfocus the ships, and advance the focus to the last unloaded unit.
3530 * If there is no unit unloaded (which shouldn't happen, but could if
3531 * the caller doesn't check if the transporter is loaded), the we
3532 * don't do anything. */
3536 }
3537}
3538
3539/**********************************************************************/
3546
3547/**********************************************************************/
3556
3557/**********************************************************************/
3573
3574/**********************************************************************/
3585
3586/**********************************************************************/
3598
3599/**********************************************************************/
3608
3609/**********************************************************************/
3620
3621/**********************************************************************/
3637
3638/**********************************************************************/
3647
3648/**********************************************************************/
3651static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
3652{
3655 cause,
3657 punit);
3658
3661 }
3663}
3664
3665/**********************************************************************/
3672
3673/**********************************************************************/
3684
3685/**********************************************************************/
3689{
3691}
3692
3693/**********************************************************************/
3704
3705/**********************************************************************/
3716
3717/**********************************************************************/
3734
3735/**********************************************************************/
3752
3753/**********************************************************************/
3764
3765/**********************************************************************/
3776
3777/**********************************************************************/
3780void key_unit_assign_battlegroup(int battlegroup, bool append)
3781{
3783 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3784 if (!append) {
3786 if (!unit_is_in_focus(punit)) {
3792 unit_list_remove(battlegroups[battlegroup], punit);
3793 }
3795 }
3797 if (punit->battlegroup != battlegroup) {
3798 if (punit->battlegroup >= 0
3801 }
3802 punit->battlegroup = battlegroup;
3805 battlegroup);
3806 unit_list_append(battlegroups[battlegroup], punit);
3808 }
3810 unit_list_iterate(battlegroups[battlegroup], punit) {
3813 }
3814}
3815
3816/**********************************************************************/
3819void key_unit_select_battlegroup(int battlegroup, bool append)
3820{
3822 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3823 int i = 0;
3824
3825 if (unit_list_size(battlegroups[battlegroup]) == 0 && !append) {
3827 return;
3828 }
3829
3830 /* FIXME: this is very inefficient and can be improved. */
3831 unit_list_iterate(battlegroups[battlegroup], punit) {
3832 if (i == 0 && !append) {
3834 } else {
3836 }
3837 i++;
3839 }
3840}
3841
3842/**********************************************************************/
3849
3850/**********************************************************************/
3857
3858/**********************************************************************/
3862{
3864}
3865
3866/**********************************************************************/
3873
3874/**********************************************************************/
3881
3882/**********************************************************************/
3889
3890/**********************************************************************/
3897
3898/**********************************************************************/
3906
3907/**********************************************************************/
3915
3916/**********************************************************************/
3923
3924/**********************************************************************/
3932
3933/**********************************************************************/
3940
3941/**********************************************************************/
3945{
3947}
3948
3949/**********************************************************************/
3953{
3955}
3956
3957/**********************************************************************/
3961{
3963}
3964
3965/**********************************************************************/
3972
3973/**********************************************************************/
3977{
3979}
3980
3981/**********************************************************************/
3985{
3987}
3988
3989/**********************************************************************/
3993{
3995}
3996
3997/**********************************************************************/
4001{
4003}
4004
4005/**********************************************************************/
4009{
4011}
4012
4013/**********************************************************************/
4017{
4019}
4020
4021/**********************************************************************/
4025{
4027}
4028
4029/**********************************************************************/
4036
4037/**********************************************************************/
4044
4045/**********************************************************************/
4052
4053/**********************************************************************/
4060
4061/**********************************************************************/
4068
4069/**********************************************************************/
4076
4077/**********************************************************************/
4087
4088/**********************************************************************/
4091void finish_city(struct tile *ptile, const char *name)
4092{
4093 unit_list_iterate(ptile->units, punit) {
4095 /* Unit will disappear only in case city building still success.
4096 * Cancel city building status just in case something has changed
4097 * to prevent city building in the meanwhile and unit will remain
4098 * alive. */
4101 0, name);
4102 }
4104}
4105
4106/**********************************************************************/
4110void cancel_city(struct tile *ptile)
4111{
4112 unit_list_iterate(ptile->units, punit) {
4115}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
const char * action_name_translation(const struct action *paction)
Definition actions.c:1230
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4612
struct act_prob action_prob_vs_extras(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4695
struct act_prob action_prob_self(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4765
struct act_prob action_prob_vs_city(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Definition actions.c:4254
bool action_id_exists(const action_id act_id)
Definition actions.c:1068
struct act_prob action_prob_unit_vs_tgt(const struct civ_map *nmap, 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:4787
struct act_prob action_prob_vs_stack(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4529
struct act_prob action_prob_vs_unit(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Definition actions.c:4337
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:710
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:241
static struct action * action_by_number(action_id act_id)
Definition actions.h:396
#define action_has_result(_act_, _res_)
Definition actions.h:180
#define action_id_get_role(act_id)
Definition actions.h:457
#define action_by_result_iterate_end
Definition actions.h:245
#define action_iterate_end
Definition actions.h:214
#define action_id(_act_)
Definition actions.h:422
#define action_iterate(_act_)
Definition actions.h:210
#define action_id_get_target_kind(act_id)
Definition actions.h:413
#define action_id_has_result_safe(act_id, result)
Definition actions.h:426
#define ACTION_NONE
Definition actions.h:55
void astr_free(struct astring *astr)
Definition astring.c:148
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:105
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Definition base.c:143
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:731
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:1093
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1242
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:312
char * incite_cost
Definition comments.c:76
double blink_turn_done_button(void)
Definition control.c:925
void key_coastline_toggle(void)
Definition control.c:3952
void key_irrigation_toggle(void)
Definition control.c:3968
void request_toggle_huts(void)
Definition control.c:2645
void key_unit_sentry(void)
Definition control.c:3756
void request_toggle_city_outlines(void)
Definition control.c:2398
void key_unit_road(void)
Definition control.c:3738
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1543
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2802
void request_toggle_resources(void)
Definition control.c:2632
void request_toggle_city_names(void)
Definition control.c:2476
void key_recall_previous_focus_unit(void)
Definition control.c:3320
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1836
void request_toggle_unit_stack_size(void)
Definition control.c:2541
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_city_output_toggle(void)
Definition control.c:3853
void request_toggle_focus_unit(void)
Definition control.c:2723
void request_toggle_city_output(void)
Definition control.c:2411
void request_unit_return(struct unit *punit)
Definition control.c:1552
void request_unit_fortify(struct unit *punit)
Definition control.c:2353
void key_unit_build_city(void)
Definition control.c:3353
void key_editor_recalculate_borders(void)
Definition control.c:4072
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1511
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2223
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
enum unit_orders goto_last_order
Definition control.c:96
void request_units_wait(struct unit_list *punits)
Definition control.c:2763
void request_unit_wakeup(struct unit *punit)
Definition control.c:1600
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:396
void key_focus_unit_toggle(void)
Definition control.c:4048
void request_toggle_map_grid(void)
Definition control.c:2424
void action_decision_request(struct unit *actor_unit)
Definition control.c:1110
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2606
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1032
int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra, const struct unit *punit, const struct player *pplayer, int rec)
Definition control.c:1337
void key_unit_action_select(void)
Definition control.c:3384
void key_unit_auto_explore(void)
Definition control.c:3577
static int action_selection_in_progress_for
Definition control.c:119
static void do_disband_alternative(void *p)
Definition control.c:1969
void key_cancel_action(void)
Definition control.c:3258
void request_toggle_city_buycost(void)
Definition control.c:2515
void clear_hover_state(void)
Definition control.c:328
void request_toggle_map_native(void)
Definition control.c:2450
void request_unit_patrol(void)
Definition control.c:2319
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3375
void key_city_full_bar_toggle(void)
Definition control.c:3885
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
void key_bases_toggle(void)
Definition control.c:3984
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2909
static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
Definition control.c:3651
void key_map_native_toggle(void)
Definition control.c:3877
void request_toggle_map_borders(void)
Definition control.c:2437
void key_resources_toggle(void)
Definition control.c:3992
static void request_unit_teleport(struct unit_list *punits)
Definition control.c:2282
static struct unit * punit_attacking
Definition control.c:105
void unit_focus_add(struct unit *punit)
Definition control.c:561
void unit_focus_set(struct unit *punit)
Definition control.c:506
static void do_unit_act_sel_vs(struct tile *ptile)
Definition control.c:2894
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1130
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3185
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:339
int goto_last_tgt
Definition control.c:94
struct extra_type * connect_tgt
Definition control.c:91
void key_unit_paradrop(void)
Definition control.c:3479
static bool can_units_attack_at(struct unit_list *punits, const struct tile *ptile)
Definition control.c:1197
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void key_end_turn(void)
Definition control.c:3312
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_toggle_irrigation(void)
Definition control.c:2593
static struct unit_list * current_focus
Definition control.c:79
static struct unit_list * previous_focus
Definition control.c:83
void request_unit_pillage(struct unit *punit)
Definition control.c:2364
void key_unit_teleport(void)
Definition control.c:3495
void request_center_focus_unit(void)
Definition control.c:2750
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:4040
void key_city_productions_toggle(void)
Definition control.c:3919
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1415
void key_unit_build_wonder(void)
Definition control.c:3363
void key_unit_plant(void)
Definition control.c:3696
void key_unit_fortress(void)
Definition control.c:3624
void key_unit_mine(void)
Definition control.c:3688
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2094
void request_toggle_fog_of_war(void)
Definition control.c:2736
void key_unit_pillage(void)
Definition control.c:3708
void request_unit_unload(struct unit *pcargo)
Definition control.c:2194
void key_editor_toggle_fogofwar(void)
Definition control.c:4081
static void client_disband_unit_data_destroy(void *p)
Definition control.c:1959
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2128
static struct unit * find_best_focus_candidate(bool accept_current)
Definition control.c:649
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1798
static struct unit * quickselect(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:3003
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2684
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:985
void key_unit_irrigate(void)
Definition control.c:3668
void request_unit_build_city(struct unit *punit)
Definition control.c:1817
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:255
static struct unit_list * urgent_focus_queue
Definition control.c:86
void key_unit_unload_all(void)
Definition control.c:3517
void key_cities_toggle(void)
Definition control.c:4016
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3341
void key_city_outlines_toggle(void)
Definition control.c:3845
void key_unit_homecity(void)
Definition control.c:3641
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2246
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:290
static int disband_unit_alternatives[3]
Definition control.c:69
void key_unit_patrol(void)
Definition control.c:3487
void request_toggle_city_full_bar(void)
Definition control.c:2463
void request_toggle_city_growth(void)
Definition control.c:2489
void key_unit_solid_bg_toggle(void)
Definition control.c:4032
void request_toggle_unit_solid_bg(void)
Definition control.c:2697
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void key_terrain_toggle(void)
Definition control.c:3944
void key_paths_toggle(void)
Definition control.c:3960
void request_unit_sentry(struct unit *punit)
Definition control.c:2342
void key_unit_wakeup_others(void)
Definition control.c:3550
bool non_ai_unit_focus
Definition control.c:125
static struct unit * punit_defending
Definition control.c:106
static struct tile * find_a_focus_unit_tile_to_center_on(void)
Definition control.c:418
enum cursor_hover_state hover_state
Definition control.c:89
void key_unit_stack_size_toggle(void)
Definition control.c:3936
static void store_previous_focus(void)
Definition control.c:194
void key_huts_toggle(void)
Definition control.c:4000
void key_fog_of_war_toggle(void)
Definition control.c:4056
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1482
void clear_unit_orders(struct unit *punit)
Definition control.c:481
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2554
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
void key_unit_wait(void)
Definition control.c:3542
void key_units_toggle(void)
Definition control.c:4024
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3241
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:591
void request_toggle_bases(void)
Definition control.c:2619
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3225
void key_unit_trade_route(void)
Definition control.c:3503
void request_toggle_coastline(void)
Definition control.c:2567
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3819
void key_map_grid_toggle(void)
Definition control.c:3861
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4091
static struct unit * punit_moving
Definition control.c:102
void key_pollution_toggle(void)
Definition control.c:4008
struct unit * head_of_units_in_focus(void)
Definition control.c:410
static bool is_activity_on_tile(struct tile *ptile, enum unit_activity activity)
Definition control.c:1321
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:822
static bool can_be_irrigated(const struct tile *ptile, const struct unit *punit)
Definition control.c:1392
void key_city_growth_toggle(void)
Definition control.c:3902
void key_unit_action_select_tgt(void)
Definition control.c:3406
static struct unit_list * battlegroups[MAX_NUM_BATTLEGROUPS]
Definition control.c:99
void key_city_buycost_toggle(void)
Definition control.c:3911
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3768
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1879
static void current_focus_append(struct unit *punit)
Definition control.c:447
void key_unit_done(void)
Definition control.c:3463
static void current_focus_remove(struct unit *punit)
Definition control.c:467
static struct tile * hover_tile
Definition control.c:98
void key_city_trade_routes_toggle(void)
Definition control.c:3928
static void focus_units_changed(void)
Definition control.c:215
void request_toggle_city_trade_routes(void)
Definition control.c:2528
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:636
void request_unit_convert(struct unit *punit)
Definition control.c:2118
void request_toggle_paths(void)
Definition control.c:2580
void request_toggle_unit_shields(void)
Definition control.c:2710
void key_city_names_toggle(void)
Definition control.c:3893
void unit_register_battlegroup(struct unit *punit)
Definition control.c:275
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1621
static bool action_requires_confirmation(action_id act, char *buf, size_t bufsize)
Definition control.c:1699
void unit_focus_update(void)
Definition control.c:789
void key_unit_auto_work(void)
Definition control.c:3590
void key_unit_airbase(void)
Definition control.c:3560
void key_unit_goto(void)
Definition control.c:3471
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
void key_unit_convert(void)
Definition control.c:3602
void key_unit_clean(void)
Definition control.c:3720
void key_center_capital(void)
Definition control.c:3295
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1583
void request_toggle_cities(void)
Definition control.c:2671
void key_unit_fortify(void)
Definition control.c:3612
void key_editor_toggle(void)
Definition control.c:4064
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3780
void request_unit_move_done(void)
Definition control.c:2776
void auto_center_on_focus_unit(void)
Definition control.c:434
void key_unit_cultivate(void)
Definition control.c:3676
double blink_active_unit(void)
Definition control.c:892
void unit_focus_advance(bool accept_current)
Definition control.c:688
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2502
void cancel_city(struct tile *ptile)
Definition control.c:4110
static void ask_server_for_actions(struct unit *punit)
Definition control.c:366
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
void request_toggle_pollution(void)
Definition control.c:2658
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3976
static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
Definition control.c:3146
void do_unit_goto(struct tile *ptile)
Definition control.c:3124
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
static bool can_ask_server_for_actions(void)
Definition control.c:352
void request_unit_autoworker(const struct unit *punit)
Definition control.c:2141
void key_map_borders_toggle(void)
Definition control.c:3869
#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 struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction request_action_confirmation
Definition dialogs_g.h:94
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Definition effects.c:1066
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:779
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:804
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:535
#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:213
@ RPT_POSSIBLE
Definition fc_types.h:532
#define DIR8_ORIGIN
Definition fc_types.h:314
int action_id
Definition fc_types.h:248
#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:61
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:712
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
void exit_goto_state(void)
Definition goto.c:1033
bool goto_is_active(void)
Definition goto.c:1070
struct pf_path * path_to_nearest_allied_city(struct unit *punit)
Definition goto.c:2007
void send_patrol_route(void)
Definition goto.c:1666
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1350
bool goto_add_waypoint(void)
Definition goto.c:489
bool goto_pop_waypoint(void)
Definition goto.c:528
void send_connect_route(enum unit_activity activity, struct extra_type *tgt)
Definition goto.c:1733
void goto_unit_killed(struct unit *punit)
Definition goto.c:1051
void free_client_goto(void)
Definition goto.c:163
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1011
void send_goto_route(void)
Definition goto.c:1894
bool is_valid_goto_destination(const struct tile *ptile)
Definition goto.c:180
void request_orders_cleared(struct unit *punit)
Definition goto.c:1377
void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *final_order)
Definition goto.c:1548
int action_selection_actor_unit(void)
void action_selection_close(void)
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
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 real_focus_units_changed(void)
Definition gui_main.c:2150
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2127
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2097
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:182
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define log_error(message,...)
Definition log.h:104
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1488
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:1067
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:1076
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Definition map.c:384
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1213
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:364
#define iterate_outward_end
Definition map.h:368
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_FREE(ptr)
Definition mem.h:41
#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:318
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:490
const struct option_set * server_optset
Definition options.c:4278
bool option_bool_get(const struct option *poption)
Definition options.c:833
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:467
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:552
#define players_iterate_alive(_pplayer)
Definition player.h:547
bool are_reqs_active(const struct req_context *context, const struct req_context *other_context, 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:301
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:286
#define FC_INFINITY
Definition shared.h:36
Definition agents.h:40
Definition city.h:317
enum capital_type capital
Definition city.h:325
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
bool draw_native
Definition options.h:216
bool enable_cursor_changes
Definition options.h:174
bool auto_turn_done
Definition options.h:165
bool draw_specials
Definition options.h:208
bool draw_city_output
Definition options.h:195
bool draw_city_names
Definition options.h:197
bool draw_city_productions
Definition options.h:199
int smooth_move_unit_msec
Definition options.h:152
bool draw_mines
Definition options.h:206
bool draw_borders
Definition options.h:215
bool draw_fortress_airbase
Definition options.h:207
bool draw_city_buycost
Definition options.h:200
bool draw_unit_stack_size
Definition options.h:219
bool draw_irrigation
Definition options.h:205
bool draw_terrain
Definition options.h:202
bool draw_units
Definition options.h:212
bool auto_center_on_automated
Definition options.h:157
bool draw_fog_of_war
Definition options.h:214
bool draw_city_trade_routes
Definition options.h:201
bool unit_selection_clears_orders
Definition options.h:176
bool draw_unit_shields
Definition options.h:218
bool draw_cities
Definition options.h:211
bool draw_map_grid
Definition options.h:196
bool draw_city_growth
Definition options.h:198
bool draw_focus_unit
Definition options.h:213
bool draw_paths
Definition options.h:204
bool draw_city_outlines
Definition options.h:194
bool draw_coastline
Definition options.h:203
bool popup_actor_arrival
Definition options.h:169
bool draw_full_citybar
Definition options.h:217
bool draw_pollution
Definition options.h:210
bool auto_center_on_unit
Definition options.h:156
bool solid_color_behind_units
Definition options.h:150
bool popup_last_move_to_allied
Definition options.h:171
bool keyboardless_goto
Definition options.h:173
struct player * playing
Definition connection.h:151
int last_request_id_used
Definition connection.h:187
struct connection::@61::@66 client
struct requirement_vector reqs
Definition extras.h:106
struct unit_order orders[MAX_LEN_ROUTE]
struct unit_list * units
Definition player.h:282
bool is_alive
Definition player.h:268
bool phase_done
Definition player.h:263
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:95
enum unit_orders order
Definition unit.h:94
int action
Definition unit.h:102
enum direction8 dir
Definition unit.h:104
int target
Definition unit.h:98
int sub_target
Definition unit.h:99
Definition unit.h:140
enum action_decision action_decision_want
Definition unit.h:205
int battlegroup
Definition unit.h:194
enum unit_activity activity
Definition unit.h:159
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
int hp
Definition unit.h:153
bool asking_city_name
Definition unit.h:228
struct unit::@84::@86 client
bool done_moving
Definition unit.h:184
struct tile * action_decision_tile
Definition unit.h:206
enum unit_focus_status focus_status
Definition unit.h:217
enum server_side_agent ssa_controller
Definition unit.h:175
enum universals_n kind
Definition fc_types.h:608
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#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:62
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:1035
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:89
#define tile_hash_iterate(hash, ptile)
Definition tile.h:83
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_hash_iterate_end
Definition tile.h:85
#define tile_continent(_tile)
Definition tile.h:93
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
double get_focus_unit_toggle_timeout(const struct tileset *t)
Definition tilespec.c:6709
void toggle_focus_unit_state(struct tileset *t)
Definition tilespec.c:6743
void focus_unit_in_combat(struct tileset *t)
Definition tilespec.c:6734
cursor_type
Definition tilespec.h:289
@ CURSOR_TELEPORT
Definition tilespec.h:293
@ CURSOR_GOTO
Definition tilespec.h:290
@ CURSOR_INVALID
Definition tilespec.h:296
@ CURSOR_PATROL
Definition tilespec.h:291
@ CURSOR_WAIT
Definition tilespec.h:300
@ CURSOR_SELECT
Definition tilespec.h:295
@ CURSOR_DEFAULT
Definition tilespec.h:302
@ CURSOR_PARADROP
Definition tilespec.h:292
@ CURSOR_NUKE
Definition tilespec.h:294
@ CURSOR_ATTACK
Definition tilespec.h:297
void timer_start(struct timer *t)
Definition timing.c:263
double timer_read_seconds(struct timer *t)
Definition timing.c:379
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:1820
bool is_attack_unit(const struct unit *punit)
Definition unit.c:305
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2518
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
bool can_unit_do_autoworker(const struct unit *punit)
Definition unit.c:630
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:830
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:297
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:846
bool is_special_unit(const struct unit *punit)
Definition unit.c:350
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1284
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
bool unit_has_orders(const struct unit *punit)
Definition unit.c:202
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1949
#define unit_tile(_pu)
Definition unit.h:404
unit_focus_status
Definition unit.h:53
@ FOCUS_AVAIL
Definition unit.h:54
@ FOCUS_DONE
Definition unit.h:54
@ FOCUS_WAIT
Definition unit.h:54
#define BATTLEGROUP_NONE
Definition unit.h:193
unit_orders
Definition unit.h:38
@ ORDER_ACTION_MOVE
Definition unit.h:46
@ ORDER_ACTIVITY
Definition unit.h:42
@ ORDER_MOVE
Definition unit.h:40
@ ORDER_LAST
Definition unit.h:50
@ ORDER_PERFORM_ACTION
Definition unit.h:48
#define unit_owner(_pu)
Definition unit.h:403
#define MAX_NUM_BATTLEGROUPS
Definition unit.h:192
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:440
#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_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:1575
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Definition unittype.c:1557
bool utype_may_act_at_all(const struct unit_type *putype)
Definition unittype.c:365
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2505
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:196
bool role_units_translations(struct astring *astr, int flag, bool alts)
Definition unittype.c:1674
void update_queue_connect_processing_finished_full(int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)