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{
247 struct dbv tile_processed;
249 bool found = FALSE;
250
252 for (;;) {
254 adjc_iterate(nmap, ptile, piter) {
256 continue;
257 } else if (piter != pexclude
259 tile_extras(piter))) {
260 found = TRUE;
261 break;
262 } else if (piter != pexclude
263 && NULL != tile_city(piter)) {
265 } else {
267 }
269
270 if (found || 0 == tile_list_size(process_queue)) {
271 break; /* No more tile to process. */
272 } else {
275 }
276 }
277
280
281 return found;
282}
283
284/************************************************************************/
289bool can_exist_at_tile(const struct civ_map *nmap,
290 const struct unit_type *utype,
291 const struct tile *ptile)
292{
293 /* Cities are safe havens except for units in the middle of non-native
294 * terrain. This can happen if adjacent terrain is changed after unit
295 * arrived to city. */
296 if (NULL != tile_city(ptile)
298 || is_native_near_tile(nmap, utype_class(utype), ptile)
299 || (1 == game.info.citymindist
300 && is_city_channel_tile(nmap, utype_class(utype), ptile, NULL)))) {
301 return TRUE;
302 }
303
304 /* UTYF_COAST_STRICT unit cannot exist in an ocean tile without access to land. */
306 && !is_safe_ocean(nmap, ptile)) {
307 return FALSE;
308 }
309
310 return is_native_tile(utype, ptile);
311}
312
313/************************************************************************/
319 const struct unit *punit,
320 const struct tile *ptile)
321{
322 return can_exist_at_tile(nmap, unit_type_get(punit), ptile);
323}
324
325/************************************************************************/
331 const struct tile *ptile)
332{
334 tile_extras(ptile));
335}
336
337/************************************************************************/
342 const struct terrain *pterrain,
343 const bv_extras *extras)
344{
345 if (!pterrain) {
346 /* Unknown is considered native terrain */
347 return TRUE;
348 }
349
350 if (BV_ISSET(pterrain->native_to, uclass_index(punitclass))) {
351 return TRUE;
352 }
353
354 if (extras != NULL) {
355 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
356 if (BV_ISSET(*extras, extra_index(pextra))) {
357 return TRUE;
358 }
360 }
361
362 return FALSE;
363}
364
365
366/************************************************************************/
372bool is_native_move(const struct civ_map *nmap,
373 const struct unit_class *punitclass,
374 const struct tile *src_tile,
375 const struct tile *dst_tile)
376{
377 const struct road_type *proad;
378
380 /* We aren't using extras to make the destination native. */
381 return TRUE;
382 } else if (!is_native_tile_to_class(punitclass, src_tile)) {
383 /* Disembarking or leaving port, so ignore road connectivity. */
384 return TRUE;
385 } else if (is_native_to_class(punitclass, tile_terrain(src_tile), NULL)) {
386 /* Native source terrain depends entirely on destination tile nativity. */
388 }
389
390 /* Check for non-road native extras on the source tile. */
391 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
392 if (tile_has_extra(src_tile, pextra)
393 && !is_extra_caused_by(pextra, EC_ROAD)
395 /* If there is one, and the destination is native, the move is native. */
396 return TRUE;
397 }
399
400 extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
401 if (!tile_has_extra(dst_tile, pextra)) {
402 continue;
403 } else if (!is_extra_caused_by(pextra, EC_ROAD)) {
404 /* The destination is native because of a non-road extra. */
405 return TRUE;
406 }
407
408 proad = extra_road_get(pextra);
409
411 extra_type_list_iterate(punitclass->cache.native_tile_extras, jextra) {
412 if (pextra != jextra
414 && tile_has_extra(src_tile, jextra)
415 && road_has_flag(jextra->data.road, RF_JUMP_FROM)) {
416 return TRUE;
417 }
419 }
420
421 extra_type_list_iterate(proad->integrators, iextra) {
422 if (!tile_has_extra(src_tile, iextra)) {
423 continue;
424 }
426 /* move_mode does not matter as all of them accept cardinal move */
427 return TRUE;
428 }
429 switch (extra_road_get(iextra)->move_mode) {
430 case RMM_FAST_ALWAYS:
431 /* Road connects source and destination, so we're fine. */
432 return TRUE;
433 case RMM_CARDINAL:
434 /* Road connects source and destination if cardinal move. */
435 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
436 return TRUE;
437 }
438 break;
439 case RMM_RELAXED:
440 if (is_move_cardinal(nmap, src_tile, dst_tile)) {
441 /* Cardinal moves have no between tiles, so connected. */
442 return TRUE;
443 }
446 || (pextra != iextra && tile_has_extra(between, pextra))) {
447 /* We have a link for the connection.
448 * 'pextra != iextra' is there just to avoid tile_has_extra()
449 * in by far more common case that 'pextra == iextra' */
450 return TRUE;
451 }
453 break;
454 }
457
458 return FALSE;
459}
460
461/************************************************************************/
465 const struct unit_class *uclass,
466 const struct tile *ptile)
467{
468 if (is_native_tile_to_class(uclass, ptile)) {
469 return TRUE;
470 }
471
472 adjc_iterate(nmap, ptile, ptile2) {
473 if (is_native_tile_to_class(uclass, ptile2)) {
474 return TRUE;
475 }
477
478 return FALSE;
479}
480
481/************************************************************************/
491 const struct unit *punit,
492 const struct tile *ptile)
493{
494 const struct unit_type *utype;
495
496 if (!can_unit_exist_at_tile(nmap, punit, ptile)) {
497 return FALSE;
498 }
499
500 if (tile_city(ptile)) {
501 return TRUE;
502 }
503
504 utype = unit_type_get(punit);
505 if (tile_has_refuel_extra(ptile, utype_class(utype))) {
506 /* Unit can always survive at refueling base */
507 return TRUE;
508 }
509
510 if (utype_has_flag(utype, UTYF_COAST) && is_safe_ocean(nmap, ptile)) {
511 /* Refueling coast */
512 return TRUE;
513 }
514
515 if (utype_fuel(utype)) {
516 /* Unit requires fuel and this is not refueling tile */
517 return FALSE;
518 }
519
520 if (is_losing_hp(punit)) {
521 /* Unit is losing HP over time in this tile (no city or native base) */
522 return FALSE;
523 }
524
525 return TRUE;
526}
527
528
529/************************************************************************/
542 const struct player *unit_owner,
543 const struct tile *src_tile,
544 const struct tile *dst_tile,
545 const struct civ_map *zmap)
546{
548 return TRUE;
549 }
551 return TRUE;
552 }
553 if (tile_city(src_tile) || tile_city(dst_tile)) {
554 return TRUE;
555 }
558 return TRUE;
559 }
560
561 return (is_my_zoc(unit_owner, src_tile, zmap)
563}
564
565/************************************************************************/
572 const struct unit *punit,
573 const struct tile *dst_tile,
574 bool igzoc,
575 bool enter_transport,
576 bool enter_enemy_city)
577{
583}
584
585/************************************************************************/
592 const struct unit *punit,
593 const struct tile *dst_tile,
594 bool enter_transport,
595 bool enter_enemy_city)
596{
601}
602
603/************************************************************************/
630 const struct unit *punit,
631 enum unit_activity activity,
632 const struct tile *src_tile,
633 const struct tile *dst_tile, bool igzoc,
634 bool enter_transport, struct unit *embark_to,
635 bool enter_enemy_city)
636{
637 bool zoc;
638 struct city *pcity;
639 const struct unit_type *punittype = unit_type_get(punit);
640 const struct player *puowner = unit_owner(punit);
641
642 /* 1) */
643 if (activity != ACTIVITY_IDLE
644 && activity != ACTIVITY_GOTO) {
645 /* For other activities the unit must be stationary. */
646 return MR_BAD_ACTIVITY;
647 }
648
649 /* 2) */
650 if (punit->stay) {
651 return MR_UNIT_STAY;
652 }
653
654 /* 3) */
657 return MR_RANDOM_ONLY;
658 }
659
660 /* 4) */
661 if (!is_tiles_adjacent(src_tile, dst_tile)) {
662 /* Of course you can only move to adjacent positions. */
663 return MR_BAD_DESTINATION;
664 }
665
666 /* 5) */
669 /* You can't move onto a tile with non-allied units on it (try
670 * attacking instead). */
672 }
673
674 /* 6) */
675 if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
676 && dst_tile->terrain->animal != punittype) {
678 }
679
680 /* 7) */
681 if (embark_to != NULL) {
684 }
689 }
690
691 /* 8) */
693 /* You can't move into a non-allied tile.
694 *
695 * FIXME: this should never happen since it should be caught by check
696 * #5. */
697 return MR_NO_WAR;
698 }
699
700 /* 9) */
701 if ((pcity = tile_city(dst_tile))) {
702 if (enter_enemy_city) {
704 /* You can't move into an empty city of a civilization you're at
705 * peace with - you must first either declare war or make an
706 * alliance. */
707 return MR_NO_WAR;
708 }
709 } else {
711 /* You can't move into an empty city of a civilization you're not
712 * allied to. Assume that the player tried to attack. */
713 return MR_NO_WAR;
714 }
715 }
716 }
717
718 /* 10) */
719 zoc = igzoc
721 if (!zoc) {
722 /* The move is illegal because of zones of control. */
723 return MR_ZOC;
724 }
725
726 /* 11) */
728 && !pcity && !is_safe_ocean(nmap, dst_tile)) {
729 return MR_TRIREME;
730 }
731
732 /* 12) */
735 return MR_PEACE;
736 }
737
738 /* 13) */
741 return MR_CANNOT_DISEMBARK;
742 }
743
744 /* 14) */
746 /* Allow non-native moves into cities or boarding transport. */
747 || pcity
749 return MR_NON_NATIVE_MOVE;
750 }
751
752 return MR_OK;
753}
754
755/************************************************************************/
775 const struct unit *punit,
776 enum unit_activity activity,
777 const struct tile *src_tile,
778 const struct tile *dst_tile,
779 bool enter_transport, struct unit *embark_to,
780 bool enter_enemy_city)
781{
782 struct city *pcity;
783 const struct unit_type *punittype = unit_type_get(punit);
784 const struct player *puowner = unit_owner(punit);
785
786 /* 1) */
789 /* You can't move onto a tile with non-allied units on it (try
790 * attacking instead). */
792 }
793
794 /* 2) */
795 if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
796 && dst_tile->terrain->animal != punittype) {
798 }
799
800 /* 3) */
801 if (embark_to != NULL) {
804 }
809 }
810
811 /* 4) */
813 /* You can't move into a non-allied tile.
814 *
815 * FIXME: this should never happen since it should be caught by check
816 * #1. */
817 return MR_NO_WAR;
818 }
819
820 /* 5) */
821 if ((pcity = tile_city(dst_tile))) {
822 if (enter_enemy_city) {
824 /* You can't move into an empty city of a civilization you're at
825 * peace with - you must first either declare war or make an
826 * alliance. */
827 return MR_NO_WAR;
828 }
829 } else {
831 /* You can't move into an empty city of a civilization you're not
832 * allied to. Assume that the player tried to attack. */
833 return MR_NO_WAR;
834 }
835 }
836 }
837
838 /* 6) */
840 && !pcity && !is_safe_ocean(nmap, dst_tile)) {
841 return MR_TRIREME;
842 }
843
844 /* 7) */
847 return MR_PEACE;
848 }
849
850 return MR_OK;
851}
852
853/************************************************************************/
856bool can_unit_transport(const struct unit *transporter,
857 const struct unit *transported)
858{
859 fc_assert_ret_val(transporter != NULL, FALSE);
860 fc_assert_ret_val(transported != NULL, FALSE);
861
862 return can_unit_type_transport(unit_type_get(transporter),
863 unit_class_get(transported));
864}
865
866/************************************************************************/
869bool can_unit_type_transport(const struct unit_type *transporter,
870 const struct unit_class *transported)
871{
872 if (transporter->transport_capacity <= 0) {
873 return FALSE;
874 }
875
876 return BV_ISSET(transporter->cargo, uclass_index(transported));
877}
878
879/************************************************************************/
884bool unit_can_load(const struct unit *punit)
885{
886 if (unit_transported(punit)) {
887 /* In another transport already. Can it unload first? */
889 return FALSE;
890 }
891 }
892
894 /* could_unit_load() instead of can_unit_load() since latter
895 * would check against unit already being transported, and we need
896 * to support unload+load to a new transport. */
897 if (ptransport != punit->transporter) {
899 return TRUE;
900 }
901 }
903
904 return FALSE;
905}
906
907/************************************************************************/
912bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
913{
916 return TRUE;
917 }
919
920 return FALSE;
921}
922
923static int move_points_denomlen = 0;
924
925/************************************************************************/
929{
930 char denomstr[10];
931 /* String length of maximum denominator for fractional representation of
932 * movement points, for padding of text representation */
933 fc_snprintf(denomstr, sizeof(denomstr), "%d", SINGLE_MOVE);
935}
936
937/************************************************************************/
949const char *move_points_text_full(int mp, bool reduce, const char *prefix,
950 const char *none, bool align)
951{
952 static struct astring str = ASTRING_INIT;
953 int pad1, pad2;
954
955 if (align && SINGLE_MOVE > 1) {
956 /* Align to worst-case denominator even if we might be reducing to
957 * lowest terms, as other entries in a table might not reduce */
958 pad1 = move_points_denomlen; /* numerator or denominator */
959 pad2 = move_points_denomlen*2+2; /* everything right of integer part */
960 } else {
961 /* If no possible fractional part, alignment unneeded even if requested */
962 pad1 = pad2 = 0;
963 }
964 if (!prefix) {
965 prefix = "";
966 }
967 astr_clear(&str);
968 if ((mp == 0 && none) || SINGLE_MOVE == 0) {
969 /* No movement points, and we have a special representation to use */
970 /* (Also used when SINGLE_MOVE == 0, to avoid dividing by zero, which is
971 * important for client before ruleset has been received. Doesn't much
972 * matter what we print in this case.) */
973 astr_add(&str, "%s%*s", none ? none : "", pad2, "");
974 } else if ((mp % SINGLE_MOVE) == 0) {
975 /* Integer move points */
976 astr_add(&str, "%s%d%*s", prefix, mp / SINGLE_MOVE, pad2, "");
977 } else {
978 /* Fractional part */
979 int cancel;
980
982 if (reduce) {
983 /* Reduce to lowest terms */
984 int gcd = mp;
985 /* Calculate greatest common divisor with Euclid's algorithm */
986 int b = SINGLE_MOVE;
987
988 while (b != 0) {
989 int t = b;
990 b = gcd % b;
991 gcd = t;
992 }
993 cancel = gcd;
994 } else {
995 /* No cancellation */
996 cancel = 1;
997 }
998 if (mp < SINGLE_MOVE) {
999 /* Fractional move points */
1000 astr_add(&str, "%s%*d/%*d", prefix,
1001 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1002 } else {
1003 /* Integer + fractional move points */
1004 astr_add(&str,
1005 "%s%d %*d/%*d", prefix, mp / SINGLE_MOVE,
1006 pad1, (mp % SINGLE_MOVE) / cancel, pad1, SINGLE_MOVE / cancel);
1007 }
1008 }
1009 return astr_str(&str);
1010}
1011
1012/************************************************************************/
1016const char *move_points_text(int mp, bool reduce)
1017{
1019}
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:241
#define action_by_result_iterate_end
Definition actions.h:245
#define action_id(_act_)
Definition actions.h:422
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
void dbv_init(struct dbv *pdbv, int bits)
Definition bitvector.c:50
void dbv_set(struct dbv *pdbv, int bit)
Definition bitvector.c:142
bool dbv_isset(const struct dbv *pdbv, int bit)
Definition bitvector.c:120
void dbv_free(struct dbv *pdbv)
Definition bitvector.c:95
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define BV_ISSET_ANY(vec)
Definition bitvector.h:117
#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
int map_num_tiles(void)
Definition map.c:1152
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:1016
const char * move_points_text_full(int mp, bool reduce, const char *prefix, const char *none, bool align)
Definition movement.c:949
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:289
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:629
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:318
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:330
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:541
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:884
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:856
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:912
static int move_points_denomlen
Definition movement.c:923
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:774
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:591
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:372
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:341
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:490
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:464
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:571
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:869
void init_move_fragments(void)
Definition movement.c:928
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:213
#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:84
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:530
bv_unit_classes cargo
Definition unittype.h:565
int move_rate
Definition unittype.h:524
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
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define tile_terrain(_tile)
Definition tile.h:111
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:121
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1541
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2265
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:801
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2518
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
#define unit_tile(_pu)
Definition unit.h:404
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:466
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:415
#define unit_owner(_pu)
Definition unit.h:403
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:487
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:440
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_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:2505
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:981
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:393
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2603
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:377
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773
#define utype_class(_t_)
Definition unittype.h:756
#define utype_fuel(ptype)
Definition unittype.h:846
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define uclass_index(_c_)
Definition unittype.h:749