Freeciv-3.2
Loading...
Searching...
No Matches
movement.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
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 "bitvector.h"
20#include "fcintl.h"
21#include "log.h"
22#include "shared.h"
23#include "support.h"
24
25/* common */
26#include "astring.h"
27#include "base.h"
28#include "effects.h"
29#include "fc_types.h"
30#include "game.h"
31#include "map.h"
32#include "road.h"
33#include "unit.h"
34#include "unitlist.h"
35#include "unittype.h"
36#include "terrain.h"
37
38#include "movement.h"
39
40/************************************************************************/
47int utype_move_rate(const struct unit_type *utype, const struct tile *ptile,
48 const struct player *pplayer, int veteran_level,
49 int hitpoints)
50{
51 const struct unit_class *uclass;
52 const struct veteran_level *vlevel;
53 int base_move_rate, move_rate;
54 int min_speed;
55
56 fc_assert_ret_val(NULL != utype, 0);
57 fc_assert_ret_val(NULL != pplayer, 0);
60 uclass = utype_class(utype);
61
62 base_move_rate = utype->move_rate + vlevel->move_bonus;
63 move_rate = base_move_rate;
64
65 if (uclass_has_flag(uclass, UCF_DAMAGE_SLOWS)) {
66 /* Scale the MP based on how many HP the unit has. */
67 move_rate = (move_rate * hitpoints) / utype->hp;
68 }
69
70 /* Add on effects bonus (Magellan's Expedition, Lighthouse,
71 * Nuclear Power). */
72 move_rate += (get_unittype_bonus(pplayer, ptile, utype, NULL,
74 * SINGLE_MOVE);
75
76 /* Don't let the move_rate be less than min_speed unless the base_move_rate is
77 * also less than min_speed. */
78 min_speed = MIN(uclass->min_speed, base_move_rate);
79 if (move_rate < min_speed) {
80 move_rate = min_speed;
81 }
82
83 return move_rate;
84}
85
86/************************************************************************/
97
98/************************************************************************/
105int utype_unknown_move_cost(const struct unit_type *utype)
106{
107 const struct unit_class *uclass = utype_class(utype);
108 int move_cost;
109 int worst_effect_mc;
110
111 if (!uclass_has_flag(uclass, UCF_TERRAIN_SPEED)) {
112 /* Unit is not subject to terrain movement costs. */
113 move_cost = SINGLE_MOVE;
114 } else if (utype_has_flag(utype, UTYF_IGTER)) {
115 /* All terrain movement costs are equal! */
116 move_cost = MOVE_COST_IGTER;
117 } else {
118 /* Unit is subject to terrain movement costs. */
119 move_cost = 1; /* Arbitrary minimum. */
120 terrain_type_iterate(pterrain) {
121 if (is_native_to_class(uclass, pterrain, NULL)
122 && pterrain->movement_cost > move_cost) {
123 /* Exact movement cost matters only if we can enter
124 * the tile. */
125 move_cost = pterrain->movement_cost;
126 }
128 move_cost *= SINGLE_MOVE; /* Real value. */
129 }
130
131 /* Move cost from effects. */
132 worst_effect_mc = 0;
134 struct universal req_pattern[] = {
135 { .kind = VUT_ACTION, .value.action = paction },
136 { .kind = VUT_UTYPE, .value.utype = utype },
137 };
138 int max_effect_mc;
139
140 if (!utype_can_do_action(utype, action_id(paction))) {
141 /* Not relevant. */
142 continue;
143 }
144
147
150 }
152 move_cost += worst_effect_mc;
153
154 /* Let's see if we can cross over all terrain types, else apply a malus.
155 * We want units that may encounter unsuitable terrain explore less.
156 * N.B.: We don't take in account terrain no unit can enter here. */
157 terrain_type_iterate(pterrain) {
158 if (BV_ISSET_ANY(pterrain->native_to)
159 && !is_native_to_class(uclass, pterrain, NULL)) {
160 /* Units that may encounter unsuitable terrain explore less. */
161 move_cost *= 2;
162 break;
163 }
165
166 return move_cost;
167}
168
169/************************************************************************/
174bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
175{
177
178 if (ptrans == NULL) {
179 /* FIXME: Redundant check; if unit is in the tile without transport
180 * it's known to be able to exist there. */
182 }
183
184 switch (unit_type_get(punit)->tp_defense) {
185 case TDT_BLOCKED:
186 return FALSE;
187 case TDT_ALIGHT:
190 case TDT_ALWAYS:
191 return TRUE;
192 }
193
195
196 return FALSE;
197}
198
199/************************************************************************/
209
210/************************************************************************/
222
223/************************************************************************/
239
240/************************************************************************/
244 const struct unit_class *punitclass,
245 const struct tile *ptile,
246 const struct tile *pexclude)
247{
249 piter != pexclude
252 piter != pexclude && NULL != tile_city(piter));
253
254 return NULL != ptile;
255}
256
257/************************************************************************/
261 const struct unit_class *punitclass,
262 const struct tile *ptile,
263 const struct player *pov_player)
264{
269 NULL != tile_city(piter));
270
271 return NULL != ptile;
272}
273
274/************************************************************************/
279bool can_exist_at_tile(const struct civ_map *nmap,
280 const struct unit_type *utype,
281 const struct tile *ptile)
282{
283 /* Cities are safe havens except for units in the middle of non-native
284 * terrain. This can happen if adjacent terrain is changed after unit
285 * arrived to city. */
286 if (NULL != tile_city(ptile)
289 || (1 == game.info.citymindist
291 return TRUE;
292 }
293
294 /* UTYF_COAST_STRICT unit cannot exist in an ocean tile without access to land. */
296 && !is_safe_ocean(nmap, ptile)) {
297 return FALSE;
298 }
299
300 return is_native_tile(utype, ptile);
301}
302
303/************************************************************************/
311 const struct player *pov_player,
312 const struct unit_type *utype,
313 const struct city *pcity)
314{
315 struct unit_class *uclass;
316 struct tile *ctile;
317
318 fc_assert_ret_val(NULL != pcity && NULL != utype, FALSE);
319
320 ctile = city_tile(pcity);
321 uclass = utype_class(utype);
322
323 if (uclass_has_flag(uclass, UCF_BUILD_ANYWHERE)) {
324 /* If the city stands, it can exist there */
325 return TRUE;
326 }
327 adjc_iterate(nmap, ctile, ptile) {
328 if (!tile_is_seen(ptile, pov_player)
329 || is_native_tile_to_class(uclass, ptile)) {
330 /* Could be native. This ignores a rare case when we don't see
331 * only the city center and any native terrain is NoCities */
332 return TRUE;
333 }
335
336 if (1 == game.info.citymindist
338 /* Channeled. */
339 return TRUE;
340 }
341
342 /* It definitely can't exist there */
343 return FALSE;
344}
345
346/************************************************************************/
352 const struct unit *punit,
353 const struct tile *ptile)
354{
355 return can_exist_at_tile(nmap, unit_type_get(punit), ptile);
356}
357
358/************************************************************************/
364 const struct tile *ptile)
365{
367 tile_extras(ptile));
368}
369
370/************************************************************************/
375 const struct terrain *pterrain,
376 const bv_extras *extras)
377{
378 if (!pterrain) {
379 /* Unknown is considered native terrain */
380 return TRUE;
381 }
382
383 if (BV_ISSET(pterrain->native_to, uclass_index(punitclass))) {
384 return TRUE;
385 }
386
387 if (extras != NULL) {
388 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
389 if (BV_ISSET(*extras, extra_index(pextra))) {
390 return TRUE;
391 }
393 }
394
395 return FALSE;
396}
397
398
399/************************************************************************/
405bool is_native_move(const struct civ_map *nmap,
406 const struct unit_class *punitclass,
407 const struct tile *src_tile,
408 const struct tile *dst_tile)
409{
410 const struct road_type *proad;
411
413 /* We aren't using extras to make the destination native. */
414 return TRUE;
415 } else if (!is_native_tile_to_class(punitclass, src_tile)) {
416 /* Disembarking or leaving port, so ignore road connectivity. */
417 return TRUE;
418 } else if (is_native_to_class(punitclass, tile_terrain(src_tile), NULL)) {
419 /* Native source terrain depends entirely on destination tile nativity. */
421 }
422
423 /* Check for non-road native extras on the source tile. */
424 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
425 if (tile_has_extra(src_tile, pextra)
426 && !is_extra_caused_by(pextra, EC_ROAD)
428 /* If there is one, and the destination is native, the move is native. */
429 return TRUE;
430 }
432
433 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
434 if (!tile_has_extra(dst_tile, pextra)) {
435 continue;
436 } else if (!is_extra_caused_by(pextra, EC_ROAD)) {
437 /* The destination is native because of a non-road extra. */
438 return TRUE;
439 }
440
441 proad = extra_road_get(pextra);
442
444 extra_type_list_iterate(punitclass->cache.native_tile_extras, jextra) {
445 if (pextra != jextra
447 && tile_has_extra(src_tile, jextra)
448 && road_has_flag(jextra->data.road, RF_JUMP_FROM)) {
449 return TRUE;
450 }
452 }
453
454 extra_type_list_iterate(proad->integrators, iextra) {
455 if (!tile_has_extra(src_tile, iextra)) {
456 continue;
457 }
459 /* move_mode does not matter as all of them accept cardinal move */
460 return TRUE;
461 }
462 switch (extra_road_get(iextra)->move_mode) {
463 case RMM_FAST_ALWAYS:
464 /* Road connects source and destination, so we're fine. */
465 return TRUE;
466 case RMM_CARDINAL:
467 /* Road connects source and destination if cardinal move. */
468 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
469 return TRUE;
470 }
471 break;
472 case RMM_RELAXED:
473 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
474 /* Cardinal moves have no between tiles, so connected. */
475 return TRUE;
476 }
479 || (pextra != iextra && tile_has_extra(between, pextra))) {
480 /* We have a link for the connection.
481 * 'pextra != iextra' is there just to avoid tile_has_extra()
482 * in by far more common case that 'pextra == iextra' */
483 return TRUE;
484 }
486 break;
487 }
490
491 return FALSE;
492}
493
494/************************************************************************/
498 const struct unit_class *uclass,
499 const struct tile *ptile)
500{
501 if (is_native_tile_to_class(uclass, ptile)) {
502 return TRUE;
503 }
504
505 adjc_iterate(nmap, ptile, ptile2) {
506 if (is_native_tile_to_class(uclass, ptile2)) {
507 return TRUE;
508 }
510
511 return FALSE;
512}
513
514/************************************************************************/
524 const struct unit *punit,
525 const struct tile *ptile)
526{
527 const struct unit_type *utype;
528
529 if (!can_unit_exist_at_tile(nmap, punit, ptile)) {
530 return FALSE;
531 }
532
533 if (tile_city(ptile)) {
534 return TRUE;
535 }
536
537 utype = unit_type_get(punit);
538 if (tile_has_refuel_extra(ptile, utype_class(utype))) {
539 /* Unit can always survive at refueling base */
540 return TRUE;
541 }
542
543 if (utype_has_flag(utype, UTYF_COAST) && is_safe_ocean(nmap, ptile)) {
544 /* Refueling coast */
545 return TRUE;
546 }
547
548 if (utype_fuel(utype)) {
549 /* Unit requires fuel and this is not refueling tile */
550 return FALSE;
551 }
552
553 if (is_losing_hp(punit)) {
554 /* Unit is losing HP over time in this tile (no city or native base) */
555 return FALSE;
556 }
557
558 return TRUE;
559}
560
561
562/************************************************************************/
575 const struct player *unit_owner,
576 const struct tile *src_tile,
577 const struct tile *dst_tile,
578 const struct civ_map *zmap)
579{
581 return TRUE;
582 }
584 return TRUE;
585 }
586 if (tile_city(src_tile) || tile_city(dst_tile)) {
587 return TRUE;
588 }
591 return TRUE;
592 }
593
594 return (is_my_zoc(unit_owner, src_tile, zmap)
596}
597
598/************************************************************************/
605 const struct unit *punit,
606 const struct tile *dst_tile,
607 bool igzoc,
608 bool enter_transport,
609 bool enter_enemy_city)
610{
616}
617
618/************************************************************************/
625 const struct unit *punit,
626 const struct tile *dst_tile,
627 bool enter_transport,
628 bool enter_enemy_city)
629{
634}
635
636/************************************************************************/
663 const struct unit *punit,
664 enum unit_activity activity,
665 const struct tile *src_tile,
666 const struct tile *dst_tile, bool igzoc,
667 bool enter_transport, struct unit *embark_to,
668 bool enter_enemy_city)
669{
670 bool zoc;
671 struct city *pcity;
672 const struct unit_type *punittype = unit_type_get(punit);
673 const struct player *puowner = unit_owner(punit);
674
675 /* 1) */
676 if (activity != ACTIVITY_IDLE
677 && activity != ACTIVITY_GOTO) {
678 /* For other activities the unit must be stationary. */
679 return MR_BAD_ACTIVITY;
680 }
681
682 /* 2) */
683 if (punit->stay) {
684 return MR_UNIT_STAY;
685 }
686
687 /* 3) */
690 return MR_RANDOM_ONLY;
691 }
692
693 /* 4) */
694 if (!is_tiles_adjacent(src_tile, dst_tile)) {
695 /* Of course you can only move to adjacent positions. */
696 return MR_BAD_DESTINATION;
697 }
698
699 /* 5) */
701 /* You can't move onto a tile with non-allied units on it (try
702 * attacking instead). */
704 }
705
706 /* 6) */
707 if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
708 && dst_tile->terrain->animal != punittype) {
710 }
711
712 /* 7) */
713 if (embark_to != NULL) {
716 }
721 }
722
723 /* 8) */
725 /* You can't move into a non-allied tile.
726 *
727 * FIXME: this should never happen since it should be caught by check
728 * #4. */
729 return MR_NO_WAR;
730 }
731
732 /* 9) */
733 if ((pcity = tile_city(dst_tile))) {
734 if (enter_enemy_city) {
736 /* You can't move into an empty city of a civilization you're at
737 * peace with - you must first either declare war or make an
738 * alliance. */
739 return MR_NO_WAR;
740 }
741 } else {
742 if (!pplayers_allied(city_owner(pcity), puowner)) {
743 /* You can't move into an empty city of a civilization you're not
744 * allied to. Assume that the player tried to attack. */
745 return MR_NO_WAR;
746 }
747 }
748 }
749
750 /* 10) */
751 zoc = igzoc
753 if (!zoc) {
754 /* The move is illegal because of zones of control. */
755 return MR_ZOC;
756 }
757
758 /* 11) */
760 && !pcity && !is_safe_ocean(nmap, dst_tile)) {
761 return MR_TRIREME;
762 }
763
764 /* 12) */
767 return MR_PEACE;
768 }
769
770 /* 13) */
773 return MR_CANNOT_DISEMBARK;
774 }
775
776 /* 14) */
778 /* Allow non-native moves into cities or boarding transport. */
779 || pcity
781 return MR_NON_NATIVE_MOVE;
782 }
783
784 return MR_OK;
785}
786
787/************************************************************************/
807 const struct unit *punit,
808 enum unit_activity activity,
809 const struct tile *src_tile,
810 const struct tile *dst_tile,
811 bool enter_transport, struct unit *embark_to,
812 bool enter_enemy_city)
813{
814 struct city *pcity;
815 const struct unit_type *punittype = unit_type_get(punit);
816 const struct player *puowner = unit_owner(punit);
817
818 /* 1) */
820 /* You can't move onto a tile with non-allied units on it (try
821 * attacking instead). */
823 }
824
825 /* 2) */
826 if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
827 && dst_tile->terrain->animal != punittype) {
829 }
830
831 /* 3) */
832 if (embark_to != NULL) {
835 }
840 }
841
842 /* 4) */
844 /* You can't move into a non-allied tile.
845 *
846 * FIXME: this should never happen since it should be caught by check
847 * #1. */
848 return MR_NO_WAR;
849 }
850
851 /* 5) */
852 if ((pcity = tile_city(dst_tile))) {
853 if (enter_enemy_city) {
855 /* You can't move into an empty city of a civilization you're at
856 * peace with - you must first either declare war or make an
857 * alliance. */
858 return MR_NO_WAR;
859 }
860 } else {
861 if (!pplayers_allied(city_owner(pcity), puowner)) {
862 /* You can't move into an empty city of a civilization you're not
863 * allied to. Assume that the player tried to attack. */
864 return MR_NO_WAR;
865 }
866 }
867 }
868
869 /* 6) */
871 && !pcity && !is_safe_ocean(nmap, dst_tile)) {
872 return MR_TRIREME;
873 }
874
875 /* 7) */
878 return MR_PEACE;
879 }
880
881 return MR_OK;
882}
883
884/************************************************************************/
887bool can_unit_transport(const struct unit *transporter,
888 const struct unit *transported)
889{
890 fc_assert_ret_val(transporter != NULL, FALSE);
891 fc_assert_ret_val(transported != NULL, FALSE);
892
893 return can_unit_type_transport(unit_type_get(transporter),
894 unit_class_get(transported));
895}
896
897/************************************************************************/
900bool can_unit_type_transport(const struct unit_type *transporter,
901 const struct unit_class *transported)
902{
903 if (transporter->transport_capacity <= 0) {
904 return FALSE;
905 }
906
907 return BV_ISSET(transporter->cargo, uclass_index(transported));
908}
909
910/************************************************************************/
915bool unit_can_load(const struct unit *punit)
916{
917 if (unit_transported(punit)) {
918 /* In another transport already. Can it unload first? */
920 return FALSE;
921 }
922 }
923
925 /* could_unit_load() instead of can_unit_load() since latter
926 * would check against unit already being transported, and we need
927 * to support unload+load to a new transport. */
928 if (ptransport != punit->transporter) {
930 return TRUE;
931 }
932 }
934
935 return FALSE;
936}
937
938/************************************************************************/
943bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
944{
947 return TRUE;
948 }
950
951 return FALSE;
952}
953
954static int move_points_denomlen = 0;
955
956/************************************************************************/
960{
961 char denomstr[10];
962 /* String length of maximum denominator for fractional representation of
963 * movement points, for padding of text representation */
964 fc_snprintf(denomstr, sizeof(denomstr), "%d", SINGLE_MOVE);
966}
967
968/************************************************************************/
980const char *move_points_text_full(int mp, bool reduce, const char *prefix,
981 const char *none, bool align)
982{
983 static struct astring str = ASTRING_INIT;
984 int pad1, pad2;
985
986 if (align && SINGLE_MOVE > 1) {
987 /* Align to worst-case denominator even if we might be reducing to
988 * lowest terms, as other entries in a table might not reduce */
989 pad1 = move_points_denomlen; /* numerator or denominator */
990 pad2 = move_points_denomlen*2+2; /* everything right of integer part */
991 } else {
992 /* If no possible fractional part, alignment unneeded even if requested */
993 pad1 = pad2 = 0;
994 }
995 if (!prefix) {
996 prefix = "";
997 }
998 astr_clear(&str);
999 if ((mp == 0 && none) || SINGLE_MOVE == 0) {
1000 /* No movement points, and we have a special representation to use */
1001 /* (Also used when SINGLE_MOVE == 0, to avoid dividing by zero, which is
1002 * important for client before ruleset has been received. Doesn't much
1003 * matter what we print in this case.) */
1004 astr_add(&str, "%s%*s", none ? none : "", pad2, "");
1005 } else if ((mp % SINGLE_MOVE) == 0) {
1006 /* Integer move points */
1007 astr_add(&str, "%s%d%*s", prefix, mp / SINGLE_MOVE, pad2, "");
1008 } else {
1009 /* Fractional part */
1010 int cancel;
1011
1013 if (reduce) {
1014 /* Reduce to lowest terms */
1015 int gcd = mp;
1016 /* Calculate greatest common divisor with Euclid's algorithm */
1017 int b = SINGLE_MOVE;
1018
1019 while (b != 0) {
1020 int t = b;
1021 b = gcd % b;
1022 gcd = t;
1023 }
1024 cancel = gcd;
1025 } else {
1026 /* No cancellation */
1027 cancel = 1;
1028 }
1029 if (mp < SINGLE_MOVE) {
1030 /* Fractional move points */
1031 astr_add(&str, "%s%*d/%*d", prefix,
1032 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1033 } else {
1034 /* Integer + fractional move points */
1035 astr_add(&str,
1036 "%s%d %*d/%*d", prefix, mp / SINGLE_MOVE,
1037 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1038 }
1039 }
1040 return astr_str(&str);
1041}
1042
1043/************************************************************************/
1047const char *move_points_text(int mp, bool reduce)
1048{
1050}
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:481
#define action_by_result_iterate_end
Definition actions.h:485
#define action_id(_act_)
Definition actions.h:661
void astr_clear(struct astring *astr)
Definition astring.c:205
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:287
#define str
Definition astring.c:76
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_ISSET_ANY(vec)
Definition bitvector.h:109
#define city_tile(_pcity_)
Definition city.h:564
#define city_owner(_pcity_)
Definition city.h:563
char * incite_cost
Definition comments.c:75
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
int effect_cumulative_max(enum effect_type type, struct universal *unis, size_t n_unis)
Definition effects.c:388
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, const struct action *paction, enum effect_type effect_type)
Definition effects.c:1035
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_type_list_iterate_end
Definition extras.h:167
#define extra_road_get(_e_)
Definition extras.h:191
static bool is_server(void)
struct civ_game game
Definition game.c:62
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
bool is_move_cardinal(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1365
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:931
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
Definition map.c:667
#define adjc_iterate_end
Definition map.h:433
#define cardinal_between_iterate(nmap, tile1, tile2, between)
Definition map.h:477
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:428
#define ALL_DIRECTIONS_CARDINAL()
Definition map.h:53
#define cardinal_between_iterate_end
Definition map.h:482
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1047
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Definition movement.c:980
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:279
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:662
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:351
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:363
bool can_step_taken_wrt_to_zoc(const struct unit_type *punittype, const struct player *unit_owner, const struct tile *src_tile, const struct tile *dst_tile, const struct civ_map *zmap)
Definition movement.c:574
bool could_exist_in_city(const struct civ_map *nmap, const struct player *pov_player, const struct unit_type *utype, const struct city *pcity)
Definition movement.c:310
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
bool unit_can_load(const struct unit *punit)
Definition movement.c:915
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:887
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Definition movement.c:943
static int move_points_denomlen
Definition movement.c:954
bool can_attack_non_native_hard_reqs(const struct unit_type *utype)
Definition movement.c:204
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:227
enum unit_move_result unit_teleport_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:806
bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
Definition movement.c:174
bool unit_can_teleport_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool enter_transport, bool enter_enemy_city)
Definition movement.c:624
bool is_native_move(const struct civ_map *nmap, const struct unit_class *punitclass, const struct tile *src_tile, const struct tile *dst_tile)
Definition movement.c:405
bool may_be_city_channel_tile(const struct civ_map *nmap, const struct unit_class *punitclass, const struct tile *ptile, const struct player *pov_player)
Definition movement.c:260
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:374
int utype_move_rate(const struct unit_type *utype, const struct tile *ptile, const struct player *pplayer, int veteran_level, int hitpoints)
Definition movement.c:47
bool is_city_channel_tile(const struct civ_map *nmap, const struct unit_class *punitclass, const struct tile *ptile, const struct tile *pexclude)
Definition movement.c:243
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:523
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:497
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_transport, bool enter_enemy_city)
Definition movement.c:604
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:900
void init_move_fragments(void)
Definition movement.c:959
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:214
#define MAP_TILE_CONN_TO_BY(_map_, _tile_, _piter_, _found_, _conn_)
Definition movement.h:163
#define SINGLE_MOVE
Definition movement.h:26
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Definition movement.h:88
unit_move_result
Definition movement.h:34
@ MR_CANNOT_DISEMBARK
Definition movement.h:48
@ MR_OK
Definition movement.h:35
@ MR_RANDOM_ONLY
Definition movement.h:52
@ MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT
Definition movement.h:45
@ MR_TRIREME
Definition movement.h:47
@ MR_NON_NATIVE_MOVE
Definition movement.h:49
@ MR_BAD_ACTIVITY
Definition movement.h:41
@ MR_ANIMAL_DISALLOWED
Definition movement.h:50
@ MR_PEACE
Definition movement.h:39
@ MR_ZOC
Definition movement.h:40
@ MR_NO_WAR
Definition movement.h:38
@ MR_BAD_DESTINATION
Definition movement.h:42
@ MR_NO_TRANSPORTER_CAPACITY
Definition movement.h:46
@ MR_UNIT_STAY
Definition movement.h:51
#define MOVE_COST_IGTER
Definition movement.h:27
bool player_can_invade_tile(const struct player *pplayer, const struct tile *ptile)
Definition player.c:270
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1405
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1459
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:410
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
Definition city.h:320
struct player * random_move_time
Definition game.h:279
struct packet_game_info info
Definition game.h:89
struct civ_game::@31::@35 server
struct unit_list * units
Definition player.h:280
enum road_move_mode move_mode
Definition road.h:75
bv_unit_classes native_to
Definition terrain.h:257
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
int min_speed
Definition unittype.h:154
int transport_capacity
Definition unittype.h:523
bv_unit_classes cargo
Definition unittype.h:558
int move_rate
Definition unittype.h:517
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
int hp
Definition unit.h:151
bool stay
Definition unit.h:205
struct unit * transporter
Definition unit.h:183
const struct unit_type * utype
Definition unit.h:139
int veteran
Definition unit.h:152
enum universals_n kind
Definition fc_types.h:902
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 terrain_type_iterate(_p)
Definition terrain.h:373
#define terrain_type_iterate_end
Definition terrain.h:379
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
bool tile_has_refuel_extra(const struct tile *ptile, const struct unit_class *uclass)
Definition tile.c:309
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
Definition tile.c:407
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:114
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:124
#define tile_has_extra(ptile, pextra)
Definition tile.h:151
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1512
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2236
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:785
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 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
#define unit_tile(_pu)
Definition unit.h:397
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:457
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:396
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:478
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2499
bool utype_can_do_action_result_when_ustate(const struct unit_type *putype, enum action_result result, const enum ustate_prop prop, const bool is_there)
Definition unittype.c:975
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:387
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2597
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:766
#define utype_class(_t_)
Definition unittype.h:749
#define utype_fuel(ptype)
Definition unittype.h:839
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617
#define uclass_index(_c_)
Definition unittype.h:742