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/**********************************************************************/
246
247/**********************************************************************/
250void unit_change_battlegroup(struct unit *punit, int battlegroup)
251{
253 battlegroup = BATTLEGROUP_NONE;
254 }
255
256 if (punit->battlegroup != battlegroup) {
257 if (battlegroup != BATTLEGROUP_NONE) {
258 unit_list_append(battlegroups[battlegroup], punit);
259 }
262 }
263 punit->battlegroup = battlegroup;
264 }
265}
266
267/**********************************************************************/
278
279/**********************************************************************/
285void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
286 enum unit_activity activity,
287 struct extra_type *tgt,
288 int last_tgt,
289 int last_sub_tgt,
291 enum unit_orders order)
292{
294 || state == HOVER_NONE);
295 fc_assert_ret(state == HOVER_CONNECT || activity == ACTIVITY_LAST);
296 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
297 || order == ORDER_LAST);
298 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
299 || action == ACTION_NONE);
300
302 && (state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT))) {
303 /* Exit goto unless this is a switch between goto states */
305 }
306
307 hover_state = state;
308 connect_activity = activity;
309 if (tgt) {
310 connect_tgt = tgt;
311 } else {
313 }
314 goto_last_order = order;
318}
319
320/**********************************************************************/
329
330/**********************************************************************/
335{
337 /* The player is interested in getting a pop up for a mere
338 * arrival. */
341}
342
343/**********************************************************************/
348{
349 /* OK as long as no other unit already asked and aren't done yet. */
352}
353
354/**********************************************************************/
362{
365
366 /* Only one action selection dialog at a time is supported. */
368 "Unit %d started action selection before unit %d was done",
371
373 punit->id,
378}
379
380/**********************************************************************/
383bool unit_is_in_focus(const struct unit *punit)
384{
386}
387
388/**********************************************************************/
391struct unit *get_focus_unit_on_tile(const struct tile *ptile)
392{
394 if (unit_tile(punit) == ptile) {
395 return punit;
396 }
398
399 return NULL;
400}
401
402/**********************************************************************/
406{
407 return unit_list_get(current_focus, 0);
408}
409
410/**********************************************************************/
414{
415 struct unit *punit;
416
418 return unit_tile(punit);
419 } else if (get_num_units_in_focus() > 0) {
421 } else {
422 return NULL;
423 }
424}
425
426/**********************************************************************/
430{
432
436 }
437}
438
439/**********************************************************************/
458
459/**********************************************************************/
462static void current_focus_remove(struct unit *punit)
463{
464 /* Close the action selection dialog if the actor unit lose focus. */
467 }
468
471}
472
473/**********************************************************************/
477{
478 if (!punit) {
479 return;
480 }
481
487 } else if (unit_has_orders(punit)) {
488 /* Clear the focus unit's orders. */
490 }
491}
492
493/**********************************************************************/
502{
503 bool focus_changed = FALSE;
504
505 if (NULL != punit
506 && NULL != client.conn.playing
508 /* Callers should make sure this never happens. */
509 return;
510 }
511
512 /* FIXME: This won't work quite right; for instance activating a
513 * battlegroup twice in a row will store the focus erroneously. The only
514 * solution would be a set_units_focus() */
515 if (!(get_num_units_in_focus() == 1
516 && punit == head_of_units_in_focus())) {
519 }
520
521 /* Close the action selection dialog if the actor unit lose focus. */
525 }
527
528 /* Redraw the old focus unit (to fix blinking or remove the selection
529 * circle). */
534
535 if (!can_client_change_view()) {
536 /* This function can be called to set the focus to NULL when
537 * disconnecting. In this case we don't want any other actions! */
538 fc_assert(punit == NULL);
539 return;
540 }
541
542 if (NULL != punit) {
545 }
546
547 if (focus_changed) {
550 }
551}
552
553/**********************************************************************/
557{
558 if (NULL != punit
559 && NULL != client.conn.playing
561 /* Callers should make sure this never happens. */
562 return;
563 }
564
565 if (NULL == punit || !can_client_change_view()) {
566 return;
567 }
568
569 if (unit_is_in_focus(punit)) {
570 return;
571 }
572
573 if (hover_state != HOVER_NONE) {
574 /* Can't continue with current goto if set of focus units
575 * change. Cancel it. */
577 }
578
581}
582
583/**********************************************************************/
587{
588 if (NULL != punit
589 && NULL != client.conn.playing
591 /* Callers should make sure this never happens. */
592 return;
593 }
594
595 if (NULL == punit || !can_client_change_view()) {
596 return;
597 }
598
599 if (!unit_is_in_focus(punit)) {
600 return;
601 }
602
603 if (hover_state != HOVER_NONE) {
604 /* Can't continue with current goto if set of focus units
605 * change. Cancel it. */
607 }
608
610 if (get_num_units_in_focus() > 0) {
612 } else {
614 }
615}
616
617/**********************************************************************/
627
628/**********************************************************************/
634{
635 struct tile *ptile = get_center_tile_mapcanvas();
636
637 if (!get_focus_unit_on_tile(ptile)) {
639
640 if (pfirst) {
641 ptile = unit_tile(pfirst);
642 }
643 }
644
652 && (punit->moves_left > 0 || unit_type_get(punit)->move_rate == 0)
653 && !punit->done_moving
655 return punit;
656 }
659
660 return NULL;
661}
662
663/**********************************************************************/
671{
672 struct unit *candidate = NULL;
674
675 if (NULL == client.conn.playing
679 return;
680 }
681
683
685 /*
686 * Is the unit which just lost focus a non-AI unit? If yes this
687 * enables the auto end turn.
688 */
689 if (punit->ssa_controller == SSA_NONE) {
691 break;
692 }
694
696 /* Try top of the urgent list. */
697 struct tile *focus_tile = (get_num_units_in_focus() > 0
699 : NULL);
700
704 /* This isn't an action decision needed because of an
705 * ORDER_ACTION_MOVE located in the middle of an order. */
707 /* We have assigned new orders to this unit since, remove it. */
709 } else if (NULL == focus_tile
710 || focus_tile == unit_tile(punit)) {
711 /* Use the first one found */
713 break;
714 } else if (NULL == candidate) {
716 }
718
719 if (NULL != candidate) {
721
722 /* Autocenter on Wakeup, regardless of the local option
723 * "auto_center_on_unit". */
726 }
727 }
728 }
729
730 if (NULL == candidate) {
732
733 if (!candidate) {
734 /* Try for "waiting" units. */
738 }
741
742 if (!candidate) {
743 /* Accept current focus unit as last resort. */
745 }
746 }
747 }
748
750
751 /*
752 * Handle auto-turn-done mode: If a unit was in focus (did move),
753 * but now none are (no more to move) and there was at least one
754 * non-AI unit this turn which was focused, then fake a Turn Done
755 * keypress.
756 */
759 && get_num_units_in_focus() == 0
761 key_end_turn();
762 }
763}
764
765/**********************************************************************/
772{
774 return;
775 }
776
779
780 /* An actor unit is asking the player what to do. Don't change the
781 * focus. */
782 return;
783 }
784
785 /* iterate zero times for no units in focus,
786 * otherwise quit for any of the conditions. */
791 && punit->moves_left > 0
792 && !punit->done_moving
794 return;
795 }
797
799}
800
801/**********************************************************************/
804struct unit *find_visible_unit(struct tile *ptile)
805{
806 struct unit *panyowned = NULL, *panyother = NULL, *ptptother = NULL;
807
808 /* If no units here, return nothing. */
809 if (unit_list_size(ptile->units) == 0) {
810 return NULL;
811 }
812
813 /* If a unit is attacking we should show that on top */
815 unit_list_iterate(ptile->units, punit) {
816 if (punit == punit_attacking) {
817 return punit;
818 }
820 }
821
822 /* If a unit is defending we should show that on top */
824 unit_list_iterate(ptile->units, punit) {
825 if (punit == punit_defending) {
826 return punit;
827 }
829 }
830
831 /* If the unit in focus is at this tile, show that on top */
833 if (punit != punit_moving && unit_tile(punit) == ptile) {
834 return punit;
835 }
837
838 /* If a city is here, return nothing (unit hidden by city). */
839 if (tile_city(ptile)) {
840 return NULL;
841 }
842
843 /* Iterate through the units to find the best one we prioritize this way:
844 1: owned transporter.
845 2: any owned unit
846 3: any transporter
847 4: any unit
848 (always return first in stack). */
851 if (!unit_transported(punit)) {
853 return punit;
854 } else if (!panyowned) {
856 }
857 }
858 } else if (!ptptother && !unit_transported(punit)) {
861 } else if (!panyother) {
863 }
864 }
866
868}
869
870/**********************************************************************/
875{
876 static struct timer *blink_timer = NULL;
878
879 if (get_num_units_in_focus() > 0) {
882
883 /* If we lag, we don't try to catch up. Instead we just start a
884 * new blink_time on every update. */
886 blink_timer != NULL ? NULL : "blink");
888
890 /* We used to unqueue here, but that's inherently risky
891 * for a function run from a timer - the UI can be in any
892 * inconsistent state. */
895 }
896
898 }
899
900 return blink_time;
901}
902
903/**********************************************************************/
908{
909 static struct timer *blink_timer = NULL;
910 const double blink_time = 0.5; /* half-second blink interval */
911
912 if (NULL != client.conn.playing
917 int is_waiting = 0, is_moving = 0;
918 bool blocking_mode;
919 struct option *opt;
920
922 if (opt != NULL) {
924 } else {
926 }
927
928 players_iterate_alive(pplayer) {
929 if ((pplayer->is_connected || blocking_mode)
930 && is_player_phase(pplayer, game.info.phase)) {
931 if (pplayer->phase_done) {
932 is_waiting++;
933 } else {
934 is_moving++;
935 }
936 }
938
939 if (is_moving == 1 && is_waiting > 0) {
940 update_turn_done_button(FALSE); /* stress the slow player! */
941 }
943 blink_timer != NULL ? NULL : "blink");
945 }
947 }
948
949 return blink_time;
950}
951
952/**********************************************************************/
967void update_unit_pix_label(struct unit_list *punitlist)
968{
969 int i;
970
971 /* Check for any change in the unit's state. This assumes that a unit's
972 * orders cannot be changed directly but must be removed and then reset. */
974 && C_S_OVER != client_state()) {
975 /* There used to be a complicated and bug-prone check here to see if
976 * the unit had actually changed. This was misguided since the stacked
977 * units (below) are redrawn in any case. Unless we write a general
978 * system for unit updates here we might as well just redraw it every
979 * time. */
980 struct unit *punit = unit_list_get(punitlist, 0);
981
982 set_unit_icon(-1, punit);
983
984 i = 0; /* index into unit_below_canvas */
986 if (aunit != punit) {
987 if (i < num_units_below) {
989 }
990 i++;
991 }
992 }
994
995 if (i > num_units_below) {
997 } else {
999 for (; i < num_units_below; i++) {
1001 }
1002 }
1003 } else {
1004 for (i = -1; i < num_units_below; i++) {
1006 }
1008 }
1009}
1010
1011/**********************************************************************/
1015{
1018
1021 /* If one of the units is the focus unit, make sure hidden-focus is
1022 * disabled. We don't just do this as a check later because then
1023 * with a blinking unit it would just disappear again right after the
1024 * battle. */
1026 }
1027}
1028
1029/**********************************************************************/
1034{
1035 /* IDENTITY_NUMBER_ZERO is accepted for cases where the unit is gone
1036 * without a trace. */
1040 "Decision taken for %d but selection is for %d.",
1042
1043 /* Stop objecting to allowing the next unit to ask. */
1045
1046 /* Clean up any client specific assumptions. */
1048}
1049
1050/**********************************************************************/
1055{
1057 /* Have the server record that a decision no longer is wanted. */
1060 }
1061}
1062
1063/**********************************************************************/
1067{
1068 struct unit *old;
1069
1071
1072 /* Go to the next unit in focus that needs a decision. */
1076 return;
1077 }
1079}
1080
1081/**********************************************************************/
1085{
1088
1090 /* Getting feed back may be urgent. A unit standing next to an enemy
1091 * could be killed while waiting. */
1093 } else if (can_client_issue_orders()
1095 /* No need to wait. The actor unit is in focus. No other actor unit
1096 * is currently asking about action selection. */
1098 }
1099}
1100
1101/**********************************************************************/
1105 action_id act_id, int sub_tgt_id)
1106{
1107 struct unit_list *punits = get_units_in_focus();
1108
1109 fc_assert_ret(act_id == ACTION_NONE
1111
1112 if (unit_list_size(punits) == 0) {
1113 return;
1114 }
1115
1117 /* An action has been specified. */
1119
1121 if (!unit_can_do_action(punit, act_id)) {
1122 /* This unit can't perform the action specified in the last
1123 * order. */
1124
1125 struct astring astr = ASTRING_INIT;
1126
1128 action_id_get_role(act_id),
1129 TRUE)) {
1130 /* ...but other units can perform it. */
1131
1133 /* TRANS: Only Nuclear or ICBM can do Explode
1134 * Nuclear. */
1135 _("Only %s can do %s."),
1136 astr_str(&astr),
1138
1139 astr_free(&astr);
1140 } else {
1142 /* TRANS: Spy can't do Explode Nuclear. */
1143 _("%s can't do %s."),
1146 }
1147
1148 return;
1149 }
1151 }
1152
1155 NO_TARGET, sub_tgt_id, act_id, last_order);
1160 } else {
1162 /* Adding a long range action in the middle isn't handled yet */
1165 }
1166}
1167
1168/**********************************************************************/
1171static bool can_units_attack_at(struct unit_list *punits,
1172 const struct tile *ptile)
1173{
1176 && can_unit_attack_tile(punit, NULL, ptile)) {
1177 return TRUE;
1178 }
1180
1181 return FALSE;
1182}
1183
1184/**********************************************************************/
1189void control_mouse_cursor(struct tile *ptile)
1190{
1191 struct unit *punit = NULL;
1192 struct city *pcity = NULL;
1193 struct unit_list *active_units = get_units_in_focus();
1195
1197 return;
1198 }
1199
1200 if (C_S_RUNNING != client_state()) {
1202 return;
1203 }
1204
1205 if (is_server_busy()) {
1206 /* Server will not accept any commands. */
1208 return;
1209 }
1210
1211 if (!ptile) {
1212 if (hover_tile) {
1213 /* hover_tile is the tile that was previously under the mouse cursor. */
1214 ptile = hover_tile;
1215 } else {
1217 return;
1218 }
1219 } else {
1220 hover_tile = ptile;
1221 }
1222
1223 punit = find_visible_unit(ptile);
1224 pcity = ptile ? tile_city(ptile) : NULL;
1225
1226 switch (hover_state) {
1227 case HOVER_NONE:
1228 if (NULL != punit
1229 && unit_owner(punit) == client_player()) {
1230 /* Set mouse cursor to select a unit. */
1232 } else if (NULL != pcity
1234 /* Set mouse cursor to select a city. */
1236 } else {
1237 /* Set default mouse cursor, because nothing selectable found. */
1238 }
1239 break;
1240 case HOVER_GOTO:
1241 /* Determine if the goto is valid, invalid, nuke or will attack. */
1242 if (is_valid_goto_destination(ptile)) {
1245 /* Goto results in nuclear attack. */
1247 } else if (can_units_attack_at(active_units, ptile)) {
1248 /* Goto results in military attack. */
1250 } else if (is_enemy_city_tile(ptile, client.conn.playing)) {
1251 /* Goto results in attack of enemy city. */
1253 } else {
1255 }
1256 } else {
1258 }
1259 break;
1260 case HOVER_PATROL:
1261 if (is_valid_goto_destination(ptile)) {
1263 } else {
1265 }
1266 break;
1267 case HOVER_CONNECT:
1268 if (is_valid_goto_destination(ptile)) {
1270 } else {
1272 }
1273 break;
1274 case HOVER_TELEPORT:
1275 /* FIXME: check for invalid tiles. */
1277 break;
1278 case HOVER_PARADROP:
1279 /* FIXME: check for invalid tiles. */
1281 break;
1282 case HOVER_ACT_SEL_TGT:
1283 case HOVER_GOTO_SEL_TGT:
1284 /* Select a tile to target / find targets on. */
1286 break;
1287 };
1288
1290}
1291
1292/**********************************************************************/
1295static bool is_activity_on_tile(struct tile *ptile,
1296 enum unit_activity activity)
1297{
1298 unit_list_iterate(ptile->units, punit) {
1299 if (punit->activity == activity) {
1300 return TRUE;
1301 }
1303
1304 return FALSE;
1305}
1306
1307/**********************************************************************/
1312 const struct extra_type *pextra,
1313 const struct unit *punit,
1314 const struct player *pplayer, int rec)
1315{
1316 int activity_mc = 0;
1317 struct terrain *pterrain = tile_terrain(ptile);
1318 const struct civ_map *nmap = &(wld.map);
1319
1320 if (rec > MAX_EXTRA_TYPES) {
1321 return -1;
1322 }
1323
1324 if (!is_extra_caused_by(pextra, EC_ROAD)) {
1325 return -1;
1326 }
1327
1328 extra_deps_iterate(&(pextra->reqs), pdep) {
1329 if (!tile_has_extra(ptile, pdep)) {
1330 int single_mc;
1331
1333 pplayer, rec + 1);
1334
1335 if (single_mc < 0) {
1336 return -1;
1337 }
1338
1340 }
1342
1343 /* Can build road after that? */
1344 if (punit != NULL) {
1345 if (!can_build_road(nmap, extra_road_get(pextra), punit, ptile)) {
1346 return -1;
1347 }
1348 } else if (pplayer != NULL) {
1350 pplayer, ptile)) {
1351 return -1;
1352 }
1353 }
1354
1355 tile_add_extra(ptile, pextra);
1356
1358
1359 return activity_mc;
1360}
1361
1362/*******************************************************************/
1366static bool can_be_irrigated(const struct tile *ptile,
1367 const struct unit *punit)
1368{
1369 struct terrain* pterrain = tile_terrain(ptile);
1370 struct universal for_unit = { .kind = VUT_UTYPE,
1371 .value.utype = unit_type_get(punit)};
1372 struct universal for_tile = { .kind = VUT_TERRAIN,
1373 .value.terrain = tile_terrain(ptile)};
1374
1375 if (T_UNKNOWN == pterrain) {
1376 return FALSE;
1377 }
1378
1380 &for_unit, &for_tile);
1381}
1382
1383/**********************************************************************/
1390 enum unit_activity activity,
1391 struct extra_type *tgt)
1392{
1393 struct tile *ptile = unit_tile(punit);
1394 struct road_type *proad = NULL;
1395 const struct req_context unit_ctxt = {
1396 .unit = punit,
1397 .unittype = unit_type_get(punit),
1398 };
1399
1400 /* HACK: This code duplicates that in
1401 * can_unit_do_activity_targeted_at(). The general logic here is that
1402 * the connect is allowed if both:
1403 * (1) the unit can do that activity type, in general
1404 * (2) either
1405 * (a) the activity has already been completed at this tile
1406 * (b) it can be done by the unit at this tile. */
1407 switch (activity) {
1408 case ACTIVITY_GEN_ROAD:
1409 {
1410 struct tile *vtile;
1411 int build_time;
1412
1414
1415 proad = extra_road_get(tgt);
1416
1417 if (tile_has_road(ptile, proad)) {
1418 /* This tile has road, can unit build road to other tiles too? */
1420 }
1421
1422 /* To start connect, unit must be able to build road to this
1423 * particular tile. */
1424 vtile = tile_virtual_new(ptile);
1425 build_time = check_recursive_road_connect(vtile, tgt, punit, NULL, 0);
1427
1428 return build_time >= 0;
1429 }
1430
1431 case ACTIVITY_IRRIGATE:
1432 /* Special case for irrigation: only irrigate to make S_IRRIGATION,
1433 * never to transform tiles. */
1435 return FALSE;
1436 }
1437 if (tile_has_extra(ptile, tgt)) {
1439 }
1440
1441 return can_be_irrigated(ptile, punit)
1442 && can_build_extra(tgt, punit, ptile)
1443 && !is_activity_on_tile(ptile,
1445 default:
1446 break;
1447 }
1448
1449 return FALSE;
1450}
1451
1452/**********************************************************************/
1457 struct extra_type *tgt)
1458{
1459 struct unit_list *punits = get_units_in_focus();
1460
1461 if (!can_units_do_connect(punits, activity, tgt)) {
1462 return;
1463 }
1464
1465 if (hover_state != HOVER_CONNECT || connect_activity != activity
1466 || (connect_tgt != tgt
1467 && (activity == ACTIVITY_GEN_ROAD
1468 || activity == ACTIVITY_IRRIGATE))) {
1470 activity, tgt, NO_TARGET, NO_TARGET,
1476 } else {
1479 }
1480}
1481
1482/**********************************************************************/
1486{
1487 struct tile *ptile = unit_tile(punit);
1488 struct unit *plast = NULL;
1489
1490 if (get_transporter_capacity(punit) == 0) {
1492 _("Only transporter units can be unloaded."));
1493 return NULL;
1494 }
1495
1496 unit_list_iterate(ptile->units, pcargo) {
1499
1500 if (pcargo->activity == ACTIVITY_SENTRY) {
1502 USSDT_SENTRY, 0);
1503 }
1504
1505 if (unit_owner(pcargo) == unit_owner(punit)) {
1506 plast = pcargo;
1507 }
1508 }
1510
1511 return plast;
1512}
1513
1514/**********************************************************************/
1517void request_unit_airlift(struct unit *punit, struct city *pcity)
1518{
1519 request_do_action(ACTION_AIRLIFT, punit->id, pcity->id, 0, "");
1520}
1521
1522/**********************************************************************/
1527{
1528 struct pf_path *path;
1529
1530 if ((path = path_to_nearest_allied_city(punit))) {
1531 int turns = pf_path_last_position(path)->turn;
1532 int max_hp = unit_type_get(punit)->hp;
1533
1534 if (punit->hp + turns *
1536 - (max_hp * unit_class_get(punit)->hp_loss_pct / 100))
1537 < max_hp) {
1538 struct unit_order order;
1539
1541 order.dir = DIR8_ORIGIN;
1542 order.activity = ACTIVITY_SENTRY;
1543 order.target = NO_TARGET;
1544 order.sub_target = NO_TARGET;
1545 order.action = ACTION_NONE;
1546 send_goto_path(punit, path, &order);
1547 } else {
1548 send_goto_path(punit, path, NULL);
1549 }
1550 pf_path_destroy(path);
1551 }
1552}
1553
1554/**********************************************************************/
1557void wakeup_sentried_units(struct tile *ptile)
1558{
1559 if (!can_client_issue_orders()) {
1560 return;
1561 }
1562 unit_list_iterate(ptile->units, punit) {
1566 }
1567 }
1569}
1570
1571/**********************************************************************/
1578
1579/**************************************************************************
1580 Defines specific hash tables needed for request_unit_select().
1581**************************************************************************/
1582#define SPECHASH_TAG unit_type
1583#define SPECHASH_IKEY_TYPE struct unit_type *
1584#define SPECHASH_IDATA_TYPE void *
1585#include "spechash.h"
1586
1587#define SPECHASH_TAG continent
1588#define SPECHASH_INT_KEY_TYPE
1589#define SPECHASH_IDATA_TYPE void *
1590#include "spechash.h"
1591
1592/**********************************************************************/
1595void request_unit_select(struct unit_list *punits,
1598{
1599 const struct player *pplayer;
1600 const struct tile *ptile;
1601 struct unit *punit_first;
1602 struct tile_hash *tile_table;
1603 struct unit_type_hash *type_table;
1604 struct continent_hash *cont_table;
1605
1607 || unit_list_size(punits) < 1) {
1608 return;
1609 }
1610
1612
1613 if (seltype == SELTYPE_SINGLE) {
1615 return;
1616 }
1617
1618 pplayer = unit_owner(punit_first);
1622
1624 if (seltype == SELTYPE_SAME) {
1626 }
1627
1628 ptile = unit_tile(punit);
1629 if (selloc == SELLOC_TILE) {
1631 } else if (selloc == SELLOC_CONT) {
1633 }
1635
1636 if (selloc == SELLOC_TILE) {
1639 if (unit_owner(punit) != pplayer) {
1640 continue;
1641 }
1642 if (seltype == SELTYPE_SAME
1644 continue;
1645 }
1649 } else {
1650 unit_list_iterate(pplayer->units, punit) {
1651 ptile = unit_tile(punit);
1652 if ((seltype == SELTYPE_SAME
1654 || (selloc == SELLOC_CONT
1656 NULL))) {
1657 continue;
1658 }
1659
1662 }
1663
1667}
1668
1669/**********************************************************************/
1674 char *buf, size_t bufsize)
1675{
1676 fc_assert(buf != NULL || bufsize == 0);
1677
1678 if (bufsize > 0) {
1679 buf[0] = '\0';
1680 }
1681
1682 if (act == ACTION_JOIN_CITY) {
1683 if (bufsize > 0) {
1684 fc_snprintf(buf, bufsize, _("Joining a city uses the unit"));
1685 }
1686
1687 return TRUE;
1688 }
1689
1690 return FALSE;
1691}
1692
1693/**********************************************************************/
1705 int target_id, int sub_tgt, const char *name)
1706{
1707 char buf[400];
1708
1709 if (action_requires_confirmation(action, buf, sizeof(buf))) {
1710 struct act_confirmation_data *data = fc_malloc(sizeof(struct act_confirmation_data));
1711
1712 data->act = action;
1713 data->actor = actor_id;
1714 data->target = target_id;
1715 data->tgt_sub = sub_tgt;
1716
1717 if (name != NULL) {
1718 data->name = fc_strdup(name);
1719 } else {
1720 data->name = NULL;
1721 }
1722
1724 } else {
1725 struct unit *actor_unit = game_unit_by_number(actor_id);
1726
1727 /* Giving an order takes back control. */
1729
1731 actor_id, target_id, sub_tgt, name,
1732 action);
1733 }
1734}
1735
1736/**********************************************************************/
1741{
1742 if (confirm) {
1743 struct unit *actor_unit = game_unit_by_number(data->actor);
1744
1745 if (actor_unit != NULL) {
1746 /* Giving an order takes back control. */
1748
1750 data->actor,
1751 data->target,
1752 data->tgt_sub,
1753 data->name,
1754 data->act);
1755 }
1756 }
1757
1758 if (data->name != NULL) {
1759 free(data->name);
1760 }
1761
1762 free(data);
1763}
1764
1765/**********************************************************************/
1773 int target_id)
1774{
1776 actor_id, target_id, action,
1777 /* Users that need the answer in the
1778 * background should send the packet them
1779 * self. At least for now. */
1781}
1782
1783/**********************************************************************/
1792{
1793 struct city *pcity;
1794
1795 if ((pcity = tile_city(unit_tile(punit)))) {
1796 /* Try to join the city. */
1797 request_do_action(ACTION_JOIN_CITY, punit->id, pcity->id, 0, "");
1798 } else {
1799 /* The reply will trigger a dialog to name the new city. */
1801 }
1802}
1803
1804/**********************************************************************/
1811 struct tile *dest_tile)
1812{
1813 struct packet_unit_orders p;
1814 int dir;
1815
1817
1818 if (dir == -1) {
1819 /* The unit isn't located next to the destination tile. */
1820 return;
1821 }
1822
1823 memset(&p, 0, sizeof(p));
1824
1825 p.repeat = FALSE;
1826 p.vigilant = FALSE;
1827
1828 p.unit_id = punit->id;
1831
1832 p.length = 1;
1833 p.orders[0].order = ORDER_MOVE;
1834 p.orders[0].dir = dir;
1836 p.orders[0].target = NO_TARGET;
1838 p.orders[0].action = ACTION_NONE;
1839
1842}
1843
1844/**********************************************************************/
1854{
1855 struct packet_unit_orders p;
1856 struct tile *dest_tile;
1857
1858 /* Catches attempts to move off map */
1859 dest_tile = mapstep(&(wld.map), unit_tile(punit), dir);
1860 if (!dest_tile) {
1861 return;
1862 }
1863
1864 if (!can_unit_exist_at_tile(&(wld.map), punit, dest_tile)) {
1865 if (request_transport(punit, dest_tile)) {
1866 return;
1867 }
1868 }
1869
1870 /* The goto system isn't used to send the order because that would
1871 * prevent direction movement from overriding it.
1872 * Example of a situation when overriding the goto system is useful:
1873 * The goto system creates a longer path to make a move legal. The player
1874 * wishes to order the illegal move so the server will explain why the
1875 * short move is illegal. */
1876
1877 memset(&p, 0, sizeof(p));
1878
1879 p.repeat = FALSE;
1880 p.vigilant = FALSE;
1881
1882 p.unit_id = punit->id;
1884 p.dest_tile = tile_index(dest_tile);
1885
1886 p.length = 1;
1889 p.orders[0].dir = dir;
1891 p.orders[0].target = NO_TARGET;
1893 p.orders[0].action = ACTION_NONE;
1894
1897}
1898
1899/**********************************************************************/
1907
1908/**********************************************************************/
1913 enum unit_activity act,
1914 struct extra_type *tgt)
1915{
1916 if (!can_client_issue_orders()) {
1917 return;
1918 }
1919
1920 /* Callers rely on this to take back control from server side agents. */
1922
1923 if (tgt == NULL) {
1925 } else {
1927 }
1928}
1929
1930/**********************************************************************/
1934{
1935 struct client_disband_unit_data *data = p;
1936
1937 free(data);
1938}
1939
1940/**********************************************************************/
1943static void do_disband_alternative(void *p)
1944{
1945 struct unit *punit;
1946 struct city *pcity;
1947 struct tile *ptile;
1948 int last_request_id_used;
1949 struct client_disband_unit_data *next;
1950 struct client_disband_unit_data *data = p;
1951 int act;
1952 const struct civ_map *nmap = &(wld.map);
1953
1955
1956 /* Fetch the unit to get rid of. */
1958
1959 if (punit == NULL) {
1960 /* Success! It is gone. */
1961 return;
1962 }
1963
1964 if (data->alt == -1) {
1965 /* All alternatives have been tried. */
1967 /* TRANS: Unable to get rid of Leader. */
1968 _("Unable to get rid of %s."),
1970 return;
1971 }
1972
1973 act = disband_unit_alternatives[data->alt];
1974
1975 /* Prepare the data for the next try in case this try fails. */
1976 next = fc_malloc(sizeof(struct client_disband_unit_data));
1977 next->unit_id = data->unit_id;
1978 next->alt = data->alt - 1;
1979
1980 /* Latest request ID before trying to send a request. */
1981 last_request_id_used = client.conn.client.last_request_id_used;
1982
1983 /* Send a request to the server unless it is known to be pointless. */
1984 switch (action_id_get_target_kind(act)) {
1985 case ATK_CITY:
1986 if ((pcity = tile_city(unit_tile(punit)))
1988 act, pcity))) {
1989 request_do_action(act, punit->id, pcity->id, 0, "");
1990 }
1991 break;
1992 case ATK_UNIT:
1994 request_do_action(act, punit->id, punit->id, 0, "");
1995 }
1996 break;
1997 case ATK_UNITS:
1998 if ((ptile = unit_tile(punit))
2000 request_do_action(act, punit->id, ptile->index, 0, "");
2001 }
2002 break;
2003 case ATK_TILE:
2004 if ((ptile = unit_tile(punit))
2006 request_do_action(act, punit->id, ptile->index, 0, "");
2007 }
2008 break;
2009 case ATK_EXTRAS:
2010 if ((ptile = unit_tile(punit))
2012 ptile, NULL))) {
2013 request_do_action(act, punit->id, ptile->index, 0, "");
2014 }
2015 break;
2016 case ATK_SELF:
2018 request_do_action(act, punit->id, punit->id, 0, "");
2019 }
2020 break;
2021 case ATK_COUNT:
2023 break;
2024 }
2025
2026 if (last_request_id_used != client.conn.client.last_request_id_used) {
2027 /* A request was sent. */
2028
2029 /* Check if it worked. Move on if it didn't. */
2034 } else {
2035 /* No request was sent. */
2036
2037 /* Move on. */
2039
2040 /* Won't be freed by anyone else. */
2042 }
2043}
2044
2045/**********************************************************************/
2049{
2050 struct client_disband_unit_data *data;
2051
2052 /* Set up disband data. Start at the end of the array. */
2053 data = fc_malloc(sizeof(struct client_disband_unit_data));
2054 data->unit_id = punit->id;
2055 data->alt = 2;
2056
2057 /* Begin. */
2059
2060 /* Won't be freed by anyone else. */
2062}
2063
2064/**********************************************************************/
2068{
2069 struct city *pcity = tile_city(unit_tile(punit));
2070
2071 if (pcity) {
2072 request_do_action(ACTION_HOME_CITY, punit->id, pcity->id, 0, "");
2073 }
2074}
2075
2076/**********************************************************************/
2080{
2081 struct city *pcity = tile_city(unit_tile(punit));
2082
2083 if (pcity) {
2085 }
2086}
2087
2088/**********************************************************************/
2095
2096/**********************************************************************/
2103{
2104 if (punit) {
2106 agent);
2107 }
2108}
2109
2110/**********************************************************************/
2115{
2118 } else if (punit) {
2120 _("Only worker units can be put into auto working mode."));
2121 }
2122}
2123
2124/**********************************************************************/
2130 struct tile *ptile)
2131{
2132 if (!ptrans) {
2134 }
2135
2136 if (ptrans
2140 same_pos(unit_tile(pcargo), ptile)
2143 enum gen_action act_id = action_id(paction);
2144
2146 ptrans))) {
2147 /* Try the first action that may be legal. */
2148 /* Implement something like do_disband_alternative() if a ruleset
2149 * appears where this isn't good enough. */
2150 request_do_action(act_id, pcargo->id, ptrans->id, 0, "");
2151 break;
2152 }
2154
2155 /* Sentry the unit. */
2156 /* FIXME: Should not sentry if above loading fails (transport moved away,
2157 * or filled already in server side) */
2159 USSDT_SENTRY, 1);
2160 }
2161}
2162
2163/**********************************************************************/
2168{
2170
2172 && ptrans != NULL
2177 pcargo->id, ptrans->id, 0, "");
2178 } else {
2180 ptrans->id, pcargo->id, 0, "");
2181 }
2182
2184 && pcargo->activity == ACTIVITY_SENTRY) {
2185 /* Activate the unit. */
2187 USSDT_SENTRY, 0);
2188 }
2189 }
2190}
2191
2192/**********************************************************************/
2197{
2198 struct city *target_city;
2199
2200 if (!((target_city = tile_city(unit_tile(punit))))) {
2201 return;
2202 }
2203
2204 if (action == ACTION_TRADE_ROUTE) {
2206 target_city->id, 0, "");
2207 } else if (action == ACTION_HELP_WONDER) {
2209 target_city->id, 0, "");
2210 } else {
2211 log_error("request_unit_caravan_action() Bad action (%d)", action);
2212 }
2213}
2214
2215/**********************************************************************/
2219void request_unit_paradrop(struct unit_list *punits)
2220{
2221 bool can = FALSE;
2222 struct tile *offender = NULL;
2223
2224 if (unit_list_size(punits) == 0) {
2225 return;
2226 }
2228 if (can_unit_paradrop(&(wld.map), punit)) {
2229 can = TRUE;
2230 break;
2231 }
2232 if (!offender) { /* Take first offender tile/unit */
2234 }
2236 if (can) {
2238 ftc_client,
2239 /* TRANS: paradrop target tile. */
2240 _("Click on a tile to paradrop to it."));
2241
2245 } else {
2247 _("Only paratrooper units can do this."));
2248 }
2249}
2250
2251/**********************************************************************/
2255static void request_unit_teleport(struct unit_list *punits)
2256{
2257 bool can = FALSE;
2258 struct tile *offender = NULL;
2259
2260 if (unit_list_size(punits) == 0) {
2261 return;
2262 }
2263
2265 if (can_unit_teleport(&(wld.map), punit)) {
2266 can = TRUE;
2267 break;
2268 }
2269 if (!offender) { /* Take first offender tile/unit */
2271 }
2273
2274 if (can) {
2276 ftc_client,
2277 /* TRANS: teleport target tile. */
2278 _("Click on a tile to teleport to it."));
2279
2283 } else {
2285 _("Only teleporting units can do this."));
2286 }
2287}
2288
2289/**********************************************************************/
2293{
2294 struct unit_list *punits = get_units_in_focus();
2295
2296 if (unit_list_size(punits) == 0) {
2297 return;
2298 }
2299
2300 if (hover_state != HOVER_PATROL) {
2306 } else {
2309 }
2310}
2311
2312/**********************************************************************/
2322
2323/**********************************************************************/
2333
2334/**********************************************************************/
2338{
2339 if (!game.info.pillage_select) {
2340 /* Leave choice up to the server */
2342 } else {
2344 int count = 0;
2345
2349 potential)) {
2351 count++;
2352 }
2354
2355 if (count > 1) {
2357 } else {
2358 /* Should be only one choice... */
2360
2361 if (target != NULL) {
2363 }
2364 }
2365 }
2366}
2367
2368/**********************************************************************/
2380
2381/**********************************************************************/
2393
2394/**********************************************************************/
2398{
2399 if (!can_client_change_view()) {
2400 return;
2401 }
2402
2405}
2406
2407/**********************************************************************/
2411{
2412 if (!can_client_change_view()) {
2413 return;
2414 }
2415
2418}
2419
2420/**********************************************************************/
2424{
2425 if (!can_client_change_view()) {
2426 return;
2427 }
2428
2431}
2432
2433/**********************************************************************/
2437{
2438 if (!can_client_change_view()) {
2439 return;
2440 }
2441
2444}
2445
2446/**********************************************************************/
2450{
2451 if (!can_client_change_view()) {
2452 return;
2453 }
2454
2457}
2458
2459/**********************************************************************/
2463{
2464 if (!can_client_change_view()) {
2465 return;
2466 }
2467
2470}
2471
2472/**********************************************************************/
2476{
2477 if (!can_client_change_view()) {
2478 return;
2479 }
2480
2483}
2484
2485/**********************************************************************/
2489{
2490 if (!can_client_change_view()) {
2491 return;
2492 }
2493
2496}
2497
2498/**********************************************************************/
2502{
2503 if (!can_client_change_view()) {
2504 return;
2505 }
2506
2509}
2510
2511/**********************************************************************/
2515{
2516 if (!can_client_change_view()) {
2517 return;
2518 }
2519
2522}
2523
2524/**********************************************************************/
2528{
2529 if (!can_client_change_view()) {
2530 return;
2531 }
2532
2535}
2536
2537/**********************************************************************/
2541{
2542 if (!can_client_change_view()) {
2543 return;
2544 }
2545
2548}
2549
2550/**********************************************************************/
2554{
2555 if (!can_client_change_view()) {
2556 return;
2557 }
2558
2561}
2562
2563/**********************************************************************/
2567{
2568 if (!can_client_change_view()) {
2569 return;
2570 }
2571
2574}
2575
2576/**********************************************************************/
2580{
2581 if (!can_client_change_view()) {
2582 return;
2583 }
2584
2587}
2588
2589/**********************************************************************/
2593{
2594 if (!can_client_change_view()) {
2595 return;
2596 }
2597
2600}
2601
2602/**********************************************************************/
2606{
2607 if (!can_client_change_view()) {
2608 return;
2609 }
2610
2613}
2614
2615/**********************************************************************/
2619{
2620 if (!can_client_change_view()) {
2621 return;
2622 }
2623
2626}
2627
2628/**********************************************************************/
2632{
2633 if (!can_client_change_view()) {
2634 return;
2635 }
2636
2639}
2640
2641/**********************************************************************/
2645{
2646 if (!can_client_change_view()) {
2647 return;
2648 }
2649
2652}
2653
2654/**********************************************************************/
2658{
2659 if (!can_client_change_view()) {
2660 return;
2661 }
2662
2665}
2666
2667/**********************************************************************/
2671{
2672 if (!can_client_change_view()) {
2673 return;
2674 }
2675
2678}
2679
2680/**********************************************************************/
2684{
2685 if (!can_client_change_view()) {
2686 return;
2687 }
2688
2691}
2692
2693/**********************************************************************/
2697{
2698 if (!can_client_change_view()) {
2699 return;
2700 }
2701
2704}
2705
2706/**********************************************************************/
2710{
2711 if (!can_client_change_view()) {
2712 return;
2713 }
2714
2718}
2719
2720/**********************************************************************/
2724{
2725 struct tile *ptile = find_a_focus_unit_tile_to_center_on();
2726
2727 if (ptile) {
2728 center_tile_mapcanvas(ptile);
2729 }
2730}
2731
2732/**********************************************************************/
2736void request_units_wait(struct unit_list *punits)
2737{
2741 if (punits == get_units_in_focus()) {
2743 }
2744}
2745
2746/**********************************************************************/
2750{
2751 if (get_num_units_in_focus() > 0) {
2754 /* If any of the focused units are busy, keep all of them
2755 * in focus; another tap of the key will dismiss them */
2756 if (punit->activity != ACTIVITY_IDLE) {
2758 }
2764 if (new_status == FOCUS_DONE) {
2766 }
2767 }
2768}
2769
2770/**********************************************************************/
2776{
2777 struct tile *src_tile = unit_tile(punit);
2781
2784
2785 if (!was_teleported
2787 && !unit_transported(punit)) {
2789 unit_type_get(punit)->sound_move_alt,
2790 NULL);
2791 }
2792
2800 || (punit->ssa_controller == SSA_NONE))
2803 }
2804
2805 if (hover_state != HOVER_NONE && in_focus) {
2806 /* Cancel current goto/patrol/connect/nuke command. */
2809 }
2810
2811 unit_list_remove(src_tile->units, punit);
2812
2813 if (!unit_transported(punit)) {
2814 /* Mark the unit as moving unit, then find_visible_unit() won't return
2815 * it. It is especially useful to don't draw many times the unit when
2816 * refreshing the canvas. */
2818
2819 /* We have to refresh the tile before moving. This will draw
2820 * the tile without the unit (because it was unlinked above). */
2822
2824 && punit->ssa_controller != SSA_NONE) {
2825 /* Dont animate automatic units */
2826 } else if (do_animation) {
2827 int dx, dy;
2828
2829 /* For the duration of the animation the unit exists at neither
2830 * tile. */
2831 map_distance_vector(&dx, &dy, src_tile, dst_tile);
2832 move_unit_map_canvas(punit, src_tile, dx, dy);
2833 }
2834 }
2835
2838
2839 if (!unit_transported(punit)) {
2840 /* For find_visible_unit(), see above. */
2842
2844 }
2845
2846 /* With the "full" city bar we have to update the city bar when units move
2847 * into or out of a city. For foreign cities this is handled separately,
2848 * via the occupied field of the short-city packet. */
2849 if (NULL != tile_city(src_tile)
2852 }
2853 if (NULL != tile_city(dst_tile)
2856 }
2857
2858 if (in_focus) {
2859 menus_update();
2860 }
2861}
2862
2863/**********************************************************************/
2867static void do_unit_act_sel_vs(struct tile *ptile)
2868{
2871 /* Have the server record that an action decision is wanted for
2872 * this unit against this tile. */
2874 USSDT_QUEUE, tile_index(ptile));
2875 }
2877}
2878
2879/**********************************************************************/
2882void do_map_click(struct tile *ptile, enum quickselect_type qtype)
2883{
2884 struct city *pcity = tile_city(ptile);
2885 struct unit_list *punits = get_units_in_focus();
2886 bool maybe_goto = FALSE;
2887
2888 if (hover_state != HOVER_NONE) {
2889 switch (hover_state) {
2890 case HOVER_NONE:
2891 break;
2892 case HOVER_GOTO:
2893 do_unit_goto(ptile);
2894 break;
2895 case HOVER_TELEPORT:
2897 do_unit_teleport_to(punit, ptile);
2899 break;
2900 case HOVER_PARADROP:
2902 do_unit_paradrop_to(punit, ptile);
2904 break;
2905 case HOVER_CONNECT:
2907 break;
2908 case HOVER_PATROL:
2909 do_unit_patrol_to(ptile);
2910 break;
2911 case HOVER_ACT_SEL_TGT:
2912 do_unit_act_sel_vs(ptile);
2913 break;
2914 case HOVER_GOTO_SEL_TGT:
2916 do_unit_goto(ptile);
2917 break;
2918 }
2919
2922 } else if (qtype != SELECT_POPUP && qtype != SELECT_APPEND) {
2923 /* Bypass stack or city popup if quickselect is specified. */
2924 struct unit *qunit = quickselect(ptile, qtype);
2925
2926 if (qunit) {
2929 }
2930 } else if (NULL != pcity
2932 /* Otherwise use popups. */
2933 popup_city_dialog(pcity);
2934 } else if (unit_list_size(ptile->units) == 0
2935 && NULL == pcity
2936 && get_num_units_in_focus() > 0) {
2938 } else if (unit_list_size(ptile->units) == 1
2940 struct unit *punit = unit_list_get(ptile->units, 0);
2941
2945 if (qtype == SELECT_APPEND) {
2947 } else {
2949 }
2950 }
2951 } else if (pcity) {
2952 /* Don't hide the unit in the city. */
2954 }
2955 } else if (unit_list_size(ptile->units) > 0) {
2956 /* The stack list is always popped up, even if it includes enemy units.
2957 * If the server doesn't want the player to know about them it shouldn't
2958 * tell them! The previous behavior would only pop up the stack if you
2959 * owned a unit on the tile. This gave cheating clients an advantage,
2960 * and also showed you allied units if (and only if) you had a unit on
2961 * the tile (inconsistent). */
2963 }
2964
2965 /* See mapctrl_common.c */
2969}
2970
2971/**********************************************************************/
2976static struct unit *quickselect(struct tile *ptile,
2978{
2979 int listsize = unit_list_size(ptile->units);
2980 struct unit *panytransporter = NULL,
2984
2986
2987 if (qtype == SELECT_FOCUS) {
2988 return head_of_units_in_focus();
2989 }
2990
2991 if (listsize == 0) {
2992 return NULL;
2993 } else if (listsize == 1) {
2994 struct unit *punit = unit_list_get(ptile->units, 0);
2995 return (unit_owner(punit) == client.conn.playing) ? punit : NULL;
2996 }
2997
2998 /* Quickselect priorities. Units with moves left
2999 * before exhausted. Focus unit is excluded.
3000 *
3001 * SEA: Transporter
3002 * Sea unit
3003 * Any unit
3004 *
3005 * LAND: Military land unit
3006 * Non-combatant
3007 * Sea unit
3008 * Any unit
3009 */
3010
3011 unit_list_iterate(ptile->units, punit) {
3013 continue;
3014 }
3015 if (qtype == SELECT_SEA) {
3016 /* Transporter. */
3018 if (punit->moves_left > 0) {
3019 return punit;
3020 } else if (!panytransporter) {
3022 }
3023 }
3024 /* Any sea, pref. moves left. */
3026 if (punit->moves_left > 0) {
3027 if (!panymovesea) {
3029 }
3030 } else if (!panysea) {
3031 panysea = punit;
3032 }
3033 }
3034 } else if (qtype == SELECT_LAND) {
3036 if (punit->moves_left > 0) {
3037 if (!is_special_unit(punit)) {
3038 return punit;
3039 } else if (!panymoveland) {
3041 }
3042 } else if (!panyland) {
3043 panyland = punit;
3044 }
3045 }
3047 if (punit->moves_left > 0) {
3049 } else {
3050 panysea = punit;
3051 }
3052 }
3053 }
3054 if (punit->moves_left > 0 && !panymoveunit) {
3056 }
3057 if (!panyunit) {
3058 panyunit = punit;
3059 }
3061
3062 if (qtype == SELECT_SEA) {
3063 if (panytransporter) {
3064 return panytransporter;
3065 } else if (panymovesea) {
3066 return panymovesea;
3067 } else if (panysea) {
3068 return panysea;
3069 } else if (panymoveunit) {
3070 return panymoveunit;
3071 } else if (panyunit) {
3072 return panyunit;
3073 }
3074 }
3075 else if (qtype == SELECT_LAND) {
3076 if (panymoveland) {
3077 return panymoveland;
3078 } else if (panyland) {
3079 return panyland;
3080 } else if (panymovesea) {
3081 return panymovesea;
3082 } else if (panysea) {
3083 return panysea;
3084 } else if (panymoveunit) {
3085 return panymoveunit;
3086 } else if (panyunit) {
3087 return panyunit;
3088 }
3089 }
3090 return NULL;
3091}
3092
3093/**********************************************************************/
3097void do_unit_goto(struct tile *ptile)
3098{
3102
3105 return;
3106 }
3107
3108 if (is_valid_goto_draw_line(ptile)) {
3110 } else {
3112 _("Didn't find a route to the destination!"));
3113 }
3114}
3115
3116/**********************************************************************/
3119static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
3120{
3121 struct action *teleport_action = NULL;
3122
3123 action_iterate(act_id) {
3124 struct action *paction = action_by_number(act_id);
3125
3127 /* Not relevant. */
3128 continue;
3129 }
3130
3133 tile_city(ptile), NULL,
3134 ptile, NULL))) {
3135 if (teleport_action == NULL) {
3136 /* This is the first possible teleport action. */
3138 } else {
3139 /* More than one teleport action may be possible. The user must
3140 * choose. Have the server record that an action decision is wanted
3141 * for this unit so the dialog will be brought up. */
3143 USSDT_QUEUE, tile_index(ptile));
3144 return;
3145 }
3146 }
3148
3149 if (teleport_action != NULL) {
3151 tile_index(ptile), 0 , "");
3152 }
3153}
3154
3155/**********************************************************************/
3158void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
3159{
3160 struct action *paradrop_action = NULL;
3161
3162 action_iterate(act_id) {
3163 struct action *paction = action_by_number(act_id);
3164
3167 /* Not relevant. */
3168 continue;
3169 }
3170
3173 tile_city(ptile), NULL,
3174 ptile, NULL))) {
3175 if (paradrop_action == NULL) {
3176 /* This is the first possible paradrop action. */
3178 } else {
3179 /* More than one paradrop action may be possible. The user must
3180 * choose. Have the server record that an action decision is wanted
3181 * for this unit so the dialog will be brought up. */
3183 USSDT_QUEUE, tile_index(ptile));
3184 return;
3185 }
3186 }
3188
3189 if (paradrop_action != NULL) {
3191 tile_index(ptile), 0 , "");
3192 }
3193}
3194
3195/**********************************************************************/
3198void do_unit_patrol_to(struct tile *ptile)
3199{
3200 if (is_valid_goto_draw_line(ptile)
3203 } else {
3205 _("Didn't find a route to the destination!"));
3206 }
3207
3209}
3210
3211/**********************************************************************/
3214void do_unit_connect(struct tile *ptile,
3215 enum unit_activity activity,
3216 struct extra_type *tgt)
3217{
3218 if (is_valid_goto_draw_line(ptile)) {
3219 send_connect_route(activity, tgt);
3220 } else {
3222 _("Didn't find a route to the destination!"));
3223 }
3224
3226}
3227
3228/**********************************************************************/
3232{
3233 struct unit_list *punits = get_units_in_focus();
3235
3236 switch (hover_state) {
3237 case HOVER_GOTO_SEL_TGT:
3241 break;
3242 case HOVER_GOTO:
3243 case HOVER_PATROL:
3244 case HOVER_CONNECT:
3245 if (goto_pop_waypoint()) {
3246 break;
3247 }
3248 fc__fallthrough; /* else fall through: */
3249 case HOVER_TELEPORT:
3250 case HOVER_PARADROP:
3251 case HOVER_ACT_SEL_TGT:
3254
3258 break;
3259 case HOVER_NONE:
3260 break;
3261 };
3262}
3263
3264/**********************************************************************/
3269{
3271
3272 if (capital) {
3273 /* Center on the tile, and pop up the crosshair overlay. */
3276 } else {
3278 _("Oh my! You seem to have no capital!"));
3279 }
3280}
3281
3282/**********************************************************************/
3286{
3288}
3289
3290/**********************************************************************/
3294{
3295 int i = 0;
3296
3297 /* Could use unit_list_copy here instead. Just having safe genlists
3298 * wouldn't be sufficient since we don't want to skip units already
3299 * removed from focus... */
3301 if (i == 0) {
3303 } else {
3305 }
3306 i++;
3308}
3309
3310/**********************************************************************/
3322
3323/**********************************************************************/
3332
3333/**********************************************************************/
3344
3345/**********************************************************************/
3349 struct extra_type *tgt)
3350{
3351 request_unit_connect(activity, tgt);
3352}
3353
3354/**********************************************************************/
3358{
3359 struct tile *ptile;
3360
3363 && (ptile = unit_tile(punit))) {
3364 /* Have the server record that an action decision is wanted for this
3365 * unit. */
3367 USSDT_QUEUE, tile_index(ptile));
3368 }
3370}
3371
3372/**********************************************************************/
3380{
3381 struct unit_list *punits = get_units_in_focus();
3382
3384 /* The 2nd key press means that the actor should target its own
3385 * tile. */
3387
3388 /* Target tile selected. Clean up hover state. */
3391
3392 return;
3393 } else if (hover_state == HOVER_GOTO_SEL_TGT) {
3395
3396 /* We don't support long range actions in the middle of orders yet so
3397 * send it at once. */
3399
3400 /* Target tile selected. Clean up hover state. */
3403
3404 return;
3405 } else if (hover_state == HOVER_GOTO
3408
3410 ftc_client,
3411 /* TRANS: Perform action inside a goto. */
3412 _("Click on a tile to do %s against it."),
3414
3419
3420 return;
3421 }
3422
3424 ftc_client,
3425 /* TRANS: "Do..." action selection dialog target. */
3426 _("Click on a tile to act against it. "
3427 "Press 'd' again to act against own tile."));
3428
3431}
3432
3433/**********************************************************************/
3437{
3439}
3440
3441/**********************************************************************/
3445{
3447}
3448
3449/**********************************************************************/
3456
3457/**********************************************************************/
3461{
3463}
3464
3465/**********************************************************************/
3472
3473/**********************************************************************/
3477{
3479 /* TODO: Is falling back on ACTION_MARKETPLACE if not able to establish
3480 * a trade route trade a good idea or an unplecant surprice? */
3483 }
3485}
3486
3487/**********************************************************************/
3491{
3492 struct unit *pnext_focus = NULL, *plast;
3493
3497 }
3499
3500 if (pnext_focus) {
3502 /* Unfocus the ships, and advance the focus to the last unloaded unit.
3503 * If there is no unit unloaded (which shouldn't happen, but could if
3504 * the caller doesn't check if the transporter is loaded), the we
3505 * don't do anything. */
3509 }
3510}
3511
3512/**********************************************************************/
3519
3520/**********************************************************************/
3529
3530/**********************************************************************/
3546
3547/**********************************************************************/
3558
3559/**********************************************************************/
3571
3572/**********************************************************************/
3581
3582/**********************************************************************/
3593
3594/**********************************************************************/
3610
3611/**********************************************************************/
3620
3621/**********************************************************************/
3624static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
3625{
3628 cause,
3630 punit);
3631
3634 }
3636}
3637
3638/**********************************************************************/
3645
3646/**********************************************************************/
3657
3658/**********************************************************************/
3662{
3664}
3665
3666/**********************************************************************/
3677
3678/**********************************************************************/
3689
3690/**********************************************************************/
3707
3708/**********************************************************************/
3725
3726/**********************************************************************/
3737
3738/**********************************************************************/
3749
3750/**********************************************************************/
3753void key_unit_assign_battlegroup(int battlegroup, bool append)
3754{
3756 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3757 if (!append) {
3759 if (!unit_is_in_focus(punit)) {
3765 unit_list_remove(battlegroups[battlegroup], punit);
3766 }
3768 }
3770 if (punit->battlegroup != battlegroup) {
3771 if (punit->battlegroup >= 0
3774 }
3775 punit->battlegroup = battlegroup;
3778 battlegroup);
3779 unit_list_append(battlegroups[battlegroup], punit);
3781 }
3783 unit_list_iterate(battlegroups[battlegroup], punit) {
3786 }
3787}
3788
3789/**********************************************************************/
3792void key_unit_select_battlegroup(int battlegroup, bool append)
3793{
3795 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3796 int i = 0;
3797
3798 if (unit_list_size(battlegroups[battlegroup]) == 0 && !append) {
3800 return;
3801 }
3802
3803 /* FIXME: this is very inefficient and can be improved. */
3804 unit_list_iterate(battlegroups[battlegroup], punit) {
3805 if (i == 0 && !append) {
3807 } else {
3809 }
3810 i++;
3812 }
3813}
3814
3815/**********************************************************************/
3822
3823/**********************************************************************/
3830
3831/**********************************************************************/
3835{
3837}
3838
3839/**********************************************************************/
3846
3847/**********************************************************************/
3854
3855/**********************************************************************/
3862
3863/**********************************************************************/
3870
3871/**********************************************************************/
3879
3880/**********************************************************************/
3888
3889/**********************************************************************/
3896
3897/**********************************************************************/
3905
3906/**********************************************************************/
3913
3914/**********************************************************************/
3918{
3920}
3921
3922/**********************************************************************/
3926{
3928}
3929
3930/**********************************************************************/
3934{
3936}
3937
3938/**********************************************************************/
3945
3946/**********************************************************************/
3950{
3952}
3953
3954/**********************************************************************/
3958{
3960}
3961
3962/**********************************************************************/
3966{
3968}
3969
3970/**********************************************************************/
3974{
3976}
3977
3978/**********************************************************************/
3982{
3984}
3985
3986/**********************************************************************/
3990{
3992}
3993
3994/**********************************************************************/
3998{
4000}
4001
4002/**********************************************************************/
4009
4010/**********************************************************************/
4017
4018/**********************************************************************/
4025
4026/**********************************************************************/
4033
4034/**********************************************************************/
4041
4042/**********************************************************************/
4049
4050/**********************************************************************/
4060
4061/**********************************************************************/
4064void finish_city(struct tile *ptile, const char *name)
4065{
4066 unit_list_iterate(ptile->units, punit) {
4068 /* Unit will disappear only in case city building still success.
4069 * Cancel city building status just in case something has changed
4070 * to prevent city building in the meanwhile and unit will remain
4071 * alive. */
4074 0, name);
4075 }
4077}
4078
4079/**********************************************************************/
4083void cancel_city(struct tile *ptile)
4084{
4085 unit_list_iterate(ptile->units, punit) {
4088}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4717
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5044
const char * action_name_translation(const struct action *paction)
Definition actions.c:1205
struct act_prob action_prob_unit_vs_tgt(const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Definition actions.c:4739
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4562
struct act_prob action_prob_vs_stack(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4478
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:4203
struct act_prob action_prob_vs_extras(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4646
bool action_id_exists(const action_id act_id)
Definition actions.c:1043
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:4286
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:688
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:236
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
#define action_has_result(_act_, _res_)
Definition actions.h:175
#define action_id_get_role(act_id)
Definition actions.h:451
#define action_by_result_iterate_end
Definition actions.h:240
#define action_iterate_end
Definition actions.h:209
#define action_id(_act_)
Definition actions.h:416
#define action_iterate(_act_)
Definition actions.h:205
#define action_id_get_target_kind(act_id)
Definition actions.h:407
#define action_id_has_result_safe(act_id, result)
Definition actions.h:420
#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:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:727
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:1082
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1231
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:74
double blink_turn_done_button(void)
Definition control.c:907
void key_coastline_toggle(void)
Definition control.c:3925
void key_irrigation_toggle(void)
Definition control.c:3941
void request_toggle_huts(void)
Definition control.c:2618
void key_unit_sentry(void)
Definition control.c:3729
void request_toggle_city_outlines(void)
Definition control.c:2371
void key_unit_road(void)
Definition control.c:3711
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1517
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2775
void request_toggle_resources(void)
Definition control.c:2605
void request_toggle_city_names(void)
Definition control.c:2449
void key_recall_previous_focus_unit(void)
Definition control.c:3293
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1810
void request_toggle_unit_stack_size(void)
Definition control.c:2514
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:383
void key_city_output_toggle(void)
Definition control.c:3826
void request_toggle_focus_unit(void)
Definition control.c:2696
void request_toggle_city_output(void)
Definition control.c:2384
void request_unit_return(struct unit *punit)
Definition control.c:1526
void request_unit_fortify(struct unit *punit)
Definition control.c:2326
void key_unit_build_city(void)
Definition control.c:3326
void key_editor_recalculate_borders(void)
Definition control.c:4045
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1485
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2196
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1033
enum unit_orders goto_last_order
Definition control.c:96
void request_units_wait(struct unit_list *punits)
Definition control.c:2736
void request_unit_wakeup(struct unit *punit)
Definition control.c:1574
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:391
void key_focus_unit_toggle(void)
Definition control.c:4021
void request_toggle_map_grid(void)
Definition control.c:2397
void action_decision_request(struct unit *actor_unit)
Definition control.c:1084
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2579
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1014
int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra, const struct unit *punit, const struct player *pplayer, int rec)
Definition control.c:1311
void key_unit_action_select(void)
Definition control.c:3357
void key_unit_auto_explore(void)
Definition control.c:3550
static int action_selection_in_progress_for
Definition control.c:119
static void do_disband_alternative(void *p)
Definition control.c:1943
void key_cancel_action(void)
Definition control.c:3231
void request_toggle_city_buycost(void)
Definition control.c:2488
void clear_hover_state(void)
Definition control.c:323
void request_toggle_map_native(void)
Definition control.c:2423
void request_unit_patrol(void)
Definition control.c:2292
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3348
void key_city_full_bar_toggle(void)
Definition control.c:3858
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2129
void key_bases_toggle(void)
Definition control.c:3957
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2882
static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
Definition control.c:3624
void key_map_native_toggle(void)
Definition control.c:3850
void request_toggle_map_borders(void)
Definition control.c:2410
void key_resources_toggle(void)
Definition control.c:3965
static void request_unit_teleport(struct unit_list *punits)
Definition control.c:2255
static struct unit * punit_attacking
Definition control.c:105
void unit_focus_add(struct unit *punit)
Definition control.c:556
void unit_focus_set(struct unit *punit)
Definition control.c:501
static void do_unit_act_sel_vs(struct tile *ptile)
Definition control.c:2867
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1104
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3158
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:334
int goto_last_tgt
Definition control.c:94
struct extra_type * connect_tgt
Definition control.c:91
void key_unit_paradrop(void)
Definition control.c:3452
static bool can_units_attack_at(struct unit_list *punits, const struct tile *ptile)
Definition control.c:1171
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1704
void key_end_turn(void)
Definition control.c:3285
void request_unit_disband(struct unit *punit)
Definition control.c:2048
void request_toggle_irrigation(void)
Definition control.c:2566
static struct unit_list * current_focus
Definition control.c:79
static struct unit_list * previous_focus
Definition control.c:83
void unit_focus_advance(void)
Definition control.c:670
void request_unit_pillage(struct unit *punit)
Definition control.c:2337
void key_unit_teleport(void)
Definition control.c:3468
void request_center_focus_unit(void)
Definition control.c:2723
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:4013
void key_city_productions_toggle(void)
Definition control.c:3892
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1389
void key_unit_build_wonder(void)
Definition control.c:3336
void key_unit_plant(void)
Definition control.c:3669
void key_unit_fortress(void)
Definition control.c:3597
void key_unit_mine(void)
Definition control.c:3661
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2067
void request_toggle_fog_of_war(void)
Definition control.c:2709
void key_unit_pillage(void)
Definition control.c:3681
void request_unit_unload(struct unit *pcargo)
Definition control.c:2167
void key_editor_toggle_fogofwar(void)
Definition control.c:4054
static void client_disband_unit_data_destroy(void *p)
Definition control.c:1933
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2101
static struct unit * find_best_focus_candidate(bool accept_current)
Definition control.c:633
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1772
static struct unit * quickselect(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2976
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2657
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1912
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:967
void key_unit_irrigate(void)
Definition control.c:3641
void request_unit_build_city(struct unit *punit)
Definition control.c:1791
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:250
static struct unit_list * urgent_focus_queue
Definition control.c:86
void key_unit_unload_all(void)
Definition control.c:3490
void key_cities_toggle(void)
Definition control.c:3989
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3314
void key_city_outlines_toggle(void)
Definition control.c:3818
void key_unit_homecity(void)
Definition control.c:3614
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2219
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:285
static int disband_unit_alternatives[3]
Definition control.c:69
void key_unit_patrol(void)
Definition control.c:3460
void request_toggle_city_full_bar(void)
Definition control.c:2436
void request_toggle_city_growth(void)
Definition control.c:2462
void key_unit_solid_bg_toggle(void)
Definition control.c:4005
void request_toggle_unit_solid_bg(void)
Definition control.c:2670
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1740
void key_terrain_toggle(void)
Definition control.c:3917
void key_paths_toggle(void)
Definition control.c:3933
void request_unit_sentry(struct unit *punit)
Definition control.c:2315
void key_unit_wakeup_others(void)
Definition control.c:3523
bool non_ai_unit_focus
Definition control.c:125
static struct unit * punit_defending
Definition control.c:106
static struct tile * find_a_focus_unit_tile_to_center_on(void)
Definition control.c:413
enum cursor_hover_state hover_state
Definition control.c:89
void key_unit_stack_size_toggle(void)
Definition control.c:3909
static void store_previous_focus(void)
Definition control.c:194
void key_huts_toggle(void)
Definition control.c:3973
void key_fog_of_war_toggle(void)
Definition control.c:4029
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1456
void clear_unit_orders(struct unit *punit)
Definition control.c:476
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2527
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1054
void key_unit_wait(void)
Definition control.c:3515
void key_units_toggle(void)
Definition control.c:3997
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3214
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:586
void request_toggle_bases(void)
Definition control.c:2592
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3198
void key_unit_trade_route(void)
Definition control.c:3476
void request_toggle_coastline(void)
Definition control.c:2540
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3792
void key_map_grid_toggle(void)
Definition control.c:3834
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4064
static struct unit * punit_moving
Definition control.c:102
void key_pollution_toggle(void)
Definition control.c:3981
struct unit * head_of_units_in_focus(void)
Definition control.c:405
static bool is_activity_on_tile(struct tile *ptile, enum unit_activity activity)
Definition control.c:1295
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:804
static bool can_be_irrigated(const struct tile *ptile, const struct unit *punit)
Definition control.c:1366
void key_city_growth_toggle(void)
Definition control.c:3875
void key_unit_action_select_tgt(void)
Definition control.c:3379
static struct unit_list * battlegroups[MAX_NUM_BATTLEGROUPS]
Definition control.c:99
void key_city_buycost_toggle(void)
Definition control.c:3884
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3741
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1853
static void current_focus_append(struct unit *punit)
Definition control.c:442
void key_unit_done(void)
Definition control.c:3436
static void current_focus_remove(struct unit *punit)
Definition control.c:462
static struct tile * hover_tile
Definition control.c:98
void key_city_trade_routes_toggle(void)
Definition control.c:3901
static void focus_units_changed(void)
Definition control.c:215
void request_toggle_city_trade_routes(void)
Definition control.c:2501
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:620
void request_unit_convert(struct unit *punit)
Definition control.c:2091
void request_toggle_paths(void)
Definition control.c:2553
void request_toggle_unit_shields(void)
Definition control.c:2683
void key_city_names_toggle(void)
Definition control.c:3866
void unit_register_battlegroup(struct unit *punit)
Definition control.c:270
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1595
static bool action_requires_confirmation(action_id act, char *buf, size_t bufsize)
Definition control.c:1673
void unit_focus_update(void)
Definition control.c:771
void key_unit_auto_work(void)
Definition control.c:3563
void key_unit_airbase(void)
Definition control.c:3533
void key_unit_goto(void)
Definition control.c:3444
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
void key_unit_convert(void)
Definition control.c:3575
void key_unit_clean(void)
Definition control.c:3693
void key_center_capital(void)
Definition control.c:3268
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1557
void request_toggle_cities(void)
Definition control.c:2644
void key_unit_fortify(void)
Definition control.c:3585
void key_editor_toggle(void)
Definition control.c:4037
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3753
void request_unit_move_done(void)
Definition control.c:2749
void auto_center_on_focus_unit(void)
Definition control.c:429
void key_unit_cultivate(void)
Definition control.c:3649
double blink_active_unit(void)
Definition control.c:874
void request_unit_upgrade(struct unit *punit)
Definition control.c:2079
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2475
void cancel_city(struct tile *ptile)
Definition control.c:4083
static void ask_server_for_actions(struct unit *punit)
Definition control.c:361
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1903
void request_toggle_pollution(void)
Definition control.c:2631
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3949
static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
Definition control.c:3119
void do_unit_goto(struct tile *ptile)
Definition control.c:3097
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1066
static bool can_ask_server_for_actions(void)
Definition control.c:347
void request_unit_autoworker(const struct unit *punit)
Definition control.c:2114
void key_map_borders_toggle(void)
Definition control.c:3842
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:43
#define MAX_NUM_UNITS_BELOW
Definition control.h:295
quickselect_type
Definition control.h:37
@ SELECT_LAND
Definition control.h:38
@ SELECT_APPEND
Definition control.h:38
@ SELECT_SEA
Definition control.h:38
@ SELECT_POPUP
Definition control.h:38
@ SELECT_FOCUS
Definition control.h:38
cursor_hover_state
Definition control.h:25
@ HOVER_GOTO
Definition control.h:27
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_TELEPORT
Definition control.h:28
@ HOVER_ACT_SEL_TGT
Definition control.h:32
@ HOVER_NONE
Definition control.h:26
@ HOVER_CONNECT
Definition control.h:30
@ HOVER_PATROL
Definition control.h:31
@ HOVER_GOTO_SEL_TGT
Definition control.h:33
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city * target_city
Definition dialogs_g.h:56
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Definition effects.c: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:358
@ RPT_POSSIBLE
Definition fc_types.h:677
#define DIR8_ORIGIN
Definition fc_types.h:459
int action_id
Definition fc_types.h:393
#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:710
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:1026
bool goto_is_active(void)
Definition goto.c:1063
struct pf_path * path_to_nearest_allied_city(struct unit *punit)
Definition goto.c:1994
void send_patrol_route(void)
Definition goto.c:1655
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1342
bool goto_add_waypoint(void)
Definition goto.c:488
bool goto_pop_waypoint(void)
Definition goto.c:525
void send_connect_route(enum unit_activity activity, struct extra_type *tgt)
Definition goto.c:1721
void goto_unit_killed(struct unit *punit)
Definition goto.c:1044
void free_client_goto(void)
Definition goto.c:163
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1005
void send_goto_route(void)
Definition goto.c:1881
bool is_valid_goto_destination(const struct tile *ptile)
Definition goto.c:180
void request_orders_cleared(struct unit *punit)
Definition goto.c:1367
void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *final_order)
Definition goto.c:1538
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 request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.c:1607
void real_focus_units_changed(void)
Definition gui_main.c:2172
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2149
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2119
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
void update_turn_done_button(bool do_restore)
Definition mapview.c:76
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:643
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
bool request_transport(struct unit *cargo, struct tile *ptile)
enum cursor_type mouse_cursor_type
Definition gui_mouse.c:46
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_error(message,...)
Definition log.h:103
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1362
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:941
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:950
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Definition map.c:375
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1087
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:353
#define iterate_outward_end
Definition map.h:357
bool keyboardless_goto_button_down
void cancel_tile_hiliting(void)
bool keyboardless_goto_active
struct tile * keyboardless_goto_start_tile
void update_map_canvas_visible(void)
struct tile * get_center_tile_mapcanvas(void)
void move_unit_map_canvas(struct unit *punit, struct tile *src_tile, int dx, int dy)
void center_tile_mapcanvas(const struct tile *ptile)
void update_city_description(struct city *pcity)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile)
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
void menus_update(void)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c: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:4281
bool option_bool_get(const struct option *poption)
Definition options.c:832
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:466
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:549
#define players_iterate_alive(_pplayer)
Definition player.h:544
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:320
int id
Definition city.h:326
enum capital_type capital
Definition city.h:328
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
bool draw_native
Definition options.h: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
struct connection::@58::@63 client
int last_request_id_used
Definition connection.h:187
struct requirement_vector reqs
Definition extras.h:106
struct unit_order orders[MAX_LEN_ROUTE]
struct unit_list * units
Definition player.h: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
struct unit::@81::@83 client
int id
Definition unit.h:147
int hp
Definition unit.h:153
bool asking_city_name
Definition unit.h:228
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:880
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:6558
void toggle_focus_unit_state(struct tileset *t)
Definition tilespec.c:6590
void focus_unit_in_combat(struct tileset *t)
Definition tilespec.c:6579
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:264
double timer_read_seconds(struct timer *t)
Definition timing.c:384
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
Definition timing.c:180
@ TIMER_ACTIVE
Definition timing.h:46
@ TIMER_USER
Definition timing.h:42
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1821
bool is_attack_unit(const struct unit *punit)
Definition unit.c:308
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2499
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:386
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:831
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:300
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:847
bool is_special_unit(const struct unit *punit)
Definition unit.c:353
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1285
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2483
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:205
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1950
#define unit_tile(_pu)
Definition unit.h:397
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:396
#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:433
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_both_iterate_end
Definition unitlist.h:37
#define unit_list_both_iterate(unitlist, plink, punit)
Definition unitlist.h:34
#define unit_list_iterate_safe_end
Definition unitlist.h:61
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Definition unittype.c:1551
bool utype_may_act_at_all(const struct unit_type *putype)
Definition unittype.c:359
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2498
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
bool role_units_translations(struct astring *astr, int flag, bool alts)
Definition unittype.c:1668
void update_queue_connect_processing_finished_full(int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)