Freeciv-3.3
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(utype != nullptr, 0);
58 fc_assert_ret_val(vlevel != nullptr, 0);
59 uclass = utype_class(utype);
60
61 base_move_rate = utype->move_rate + vlevel->move_bonus;
62 move_rate = base_move_rate;
63
64 if (uclass_has_flag(uclass, UCF_DAMAGE_SLOWS)) {
65 /* Scale the MP based on how many HP the unit has. */
66 move_rate = (move_rate * hitpoints) / utype->hp;
67 }
68
69 /* Add on effects bonus (Magellan's Expedition, Lighthouse,
70 * Nuclear Power). */
71 move_rate += (get_unittype_bonus(pplayer, ptile, utype, nullptr,
73 * SINGLE_MOVE);
74
75 /* Don't let the move_rate be less than min_speed unless the base_move_rate is
76 * also less than min_speed. */
77 min_speed = MIN(uclass->min_speed, base_move_rate);
78 if (move_rate < min_speed) {
79 move_rate = min_speed;
80 }
81
82 return move_rate;
83}
84
85/************************************************************************/
96
97/************************************************************************/
104int utype_unknown_move_cost(const struct unit_type *utype)
105{
106 const struct unit_class *uclass = utype_class(utype);
107 int move_cost;
108 int worst_effect_mc;
109
110 if (!uclass_has_flag(uclass, UCF_TERRAIN_SPEED)) {
111 /* Unit is not subject to terrain movement costs. */
112 move_cost = SINGLE_MOVE;
113 } else if (utype_has_flag(utype, UTYF_IGTER)) {
114 /* All terrain movement costs are equal! */
115 move_cost = MOVE_COST_IGTER;
116 } else {
117 /* Unit is subject to terrain movement costs. */
118 move_cost = 1; /* Arbitrary minimum. */
119 terrain_type_iterate(pterrain) {
120 if (is_native_to_class(uclass, pterrain, NULL)
121 && pterrain->movement_cost > move_cost) {
122 /* Exact movement cost matters only if we can enter
123 * the tile. */
124 move_cost = pterrain->movement_cost;
125 }
127 move_cost *= SINGLE_MOVE; /* Real value. */
128 }
129
130 /* Move cost from effects. */
131 worst_effect_mc = 0;
133 struct universal req_pattern[] = {
134 { .kind = VUT_ACTION, .value.action = paction },
135 { .kind = VUT_UTYPE, .value.utype = utype },
136 };
137 int max_effect_mc;
138
139 if (!utype_can_do_action(utype, action_id(paction))) {
140 /* Not relevant. */
141 continue;
142 }
143
146
149 }
151 move_cost += worst_effect_mc;
152
153 /* Let's see if we can cross over all terrain types, else apply a malus.
154 * We want units that may encounter unsuitable terrain explore less.
155 * N.B.: We don't take in account terrain no unit can enter here. */
156 terrain_type_iterate(pterrain) {
157 if (BV_ISSET_ANY(pterrain->native_to)
158 && !is_native_to_class(uclass, pterrain, NULL)) {
159 /* Units that may encounter unsuitable terrain explore less. */
160 move_cost *= 2;
161 break;
162 }
164
165 return move_cost;
166}
167
168/************************************************************************/
173bool unit_can_defend_here(const struct civ_map *nmap, const struct unit *punit)
174{
176
177 if (ptrans == NULL) {
178 /* FIXME: Redundant check; if unit is in the tile without transport
179 * it's known to be able to exist there. */
181 }
182
183 switch (unit_type_get(punit)->tp_defense) {
184 case TDT_BLOCKED:
185 return FALSE;
186 case TDT_ALIGHT:
189 case TDT_ALWAYS:
190 return TRUE;
191 }
192
194
195 return FALSE;
196}
197
198/************************************************************************/
208
209/************************************************************************/
221
222/************************************************************************/
238
239/************************************************************************/
243 const struct unit_class *punitclass,
244 const struct tile *ptile,
245 const struct tile *pexclude)
246{
248 piter != pexclude
251 piter != pexclude && nullptr != tile_city(piter));
252
253 return nullptr != ptile;
254}
255
256/************************************************************************/
260 const struct unit_class *punitclass,
261 const struct tile *ptile,
262 const struct player *pov_player)
263{
268 nullptr != tile_city(piter));
269
270 return nullptr != ptile;
271}
272
273/************************************************************************/
278bool can_exist_at_tile(const struct civ_map *nmap,
279 const struct unit_type *utype,
280 const struct tile *ptile)
281{
282 /* Cities are safe havens except for units in the middle of non-native
283 * terrain. This can happen if adjacent terrain is changed after unit
284 * arrived to city. */
285 if (NULL != tile_city(ptile)
288 || (1 == game.info.citymindist
290 return TRUE;
291 }
292
293 /* UTYF_COAST_STRICT unit cannot exist in an ocean tile without access to land. */
295 && !is_safe_ocean(nmap, ptile)) {
296 return FALSE;
297 }
298
299 return is_native_tile(utype, ptile);
300}
301
302/************************************************************************/
310 const struct player *pov_player,
311 const struct unit_type *utype,
312 const struct city *pcity)
313{
314 struct unit_class *uclass;
315 struct tile *ctile;
316
317 fc_assert_ret_val(nullptr != pcity && nullptr != utype, FALSE);
318
320 uclass = utype_class(utype);
321
322 if (uclass_has_flag(uclass, UCF_BUILD_ANYWHERE)) {
323 /* If the city stands, it can exist there */
324 return TRUE;
325 }
326 adjc_iterate(nmap, ctile, ptile) {
327 if (!tile_is_seen(ptile, pov_player)
328 || is_native_tile_to_class(uclass, ptile)) {
329 /* Could be native. This ignores a rare case when we don't see
330 * only the city center and any native terrain is NoCities */
331 return TRUE;
332 }
334
335 if (1 == game.info.citymindist
337 /* Channeled. */
338 return TRUE;
339 }
340
341 /* It definitely can't exist there */
342 return FALSE;
343}
344
345/************************************************************************/
351 const struct unit *punit,
352 const struct tile *ptile)
353{
354 return can_exist_at_tile(nmap, unit_type_get(punit), ptile);
355}
356
357/************************************************************************/
363 const struct tile *ptile)
364{
366 tile_extras(ptile));
367}
368
369/************************************************************************/
374 const struct terrain *pterrain,
375 const bv_extras *extras)
376{
377 if (!pterrain) {
378 /* Unknown is considered native terrain */
379 return TRUE;
380 }
381
382 if (BV_ISSET(pterrain->native_to, uclass_index(punitclass))) {
383 return TRUE;
384 }
385
386 if (extras != NULL) {
387 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
388 if (BV_ISSET(*extras, extra_index(pextra))) {
389 return TRUE;
390 }
392 }
393
394 return FALSE;
395}
396
397
398/************************************************************************/
404bool is_native_move(const struct civ_map *nmap,
405 const struct unit_class *punitclass,
406 const struct tile *src_tile,
407 const struct tile *dst_tile)
408{
409 const struct road_type *proad;
410
412 /* We aren't using extras to make the destination native. */
413 return TRUE;
414 } else if (!is_native_tile_to_class(punitclass, src_tile)) {
415 /* Disembarking or leaving port, so ignore road connectivity. */
416 return TRUE;
417 } else if (is_native_to_class(punitclass, tile_terrain(src_tile), NULL)) {
418 /* Native source terrain depends entirely on destination tile nativity. */
420 }
421
422 /* Check for non-road native extras on the source tile. */
423 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
424 if (tile_has_extra(src_tile, pextra)
425 && !is_extra_caused_by(pextra, EC_ROAD)
427 /* If there is one, and the destination is native, the move is native. */
428 return TRUE;
429 }
431
432 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
433 if (!tile_has_extra(dst_tile, pextra)) {
434 continue;
435 } else if (!is_extra_caused_by(pextra, EC_ROAD)) {
436 /* The destination is native because of a non-road extra. */
437 return TRUE;
438 }
439
440 proad = extra_road_get(pextra);
441
443 extra_type_list_iterate(punitclass->cache.native_tile_extras, jextra) {
444 if (pextra != jextra
446 && tile_has_extra(src_tile, jextra)
447 && road_has_flag(jextra->data.road, RF_JUMP_FROM)) {
448 return TRUE;
449 }
451 }
452
453 extra_type_list_iterate(proad->integrators, iextra) {
454 if (!tile_has_extra(src_tile, iextra)) {
455 continue;
456 }
458 /* move_mode does not matter as all of them accept cardinal move */
459 return TRUE;
460 }
461 switch (extra_road_get(iextra)->move_mode) {
462 case RMM_FAST_ALWAYS:
463 /* Road connects source and destination, so we're fine. */
464 return TRUE;
465 case RMM_CARDINAL:
466 /* Road connects source and destination if cardinal move. */
467 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
468 return TRUE;
469 }
470 break;
471 case RMM_RELAXED:
472 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
473 /* Cardinal moves have no between tiles, so connected. */
474 return TRUE;
475 }
478 || (pextra != iextra && tile_has_extra(between, pextra))) {
479 /* We have a link for the connection.
480 * 'pextra != iextra' is there just to avoid tile_has_extra()
481 * in by far more common case that 'pextra == iextra' */
482 return TRUE;
483 }
485 break;
486 }
489
490 return FALSE;
491}
492
493/************************************************************************/
497 const struct unit_class *uclass,
498 const struct tile *ptile)
499{
500 if (is_native_tile_to_class(uclass, ptile)) {
501 return TRUE;
502 }
503
504 adjc_iterate(nmap, ptile, ptile2) {
505 if (is_native_tile_to_class(uclass, ptile2)) {
506 return TRUE;
507 }
509
510 return FALSE;
511}
512
513/************************************************************************/
523 const struct unit *punit,
524 const struct tile *ptile)
525{
526 const struct unit_type *utype;
527
528 if (!can_unit_exist_at_tile(nmap, punit, ptile)) {
529 return FALSE;
530 }
531
532 if (tile_city(ptile)) {
533 return TRUE;
534 }
535
536 utype = unit_type_get(punit);
537 if (tile_has_refuel_extra(ptile, utype_class(utype))) {
538 /* Unit can always survive at refueling base */
539 return TRUE;
540 }
541
542 if (utype_has_flag(utype, UTYF_COAST) && is_safe_ocean(nmap, ptile)) {
543 /* Refueling coast */
544 return TRUE;
545 }
546
547 if (utype_fuel(utype)) {
548 /* Unit requires fuel and this is not refueling tile */
549 return FALSE;
550 }
551
552 if (is_losing_hp(punit)) {
553 /* Unit is losing HP over time in this tile (no city or native base) */
554 return FALSE;
555 }
556
557 return TRUE;
558}
559
560
561/************************************************************************/
574 const struct player *unit_owner,
575 const struct tile *src_tile,
576 const struct tile *dst_tile,
577 const struct civ_map *zmap)
578{
580 return TRUE;
581 }
583 return TRUE;
584 }
585 if (tile_city(src_tile) || tile_city(dst_tile)) {
586 return TRUE;
587 }
590 return TRUE;
591 }
592
593 return (is_my_zoc(unit_owner, src_tile, zmap)
595}
596
597/************************************************************************/
604 const struct unit *punit,
605 const struct tile *dst_tile,
606 bool igzoc,
607 bool enter_transport,
608 bool enter_enemy_city)
609{
615}
616
617/************************************************************************/
624 const struct unit *punit,
625 const struct tile *dst_tile,
626 bool enter_transport,
627 bool enter_enemy_city)
628{
633}
634
635/************************************************************************/
662 const struct unit *punit,
663 enum unit_activity activity,
664 const struct tile *src_tile,
665 const struct tile *dst_tile, bool igzoc,
666 bool enter_transport, struct unit *embark_to,
667 bool enter_enemy_city)
668{
669 bool zoc;
670 struct city *pcity;
671 const struct unit_type *punittype = unit_type_get(punit);
672 const struct player *puowner = unit_owner(punit);
673
674 /* 1) */
675 if (activity != ACTIVITY_IDLE
676 && activity != ACTIVITY_GOTO) {
677 /* For other activities the unit must be stationary. */
678 return MR_BAD_ACTIVITY;
679 }
680
681 /* 2) */
682 if (punit->stay) {
683 return MR_UNIT_STAY;
684 }
685
686 /* 3) */
689 return MR_RANDOM_ONLY;
690 }
691
692 /* 4) */
693 if (!is_tiles_adjacent(src_tile, dst_tile)) {
694 /* Of course you can only move to adjacent positions. */
695 return MR_BAD_DESTINATION;
696 }
697
698 /* 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 * #5. */
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 {
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) */
821 /* You can't move onto a tile with non-allied units on it (try
822 * attacking instead). */
824 }
825
826 /* 2) */
827 if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
828 && dst_tile->terrain->animal != punittype) {
830 }
831
832 /* 3) */
833 if (embark_to != NULL) {
836 }
841 }
842
843 /* 4) */
845 /* You can't move into a non-allied tile.
846 *
847 * FIXME: this should never happen since it should be caught by check
848 * #1. */
849 return MR_NO_WAR;
850 }
851
852 /* 5) */
853 if ((pcity = tile_city(dst_tile))) {
854 if (enter_enemy_city) {
856 /* You can't move into an empty city of a civilization you're at
857 * peace with - you must first either declare war or make an
858 * alliance. */
859 return MR_NO_WAR;
860 }
861 } else {
863 /* You can't move into an empty city of a civilization you're not
864 * allied to. Assume that the player tried to attack. */
865 return MR_NO_WAR;
866 }
867 }
868 }
869
870 /* 6) */
872 && !pcity && !is_safe_ocean(nmap, dst_tile)) {
873 return MR_TRIREME;
874 }
875
876 /* 7) */
879 return MR_PEACE;
880 }
881
882 return MR_OK;
883}
884
885/************************************************************************/
888bool can_unit_transport(const struct unit *transporter,
889 const struct unit *transported)
890{
891 fc_assert_ret_val(transporter != NULL, FALSE);
892 fc_assert_ret_val(transported != NULL, FALSE);
893
894 return can_unit_type_transport(unit_type_get(transporter),
895 unit_class_get(transported));
896}
897
898/************************************************************************/
901bool can_unit_type_transport(const struct unit_type *transporter,
902 const struct unit_class *transported)
903{
904 if (transporter->transport_capacity <= 0) {
905 return FALSE;
906 }
907
908 return BV_ISSET(transporter->cargo, uclass_index(transported));
909}
910
911/************************************************************************/
916bool unit_can_load(const struct unit *punit)
917{
918 if (unit_transported(punit)) {
919 /* In another transport already. Can it unload first? */
921 return FALSE;
922 }
923 }
924
926 /* could_unit_load() instead of can_unit_load() since latter
927 * would check against unit already being transported, and we need
928 * to support unload+load to a new transport. */
929 if (ptransport != punit->transporter) {
931 return TRUE;
932 }
933 }
935
936 return FALSE;
937}
938
939/************************************************************************/
944bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
945{
948 return TRUE;
949 }
951
952 return FALSE;
953}
954
955static int move_points_denomlen = 0;
956
957/************************************************************************/
961{
962 char denomstr[10];
963 /* String length of maximum denominator for fractional representation of
964 * movement points, for padding of text representation */
965 fc_snprintf(denomstr, sizeof(denomstr), "%d", SINGLE_MOVE);
967}
968
969/************************************************************************/
981const char *move_points_text_full(int mp, bool reduce, const char *prefix,
982 const char *none, bool align)
983{
984 static struct astring str = ASTRING_INIT;
985 int pad1, pad2;
986
987 if (align && SINGLE_MOVE > 1) {
988 /* Align to worst-case denominator even if we might be reducing to
989 * lowest terms, as other entries in a table might not reduce */
990 pad1 = move_points_denomlen; /* numerator or denominator */
991 pad2 = move_points_denomlen*2+2; /* everything right of integer part */
992 } else {
993 /* If no possible fractional part, alignment unneeded even if requested */
994 pad1 = pad2 = 0;
995 }
996 if (!prefix) {
997 prefix = "";
998 }
999 astr_clear(&str);
1000 if ((mp == 0 && none) || SINGLE_MOVE == 0) {
1001 /* No movement points, and we have a special representation to use */
1002 /* (Also used when SINGLE_MOVE == 0, to avoid dividing by zero, which is
1003 * important for client before ruleset has been received. Doesn't much
1004 * matter what we print in this case.) */
1005 astr_add(&str, "%s%*s", none ? none : "", pad2, "");
1006 } else if ((mp % SINGLE_MOVE) == 0) {
1007 /* Integer move points */
1008 astr_add(&str, "%s%d%*s", prefix, mp / SINGLE_MOVE, pad2, "");
1009 } else {
1010 /* Fractional part */
1011 int cancel;
1012
1014 if (reduce) {
1015 /* Reduce to lowest terms */
1016 int gcd = mp;
1017 /* Calculate greatest common divisor with Euclid's algorithm */
1018 int b = SINGLE_MOVE;
1019
1020 while (b != 0) {
1021 int t = b;
1022 b = gcd % b;
1023 gcd = t;
1024 }
1025 cancel = gcd;
1026 } else {
1027 /* No cancellation */
1028 cancel = 1;
1029 }
1030 if (mp < SINGLE_MOVE) {
1031 /* Fractional move points */
1032 astr_add(&str, "%s%*d/%*d", prefix,
1033 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1034 } else {
1035 /* Integer + fractional move points */
1036 astr_add(&str,
1037 "%s%d %*d/%*d", prefix, mp / SINGLE_MOVE,
1038 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1039 }
1040 }
1041 return astr_str(&str);
1042}
1043
1044/************************************************************************/
1048const char *move_points_text(int mp, bool reduce)
1049{
1051}
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:245
#define action_by_result_iterate_end
Definition actions.h:249
#define action_id(_act_)
Definition actions.h:426
void astr_clear(struct astring *astr)
Definition astring.c:201
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:271
#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:86
#define BV_ISSET_ANY(vec)
Definition bitvector.h:117
#define city_tile(_pcity_)
Definition city.h:561
#define city_owner(_pcity_)
Definition city.h:560
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
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:1031
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:61
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
bool is_move_cardinal(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Definition map.c:1507
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:1067
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
Definition map.c:712
#define adjc_iterate_end
Definition map.h:430
#define cardinal_between_iterate(nmap, tile1, tile2, between)
Definition map.h:474
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:425
#define ALL_DIRECTIONS_CARDINAL()
Definition map.h:48
#define cardinal_between_iterate_end
Definition map.h:479
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1048
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Definition movement.c:981
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:278
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:661
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:350
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:362
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:573
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:309
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:104
bool unit_can_load(const struct unit *punit)
Definition movement.c:916
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:888
int unit_move_rate(const struct unit *punit)
Definition movement.c:89
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Definition movement.c:944
static int move_points_denomlen
Definition movement.c:955
bool can_attack_non_native_hard_reqs(const struct unit_type *utype)
Definition movement.c:203
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:226
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:173
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:623
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:404
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:259
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:373
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:242
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:522
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:496
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:603
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:901
void init_move_fragments(void)
Definition movement.c:960
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:213
#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:1409
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1463
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:416
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
Definition city.h:317
struct player * random_move_time
Definition game.h:283
struct packet_game_info info
Definition game.h:89
struct civ_game::@32::@36 server
struct unit_list * units
Definition player.h:282
enum road_move_mode move_mode
Definition road.h:75
bv_unit_classes native_to
Definition terrain.h:150
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:528
bv_unit_classes cargo
Definition unittype.h:563
int move_rate
Definition unittype.h:522
Definition unit.h:140
enum unit_activity activity
Definition unit.h:159
int hp
Definition unit.h:153
bool stay
Definition unit.h:208
struct unit * transporter
Definition unit.h:186
const struct unit_type * utype
Definition unit.h:141
int veteran
Definition unit.h:154
enum universals_n kind
Definition fc_types.h:608
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define terrain_type_iterate_end
Definition terrain.h:272
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
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:115
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:125
#define tile_has_extra(ptile, pextra)
Definition tile.h:152
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1567
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2291
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:819
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2544
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:742
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2528
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:794
#define unit_tile(_pu)
Definition unit.h:407
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:469
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:418
#define unit_owner(_pu)
Definition unit.h:406
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:490
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:443
#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:2503
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:979
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:391
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2601
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:375
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:771
#define utype_class(_t_)
Definition unittype.h:754
#define utype_fuel(ptype)
Definition unittype.h:844
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:622
#define uclass_index(_c_)
Definition unittype.h:747