Freeciv-3.2
Loading...
Searching...
No Matches
control.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20#include "bitvector.h"
21#include "fcintl.h"
22#include "log.h"
23#include "mem.h"
24#include "timing.h"
25
26/* common */
27#include "combat.h"
28#include "game.h"
29#include "map.h"
30#include "movement.h"
31#include "unitlist.h"
32
33/* common/aicore */
34#include "path_finding.h"
35
36/* client/include */
37#include "chatline_g.h"
38#include "citydlg_g.h"
39#include "dialogs_g.h"
40#include "gui_main_g.h"
41#include "mapctrl_g.h"
42#include "mapview_g.h"
43#include "menu_g.h"
44
45/* client */
46#include "audio.h"
47#include "client_main.h"
48#include "climap.h"
49#include "climisc.h"
50#include "editor.h"
51#include "goto.h"
52#include "options.h"
53#include "overview_common.h"
54#include "tilespec.h"
55#include "update_queue.h"
56
57#include "control.h"
58
59
64
65/* Ways to disband a unit. Sorted by preference. Starts with the worst. */
66/* TODO: Should other actions that consumes the unit be considered?
67 * Join City may be an appealing alternative. Perhaps it should be a
68 * user configurable client option? */
74
75/* gui-dep code may adjust depending on tile size etc: */
77
78/* current_focus points to the current unit(s) in focus */
79static struct unit_list *current_focus = NULL;
80
81/* The previously focused unit(s). Focus can generally be recalled
82 * with keypad 5 (or the equivalent). */
83static struct unit_list *previous_focus = NULL;
84
85/* The priority unit(s) for unit_focus_advance(). */
86static struct unit_list *urgent_focus_queue = NULL;
87
88/* These should be set via set_hover_state() */
92
96enum unit_orders goto_last_order; /* Last order for goto */
97
98static struct tile *hover_tile = NULL;
99static struct unit_list *battlegroups[MAX_NUM_BATTLEGROUPS];
100
101/* Current moving unit. */
102static struct unit *punit_moving = NULL;
103
104/* units involved in current combat */
105static struct unit *punit_attacking = NULL;
106static struct unit *punit_defending = NULL;
107
108/* The ID of the unit that currently is in the action selection process.
109 *
110 * The action selection process begins when the client asks the server what
111 * actions a unit can take. It ends when the last follow up question is
112 * answered.
113 *
114 * No common client code using client supports more than one action
115 * selection process at once. The interface between the common client code
116 * and the clients would have to change before that could happen. (See
117 * action_selection_actor_unit() etc)
118 */
120
121/*
122 * This variable is TRUE iff a NON-AI controlled unit was focused this
123 * turn.
124 */
126
127static void do_unit_teleport_to(struct unit *punit, struct tile *ptile);
128
129/*************************************************************************/
130
131static struct unit *quickselect(struct tile *ptile,
133
134/**********************************************************************/
137void control_init(void)
138{
139 int i;
140
144
145 for (i = 0; i < MAX_NUM_BATTLEGROUPS; i++) {
147 }
149}
150
151/**********************************************************************/
173
174/**********************************************************************/
177struct unit_list *get_units_in_focus(void)
178{
179 return current_focus;
180}
181
182/**********************************************************************/
186{
188}
189
190/**********************************************************************/
203
204/**********************************************************************/
211
212/**********************************************************************/
215static void focus_units_changed(void)
216{
218 menus_update();
219 /* Notify the GUI */
221}
222
223/**********************************************************************/
251
252/**********************************************************************/
255void unit_change_battlegroup(struct unit *punit, int battlegroup)
256{
258 battlegroup = BATTLEGROUP_NONE;
259 }
260
261 if (punit->battlegroup != battlegroup) {
262 if (battlegroup != BATTLEGROUP_NONE) {
263 unit_list_append(battlegroups[battlegroup], punit);
264 }
267 }
268 punit->battlegroup = battlegroup;
269 }
270}
271
272/**********************************************************************/
283
284/**********************************************************************/
290void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
291 enum unit_activity activity,
292 struct extra_type *tgt,
293 int last_tgt,
294 int last_sub_tgt,
296 enum unit_orders order)
297{
299 || state == HOVER_NONE);
300 fc_assert_ret(state == HOVER_CONNECT || activity == ACTIVITY_LAST);
301 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
302 || order == ORDER_LAST);
303 fc_assert_ret((state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT)
304 || action == ACTION_NONE);
305
307 && (state == HOVER_GOTO || state == HOVER_GOTO_SEL_TGT))) {
308 /* Exit goto unless this is a switch between goto states */
310 }
311
312 hover_state = state;
313 connect_activity = activity;
314 if (tgt) {
315 connect_tgt = tgt;
316 } else {
318 }
319 goto_last_order = order;
323}
324
325/**********************************************************************/
334
335/**********************************************************************/
340{
342 /* The player is interested in getting a pop up for a mere
343 * arrival. */
346}
347
348/**********************************************************************/
353{
354 /* OK as long as no other unit already asked and aren't done yet. */
357}
358
359/**********************************************************************/
367{
370
371 /* Only one action selection dialog at a time is supported. */
373 "Unit %d started action selection before unit %d was done",
376
378 punit->id,
383}
384
385/**********************************************************************/
388bool unit_is_in_focus(const struct unit *punit)
389{
391}
392
393/**********************************************************************/
396struct unit *get_focus_unit_on_tile(const struct tile *ptile)
397{
399 if (unit_tile(punit) == ptile) {
400 return punit;
401 }
403
404 return NULL;
405}
406
407/**********************************************************************/
411{
412 return unit_list_get(current_focus, 0);
413}
414
415/**********************************************************************/
419{
420 struct unit *punit;
421
423 return unit_tile(punit);
424 } else if (get_num_units_in_focus() > 0) {
426 } else {
427 return NULL;
428 }
429}
430
431/**********************************************************************/
435{
437
441 }
442}
443
444/**********************************************************************/
463
464/**********************************************************************/
467static void current_focus_remove(struct unit *punit)
468{
469 /* Close the action selection dialog if the actor unit lose focus. */
472 }
473
476}
477
478/**********************************************************************/
482{
483 if (!punit) {
484 return;
485 }
486
492 } else if (unit_has_orders(punit)) {
493 /* Clear the focus unit's orders. */
495 }
496}
497
498/**********************************************************************/
503{
504 if (punit->activity == ACTIVITY_IDLE) {
505 /* Only idle units can be at focus. */
507 }
508}
509
510/**********************************************************************/
519{
520 bool focus_changed = FALSE;
521
522 if (NULL != punit
523 && NULL != client.conn.playing
525 /* Callers should make sure this never happens. */
526 return;
527 }
528
529 /* FIXME: This won't work quite right; for instance activating a
530 * battlegroup twice in a row will store the focus erroneously. The only
531 * solution would be a set_units_focus() */
532 if (!(get_num_units_in_focus() == 1
533 && punit == head_of_units_in_focus())) {
536 }
537
538 /* Close the action selection dialog if the actor unit lose focus. */
542 }
544
545 /* Redraw the old focus unit (to fix blinking or remove the selection
546 * circle). */
551
552 if (!can_client_change_view()) {
553 /* This function can be called to set the focus to NULL when
554 * disconnecting. In this case we don't want any other actions! */
555 fc_assert(punit == NULL);
556 return;
557 }
558
559 if (NULL != punit) {
562 }
563
564 if (focus_changed) {
567 }
568}
569
570/**********************************************************************/
574{
575 if (NULL != punit
576 && NULL != client.conn.playing
578 /* Callers should make sure this never happens. */
579 return;
580 }
581
582 if (NULL == punit || !can_client_change_view()) {
583 return;
584 }
585
586 if (unit_is_in_focus(punit)) {
587 return;
588 }
589
590 if (hover_state != HOVER_NONE) {
591 /* Can't continue with current goto if set of focus units
592 * change. Cancel it. */
594 }
595
598}
599
600/**********************************************************************/
604{
605 bool keep_in_focus = FALSE;
606
607 if (NULL != punit
608 && NULL != client.conn.playing
610 /* Callers should make sure this never happens. */
611 return;
612 }
613
614 if (NULL == punit || !can_client_change_view()) {
615 return;
616 }
617
618 if (!unit_is_in_focus(punit)) {
619 return;
620 }
621
622 if (hover_state != HOVER_NONE) {
623 /* Can't continue with current goto if set of focus units
624 * change. Cancel it. */
626 }
627
628 if (get_num_units_in_focus() == 1) {
630
631 if (unit_is_in_focus(punit)) {
632 /* Unit was restored to focus (there was no other units to focus to) */
634 }
635 }
636
637 if (!keep_in_focus) {
639 if (get_num_units_in_focus() > 0) {
641 }
642 }
643}
644
645/**********************************************************************/
655
656/**********************************************************************/
662{
663 struct tile *ptile = get_center_tile_mapcanvas();
664
665 if (!get_focus_unit_on_tile(ptile)) {
667
668 if (pfirst) {
669 ptile = unit_tile(pfirst);
670 }
671 }
672
680 && (punit->moves_left > 0 || unit_type_get(punit)->move_rate == 0)
681 && !punit->done_moving
683 return punit;
684 }
687
688 return NULL;
689}
690
691/**********************************************************************/
701{
702 struct unit *candidate = NULL;
704
705 if (NULL == client.conn.playing
709 return;
710 }
711
713
715 /*
716 * Is the unit which just lost focus a non-AI unit? If yes this
717 * enables the auto end turn.
718 */
719 if (punit->ssa_controller == SSA_NONE) {
721 break;
722 }
724
726 /* Try top of the urgent list. */
727 struct tile *focus_tile = (get_num_units_in_focus() > 0
729 : NULL);
730
734 /* This isn't an action decision needed because of an
735 * ORDER_ACTION_MOVE located in the middle of an order. */
737 /* We have assigned new orders to this unit since, remove it. */
739 } else if (NULL == focus_tile
740 || focus_tile == unit_tile(punit)) {
741 /* Use the first one found */
743 break;
744 } else if (NULL == candidate) {
746 }
748
749 if (NULL != candidate) {
751
752 /* Autocenter on Wakeup, regardless of the local option
753 * "auto_center_on_unit". */
756 }
757 }
758 }
759
760 if (NULL == candidate) {
762
763 if (!candidate) {
764 /* Try for "waiting" units. */
768 }
771
772 if (!candidate && accept_current) {
773 /* Accept current focus unit as last resort. */
775 }
776 }
777 }
778
780
781 /*
782 * Handle auto-turn-done mode: If a unit was in focus (did move),
783 * but now none are (no more to move) and there was at least one
784 * non-AI unit this turn which was focused, then fake a Turn Done
785 * keypress.
786 */
789 && get_num_units_in_focus() == 0
791 key_end_turn();
792 }
793}
794
795/**********************************************************************/
802{
804 return;
805 }
806
809
810 /* An actor unit is asking the player what to do. Don't change the
811 * focus. */
812 return;
813 }
814
815 /* iterate zero times for no units in focus,
816 * otherwise quit for any of the conditions. */
821 && punit->moves_left > 0
822 && !punit->done_moving
824 return;
825 }
827
829}
830
831/**********************************************************************/
834struct unit *find_visible_unit(struct tile *ptile)
835{
836 struct unit *panyowned = NULL, *panyother = NULL, *ptptother = NULL;
837
838 /* If no units here, return nothing. */
839 if (unit_list_size(ptile->units) == 0) {
840 return NULL;
841 }
842
843 /* If a unit is attacking we should show that on top */
845 unit_list_iterate(ptile->units, punit) {
846 if (punit == punit_attacking) {
847 return punit;
848 }
850 }
851
852 /* If a unit is defending we should show that on top */
854 unit_list_iterate(ptile->units, punit) {
855 if (punit == punit_defending) {
856 return punit;
857 }
859 }
860
861 /* If the unit in focus is at this tile, show that on top */
863 if (punit != punit_moving && unit_tile(punit) == ptile) {
864 return punit;
865 }
867
868 /* If a city is here, return nothing (unit hidden by city). */
869 if (tile_city(ptile)) {
870 return NULL;
871 }
872
873 /* Iterate through the units to find the best one we prioritize this way:
874 1: owned transporter.
875 2: any owned unit
876 3: any transporter
877 4: any unit
878 (always return first in stack). */
881 if (!unit_transported(punit)) {
883 return punit;
884 } else if (!panyowned) {
886 }
887 }
888 } else if (!ptptother && !unit_transported(punit)) {
891 } else if (!panyother) {
893 }
894 }
896
898}
899
900/**********************************************************************/
905{
906 static struct timer *blink_timer = NULL;
908
909 if (get_num_units_in_focus() > 0) {
912
913 /* If we lag, we don't try to catch up. Instead we just start a
914 * new blink_time on every update. */
916 blink_timer != NULL ? NULL : "blink");
918
920 /* We used to unqueue here, but that's inherently risky
921 * for a function run from a timer - the UI can be in any
922 * inconsistent state. */
925 }
926
928 }
929
930 return blink_time;
931}
932
933/**********************************************************************/
938{
939 static struct timer *blink_timer = NULL;
940 const double blink_time = 0.5; /* half-second blink interval */
941
942 if (NULL != client.conn.playing
947 int is_waiting = 0, is_moving = 0;
948 bool blocking_mode;
949 struct option *opt;
950
952 if (opt != NULL) {
954 } else {
956 }
957
958 players_iterate_alive(pplayer) {
959 if ((pplayer->is_connected || blocking_mode)
960 && is_player_phase(pplayer, game.info.phase)) {
961 if (pplayer->phase_done) {
962 is_waiting++;
963 } else {
964 is_moving++;
965 }
966 }
968
969 if (is_moving == 1 && is_waiting > 0) {
970 update_turn_done_button(FALSE); /* stress the slow player! */
971 }
973 blink_timer != NULL ? NULL : "blink");
975 }
977 }
978
979 return blink_time;
980}
981
982/**********************************************************************/
997void update_unit_pix_label(struct unit_list *punitlist)
998{
999 int i;
1000
1001 /* Check for any change in the unit's state. This assumes that a unit's
1002 * orders cannot be changed directly but must be removed and then reset. */
1004 && C_S_OVER != client_state()) {
1005 /* There used to be a complicated and bug-prone check here to see if
1006 * the unit had actually changed. This was misguided since the stacked
1007 * units (below) are redrawn in any case. Unless we write a general
1008 * system for unit updates here we might as well just redraw it every
1009 * time. */
1010 struct unit *punit = unit_list_get(punitlist, 0);
1011
1012 set_unit_icon(-1, punit);
1013
1014 i = 0; /* index into unit_below_canvas */
1016 if (aunit != punit) {
1017 if (i < num_units_below) {
1019 }
1020 i++;
1021 }
1022 }
1024
1025 if (i > num_units_below) {
1027 } else {
1029 for (; i < num_units_below; i++) {
1031 }
1032 }
1033 } else {
1034 for (i = -1; i < num_units_below; i++) {
1036 }
1038 }
1039}
1040
1041/**********************************************************************/
1045{
1048
1051 /* If one of the units is the focus unit, make sure hidden-focus is
1052 * disabled. We don't just do this as a check later because then
1053 * with a blinking unit it would just disappear again right after the
1054 * battle. */
1056 }
1057}
1058
1059/**********************************************************************/
1064{
1065 struct unit *old_actor_unit;
1066
1067 /* IDENTITY_NUMBER_ZERO is accepted for cases where the unit is gone
1068 * without a trace. */
1072 "Decision taken for %d but selection is for %d.",
1074
1076 if (old_actor_unit != NULL
1077 && old_actor_unit->client.act_prob_cache != NULL) {
1078 FC_FREE(old_actor_unit->client.act_prob_cache);
1079 }
1080
1081 /* Stop objecting to allowing the next unit to ask. */
1083
1084 /* Clean up any client specific assumptions. */
1086}
1087
1088/**********************************************************************/
1093{
1095 /* Have the server record that a decision no longer is wanted. */
1098 }
1099}
1100
1101/**********************************************************************/
1105{
1106 struct unit *old;
1107
1109
1110 /* Go to the next unit in focus that needs a decision. */
1112 if (old != funit && should_ask_server_for_actions(funit)) {
1114 return;
1115 }
1117}
1118
1119/**********************************************************************/
1123{
1126
1128 /* Getting feed back may be urgent. A unit standing next to an enemy
1129 * could be killed while waiting. */
1131 } else if (can_client_issue_orders()
1133 /* No need to wait. The actor unit is in focus. No other actor unit
1134 * is currently asking about action selection. */
1136 }
1137}
1138
1139/**********************************************************************/
1143 action_id act_id, int sub_tgt_id)
1144{
1145 struct unit_list *punits = get_units_in_focus();
1146
1147 fc_assert_ret(act_id == ACTION_NONE
1149
1150 if (unit_list_size(punits) == 0) {
1151 return;
1152 }
1153
1155 /* An action has been specified. */
1157
1159 if (!unit_can_do_action(punit, act_id)) {
1160 /* This unit can't perform the action specified in the last
1161 * order. */
1162
1163 struct astring astr = ASTRING_INIT;
1164
1166 action_id_get_role(act_id),
1167 TRUE)) {
1168 /* ...but other units can perform it. */
1169
1171 /* TRANS: Only Nuclear or ICBM can do Explode
1172 * Nuclear. */
1173 _("Only %s can do %s."),
1174 astr_str(&astr),
1176
1177 astr_free(&astr);
1178 } else {
1180 /* TRANS: Spy can't do Explode Nuclear. */
1181 _("%s can't do %s."),
1184 }
1185
1186 return;
1187 }
1189 }
1190
1193 NO_TARGET, sub_tgt_id, act_id, last_order);
1198 } else {
1200 /* Adding a long range action in the middle isn't handled yet */
1203 }
1204}
1205
1206/**********************************************************************/
1209static bool can_units_attack_at(struct unit_list *punits,
1210 const struct tile *ptile)
1211{
1214 && can_unit_attack_tile(punit, NULL, ptile)) {
1215 return TRUE;
1216 }
1218
1219 return FALSE;
1220}
1221
1222/**********************************************************************/
1227void control_mouse_cursor(struct tile *ptile)
1228{
1229 struct unit *punit = NULL;
1230 struct city *pcity = NULL;
1231 struct unit_list *active_units = get_units_in_focus();
1233
1235 return;
1236 }
1237
1238 if (C_S_RUNNING != client_state()) {
1240 return;
1241 }
1242
1243 if (is_server_busy()) {
1244 /* Server will not accept any commands. */
1246 return;
1247 }
1248
1249 if (!ptile) {
1250 if (hover_tile) {
1251 /* hover_tile is the tile that was previously under the mouse cursor. */
1252 ptile = hover_tile;
1253 } else {
1255 return;
1256 }
1257 } else {
1258 hover_tile = ptile;
1259 }
1260
1261 punit = find_visible_unit(ptile);
1262 pcity = ptile ? tile_city(ptile) : NULL;
1263
1264 switch (hover_state) {
1265 case HOVER_NONE:
1266 if (NULL != punit
1267 && unit_owner(punit) == client_player()) {
1268 /* Set mouse cursor to select a unit. */
1270 } else if (NULL != pcity
1272 /* Set mouse cursor to select a city. */
1274 } else {
1275 /* Set default mouse cursor, because nothing selectable found. */
1276 }
1277 break;
1278 case HOVER_GOTO:
1279 /* Determine if the goto is valid, invalid, nuke or will attack. */
1280 if (is_valid_goto_destination(ptile)) {
1283 /* Goto results in nuclear attack. */
1285 } else if (can_units_attack_at(active_units, ptile)) {
1286 /* Goto results in military attack. */
1288 } else if (is_enemy_city_tile(ptile, client.conn.playing)) {
1289 /* Goto results in attack of enemy city. */
1291 } else {
1293 }
1294 } else {
1296 }
1297 break;
1298 case HOVER_PATROL:
1299 if (is_valid_goto_destination(ptile)) {
1301 } else {
1303 }
1304 break;
1305 case HOVER_CONNECT:
1306 if (is_valid_goto_destination(ptile)) {
1308 } else {
1310 }
1311 break;
1312 case HOVER_TELEPORT:
1313 /* FIXME: check for invalid tiles. */
1315 break;
1316 case HOVER_PARADROP:
1317 /* FIXME: check for invalid tiles. */
1319 break;
1320 case HOVER_ACT_SEL_TGT:
1321 case HOVER_GOTO_SEL_TGT:
1322 /* Select a tile to target / find targets on. */
1324 break;
1325 };
1326
1328}
1329
1330/**********************************************************************/
1333static bool is_activity_on_tile(struct tile *ptile,
1334 enum unit_activity activity)
1335{
1336 unit_list_iterate(ptile->units, punit) {
1337 if (punit->activity == activity) {
1338 return TRUE;
1339 }
1341
1342 return FALSE;
1343}
1344
1345/**********************************************************************/
1350 const struct extra_type *pextra,
1351 const struct unit *punit,
1352 const struct player *pplayer, int rec)
1353{
1354 int activity_mc = 0;
1355 struct terrain *pterrain = tile_terrain(ptile);
1356 const struct civ_map *nmap = &(wld.map);
1357
1358 if (rec > MAX_EXTRA_TYPES) {
1359 return -1;
1360 }
1361
1362 if (!is_extra_caused_by(pextra, EC_ROAD)) {
1363 return -1;
1364 }
1365
1366 extra_deps_iterate(&(pextra->reqs), pdep) {
1367 if (!tile_has_extra(ptile, pdep)) {
1368 int single_mc;
1369
1371 pplayer, rec + 1);
1372
1373 if (single_mc < 0) {
1374 return -1;
1375 }
1376
1378 }
1380
1381 /* Can build road after that? */
1382 if (punit != NULL) {
1383 if (!can_build_road(nmap, extra_road_get(pextra), punit, ptile)) {
1384 return -1;
1385 }
1386 } else if (pplayer != NULL) {
1388 pplayer, ptile)) {
1389 return -1;
1390 }
1391 }
1392
1393 tile_add_extra(ptile, pextra);
1394
1396
1397 return activity_mc;
1398}
1399
1400/*******************************************************************/
1404static bool can_be_irrigated(const struct tile *ptile,
1405 const struct unit *punit)
1406{
1407 struct terrain* pterrain = tile_terrain(ptile);
1408 struct universal for_unit = { .kind = VUT_UTYPE,
1409 .value.utype = unit_type_get(punit)};
1410 struct universal for_tile = { .kind = VUT_TERRAIN,
1411 .value.terrain = tile_terrain(ptile)};
1412
1413 if (T_UNKNOWN == pterrain) {
1414 return FALSE;
1415 }
1416
1418 &for_unit, &for_tile);
1419}
1420
1421/**********************************************************************/
1428 enum unit_activity activity,
1429 struct extra_type *tgt)
1430{
1431 struct tile *ptile = unit_tile(punit);
1432 struct road_type *proad = NULL;
1433 const struct req_context unit_ctxt = {
1434 .unit = punit,
1435 .unittype = unit_type_get(punit),
1436 };
1437
1438 /* HACK: This code duplicates that in
1439 * can_unit_do_activity_targeted_at(). The general logic here is that
1440 * the connect is allowed if both:
1441 * (1) the unit can do that activity type, in general
1442 * (2) either
1443 * (a) the activity has already been completed at this tile
1444 * (b) it can be done by the unit at this tile. */
1445 switch (activity) {
1446 case ACTIVITY_GEN_ROAD:
1447 {
1448 struct tile *vtile;
1449 int build_time;
1450
1452
1453 proad = extra_road_get(tgt);
1454
1455 if (tile_has_road(ptile, proad)) {
1456 /* This tile has road, can unit build road to other tiles too? */
1458 }
1459
1460 /* To start connect, unit must be able to build road to this
1461 * particular tile. */
1462 vtile = tile_virtual_new(ptile);
1463 build_time = check_recursive_road_connect(vtile, tgt, punit, NULL, 0);
1465
1466 return build_time >= 0;
1467 }
1468
1469 case ACTIVITY_IRRIGATE:
1470 /* Special case for irrigation: only irrigate to make S_IRRIGATION,
1471 * never to transform tiles. */
1473 return FALSE;
1474 }
1475 if (tile_has_extra(ptile, tgt)) {
1477 }
1478
1479 return can_be_irrigated(ptile, punit)
1480 && can_build_extra(tgt, punit, ptile)
1481 && !is_activity_on_tile(ptile,
1483 default:
1484 break;
1485 }
1486
1487 return FALSE;
1488}
1489
1490/**********************************************************************/
1495 struct extra_type *tgt)
1496{
1497 struct unit_list *punits = get_units_in_focus();
1498
1499 if (!can_units_do_connect(punits, activity, tgt)) {
1500 return;
1501 }
1502
1503 if (hover_state != HOVER_CONNECT || connect_activity != activity
1504 || (connect_tgt != tgt
1505 && (activity == ACTIVITY_GEN_ROAD
1506 || activity == ACTIVITY_IRRIGATE))) {
1508 activity, tgt, NO_TARGET, NO_TARGET,
1514 } else {
1517 }
1518}
1519
1520/**********************************************************************/
1524{
1525 struct tile *ptile = unit_tile(punit);
1526 struct unit *plast = NULL;
1527
1528 if (get_transporter_capacity(punit) == 0) {
1530 _("Only transporter units can be unloaded."));
1531 return NULL;
1532 }
1533
1534 unit_list_iterate(ptile->units, pcargo) {
1537
1538 if (pcargo->activity == ACTIVITY_SENTRY) {
1540 USSDT_SENTRY, 0);
1541 }
1542
1543 if (unit_owner(pcargo) == unit_owner(punit)) {
1544 plast = pcargo;
1545 }
1546 }
1548
1549 return plast;
1550}
1551
1552/**********************************************************************/
1555void request_unit_airlift(struct unit *punit, struct city *pcity)
1556{
1557 request_do_action(ACTION_AIRLIFT, punit->id, pcity->id, 0, "");
1558}
1559
1560/**********************************************************************/
1565{
1566 struct pf_path *path;
1567
1568 if ((path = path_to_nearest_allied_city(punit))) {
1569 int turns = pf_path_last_position(path)->turn;
1570 int max_hp = unit_type_get(punit)->hp;
1571
1572 if (punit->hp + turns *
1574 - (max_hp * unit_class_get(punit)->hp_loss_pct / 100))
1575 < max_hp) {
1576 struct unit_order order;
1577
1579 order.dir = DIR8_ORIGIN;
1580 order.activity = ACTIVITY_SENTRY;
1581 order.target = NO_TARGET;
1582 order.sub_target = NO_TARGET;
1583 order.action = ACTION_NONE;
1584 send_goto_path(punit, path, &order);
1585 } else {
1586 send_goto_path(punit, path, NULL);
1587 }
1588 pf_path_destroy(path);
1589 }
1590}
1591
1592/**********************************************************************/
1595void wakeup_sentried_units(struct tile *ptile)
1596{
1597 if (!can_client_issue_orders()) {
1598 return;
1599 }
1600 unit_list_iterate(ptile->units, punit) {
1604 }
1605 }
1607}
1608
1609/**********************************************************************/
1616
1617/**************************************************************************
1618 Defines specific hash tables needed for request_unit_select().
1619**************************************************************************/
1620#define SPECHASH_TAG unit_type
1621#define SPECHASH_IKEY_TYPE struct unit_type *
1622#define SPECHASH_IDATA_TYPE void *
1623#include "spechash.h"
1624
1625#define SPECHASH_TAG continent
1626#define SPECHASH_INT_KEY_TYPE
1627#define SPECHASH_IDATA_TYPE void *
1628#include "spechash.h"
1629
1630/**********************************************************************/
1633void request_unit_select(struct unit_list *punits,
1636{
1637 const struct player *pplayer;
1638 const struct tile *ptile;
1639 struct unit *punit_first;
1640 struct tile_hash *tile_table;
1641 struct unit_type_hash *type_table;
1642 struct continent_hash *cont_table;
1643
1645 || unit_list_size(punits) < 1) {
1646 return;
1647 }
1648
1650
1651 if (seltype == SELTYPE_SINGLE) {
1653 return;
1654 }
1655
1656 pplayer = unit_owner(punit_first);
1660
1662 if (seltype == SELTYPE_SAME) {
1664 }
1665
1666 ptile = unit_tile(punit);
1667 if (selloc == SELLOC_TILE) {
1669 } else if (selloc == SELLOC_CONT) {
1671 }
1673
1674 if (selloc == SELLOC_TILE) {
1677 if (unit_owner(punit) != pplayer) {
1678 continue;
1679 }
1680 if (seltype == SELTYPE_SAME
1682 continue;
1683 }
1687 } else {
1688 unit_list_iterate(pplayer->units, punit) {
1689 ptile = unit_tile(punit);
1690 if ((seltype == SELTYPE_SAME
1692 || (selloc == SELLOC_CONT
1694 NULL))) {
1695 continue;
1696 }
1697
1700 }
1701
1705}
1706
1707/**********************************************************************/
1712 char *buf, size_t bufsize)
1713{
1714 fc_assert(buf != NULL || bufsize == 0);
1715
1716 if (bufsize > 0) {
1717 buf[0] = '\0';
1718 }
1719
1720 if (act == ACTION_JOIN_CITY) {
1721 if (bufsize > 0) {
1722 fc_snprintf(buf, bufsize, _("Joining a city uses the unit"));
1723 }
1724
1725 return TRUE;
1726 }
1727
1728 return FALSE;
1729}
1730
1731/**********************************************************************/
1743 int target_id, int sub_tgt, const char *name)
1744{
1745 char buf[400];
1746
1747 if (action_requires_confirmation(action, buf, sizeof(buf))) {
1748 struct act_confirmation_data *data = fc_malloc(sizeof(struct act_confirmation_data));
1749
1750 data->act = action;
1751 data->actor = actor_id;
1752 data->target = target_id;
1753 data->tgt_sub = sub_tgt;
1754
1755 if (name != NULL) {
1756 data->name = fc_strdup(name);
1757 } else {
1758 data->name = NULL;
1759 }
1760
1762 } else {
1763 struct unit *actor_unit = game_unit_by_number(actor_id);
1764
1765 /* Giving an order takes back control. */
1767
1769 actor_id, target_id, sub_tgt, name,
1770 action);
1771 }
1772}
1773
1774/**********************************************************************/
1779{
1780 if (confirm) {
1781 struct unit *actor_unit = game_unit_by_number(data->actor);
1782
1783 if (actor_unit != NULL) {
1784 /* Giving an order takes back control. */
1786
1788 data->actor,
1789 data->target,
1790 data->tgt_sub,
1791 data->name,
1792 data->act);
1793 }
1794 }
1795
1796 if (data->name != NULL) {
1797 free(data->name);
1798 }
1799
1800 free(data);
1801}
1802
1803/**********************************************************************/
1811 int target_id)
1812{
1814 actor_id, target_id, action,
1815 /* Users that need the answer in the
1816 * background should send the packet them
1817 * self. At least for now. */
1819}
1820
1821/**********************************************************************/
1830{
1831 struct city *pcity;
1832
1833 if ((pcity = tile_city(unit_tile(punit)))) {
1834 /* Try to join the city. */
1835 request_do_action(ACTION_JOIN_CITY, punit->id, pcity->id, 0, "");
1836 } else {
1837 /* The reply will trigger a dialog to name the new city. */
1839 }
1840}
1841
1842/**********************************************************************/
1849 struct tile *dest_tile)
1850{
1851 struct packet_unit_orders p;
1852 int dir;
1853
1855
1856 if (dir == -1) {
1857 /* The unit isn't located next to the destination tile. */
1858 return;
1859 }
1860
1861 memset(&p, 0, sizeof(p));
1862
1863 p.repeat = FALSE;
1864 p.vigilant = FALSE;
1865
1866 p.unit_id = punit->id;
1869
1870 p.length = 1;
1871 p.orders[0].order = ORDER_MOVE;
1872 p.orders[0].dir = dir;
1874 p.orders[0].target = NO_TARGET;
1876 p.orders[0].action = ACTION_NONE;
1877
1880}
1881
1882/**********************************************************************/
1892{
1893 struct packet_unit_orders p;
1894 struct tile *dest_tile;
1895
1896 /* Catches attempts to move off map */
1897 dest_tile = mapstep(&(wld.map), unit_tile(punit), dir);
1898 if (!dest_tile) {
1899 return;
1900 }
1901
1902 if (!can_unit_exist_at_tile(&(wld.map), punit, dest_tile)) {
1903 if (request_transport(punit, dest_tile)) {
1904 return;
1905 }
1906 }
1907
1908 /* The goto system isn't used to send the order because that would
1909 * prevent direction movement from overriding it.
1910 * Example of a situation when overriding the goto system is useful:
1911 * The goto system creates a longer path to make a move legal. The player
1912 * wishes to order the illegal move so the server will explain why the
1913 * short move is illegal. */
1914
1915 memset(&p, 0, sizeof(p));
1916
1917 p.repeat = FALSE;
1918 p.vigilant = FALSE;
1919
1920 p.unit_id = punit->id;
1922 p.dest_tile = tile_index(dest_tile);
1923
1924 p.length = 1;
1927 p.orders[0].dir = dir;
1929 p.orders[0].target = NO_TARGET;
1931 p.orders[0].action = ACTION_NONE;
1932
1935}
1936
1937/**********************************************************************/
1945
1946/**********************************************************************/
1951 enum unit_activity act,
1952 struct extra_type *tgt)
1953{
1954 if (!can_client_issue_orders()) {
1955 return;
1956 }
1957
1958 /* Callers rely on this to take back control from server side agents. */
1960
1961 if (tgt == NULL) {
1963 } else {
1965 }
1966}
1967
1968/**********************************************************************/
1972{
1973 struct client_disband_unit_data *data = p;
1974
1975 free(data);
1976}
1977
1978/**********************************************************************/
1981static void do_disband_alternative(void *p)
1982{
1983 struct unit *punit;
1984 struct city *pcity;
1985 struct tile *ptile;
1986 int last_request_id_used;
1987 struct client_disband_unit_data *next;
1988 struct client_disband_unit_data *data = p;
1989 int act;
1990 const struct civ_map *nmap = &(wld.map);
1991
1993
1994 /* Fetch the unit to get rid of. */
1996
1997 if (punit == NULL) {
1998 /* Success! It is gone. */
1999 return;
2000 }
2001
2002 if (data->alt == -1) {
2003 /* All alternatives have been tried. */
2005 /* TRANS: Unable to get rid of Leader. */
2006 _("Unable to get rid of %s."),
2008 return;
2009 }
2010
2011 act = disband_unit_alternatives[data->alt];
2012
2013 /* Prepare the data for the next try in case this try fails. */
2014 next = fc_malloc(sizeof(struct client_disband_unit_data));
2015 next->unit_id = data->unit_id;
2016 next->alt = data->alt - 1;
2017
2018 /* Latest request ID before trying to send a request. */
2019 last_request_id_used = client.conn.client.last_request_id_used;
2020
2021 /* Send a request to the server unless it is known to be pointless. */
2022 switch (action_id_get_target_kind(act)) {
2023 case ATK_CITY:
2024 if ((pcity = tile_city(unit_tile(punit)))
2026 act, pcity))) {
2027 request_do_action(act, punit->id, pcity->id, 0, "");
2028 }
2029 break;
2030 case ATK_UNIT:
2032 request_do_action(act, punit->id, punit->id, 0, "");
2033 }
2034 break;
2035 case ATK_UNITS:
2036 if ((ptile = unit_tile(punit))
2038 request_do_action(act, punit->id, ptile->index, 0, "");
2039 }
2040 break;
2041 case ATK_TILE:
2042 if ((ptile = unit_tile(punit))
2044 ptile, NULL))) {
2045 request_do_action(act, punit->id, ptile->index, 0, "");
2046 }
2047 break;
2048 case ATK_EXTRAS:
2049 if ((ptile = unit_tile(punit))
2051 ptile, NULL))) {
2052 request_do_action(act, punit->id, ptile->index, 0, "");
2053 }
2054 break;
2055 case ATK_SELF:
2057 request_do_action(act, punit->id, punit->id, 0, "");
2058 }
2059 break;
2060 case ATK_COUNT:
2062 break;
2063 }
2064
2065 if (last_request_id_used != client.conn.client.last_request_id_used) {
2066 /* A request was sent. */
2067
2068 /* Check if it worked. Move on if it didn't. */
2073 } else {
2074 /* No request was sent. */
2075
2076 /* Move on. */
2078
2079 /* Won't be freed by anyone else. */
2081 }
2082}
2083
2084/**********************************************************************/
2088{
2089 struct client_disband_unit_data *data;
2090
2091 /* Set up disband data. Start at the end of the array. */
2092 data = fc_malloc(sizeof(struct client_disband_unit_data));
2093 data->unit_id = punit->id;
2094 data->alt = 2;
2095
2096 /* Begin. */
2098
2099 /* Won't be freed by anyone else. */
2101}
2102
2103/**********************************************************************/
2107{
2108 struct city *pcity = tile_city(unit_tile(punit));
2109
2110 if (pcity) {
2111 request_do_action(ACTION_HOME_CITY, punit->id, pcity->id, 0, "");
2112 }
2113}
2114
2115/**********************************************************************/
2119{
2120 struct city *pcity = tile_city(unit_tile(punit));
2121
2122 if (pcity) {
2124 }
2125}
2126
2127/**********************************************************************/
2134
2135/**********************************************************************/
2142{
2143 if (punit) {
2145 agent);
2146 }
2147}
2148
2149/**********************************************************************/
2154{
2157 } else if (punit) {
2159 _("Only settler units can be put into auto mode."));
2160 }
2161}
2162
2163/**********************************************************************/
2169 struct tile *ptile)
2170{
2171 if (!ptrans) {
2173 }
2174
2175 if (ptrans
2179 same_pos(unit_tile(pcargo), ptile)
2182 enum gen_action act_id = action_id(paction);
2183
2185 ptrans))) {
2186 /* Try the first action that may be legal. */
2187 /* Implement something like do_disband_alternative() if a ruleset
2188 * appears where this isn't good enough. */
2189 request_do_action(act_id, pcargo->id, ptrans->id, 0, "");
2190 break;
2191 }
2193
2194 /* Sentry the unit. */
2195 /* FIXME: Should not sentry if above loading fails (transport moved away,
2196 * or filled already in server side) */
2198 USSDT_SENTRY, 1);
2199 }
2200}
2201
2202/**********************************************************************/
2207{
2209
2211 && ptrans != NULL
2216 pcargo->id, ptrans->id, 0, "");
2217 } else {
2219 ptrans->id, pcargo->id, 0, "");
2220 }
2221
2223 && pcargo->activity == ACTIVITY_SENTRY) {
2224 /* Activate the unit. */
2226 USSDT_SENTRY, 0);
2227 }
2228 }
2229}
2230
2231/**********************************************************************/
2236{
2237 struct city *target_city;
2238
2239 if (!((target_city = tile_city(unit_tile(punit))))) {
2240 return;
2241 }
2242
2243 if (action == ACTION_TRADE_ROUTE) {
2245 target_city->id, 0, "");
2246 } else if (action == ACTION_HELP_WONDER) {
2248 target_city->id, 0, "");
2249 } else {
2250 log_error("request_unit_caravan_action() Bad action (%d)", action);
2251 }
2252}
2253
2254/**********************************************************************/
2258void request_unit_paradrop(struct unit_list *punits)
2259{
2260 bool can = FALSE;
2261 struct tile *offender = NULL;
2262
2263 if (unit_list_size(punits) == 0) {
2264 return;
2265 }
2267 if (can_unit_paradrop(&(wld.map), punit)) {
2268 can = TRUE;
2269 break;
2270 }
2271 if (!offender) { /* Take first offender tile/unit */
2273 }
2275 if (can) {
2277 ftc_client,
2278 /* TRANS: paradrop target tile. */
2279 _("Click on a tile to paradrop to it."));
2280
2284 } else {
2286 _("Only paratrooper units can do this."));
2287 }
2288}
2289
2290/**********************************************************************/
2294static void request_unit_teleport(struct unit_list *punits)
2295{
2296 bool can = FALSE;
2297 struct tile *offender = NULL;
2298
2299 if (unit_list_size(punits) == 0) {
2300 return;
2301 }
2302
2304 if (can_unit_teleport(&(wld.map), punit)) {
2305 can = TRUE;
2306 break;
2307 }
2308 if (!offender) { /* Take first offender tile/unit */
2310 }
2312
2313 if (can) {
2315 ftc_client,
2316 /* TRANS: teleport target tile. */
2317 _("Click on a tile to teleport to it."));
2318
2322 } else {
2324 _("Only teleporting units can do this."));
2325 }
2326}
2327
2328/**********************************************************************/
2332{
2333 struct unit_list *punits = get_units_in_focus();
2334
2335 if (unit_list_size(punits) == 0) {
2336 return;
2337 }
2338
2339 if (hover_state != HOVER_PATROL) {
2345 } else {
2348 }
2349}
2350
2351/**********************************************************************/
2361
2362/**********************************************************************/
2372
2373/**********************************************************************/
2377{
2378 if (!game.info.pillage_select) {
2379 /* Leave choice up to the server */
2381 } else {
2383 int count = 0;
2384
2388 potential)) {
2390 count++;
2391 }
2393
2394 if (count > 1) {
2396 } else {
2397 /* Should be only one choice... */
2399
2400 if (target != NULL) {
2402 }
2403 }
2404 }
2405}
2406
2407/**********************************************************************/
2419
2420/**********************************************************************/
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
2717}
2718
2719/**********************************************************************/
2723{
2724 if (!can_client_change_view()) {
2725 return;
2726 }
2727
2730}
2731
2732/**********************************************************************/
2736{
2737 if (!can_client_change_view()) {
2738 return;
2739 }
2740
2743}
2744
2745/**********************************************************************/
2749{
2750 if (!can_client_change_view()) {
2751 return;
2752 }
2753
2757}
2758
2759/**********************************************************************/
2763{
2764 struct tile *ptile = find_a_focus_unit_tile_to_center_on();
2765
2766 if (ptile) {
2767 center_tile_mapcanvas(ptile);
2768 }
2769}
2770
2771/**********************************************************************/
2775void request_units_wait(struct unit_list *punits)
2776{
2780 if (punits == get_units_in_focus()) {
2782 }
2783}
2784
2785/**********************************************************************/
2789{
2790 if (get_num_units_in_focus() > 0) {
2793 /* If any of the focused units are busy, keep all of them
2794 * in focus; another tap of the key will dismiss them */
2795 if (punit->activity != ACTIVITY_IDLE) {
2797 }
2803 if (new_status == FOCUS_DONE) {
2805 }
2806 }
2807}
2808
2809/**********************************************************************/
2815{
2816 struct tile *src_tile = unit_tile(punit);
2820
2823
2824 if (!was_teleported
2826 && !unit_transported(punit)) {
2828 unit_type_get(punit)->sound_move_alt,
2829 NULL);
2830 }
2831
2839 || (punit->ssa_controller == SSA_NONE))
2842 }
2843
2844 if (hover_state != HOVER_NONE && in_focus) {
2845 /* Cancel current goto/patrol/connect/nuke command. */
2848 }
2849
2850 unit_list_remove(src_tile->units, punit);
2851
2852 if (!unit_transported(punit)) {
2853 /* Mark the unit as moving unit, then find_visible_unit() won't return
2854 * it. It is especially useful to don't draw many times the unit when
2855 * refreshing the canvas. */
2857
2858 /* We have to refresh the tile before moving. This will draw
2859 * the tile without the unit (because it was unlinked above). */
2861
2863 && punit->ssa_controller != SSA_NONE) {
2864 /* Dont animate automatic units */
2865 } else if (do_animation) {
2866 int dx, dy;
2867
2868 /* For the duration of the animation the unit exists at neither
2869 * tile. */
2870 map_distance_vector(&dx, &dy, src_tile, dst_tile);
2871 move_unit_map_canvas(punit, src_tile, dx, dy);
2872 }
2873 }
2874
2877
2878 if (!unit_transported(punit)) {
2879 /* For find_visible_unit(), see above. */
2881
2883 }
2884
2885 /* With the "full" city bar we have to update the city bar when units move
2886 * into or out of a city. For foreign cities this is handled separately,
2887 * via the occupied field of the short-city packet. */
2888 if (NULL != tile_city(src_tile)
2891 }
2892 if (NULL != tile_city(dst_tile)
2895 }
2896
2897 if (in_focus) {
2898 menus_update();
2899 }
2900}
2901
2902/**********************************************************************/
2906static void do_unit_act_sel_vs(struct tile *ptile)
2907{
2910 /* Have the server record that an action decision is wanted for
2911 * this unit against this tile. */
2913 USSDT_QUEUE, tile_index(ptile));
2914 }
2916}
2917
2918/**********************************************************************/
2921void do_map_click(struct tile *ptile, enum quickselect_type qtype)
2922{
2923 struct city *pcity = tile_city(ptile);
2924 struct unit_list *punits = get_units_in_focus();
2925 bool maybe_goto = FALSE;
2926
2927 if (hover_state != HOVER_NONE) {
2928 switch (hover_state) {
2929 case HOVER_NONE:
2930 break;
2931 case HOVER_GOTO:
2932 do_unit_goto(ptile);
2933 break;
2934 case HOVER_TELEPORT:
2936 do_unit_teleport_to(punit, ptile);
2938 break;
2939 case HOVER_PARADROP:
2941 do_unit_paradrop_to(punit, ptile);
2943 break;
2944 case HOVER_CONNECT:
2946 break;
2947 case HOVER_PATROL:
2948 do_unit_patrol_to(ptile);
2949 break;
2950 case HOVER_ACT_SEL_TGT:
2951 do_unit_act_sel_vs(ptile);
2952 break;
2953 case HOVER_GOTO_SEL_TGT:
2955 do_unit_goto(ptile);
2956 break;
2957 }
2958
2961 } else if (qtype != SELECT_POPUP && qtype != SELECT_APPEND) {
2962 /* Bypass stack or city popup if quickselect is specified. */
2963 struct unit *qunit = quickselect(ptile, qtype);
2964
2965 if (qunit) {
2968 }
2969 } else if (NULL != pcity
2971 /* Otherwise use popups. */
2972 popup_city_dialog(pcity);
2973 } else if (unit_list_size(ptile->units) == 0
2974 && NULL == pcity
2975 && get_num_units_in_focus() > 0) {
2977 } else if (unit_list_size(ptile->units) == 1
2979 struct unit *punit = unit_list_get(ptile->units, 0);
2980
2984 if (qtype == SELECT_APPEND) {
2986 } else {
2988 }
2989 }
2990 } else if (pcity) {
2991 /* Don't hide the unit in the city. */
2993 }
2994 } else if (unit_list_size(ptile->units) > 0) {
2995 /* The stack list is always popped up, even if it includes enemy units.
2996 * If the server doesn't want the player to know about them it shouldn't
2997 * tell them! The previous behavior would only pop up the stack if you
2998 * owned a unit on the tile. This gave cheating clients an advantage,
2999 * and also showed you allied units if (and only if) you had a unit on
3000 * the tile (inconsistent). */
3002 }
3003
3004 /* See mapctrl_common.c */
3008}
3009
3010/**********************************************************************/
3015static struct unit *quickselect(struct tile *ptile,
3017{
3018 int listsize = unit_list_size(ptile->units);
3019 struct unit *panytransporter = NULL,
3023
3025
3026 if (qtype == SELECT_FOCUS) {
3027 return head_of_units_in_focus();
3028 }
3029
3030 if (listsize == 0) {
3031 return NULL;
3032 } else if (listsize == 1) {
3033 struct unit *punit = unit_list_get(ptile->units, 0);
3034 return (unit_owner(punit) == client.conn.playing) ? punit : NULL;
3035 }
3036
3037 /* Quickselect priorities. Units with moves left
3038 * before exhausted. Focus unit is excluded.
3039 *
3040 * SEA: Transporter
3041 * Sea unit
3042 * Any unit
3043 *
3044 * LAND: Military land unit
3045 * Non-combatant
3046 * Sea unit
3047 * Any unit
3048 */
3049
3050 unit_list_iterate(ptile->units, punit) {
3052 continue;
3053 }
3054 if (qtype == SELECT_SEA) {
3055 /* Transporter. */
3057 if (punit->moves_left > 0) {
3058 return punit;
3059 } else if (!panytransporter) {
3061 }
3062 }
3063 /* Any sea, pref. moves left. */
3065 if (punit->moves_left > 0) {
3066 if (!panymovesea) {
3068 }
3069 } else if (!panysea) {
3070 panysea = punit;
3071 }
3072 }
3073 } else if (qtype == SELECT_LAND) {
3075 if (punit->moves_left > 0) {
3076 if (!is_special_unit(punit)) {
3077 return punit;
3078 } else if (!panymoveland) {
3080 }
3081 } else if (!panyland) {
3082 panyland = punit;
3083 }
3084 }
3086 if (punit->moves_left > 0) {
3088 } else {
3089 panysea = punit;
3090 }
3091 }
3092 }
3093 if (punit->moves_left > 0 && !panymoveunit) {
3095 }
3096 if (!panyunit) {
3097 panyunit = punit;
3098 }
3100
3101 if (qtype == SELECT_SEA) {
3102 if (panytransporter) {
3103 return panytransporter;
3104 } else if (panymovesea) {
3105 return panymovesea;
3106 } else if (panysea) {
3107 return panysea;
3108 } else if (panymoveunit) {
3109 return panymoveunit;
3110 } else if (panyunit) {
3111 return panyunit;
3112 }
3113 }
3114 else if (qtype == SELECT_LAND) {
3115 if (panymoveland) {
3116 return panymoveland;
3117 } else if (panyland) {
3118 return panyland;
3119 } else if (panymovesea) {
3120 return panymovesea;
3121 } else if (panysea) {
3122 return panysea;
3123 } else if (panymoveunit) {
3124 return panymoveunit;
3125 } else if (panyunit) {
3126 return panyunit;
3127 }
3128 }
3129 return NULL;
3130}
3131
3132/**********************************************************************/
3136void do_unit_goto(struct tile *ptile)
3137{
3141
3144 return;
3145 }
3146
3147 if (is_valid_goto_draw_line(ptile)) {
3149 } else {
3151 _("Didn't find a route to the destination!"));
3152 }
3153}
3154
3155/**********************************************************************/
3158static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
3159{
3160 struct action *teleport_action = NULL;
3161
3162 action_iterate(act_id) {
3163 struct action *paction = action_by_number(act_id);
3164
3166 /* Not relevant. */
3167 continue;
3168 }
3169
3172 tile_city(ptile), NULL,
3173 ptile, NULL))) {
3174 if (teleport_action == NULL) {
3175 /* This is the first possible teleport action. */
3177 } else {
3178 /* More than one teleport action may be possible. The user must
3179 * choose. Have the server record that an action decision is wanted
3180 * for this unit so the dialog will be brought up. */
3182 USSDT_QUEUE, tile_index(ptile));
3183 return;
3184 }
3185 }
3187
3188 if (teleport_action != NULL) {
3190 tile_index(ptile), 0 , "");
3191 }
3192}
3193
3194/**********************************************************************/
3197void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
3198{
3199 struct action *paradrop_action = NULL;
3200
3201 action_iterate(act_id) {
3202 struct action *paction = action_by_number(act_id);
3203
3206 /* Not relevant. */
3207 continue;
3208 }
3209
3212 tile_city(ptile), NULL,
3213 ptile, NULL))) {
3214 if (paradrop_action == NULL) {
3215 /* This is the first possible paradrop action. */
3217 } else {
3218 /* More than one paradrop action may be possible. The user must
3219 * choose. Have the server record that an action decision is wanted
3220 * for this unit so the dialog will be brought up. */
3222 USSDT_QUEUE, tile_index(ptile));
3223 return;
3224 }
3225 }
3227
3228 if (paradrop_action != NULL) {
3230 tile_index(ptile), 0 , "");
3231 }
3232}
3233
3234/**********************************************************************/
3237void do_unit_patrol_to(struct tile *ptile)
3238{
3239 if (is_valid_goto_draw_line(ptile)
3242 } else {
3244 _("Didn't find a route to the destination!"));
3245 }
3246
3248}
3249
3250/**********************************************************************/
3253void do_unit_connect(struct tile *ptile,
3254 enum unit_activity activity,
3255 struct extra_type *tgt)
3256{
3257 if (is_valid_goto_draw_line(ptile)) {
3258 send_connect_route(activity, tgt);
3259 } else {
3261 _("Didn't find a route to the destination!"));
3262 }
3263
3265}
3266
3267/**********************************************************************/
3271{
3272 struct unit_list *punits = get_units_in_focus();
3274
3275 switch (hover_state) {
3276 case HOVER_GOTO_SEL_TGT:
3280 break;
3281 case HOVER_GOTO:
3282 case HOVER_PATROL:
3283 case HOVER_CONNECT:
3284 if (goto_pop_waypoint()) {
3285 break;
3286 }
3287 fc__fallthrough; /* else fall through: */
3288 case HOVER_TELEPORT:
3289 case HOVER_PARADROP:
3290 case HOVER_ACT_SEL_TGT:
3293
3297 break;
3298 case HOVER_NONE:
3299 break;
3300 };
3301}
3302
3303/**********************************************************************/
3308{
3310
3311 if (capital) {
3312 /* Center on the tile, and pop up the crosshair overlay. */
3315 } else {
3317 _("Oh my! You seem to have no capital!"));
3318 }
3319}
3320
3321/**********************************************************************/
3325{
3327}
3328
3329/**********************************************************************/
3333{
3334 int i = 0;
3335
3336 /* Could use unit_list_copy here instead. Just having safe genlists
3337 * wouldn't be sufficient since we don't want to skip units already
3338 * removed from focus... */
3340 if (i == 0) {
3342 } else {
3344 }
3345 i++;
3347}
3348
3349/**********************************************************************/
3361
3362/**********************************************************************/
3371
3372/**********************************************************************/
3383
3384/**********************************************************************/
3388 struct extra_type *tgt)
3389{
3390 request_unit_connect(activity, tgt);
3391}
3392
3393/**********************************************************************/
3397{
3398 struct tile *ptile;
3399
3402 && (ptile = unit_tile(punit))) {
3403 /* Have the server record that an action decision is wanted for this
3404 * unit. */
3406 USSDT_QUEUE, tile_index(ptile));
3407 }
3409}
3410
3411/**********************************************************************/
3419{
3420 struct unit_list *punits = get_units_in_focus();
3421
3423 /* The 2nd key press means that the actor should target its own
3424 * tile. */
3426
3427 /* Target tile selected. Clean up hover state. */
3430
3431 return;
3432 } else if (hover_state == HOVER_GOTO_SEL_TGT) {
3434
3435 /* We don't support long range actions in the middle of orders yet so
3436 * send it at once. */
3438
3439 /* Target tile selected. Clean up hover state. */
3442
3443 return;
3444 } else if (hover_state == HOVER_GOTO
3447
3449 ftc_client,
3450 /* TRANS: Perform action inside a goto. */
3451 _("Click on a tile to do %s against it."),
3453
3458
3459 return;
3460 }
3461
3463 ftc_client,
3464 /* TRANS: "Do..." action selection dialog target. */
3465 _("Click on a tile to act against it. "
3466 "Press 'd' again to act against own tile."));
3467
3470}
3471
3472/**********************************************************************/
3476{
3478}
3479
3480/**********************************************************************/
3484{
3486}
3487
3488/**********************************************************************/
3495
3496/**********************************************************************/
3500{
3502}
3503
3504/**********************************************************************/
3511
3512/**********************************************************************/
3516{
3518 /* TODO: Is falling back on ACTION_MARKETPLACE if not able to establish
3519 * a trade route trade a good idea or an unplecant surprice? */
3522 }
3524}
3525
3526/**********************************************************************/
3530{
3531 struct unit *pnext_focus = NULL, *plast;
3532
3536 }
3538
3539 if (pnext_focus) {
3541 /* Unfocus the ships, and advance the focus to the last unloaded unit.
3542 * If there is no unit unloaded (which shouldn't happen, but could if
3543 * the caller doesn't check if the transporter is loaded), the we
3544 * don't do anything. */
3548 }
3549}
3550
3551/**********************************************************************/
3558
3559/**********************************************************************/
3568
3569/**********************************************************************/
3585
3586/**********************************************************************/
3597
3598/**********************************************************************/
3610
3611/**********************************************************************/
3620
3621/**********************************************************************/
3632
3633/**********************************************************************/
3649
3650/**********************************************************************/
3659
3660/**********************************************************************/
3663static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
3664{
3667 cause,
3669 punit);
3670
3673 }
3675}
3676
3677/**********************************************************************/
3684
3685/**********************************************************************/
3696
3697/**********************************************************************/
3701{
3703}
3704
3705/**********************************************************************/
3716
3717/**********************************************************************/
3728
3729/**********************************************************************/
3746
3747/**********************************************************************/
3764
3765/**********************************************************************/
3776
3777/**********************************************************************/
3788
3789/**********************************************************************/
3792void key_unit_assign_battlegroup(int battlegroup, bool append)
3793{
3795 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3796 if (!append) {
3798 if (!unit_is_in_focus(punit)) {
3804 unit_list_remove(battlegroups[battlegroup], punit);
3805 }
3807 }
3809 if (punit->battlegroup != battlegroup) {
3810 if (punit->battlegroup >= 0
3813 }
3814 punit->battlegroup = battlegroup;
3817 battlegroup);
3818 unit_list_append(battlegroups[battlegroup], punit);
3820 }
3822 unit_list_iterate(battlegroups[battlegroup], punit) {
3825 }
3826}
3827
3828/**********************************************************************/
3831void key_unit_select_battlegroup(int battlegroup, bool append)
3832{
3834 && battlegroups >= 0 && battlegroup < MAX_NUM_BATTLEGROUPS) {
3835 int i = 0;
3836
3837 if (unit_list_size(battlegroups[battlegroup]) == 0 && !append) {
3839 return;
3840 }
3841
3842 /* FIXME: this is very inefficient and can be improved. */
3843 unit_list_iterate(battlegroups[battlegroup], punit) {
3844 if (i == 0 && !append) {
3846 } else {
3848 }
3849 i++;
3851 }
3852}
3853
3854/**********************************************************************/
3861
3862/**********************************************************************/
3869
3870/**********************************************************************/
3874{
3876}
3877
3878/**********************************************************************/
3885
3886/**********************************************************************/
3893
3894/**********************************************************************/
3901
3902/**********************************************************************/
3909
3910/**********************************************************************/
3918
3919/**********************************************************************/
3927
3928/**********************************************************************/
3935
3936/**********************************************************************/
3944
3945/**********************************************************************/
3952
3953/**********************************************************************/
3957{
3959}
3960
3961/**********************************************************************/
3965{
3967}
3968
3969/**********************************************************************/
3973{
3975}
3976
3977/**********************************************************************/
3984
3985/**********************************************************************/
3989{
3991}
3992
3993/**********************************************************************/
3997{
3999}
4000
4001/**********************************************************************/
4005{
4007}
4008
4009/**********************************************************************/
4013{
4015}
4016
4017/**********************************************************************/
4021{
4023}
4024
4025/**********************************************************************/
4029{
4031}
4032
4033/**********************************************************************/
4037{
4039}
4040
4041/**********************************************************************/
4048
4049/**********************************************************************/
4056
4057/**********************************************************************/
4064
4065/**********************************************************************/
4072
4073/**********************************************************************/
4080
4081/**********************************************************************/
4088
4089/**********************************************************************/
4099
4100/**********************************************************************/
4103void finish_city(struct tile *ptile, const char *name)
4104{
4105 unit_list_iterate(ptile->units, punit) {
4107 /* Unit will disappear only in case city building still success.
4108 * Cancel city building status just in case something has changed
4109 * to prevent city building in the meanwhile and unit will remain
4110 * alive. */
4113 0, name);
4114 }
4116}
4117
4118/**********************************************************************/
4122void cancel_city(struct tile *ptile)
4123{
4124 unit_list_iterate(ptile->units, punit) {
4127}
const char * action_name_translation(const struct action *action)
Definition actions.c:1991
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5821
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:5342
struct act_prob action_prob_vs_extras(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:5425
struct act_prob action_prob_self(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id)
Definition actions.c:5495
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:4984
bool action_id_exists(const action_id act_id)
Definition actions.c:1829
struct act_prob action_prob_unit_vs_tgt(const struct civ_map *nmap, const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Definition actions.c:5517
struct act_prob action_prob_vs_stack(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:5259
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:5067
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:945
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:481
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define action_has_result(_act_, _res_)
Definition actions.h:431
#define action_id_get_role(act_id)
Definition actions.h:696
#define action_by_result_iterate_end
Definition actions.h:485
#define action_iterate_end
Definition actions.h:465
#define action_id(_act_)
Definition actions.h:661
#define action_iterate(_act_)
Definition actions.h:461
#define action_id_get_target_kind(act_id)
Definition actions.h:652
#define action_id_has_result_safe(act_id, result)
Definition actions.h:665
#define ACTION_NONE
Definition actions.h:311
void astr_free(struct astring *astr)
Definition astring.c:153
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void audio_play_sound(const char *const tag, const char *const alt_tag, const char *const alt_tag2)
Definition audio.c:529
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Definition base.c:139
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:734
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:1092
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1241
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:311
char * incite_cost
Definition comments.c:75
double blink_turn_done_button(void)
Definition control.c:937
void key_coastline_toggle(void)
Definition control.c:3964
void key_irrigation_toggle(void)
Definition control.c:3980
void request_toggle_huts(void)
Definition control.c:2657
void key_unit_sentry(void)
Definition control.c:3768
void request_toggle_city_outlines(void)
Definition control.c:2410
void key_unit_road(void)
Definition control.c:3750
void request_unit_airlift(struct unit *punit, struct city *pcity)
Definition control.c:1555
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2814
void request_toggle_resources(void)
Definition control.c:2644
void request_toggle_city_names(void)
Definition control.c:2488
void key_recall_previous_focus_unit(void)
Definition control.c:3332
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Definition control.c:1848
void request_toggle_unit_stack_size(void)
Definition control.c:2553
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_city_output_toggle(void)
Definition control.c:3865
void request_toggle_focus_unit(void)
Definition control.c:2735
void request_toggle_city_output(void)
Definition control.c:2423
void request_unit_return(struct unit *punit)
Definition control.c:1564
void request_unit_fortify(struct unit *punit)
Definition control.c:2365
void key_unit_build_city(void)
Definition control.c:3365
void key_editor_recalculate_borders(void)
Definition control.c:4084
struct unit * request_unit_unload_all(struct unit *punit)
Definition control.c:1523
void request_unit_caravan_action(struct unit *punit, action_id action)
Definition control.c:2235
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1063
enum unit_orders goto_last_order
Definition control.c:96
void request_units_wait(struct unit_list *punits)
Definition control.c:2775
void request_unit_wakeup(struct unit *punit)
Definition control.c:1612
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:396
void key_focus_unit_toggle(void)
Definition control.c:4060
void request_toggle_map_grid(void)
Definition control.c:2436
void action_decision_request(struct unit *actor_unit)
Definition control.c:1122
void control_free(void)
Definition control.c:154
void request_toggle_mines(void)
Definition control.c:2618
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1044
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:1349
void key_unit_action_select(void)
Definition control.c:3396
void key_unit_auto_explore(void)
Definition control.c:3589
static int action_selection_in_progress_for
Definition control.c:119
static void do_disband_alternative(void *p)
Definition control.c:1981
void key_cancel_action(void)
Definition control.c:3270
void request_toggle_city_buycost(void)
Definition control.c:2527
void key_unit_auto_settle(void)
Definition control.c:3602
void clear_hover_state(void)
Definition control.c:328
void request_toggle_map_native(void)
Definition control.c:2462
void request_unit_patrol(void)
Definition control.c:2331
int num_units_below
Definition control.c:76
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3387
void key_city_full_bar_toggle(void)
Definition control.c:3897
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2168
void key_bases_toggle(void)
Definition control.c:3996
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2921
static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
Definition control.c:3663
void key_map_native_toggle(void)
Definition control.c:3889
void request_toggle_map_borders(void)
Definition control.c:2449
void key_resources_toggle(void)
Definition control.c:4004
static void request_unit_teleport(struct unit_list *punits)
Definition control.c:2294
static struct unit * punit_attacking
Definition control.c:105
void unit_focus_add(struct unit *punit)
Definition control.c:573
void unit_focus_set(struct unit *punit)
Definition control.c:518
static void do_unit_act_sel_vs(struct tile *ptile)
Definition control.c:2906
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1142
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3197
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:339
int goto_last_tgt
Definition control.c:94
struct extra_type * connect_tgt
Definition control.c:91
void key_unit_paradrop(void)
Definition control.c:3491
static bool can_units_attack_at(struct unit_list *punits, const struct tile *ptile)
Definition control.c:1209
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:1742
void key_end_turn(void)
Definition control.c:3324
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_toggle_irrigation(void)
Definition control.c:2605
static struct unit_list * current_focus
Definition control.c:79
static struct unit_list * previous_focus
Definition control.c:83
void request_unit_autosettlers(const struct unit *punit)
Definition control.c:2153
void request_unit_pillage(struct unit *punit)
Definition control.c:2376
void key_unit_teleport(void)
Definition control.c:3507
void request_center_focus_unit(void)
Definition control.c:2762
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void key_unit_shields_toggle(void)
Definition control.c:4052
void key_city_productions_toggle(void)
Definition control.c:3931
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1427
void key_unit_build_wonder(void)
Definition control.c:3375
void key_unit_plant(void)
Definition control.c:3708
void key_unit_fortress(void)
Definition control.c:3636
void key_unit_mine(void)
Definition control.c:3700
void unit_focus_try(struct unit *punit)
Definition control.c:502
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2106
void request_toggle_fog_of_war(void)
Definition control.c:2748
void key_unit_pillage(void)
Definition control.c:3720
void request_unit_unload(struct unit *pcargo)
Definition control.c:2206
void key_editor_toggle_fogofwar(void)
Definition control.c:4093
static void client_disband_unit_data_destroy(void *p)
Definition control.c:1971
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Definition control.c:2140
static struct unit * find_best_focus_candidate(bool accept_current)
Definition control.c:661
void request_action_details(action_id action, int actor_id, int target_id)
Definition control.c:1810
static struct unit * quickselect(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:3015
enum unit_activity connect_activity
Definition control.c:90
void request_toggle_units(void)
Definition control.c:2696
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:997
void key_unit_irrigate(void)
Definition control.c:3680
void request_unit_build_city(struct unit *punit)
Definition control.c:1829
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:255
static struct unit_list * urgent_focus_queue
Definition control.c:86
void key_unit_unload_all(void)
Definition control.c:3529
void key_cities_toggle(void)
Definition control.c:4028
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3353
void key_city_outlines_toggle(void)
Definition control.c:3857
void key_unit_homecity(void)
Definition control.c:3653
void request_unit_paradrop(struct unit_list *punits)
Definition control.c:2258
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:290
static int disband_unit_alternatives[3]
Definition control.c:69
void key_unit_patrol(void)
Definition control.c:3499
void request_toggle_city_full_bar(void)
Definition control.c:2475
void request_toggle_city_growth(void)
Definition control.c:2501
void key_unit_solid_bg_toggle(void)
Definition control.c:4044
void request_toggle_unit_solid_bg(void)
Definition control.c:2709
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void key_terrain_toggle(void)
Definition control.c:3956
void key_paths_toggle(void)
Definition control.c:3972
void request_unit_sentry(struct unit *punit)
Definition control.c:2354
void key_unit_wakeup_others(void)
Definition control.c:3562
bool non_ai_unit_focus
Definition control.c:125
static struct unit * punit_defending
Definition control.c:106
static struct tile * find_a_focus_unit_tile_to_center_on(void)
Definition control.c:418
enum cursor_hover_state hover_state
Definition control.c:89
void key_unit_stack_size_toggle(void)
Definition control.c:3948
static void store_previous_focus(void)
Definition control.c:194
void key_huts_toggle(void)
Definition control.c:4012
void key_fog_of_war_toggle(void)
Definition control.c:4068
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1494
void clear_unit_orders(struct unit *punit)
Definition control.c:481
void control_init(void)
Definition control.c:137
void request_toggle_terrain(void)
Definition control.c:2566
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1092
void key_unit_wait(void)
Definition control.c:3554
void key_units_toggle(void)
Definition control.c:4036
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:3253
int goto_last_sub_tgt
Definition control.c:95
void unit_focus_remove(struct unit *punit)
Definition control.c:603
void request_toggle_bases(void)
Definition control.c:2631
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3237
void key_unit_trade_route(void)
Definition control.c:3515
void request_toggle_coastline(void)
Definition control.c:2579
void key_unit_select_battlegroup(int battlegroup, bool append)
Definition control.c:3831
void key_map_grid_toggle(void)
Definition control.c:3873
void finish_city(struct tile *ptile, const char *name)
Definition control.c:4103
static struct unit * punit_moving
Definition control.c:102
void key_pollution_toggle(void)
Definition control.c:4020
struct unit * head_of_units_in_focus(void)
Definition control.c:410
static bool is_activity_on_tile(struct tile *ptile, enum unit_activity activity)
Definition control.c:1333
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:834
static bool can_be_irrigated(const struct tile *ptile, const struct unit *punit)
Definition control.c:1404
void key_city_growth_toggle(void)
Definition control.c:3914
void key_unit_action_select_tgt(void)
Definition control.c:3418
static struct unit_list * battlegroups[MAX_NUM_BATTLEGROUPS]
Definition control.c:99
void key_city_buycost_toggle(void)
Definition control.c:3923
int get_num_units_in_focus(void)
Definition control.c:185
void key_unit_transform(void)
Definition control.c:3780
void request_move_unit_direction(struct unit *punit, int dir)
Definition control.c:1891
static void current_focus_append(struct unit *punit)
Definition control.c:447
void key_unit_done(void)
Definition control.c:3475
static void current_focus_remove(struct unit *punit)
Definition control.c:467
static struct tile * hover_tile
Definition control.c:98
void key_city_trade_routes_toggle(void)
Definition control.c:3940
static void focus_units_changed(void)
Definition control.c:215
void request_toggle_city_trade_routes(void)
Definition control.c:2540
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:648
void request_unit_convert(struct unit *punit)
Definition control.c:2130
void request_toggle_paths(void)
Definition control.c:2592
void request_toggle_unit_shields(void)
Definition control.c:2722
void key_city_names_toggle(void)
Definition control.c:3905
void unit_register_battlegroup(struct unit *punit)
Definition control.c:275
void request_unit_select(struct unit_list *punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Definition control.c:1633
static bool action_requires_confirmation(action_id act, char *buf, size_t bufsize)
Definition control.c:1711
void unit_focus_update(void)
Definition control.c:801
void key_unit_airbase(void)
Definition control.c:3572
void key_unit_goto(void)
Definition control.c:3483
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1227
void key_unit_convert(void)
Definition control.c:3614
void key_unit_clean(void)
Definition control.c:3732
void key_center_capital(void)
Definition control.c:3307
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1595
void request_toggle_cities(void)
Definition control.c:2683
void key_unit_fortify(void)
Definition control.c:3624
void key_editor_toggle(void)
Definition control.c:4076
void key_unit_assign_battlegroup(int battlegroup, bool append)
Definition control.c:3792
void request_unit_move_done(void)
Definition control.c:2788
void auto_center_on_focus_unit(void)
Definition control.c:434
void key_unit_cultivate(void)
Definition control.c:3688
double blink_active_unit(void)
Definition control.c:904
void unit_focus_advance(bool accept_current)
Definition control.c:700
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void control_unit_killed(struct unit *punit)
Definition control.c:226
void request_toggle_city_productions(void)
Definition control.c:2514
void cancel_city(struct tile *ptile)
Definition control.c:4122
static void ask_server_for_actions(struct unit *punit)
Definition control.c:366
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1941
void request_toggle_pollution(void)
Definition control.c:2670
action_id goto_last_action
Definition control.c:93
void key_mines_toggle(void)
Definition control.c:3988
static void do_unit_teleport_to(struct unit *punit, struct tile *ptile)
Definition control.c:3158
void do_unit_goto(struct tile *ptile)
Definition control.c:3136
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
static bool can_ask_server_for_actions(void)
Definition control.c:352
void key_map_borders_toggle(void)
Definition control.c:3881
#define can_unit_do_activity_targeted_client(_punit_, _act_, _tgt_)
Definition control.h:43
#define MAX_NUM_UNITS_BELOW
Definition control.h:296
quickselect_type
Definition control.h:37
@ SELECT_LAND
Definition control.h:38
@ SELECT_APPEND
Definition control.h:38
@ SELECT_SEA
Definition control.h:38
@ SELECT_POPUP
Definition control.h:38
@ SELECT_FOCUS
Definition control.h:38
cursor_hover_state
Definition control.h:25
@ HOVER_GOTO
Definition control.h:27
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_TELEPORT
Definition control.h:28
@ HOVER_ACT_SEL_TGT
Definition control.h:32
@ HOVER_NONE
Definition control.h:26
@ HOVER_CONNECT
Definition control.h:30
@ HOVER_PATROL
Definition control.h:31
@ HOVER_GOTO_SEL_TGT
Definition control.h:33
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs action_selection_no_longer_in_progress_gui_specific
Definition dialogs_g.h:69
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city * target_city
Definition dialogs_g.h:56
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Definition effects.c:1070
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:790
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:533
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_deps_iterate(_reqs, _dep)
Definition extras.h:371
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_deps_iterate_end
Definition extras.h:379
#define EXTRA_NONE
Definition extras.h:85
#define extra_road_get(_e_)
Definition extras.h:191
#define NO_TARGET
Definition fc_types.h:354
@ RPT_POSSIBLE
Definition fc_types.h:700
#define DIR8_ORIGIN
Definition fc_types.h:457
int action_id
Definition fc_types.h:389
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:707
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
void exit_goto_state(void)
Definition goto.c:1022
bool goto_is_active(void)
Definition goto.c:1059
struct pf_path * path_to_nearest_allied_city(struct unit *punit)
Definition goto.c:1982
void send_patrol_route(void)
Definition goto.c:1647
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1338
bool goto_add_waypoint(void)
Definition goto.c:487
bool goto_pop_waypoint(void)
Definition goto.c:524
void send_connect_route(enum unit_activity activity, struct extra_type *tgt)
Definition goto.c:1713
void goto_unit_killed(struct unit *punit)
Definition goto.c:1040
void free_client_goto(void)
Definition goto.c:162
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1001
void send_goto_route(void)
Definition goto.c:1869
bool is_valid_goto_destination(const struct tile *ptile)
Definition goto.c:179
void request_orders_cleared(struct unit *punit)
Definition goto.c:1363
void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *final_order)
Definition goto.c:1530
int action_selection_actor_unit(void)
void action_selection_close(void)
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c: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:2148
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2125
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2095
void create_line_at_mouse_pos(void)
Definition mapctrl.c:355
void update_turn_done_button(bool do_restore)
Definition mapview.c:76
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:643
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.c:257
bool request_transport(struct unit *cargo, struct tile *ptile)
enum cursor_type mouse_cursor_type
Definition gui_mouse.c:46
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_error(message,...)
Definition log.h:103
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1347
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:931
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:940
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Definition map.c:371
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1073
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:367
#define iterate_outward_end
Definition map.h:371
bool keyboardless_goto_button_down
void cancel_tile_hiliting(void)
bool keyboardless_goto_active
struct tile * keyboardless_goto_start_tile
void update_map_canvas_visible(void)
struct tile * get_center_tile_mapcanvas(void)
void move_unit_map_canvas(struct unit *punit, struct tile *src_tile, int dx, int dy)
void center_tile_mapcanvas(const struct tile *ptile)
void update_city_description(struct city *pcity)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile)
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
void menus_update(void)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:351
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:523
const struct option_set * server_optset
Definition options.c:4020
bool option_bool_get(const struct option *poption)
Definition options.c:801
struct client_options gui_options
Definition options.c:72
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:435
void refresh_overview_canvas(void)
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
int dsend_packet_unit_change_activity(struct connection *pc, int unit_id, enum unit_activity activity, int target)
int dsend_packet_unit_do_action(struct connection *pc, int actor_id, int target_id, int sub_tgt_id, const char *name, action_id action_type)
int send_packet_unit_orders(struct connection *pc, const struct packet_unit_orders *packet)
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_unit_server_side_agent_set(struct connection *pc, int unit_id, enum server_side_agent agent)
int send_packet_edit_recalculate_borders(struct connection *pc)
int dsend_packet_unit_action_query(struct connection *pc, int actor_id, int target_id, action_id action_type, int request_kind)
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
int dsend_packet_edit_toggle_fogofwar(struct connection *pc, int player)
int dsend_packet_unit_sscs_set(struct connection *pc, int unit_id, enum unit_ss_data_type type, int value)
int dsend_packet_edit_mode(struct connection *pc, bool state)
const struct pf_position * pf_path_last_position(const struct pf_path *path)
void pf_path_destroy(struct pf_path *path)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1133
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
#define players_iterate_alive_end
Definition player.h:547
#define players_iterate_alive(_pplayer)
Definition player.h:542
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
bool player_can_build_road(const struct civ_map *nmap, const struct road_type *proad, const struct player *pplayer, const struct tile *ptile)
Definition road.c:280
#define FC_INFINITY
Definition shared.h:36
Definition agents.h:40
Definition city.h:320
int id
Definition city.h:326
enum capital_type capital
Definition city.h:328
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
bool draw_native
Definition options.h:215
bool enable_cursor_changes
Definition options.h:173
bool auto_turn_done
Definition options.h:164
bool draw_specials
Definition options.h:207
bool draw_city_output
Definition options.h:194
bool draw_city_names
Definition options.h:196
bool draw_city_productions
Definition options.h:198
int smooth_move_unit_msec
Definition options.h:151
bool draw_mines
Definition options.h:205
bool draw_borders
Definition options.h:214
bool draw_fortress_airbase
Definition options.h:206
bool draw_city_buycost
Definition options.h:199
bool draw_unit_stack_size
Definition options.h:218
bool draw_irrigation
Definition options.h:204
bool draw_terrain
Definition options.h:201
bool draw_units
Definition options.h:211
bool auto_center_on_automated
Definition options.h:156
bool draw_fog_of_war
Definition options.h:213
bool draw_city_trade_routes
Definition options.h:200
bool unit_selection_clears_orders
Definition options.h:175
bool draw_unit_shields
Definition options.h:217
bool draw_cities
Definition options.h:210
bool draw_map_grid
Definition options.h:195
bool draw_city_growth
Definition options.h:197
bool draw_focus_unit
Definition options.h:212
bool draw_paths
Definition options.h:203
bool draw_city_outlines
Definition options.h:193
bool draw_coastline
Definition options.h:202
bool popup_actor_arrival
Definition options.h:168
bool draw_full_citybar
Definition options.h:216
bool draw_pollution
Definition options.h:209
bool auto_center_on_unit
Definition options.h:155
bool solid_color_behind_units
Definition options.h:149
bool popup_last_move_to_allied
Definition options.h:170
bool keyboardless_goto
Definition options.h:172
struct player * playing
Definition connection.h:151
struct connection::@58::@63 client
int last_request_id_used
Definition connection.h:187
struct requirement_vector reqs
Definition extras.h:106
struct unit_order orders[MAX_LEN_ROUTE]
struct unit_list * units
Definition player.h:280
bool is_alive
Definition player.h:266
bool phase_done
Definition player.h:261
enum unit_activity activity
const struct unit * unit
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
Definition timing.c:81
enum unit_activity activity
Definition unit.h:94
enum unit_orders order
Definition unit.h:93
int action
Definition unit.h:100
enum direction8 dir
Definition unit.h:102
int target
Definition unit.h:97
int sub_target
Definition unit.h:98
Definition unit.h:138
enum action_decision action_decision_want
Definition unit.h:202
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int id
Definition unit.h:145
int hp
Definition unit.h:151
bool asking_city_name
Definition unit.h:225
bool done_moving
Definition unit.h:181
struct tile * action_decision_tile
Definition unit.h:203
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
enum universals_n kind
Definition fc_types.h:902
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:119
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:699
#define T_UNKNOWN
Definition terrain.h:57
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Definition tile.c:955
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1033
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Definition tile.c:844
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:981
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define tile_hash_iterate(hash, ptile)
Definition tile.h:82
#define tile_terrain(_tile)
Definition tile.h:114
#define tile_hash_iterate_end
Definition tile.h:84
#define tile_continent(_tile)
Definition tile.h:92
#define tile_has_extra(ptile, pextra)
Definition tile.h:151
double get_focus_unit_toggle_timeout(const struct tileset *t)
Definition tilespec.c:6530
void toggle_focus_unit_state(struct tileset *t)
Definition tilespec.c:6562
void focus_unit_in_combat(struct tileset *t)
Definition tilespec.c:6551
cursor_type
Definition tilespec.h:288
@ CURSOR_TELEPORT
Definition tilespec.h:292
@ CURSOR_GOTO
Definition tilespec.h:289
@ CURSOR_INVALID
Definition tilespec.h:295
@ CURSOR_PATROL
Definition tilespec.h:290
@ CURSOR_WAIT
Definition tilespec.h:299
@ CURSOR_SELECT
Definition tilespec.h:294
@ CURSOR_DEFAULT
Definition tilespec.h:301
@ CURSOR_PARADROP
Definition tilespec.h:291
@ CURSOR_NUKE
Definition tilespec.h:293
@ CURSOR_ATTACK
Definition tilespec.h:296
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:1791
bool is_attack_unit(const struct unit *punit)
Definition unit.c:313
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2449
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:708
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:614
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:367
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:814
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:305
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:830
bool is_special_unit(const struct unit *punit)
Definition unit.c:358
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1263
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2433
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:760
bool unit_has_orders(const struct unit *punit)
Definition unit.c:210
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1920
#define unit_tile(_pu)
Definition unit.h:397
unit_focus_status
Definition unit.h:52
@ FOCUS_AVAIL
Definition unit.h:53
@ FOCUS_DONE
Definition unit.h:53
@ FOCUS_WAIT
Definition unit.h:53
#define BATTLEGROUP_NONE
Definition unit.h:190
unit_orders
Definition unit.h:37
@ ORDER_ACTION_MOVE
Definition unit.h:45
@ ORDER_ACTIVITY
Definition unit.h:41
@ ORDER_MOVE
Definition unit.h:39
@ ORDER_LAST
Definition unit.h:49
@ ORDER_PERFORM_ACTION
Definition unit.h:47
#define unit_owner(_pu)
Definition unit.h:396
#define MAX_NUM_BATTLEGROUPS
Definition unit.h:189
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_iterate_safe_end
Definition unitlist.h:61
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c: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:2499
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)