Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/aicore/pf_tools.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
pf_tools.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2003 - The Freeciv Project
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#include <string.h>
19
20/* utility */
21#include "bitvector.h"
22#include "log.h"
23#include "mem.h"
24
25/* common */
26#include "base.h"
27#include "combat.h"
28#include "game.h"
29#include "movement.h"
30#include "tile.h"
31#include "unit.h"
32#include "unittype.h"
33
34/* aicore */
35#include "aiactions.h"
36
37#include "pf_tools.h"
38
39/* ===================== Capability Functions ======================== */
40
41/************************************************************************/
45 static inline bool pf_attack_possible(const struct tile *ptile,
46 enum known_type known,
47 const struct pf_parameter *param)
48{
49 bool non_allied_city;
50 bool attack_any;
51
52 if (!can_attack_non_native(param->utype)
53 && !is_native_tile(param->utype, ptile)) {
54 return FALSE;
55 }
56
57 if (TILE_KNOWN_SEEN != known) {
58 /* We cannot see units, let's assume we can attack. */
59 return TRUE;
60 }
61
62 non_allied_city = is_non_allied_city_tile(ptile, param->owner);
63 attack_any = FALSE;
64
65 unit_list_iterate(ptile->units, punit) {
66 /* Any non-hostile unit will fail the whole stack*/
67 if (!pplayers_at_war(unit_owner(punit), param->owner)) {
68 return FALSE;
69 }
70
71 /* Hostile unit reachability test. */
72 if (BV_ISSET(param->utype->targets, uclass_index(unit_class_get(punit)))
73 || tile_has_native_base(ptile, unit_type_get(punit))
74 || non_allied_city) {
75 attack_any = TRUE;
76 } else if (game.info.unreachable_protects) {
77 /* We get here if punit is unreachable to utype */
78 if (!utype_has_flag(unit_type_get(punit), UTYF_NEVER_PROTECTS)) {
79 return FALSE;
80 }
81 /* NB: if there are UTYF_NEVER_PROTECTS units on the tile, 'attack_any'
82 has to get set TRUE at least once to enable an attack to the tile,
83 which is exactly correct behaviour. */
84 }
85 } unit_list_iterate_end;
86
87 return attack_any;
88}
89
90/************************************************************************/
96 static enum pf_action pf_get_action(const struct tile *ptile,
97 enum known_type known,
98 const struct pf_parameter *param)
99{
100 bool non_allied_city = is_non_allied_city_tile(ptile, param->owner);
101
102 if (non_allied_city) {
103 if (PF_AA_TRADE_ROUTE & param->actions) {
104 return PF_ACTION_TRADE_ROUTE;
105 }
106
107 if (PF_AA_DIPLOMAT & param->actions) {
108 return PF_ACTION_DIPLOMAT;
109 }
110 }
111
112 if (is_non_allied_unit_tile(ptile, param->owner)) {
113 if (PF_AA_DIPLOMAT & param->actions) {
114 return PF_ACTION_DIPLOMAT;
115 }
116
117 if (PF_AA_UNIT_ATTACK & param->actions) {
118 return (pf_attack_possible(ptile, known, param)
119 ? PF_ACTION_ATTACK : PF_ACTION_IMPOSSIBLE);
120 }
121 }
122
123 if (non_allied_city && PF_AA_CITY_ATTACK & param->actions) {
124 /* Consider that there are potentially units, even if
125 * is_non_allied_unit_tile() returned NULL (usually when
126 * '!param->omniscience'). */
127 return ((utype_can_take_over(param->utype)
128 || pf_attack_possible(ptile, TILE_KNOWN_UNSEEN, param))
129 ? PF_ACTION_ATTACK : PF_ACTION_IMPOSSIBLE);
130 }
131
132 return PF_ACTION_NONE;
133}
134
135/************************************************************************/
139 static bool pf_action_possible(const struct tile *src,
140 enum pf_move_scope src_scope,
141 const struct tile *dst,
142 enum pf_action action,
143 const struct pf_parameter *param)
144{
145 if (PF_ACTION_ATTACK == action) {
146 return (PF_MS_NATIVE & src_scope
147 || can_attack_from_non_native(param->utype));
148
149 } else if (PF_ACTION_DIPLOMAT == action
150 || PF_ACTION_TRADE_ROUTE == action) {
151 /* Don't try to act when inside of a transport over non native terrain
152 * when all actions the unit type can do requires the unit to be on
153 * native terrain. */
154 if (can_unit_act_when_ustate_is(param->utype, USP_LIVABLE_TILE, FALSE)) {
155 return (PF_MS_NATIVE | PF_MS_CITY | PF_MS_TRANSPORT) & src_scope;
156 } else {
157 return (PF_MS_NATIVE | PF_MS_CITY) & src_scope;
158 }
159 }
160 return TRUE;
161}
162
163/************************************************************************/
167 static enum pf_action pf_reverse_get_action(const struct tile *ptile,
168 enum known_type known,
169 const struct pf_parameter *param)
170{
171 return (ptile == param->data ? PF_ACTION_ATTACK : PF_ACTION_NONE);
172}
173
174/************************************************************************/
177 static inline bool pf_transport_check(const struct pf_parameter *param,
178 const struct unit *ptrans,
179 const struct unit_type *trans_utype)
180{
181 if (!pplayers_allied(unit_owner(ptrans), param->owner)
182 || param->utype == trans_utype
183 || !can_unit_type_transport(trans_utype, utype_class(param->utype))
184 || can_unit_type_transport(param->utype, utype_class(trans_utype))
185 || (GAME_TRANSPORT_MAX_RECURSIVE
186 < 1 + unit_transport_depth(ptrans) + param->cargo_depth)) {
187 return FALSE;
188 }
189
190 if (1 <= param->cargo_depth) {
191 unit_type_iterate(cargo_utype) {
192 if (BV_ISSET(param->cargo_types, utype_index(cargo_utype))
193 && (cargo_utype == trans_utype
194 || can_unit_type_transport(cargo_utype,
195 utype_class(trans_utype)))) {
196 return FALSE;
197 }
198 } unit_type_iterate_end;
199 }
200
201 unit_transports_iterate(ptrans, pparent) {
202 if (unit_has_orders(pparent)
203 || param->utype == (trans_utype = unit_type_get(pparent))
204 || can_unit_type_transport(param->utype, utype_class(trans_utype))) {
205 return FALSE;
206 }
207
208 if (1 <= param->cargo_depth) {
209 unit_type_iterate(cargo_utype) {
210 if (BV_ISSET(param->cargo_types, utype_index(cargo_utype))
211 && (cargo_utype == trans_utype
212 || can_unit_type_transport(cargo_utype,
213 utype_class(trans_utype)))) {
214 return FALSE;
215 }
216 } unit_type_iterate_end;
217 }
218 } unit_transports_iterate_end;
219
220 return TRUE;
221}
222
223/************************************************************************/
227static enum pf_move_scope
228pf_get_move_scope(const struct tile *ptile,
229 bool *can_disembark,
230 enum pf_move_scope previous_scope,
231 const struct pf_parameter *param)
232{
233 enum pf_move_scope scope = PF_MS_NONE;
234 const struct unit_class *uclass = utype_class(param->utype);
235 struct city *pcity = tile_city(ptile);
236
237 if ((is_native_tile_to_class(uclass, ptile)
238 && (!utype_has_flag(param->utype, UTYF_COAST_STRICT)
239 || is_safe_ocean(param->map, ptile)))) {
240 scope |= PF_MS_NATIVE;
241 }
242
243 if (NULL != pcity
244 && (utype_can_take_over(param->utype)
245 || pplayers_allied(param->owner, city_owner(pcity)))
246 && ((previous_scope & PF_MS_CITY) /* City channel previously tested */
247 || uclass_has_flag(uclass, UCF_BUILD_ANYWHERE)
248 || is_native_near_tile(param->map, uclass, ptile)
249 || (1 == game.info.citymindist
250 && is_city_channel_tile(param->map, uclass, ptile, NULL)))) {
251 scope |= PF_MS_CITY;
252 }
253
254 if (PF_MS_NONE == scope) {
255 /* Check for transporters. Useless if we already got another way to
256 * move. */
257 bool allied_city_tile = (NULL != pcity
258 && pplayers_allied(param->owner,
259 city_owner(pcity)));
260 const struct unit_type *utype;
261
262 *can_disembark = FALSE;
263
264 unit_list_iterate(ptile->units, punit) {
265 utype = unit_type_get(punit);
266
267 if (!pf_transport_check(param, punit, utype)) {
268 continue;
269 }
270
271 if (allied_city_tile
272 || tile_has_native_base(ptile, utype)) {
273 scope |= PF_MS_TRANSPORT;
274
275 /* If transport is moving, we are not going to continue where we expected
276 * through it. */
277 *can_disembark = !unit_has_orders(punit);
278 break;
279 }
280
281 if (!utype_can_freely_load(param->utype, utype)) {
282 continue;
283 }
284
285 scope |= PF_MS_TRANSPORT;
286
287 if (utype_can_freely_unload(param->utype, utype)) {
288
289 /* If transport is moving, we are not going to continue where we expected
290 * through it. */
291 *can_disembark = !unit_has_orders(punit);
292 break;
293 }
294 } unit_list_iterate_end;
295 }
296
297 return scope;
298}
299
300/************************************************************************/
303static enum pf_move_scope
304amphibious_move_scope(const struct tile *ptile,
305 bool *can_disembark,
306 enum pf_move_scope previous_scope,
307 const struct pf_parameter *param)
308{
309 struct pft_amphibious *amphibious = param->data;
310 enum pf_move_scope land_scope, sea_scope;
311 bool dumb;
312
313 land_scope = pf_get_move_scope(ptile, &dumb, previous_scope,
314 &amphibious->land);
315 sea_scope = pf_get_move_scope(ptile, &dumb, land_scope, &amphibious->sea);
316
317 if ((PF_MS_NATIVE | PF_MS_CITY) & sea_scope) {
318 *can_disembark = (PF_MS_CITY & sea_scope
319 || utype_can_freely_unload(amphibious->land.utype,
320 amphibious->sea.utype)
321 || tile_has_native_base(ptile, amphibious->sea.utype));
322 return PF_MS_TRANSPORT | land_scope;
323 }
324 return ~PF_MS_TRANSPORT & land_scope;
325}
326
327/************************************************************************/
335 static inline bool pf_move_possible(const struct tile *src,
336 enum pf_move_scope src_scope,
337 const struct tile *dst,
338 enum pf_move_scope dst_scope,
339 const struct pf_parameter *param)
340{
341 fc_assert(PF_MS_NONE != src_scope);
342
343 if (PF_MS_NONE == dst_scope) {
344 return FALSE;
345 }
346
347 if (PF_MS_NATIVE == dst_scope
348 && (PF_MS_NATIVE & src_scope)
349 && !is_native_move(param->map, utype_class(param->utype), src, dst)) {
350 return FALSE;
351 }
352
353 return TRUE;
354}
355
356
357/* ===================== Move Cost Callbacks ========================= */
358
359/************************************************************************/
364 static unsigned normal_move(const struct tile *src,
365 enum pf_move_scope src_scope,
366 const struct tile *dst,
367 enum pf_move_scope dst_scope,
368 const struct pf_parameter *param)
369{
370 if (pf_move_possible(src, src_scope, dst, dst_scope, param)) {
371 return map_move_cost(param->map, param->owner, param->utype, src, dst);
372 }
373
374 return PF_IMPOSSIBLE_MC;
375}
376
377/************************************************************************/
384 static unsigned overlap_move(const struct tile *src,
385 enum pf_move_scope src_scope,
386 const struct tile *dst,
387 enum pf_move_scope dst_scope,
388 const struct pf_parameter *param)
389{
390 if (pf_move_possible(src, src_scope, dst, dst_scope, param)) {
391 return map_move_cost(param->map, param->owner, param->utype, src, dst);
392 } else if (!(PF_MS_NATIVE & dst_scope)) {
393 /* This should always be the last tile reached. */
394 return param->move_rate;
395 }
396
397 return PF_IMPOSSIBLE_MC;
398}
399
400/************************************************************************/
403 static unsigned amphibious_move(const struct tile *ptile,
404 enum pf_move_scope src_scope,
405 const struct tile *ptile1,
406 enum pf_move_scope dst_scope,
407 const struct pf_parameter *param)
408{
409 struct pft_amphibious *amphibious = param->data;
410 unsigned cost;
411 int scale;
412
413 if (PF_MS_TRANSPORT & src_scope) {
414 if (PF_MS_TRANSPORT & dst_scope) {
415 /* Sea move, moving from native terrain to a city, or leaving port. */
416 cost = amphibious->sea.get_MC(ptile,
417 (PF_MS_CITY & src_scope) | PF_MS_NATIVE,
418 ptile1,
419 (PF_MS_CITY & dst_scope) | PF_MS_NATIVE,
420 &amphibious->sea);
421 scale = amphibious->sea_scale;
422 } else if (PF_MS_NATIVE & dst_scope) {
423 /* Disembark; use land movement function to handle non-native attacks. */
424 cost = amphibious->land.get_MC(ptile, PF_MS_TRANSPORT, ptile1,
425 PF_MS_NATIVE, &amphibious->land);
426 scale = amphibious->land_scale;
427 } else {
428 /* Neither ferry nor passenger can enter tile. */
429 return PF_IMPOSSIBLE_MC;
430 }
431 } else if ((PF_MS_NATIVE | PF_MS_CITY) & dst_scope) {
432 /* Land move */
433 cost = amphibious->land.get_MC(ptile, PF_MS_NATIVE, ptile1,
434 PF_MS_NATIVE, &amphibious->land);
435 scale = amphibious->land_scale;
436 } else {
437 /* Now we have disembarked, our ferry can not help us - we have to
438 * stay on the land. */
439 return PF_IMPOSSIBLE_MC;
440 }
441 if (cost != PF_IMPOSSIBLE_MC && cost < FC_INFINITY) {
442 cost *= scale;
443 }
444
445 return cost;
446}
447
448/* ===================== Extra Cost Callbacks ======================== */
449
450/************************************************************************/
453 static unsigned amphibious_extra_cost(const struct tile *ptile,
454 enum known_type known,
455 const struct pf_parameter *param)
456{
457 struct pft_amphibious *amphibious = param->data;
458 const bool ferry_move = is_native_tile(amphibious->sea.utype, ptile);
459 unsigned cost;
460 int scale;
461
462 if (known == TILE_UNKNOWN) {
463 /* We can travel almost anywhere */
464 cost = SINGLE_MOVE;
465 scale = MAX(amphibious->sea_scale, amphibious->land_scale);
466 } else if (ferry_move && amphibious->sea.get_EC) {
467 /* Do the EC callback for sea moves. */
468 cost = amphibious->sea.get_EC(ptile, known, &amphibious->sea);
469 scale = amphibious->sea_scale;
470 } else if (!ferry_move && amphibious->land.get_EC) {
471 /* Do the EC callback for land moves. */
472 cost = amphibious->land.get_EC(ptile, known, &amphibious->land);
473 scale = amphibious->land_scale;
474 } else {
475 cost = 0;
476 scale = 1;
477 }
478
479 if (cost != PF_IMPOSSIBLE_MC) {
480 cost *= scale;
481 }
482
483 return cost;
484}
485
486
487/* ===================== Tile Behaviour Callbacks ==================== */
488
489/************************************************************************/
493 enum tile_behavior no_fights_or_unknown(const struct tile *ptile,
494 enum known_type known,
495 const struct pf_parameter *param)
496{
497 if (known == TILE_UNKNOWN
498 || is_non_allied_unit_tile(ptile, param->owner)
499 || is_non_allied_city_tile(ptile, param->owner)) {
500 /* Can't attack */
501 return TB_IGNORE;
502 }
503 return TB_NORMAL;
504}
505
506/************************************************************************/
509 enum tile_behavior no_fights(const struct tile *ptile,
510 enum known_type known,
511 const struct pf_parameter *param)
512{
513 if (is_non_allied_unit_tile(ptile, param->owner)
514 || is_non_allied_city_tile(ptile, param->owner)) {
515 /* Can't attack */
516 return TB_IGNORE;
517 }
518 return TB_NORMAL;
519}
520
521/************************************************************************/
524 enum tile_behavior no_intermediate_fights(const struct tile *ptile,
525 enum known_type known,
526 const struct pf_parameter *param)
527{
528 if (is_non_allied_unit_tile(ptile, param->owner)
529 || is_non_allied_city_tile(ptile, param->owner)) {
530 return TB_DONT_LEAVE;
531 }
532 return TB_NORMAL;
533}
534
535/************************************************************************/
538static enum tile_behavior
539amphibious_behaviour(const struct tile *ptile, enum known_type known,
540 const struct pf_parameter *param)
541{
542 struct pft_amphibious *amphibious = param->data;
543 const bool ferry_move = is_native_tile(amphibious->sea.utype, ptile);
544
545 /* Simply a wrapper for the sea or land tile_behavior callbacks. */
546 if (ferry_move && amphibious->sea.get_TB) {
547 return amphibious->sea.get_TB(ptile, known, &amphibious->sea);
548 } else if (!ferry_move && amphibious->land.get_TB) {
549 return amphibious->land.get_TB(ptile, known, &amphibious->land);
550 }
551 return TB_NORMAL;
552}
553
554/* ===================== Required Moves Lefts Callbacks ================= */
555
556/************************************************************************/
559 static bool is_possible_base_fuel(const struct tile *ptile,
560 const struct pf_parameter *param)
561{
562 const struct unit_class *uclass;
563 enum known_type tile_known = (param->omniscience ? TILE_KNOWN_SEEN
564 : tile_get_known(ptile, param->owner));
565
566 if (tile_known == TILE_UNKNOWN) {
567 /* Cannot guess if it is */
568 return FALSE;
569 }
570
571 if (is_allied_city_tile(ptile, param->owner)) {
572 return TRUE;
573 }
574
575 uclass = utype_class(param->utype);
576 extra_type_list_iterate(uclass->cache.refuel_extras, pextra) {
577 /* All airbases are considered possible, simply attack enemies. */
578 if (tile_has_extra(ptile, pextra)) {
579 return TRUE;
580 }
581 } extra_type_list_iterate_end;
582
583 if (utype_has_flag(param->utype, UTYF_COAST)) {
584 return is_safe_ocean(param->map, ptile);
585 }
586
587 if (tile_known == TILE_KNOWN_UNSEEN) {
588 /* Cannot see units */
589 return FALSE;
590 }
591
592 /* Check for carriers */
593 unit_list_iterate(ptile->units, ptrans) {
594 const struct unit_type *trans_utype = unit_type_get(ptrans);
595
596 if (pf_transport_check(param, ptrans, trans_utype)
597 && !unit_has_orders(ptrans) /* Don't load to moving carrier */
598 && (utype_can_freely_load(param->utype, trans_utype)
599 || tile_has_native_base(ptile, trans_utype))) {
600 return TRUE;
601 }
602 } unit_list_iterate_end;
603
604 return FALSE;
605}
606
607/************************************************************************/
610 static int get_closest_safe_tile_distance(const struct tile *src_tile,
611 const struct pf_parameter *param,
612 int max_distance)
613{
614 /* This iteration should, according to the documentation in map.h iterate
615 * tiles from the center tile, so we stop the iteration to the first found
616 * refuel point (as it should be the closest). */
617 iterate_outward_dxy(param->map, src_tile, max_distance, ptile, x, y) {
618 if (tile_get_known(ptile, param->owner) == TILE_UNKNOWN) {
619 /* Cannot guess if the tile is safe */
620 continue;
621 }
622 if (is_possible_base_fuel(ptile, param)) {
623 return map_vector_to_real_distance(x, y);
624 }
625 } iterate_outward_dxy_end;
626
627 return -1;
628}
629
630/* ==================== Postion Dangerous Callbacks =================== */
631
632/************************************************************************/
635 static int get_fuel_moves_left_req(const struct tile *ptile,
636 enum known_type known,
637 const struct pf_parameter *param)
638{
639 int dist, max;
640
641 if (is_possible_base_fuel(ptile, param)) {
642 return 0;
643 }
644
645 /* Upper bound for search for refuel point. Sometimes unit can have more
646 * moves left than its own move rate due to wonder transfer. Compare
647 * pf_moves_left_initially(). */
648 max = MAX(param->moves_left_initially
649 + (param->fuel_left_initially - 1) * param->move_rate,
650 param->move_rate * param->fuel);
651 dist = get_closest_safe_tile_distance(ptile, param, max / SINGLE_MOVE);
652
653 return dist != -1 ? dist * SINGLE_MOVE : PF_IMPOSSIBLE_MC;
654}
655
656/************************************************************************/
659 static bool amphibious_is_pos_dangerous(const struct tile *ptile,
660 enum known_type known,
661 const struct pf_parameter *param)
662{
663 struct pft_amphibious *amphibious = param->data;
664 const bool ferry_move = is_native_tile(amphibious->sea.utype, ptile);
665
666 /* Simply a wrapper for the sea or land danger callbacks. */
667 if (ferry_move && amphibious->sea.is_pos_dangerous) {
668 return amphibious->sea.is_pos_dangerous(ptile, known, param);
669 } else if (!ferry_move && amphibious->land.is_pos_dangerous) {
670 return amphibious->land.is_pos_dangerous(ptile, known, param);
671 }
672 return FALSE;
673}
674
675/* ======================= Tools for filling parameters ================= */
676
677/************************************************************************/
680static inline void
681pft_fill_default_parameter(struct pf_parameter *parameter,
682 const struct civ_map *nmap,
683 const struct unit_type *punittype)
684{
685 parameter->map = nmap;
686 parameter->get_TB = NULL;
687 parameter->get_EC = NULL;
688 parameter->is_pos_dangerous = NULL;
689 parameter->get_moves_left_req = NULL;
690 parameter->get_costs = NULL;
691 parameter->get_zoc = NULL;
692 parameter->get_move_scope = pf_get_move_scope;
693 parameter->get_action = NULL;
694 parameter->is_action_possible = NULL;
695 parameter->actions = PF_AA_NONE;
696
697 parameter->utype = punittype;
698}
699
700/************************************************************************/
703static inline void
704pft_enable_default_actions(struct pf_parameter *parameter)
705{
706 if (!utype_has_flag(parameter->utype, UTYF_CIVILIAN)) {
707 parameter->actions |= PF_AA_UNIT_ATTACK;
708 parameter->get_action = pf_get_action;
709 parameter->is_action_possible = pf_action_possible;
710 if (!parameter->omniscience) {
711 /* Consider units hidden in cities. */
712 parameter->actions |= PF_AA_CITY_ATTACK;
713 }
714 }
715 if (utype_may_act_at_all(parameter->utype)) {
716 /* FIXME: it should consider action enablers. */
717 if (aia_utype_is_considered_caravan_trade(parameter->utype)) {
718 parameter->actions |= PF_AA_TRADE_ROUTE;
719 }
720 if (aia_utype_is_considered_spy(parameter->utype)) {
721 parameter->actions |= PF_AA_DIPLOMAT;
722 }
723 parameter->get_action = pf_get_action;
724 parameter->is_action_possible = pf_action_possible;
725 }
726}
727
728/************************************************************************/
731static inline void
732pft_fill_utype_default_parameter(struct pf_parameter *parameter,
733 const struct civ_map *nmap,
734 const struct unit_type *punittype,
735 struct tile *pstart_tile,
736 struct player *powner)
737{
738 int veteran_level = get_unittype_bonus(powner, pstart_tile, punittype,
739 NULL, EFT_VETERAN_BUILD);
740
741 if (veteran_level >= utype_veteran_levels(punittype)) {
742 veteran_level = utype_veteran_levels(punittype) - 1;
743 }
744
745 pft_fill_default_parameter(parameter, nmap, punittype);
746
747 parameter->start_tile = pstart_tile;
748 parameter->moves_left_initially = punittype->move_rate;
749 parameter->move_rate = utype_move_rate(punittype, pstart_tile, powner,
750 veteran_level, punittype->hp);
751 if (utype_fuel(punittype)) {
752 parameter->fuel_left_initially = utype_fuel(punittype);
753 parameter->fuel = utype_fuel(punittype);
754 } else {
755 parameter->fuel = 1;
756 parameter->fuel_left_initially = 1;
757 }
758 parameter->transported_by_initially = NULL;
759 parameter->cargo_depth = 0;
760 BV_CLR_ALL(parameter->cargo_types);
761 parameter->owner = powner;
762
763 parameter->omniscience = FALSE;
764}
765
766/************************************************************************/
769static inline void
770pft_fill_unit_default_parameter(struct pf_parameter *parameter,
771 const struct civ_map *nmap,
772 const struct unit *punit)
773{
774 const struct unit *ptrans = unit_transport_get(punit);
775 const struct unit_type *ptype = unit_type_get(punit);
776
777 pft_fill_default_parameter(parameter, nmap, ptype);
778
779 parameter->start_tile = unit_tile(punit);
780 parameter->moves_left_initially = punit->moves_left;
781 parameter->move_rate = unit_move_rate(punit);
782 if (utype_fuel(ptype)) {
783 parameter->fuel_left_initially = punit->fuel;
784 parameter->fuel = utype_fuel(ptype);
785 } else {
786 parameter->fuel = 1;
787 parameter->fuel_left_initially = 1;
788 }
789 parameter->transported_by_initially = (NULL != ptrans ? unit_type_get(ptrans)
790 : NULL);
791 parameter->cargo_depth = unit_cargo_depth(punit);
792 BV_CLR_ALL(parameter->cargo_types);
793 unit_cargo_iterate(punit, pcargo) {
794 BV_SET(parameter->cargo_types, utype_index(unit_type_get(pcargo)));
795 } unit_cargo_iterate_end;
796 parameter->owner = unit_owner(punit);
797
798 parameter->omniscience = FALSE;
799}
800
801/************************************************************************/
804 static inline void pft_fill_parameter(struct pf_parameter *parameter,
805 const struct unit_type *punittype)
806{
807 parameter->get_MC = normal_move;
808 parameter->ignore_none_scopes = TRUE;
809 pft_enable_default_actions(parameter);
810
811 if (!parameter->get_moves_left_req && utype_fuel(punittype)) {
812 /* Unit needs fuel */
813 parameter->get_moves_left_req = get_fuel_moves_left_req;
814 }
815
816 if (!unit_type_really_ignores_zoc(punittype)) {
817 parameter->get_zoc = is_server() ? is_plr_zoc_srv : is_plr_zoc_client;
818 } else {
819 parameter->get_zoc = NULL;
820 }
821}
822
823/************************************************************************/
826 void pft_fill_utype_parameter(struct pf_parameter *parameter,
827 const struct civ_map *nmap,
828 const struct unit_type *punittype,
829 struct tile *pstart_tile,
830 struct player *pplayer)
831{
832 pft_fill_utype_default_parameter(parameter, nmap, punittype,
833 pstart_tile, pplayer);
834 pft_fill_parameter(parameter, punittype);
835}
836
837/************************************************************************/
840 void pft_fill_unit_parameter(struct pf_parameter *parameter,
841 const struct civ_map *nmap,
842 const struct unit *punit)
843{
844 pft_fill_unit_default_parameter(parameter, nmap, punit);
845 pft_fill_parameter(parameter, unit_type_get(punit));
846}
847
848/************************************************************************/
854 static void pft_fill_overlap_param(struct pf_parameter *parameter,
855 const struct unit_type *punittype)
856{
857 parameter->get_MC = overlap_move;
858 parameter->ignore_none_scopes = FALSE;
859
860 if (!unit_type_really_ignores_zoc(punittype)) {
861 parameter->get_zoc = is_server() ? is_plr_zoc_srv : is_plr_zoc_client;
862 } else {
863 parameter->get_zoc = NULL;
864 }
865
866 if (!parameter->get_moves_left_req && utype_fuel(punittype)) {
867 /* Unit needs fuel */
868 parameter->get_moves_left_req = get_fuel_moves_left_req;
869 }
870}
871
872/************************************************************************/
876 void pft_fill_utype_overlap_param(struct pf_parameter *parameter,
877 const struct civ_map *nmap,
878 const struct unit_type *punittype,
879 struct tile *pstart_tile,
880 struct player *pplayer)
881{
882 pft_fill_utype_default_parameter(parameter, nmap, punittype,
883 pstart_tile, pplayer);
884 pft_fill_overlap_param(parameter, punittype);
885}
886
887/************************************************************************/
891 void pft_fill_unit_overlap_param(struct pf_parameter *parameter,
892 const struct civ_map *nmap,
893 const struct unit *punit)
894{
895 pft_fill_unit_default_parameter(parameter, nmap, punit);
896 pft_fill_overlap_param(parameter, unit_type_get(punit));
897}
898
899/************************************************************************/
904 static void pft_fill_attack_param(struct pf_parameter *parameter,
905 const struct unit_type *punittype)
906{
907 parameter->get_MC = normal_move;
908 parameter->ignore_none_scopes = TRUE;
909 pft_enable_default_actions(parameter);
910 /* We want known units! */
911 parameter->actions &= ~PF_AA_CITY_ATTACK;
912
913 if (!unit_type_really_ignores_zoc(punittype)) {
914 parameter->get_zoc = is_server() ? is_plr_zoc_srv : is_plr_zoc_client;
915 } else {
916 parameter->get_zoc = NULL;
917 }
918
919 /* It is too complicated to work with danger here */
920 parameter->is_pos_dangerous = NULL;
921
922 if (!parameter->get_moves_left_req && utype_fuel(punittype)) {
923 /* Unit needs fuel */
924 parameter->get_moves_left_req = get_fuel_moves_left_req;
925 }
926}
927
928/************************************************************************/
933 void pft_fill_utype_attack_param(struct pf_parameter *parameter,
934 const struct civ_map *nmap,
935 const struct unit_type *punittype,
936 struct tile *pstart_tile,
937 struct player *pplayer)
938{
939 pft_fill_utype_default_parameter(parameter, nmap, punittype,
940 pstart_tile, pplayer);
941 pft_fill_attack_param(parameter, punittype);
942}
943
944/************************************************************************/
949 void pft_fill_unit_attack_param(struct pf_parameter *parameter,
950 const struct civ_map *nmap,
951 const struct unit *punit)
952{
953 pft_fill_unit_default_parameter(parameter, nmap, punit);
954 pft_fill_attack_param(parameter, unit_type_get(punit));
955}
956
957/************************************************************************/
960 void pft_fill_reverse_parameter(const struct civ_map *nmap,
961 struct pf_parameter *parameter,
962 struct tile *target_tile)
963{
964 memset(parameter, 0, sizeof(*parameter));
965
966 parameter->map = nmap;
967
968 /* We ignore refuel bases in reverse mode. */
969 parameter->fuel = 1;
970 parameter->fuel_left_initially = 1;
971
972 parameter->get_MC = normal_move;
973 parameter->get_move_scope = pf_get_move_scope;
974 parameter->ignore_none_scopes = TRUE;
975
976 parameter->get_action = pf_reverse_get_action;
977 parameter->data = target_tile;
978
979 /* Other data may stay at zero. */
980}
981
982/************************************************************************/
994 void pft_fill_amphibious_parameter(struct pft_amphibious *parameter)
995{
996 const int move_rate = parameter->land.move_rate * parameter->sea.move_rate;
997
998 parameter->sea.cargo_depth = 1;
999 BV_SET(parameter->sea.cargo_types, utype_index(parameter->land.utype));
1000
1001 parameter->combined = parameter->sea;
1002 parameter->land_scale = move_rate / parameter->land.move_rate;
1003 parameter->sea_scale = move_rate / parameter->sea.move_rate;
1004 parameter->combined.moves_left_initially *= parameter->sea_scale;
1005 parameter->combined.move_rate = move_rate;
1006 parameter->combined.get_MC = amphibious_move;
1007 parameter->combined.get_move_scope = amphibious_move_scope;
1008 parameter->combined.get_TB = amphibious_behaviour;
1009 parameter->combined.get_EC = amphibious_extra_cost;
1010 if (NULL != parameter->land.is_pos_dangerous
1011 || NULL != parameter->sea.is_pos_dangerous) {
1012 parameter->combined.is_pos_dangerous = amphibious_is_pos_dangerous;
1013 } else {
1014 parameter->combined.is_pos_dangerous = NULL;
1015 }
1016 if (parameter->sea.get_moves_left_req != NULL) {
1017 parameter->combined.get_moves_left_req = parameter->sea.get_moves_left_req;
1018 } else if (parameter->land.get_moves_left_req != NULL) {
1019 parameter->combined.get_moves_left_req = parameter->land.get_moves_left_req;
1020 } else {
1021 parameter->combined.get_moves_left_req = NULL;
1022 }
1023 parameter->combined.get_action = NULL;
1024 parameter->combined.is_action_possible = NULL;
1025
1026 parameter->combined.data = parameter;
1027}
aia_utype_is_considered_caravan_trade
bool aia_utype_is_considered_caravan_trade(const struct unit_type *putype)
Definition aiactions.c:68
aia_utype_is_considered_spy
bool aia_utype_is_considered_spy(const struct unit_type *putype)
Definition aiactions.c:53
aiactions.h
base.h
bitvector.h
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
is_non_allied_city_tile
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:741
is_allied_city_tile
static bool is_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:717
city_owner
#define city_owner(_pcity_)
Definition city.h:543
combat.h
target_tile
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
punit
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:73
cost
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 cost
Definition dialogs_g.h:73
get_unittype_bonus
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:957
extra_type_list_iterate
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:159
extra_type_list_iterate_end
#define extra_type_list_iterate_end
Definition extras.h:161
is_server
static bool is_server(void)
Definition fc_interface.h:69
game
struct civ_game game
Definition game.c:57
game.h
GAME_TRANSPORT_MAX_RECURSIVE
#define GAME_TRANSPORT_MAX_RECURSIVE
Definition game.h:730
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
is_safe_ocean
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
Definition map.c:665
map_vector_to_real_distance
int map_vector_to_real_distance(int dx, int dy)
Definition map.c:576
iterate_outward_dxy_end
#define iterate_outward_dxy_end
Definition map.h:356
iterate_outward_dxy
#define iterate_outward_dxy(nmap, start_tile, max_dist, _tile, _x, _y)
Definition map.h:333
map_move_cost
static int map_move_cost(const struct civ_map *nmap, const struct player *pplayer, const struct unit_type *punittype, const struct tile *src_tile, const struct tile *dst_tile)
Definition map.h:299
mem.h
is_native_tile
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:316
unit_move_rate
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
can_attack_from_non_native
bool can_attack_from_non_native(const struct unit_type *utype)
Definition movement.c:215
is_native_move
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:358
utype_move_rate
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
is_city_channel_tile
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:228
is_native_near_tile
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Definition movement.c:450
can_unit_type_transport
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:826
can_attack_non_native
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:202
movement.h
SINGLE_MOVE
#define SINGLE_MOVE
Definition movement.h:24
is_native_tile_to_class
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
Definition movement.h:80
PF_IMPOSSIBLE_MC
#define PF_IMPOSSIBLE_MC
Definition path_finding.h:266
pf_action
pf_action
Definition path_finding.h:287
PF_ACTION_ATTACK
@ PF_ACTION_ATTACK
Definition path_finding.h:289
PF_ACTION_DIPLOMAT
@ PF_ACTION_DIPLOMAT
Definition path_finding.h:290
PF_ACTION_TRADE_ROUTE
@ PF_ACTION_TRADE_ROUTE
Definition path_finding.h:291
PF_ACTION_IMPOSSIBLE
@ PF_ACTION_IMPOSSIBLE
Definition path_finding.h:292
PF_ACTION_NONE
@ PF_ACTION_NONE
Definition path_finding.h:288
pf_move_scope
pf_move_scope
Definition path_finding.h:319
PF_MS_TRANSPORT
@ PF_MS_TRANSPORT
Definition path_finding.h:323
PF_MS_CITY
@ PF_MS_CITY
Definition path_finding.h:322
PF_MS_NATIVE
@ PF_MS_NATIVE
Definition path_finding.h:321
PF_MS_NONE
@ PF_MS_NONE
Definition path_finding.h:320
PF_AA_CITY_ATTACK
@ PF_AA_CITY_ATTACK
Definition path_finding.h:302
PF_AA_UNIT_ATTACK
@ PF_AA_UNIT_ATTACK
Definition path_finding.h:298
PF_AA_NONE
@ PF_AA_NONE
Definition path_finding.h:297
PF_AA_DIPLOMAT
@ PF_AA_DIPLOMAT
Definition path_finding.h:303
PF_AA_TRADE_ROUTE
@ PF_AA_TRADE_ROUTE
Definition path_finding.h:304
tile_behavior
tile_behavior
Definition path_finding.h:308
TB_NORMAL
@ TB_NORMAL
Definition path_finding.h:309
TB_DONT_LEAVE
@ TB_DONT_LEAVE
Definition path_finding.h:311
TB_IGNORE
@ TB_IGNORE
Definition path_finding.h:310
pft_fill_unit_parameter
void pft_fill_unit_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:840
pft_fill_unit_attack_param
void pft_fill_unit_attack_param(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:949
pft_fill_utype_default_parameter
static void pft_fill_utype_default_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit_type *punittype, struct tile *pstart_tile, struct player *powner)
Definition pf_tools.c:732
pft_fill_unit_overlap_param
void pft_fill_unit_overlap_param(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:891
pft_fill_overlap_param
static void pft_fill_overlap_param(struct pf_parameter *parameter, const struct unit_type *punittype)
Definition pf_tools.c:854
pft_fill_reverse_parameter
void pft_fill_reverse_parameter(const struct civ_map *nmap, struct pf_parameter *parameter, struct tile *target_tile)
Definition pf_tools.c:960
pf_action_possible
static bool pf_action_possible(const struct tile *src, enum pf_move_scope src_scope, const struct tile *dst, enum pf_action action, const struct pf_parameter *param)
Definition pf_tools.c:139
get_fuel_moves_left_req
static int get_fuel_moves_left_req(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:635
pft_fill_utype_attack_param
void pft_fill_utype_attack_param(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit_type *punittype, struct tile *pstart_tile, struct player *pplayer)
Definition pf_tools.c:933
pf_get_move_scope
static enum pf_move_scope pf_get_move_scope(const struct tile *ptile, bool *can_disembark, enum pf_move_scope previous_scope, const struct pf_parameter *param)
Definition pf_tools.c:228
overlap_move
static unsigned overlap_move(const struct tile *src, enum pf_move_scope src_scope, const struct tile *dst, enum pf_move_scope dst_scope, const struct pf_parameter *param)
Definition pf_tools.c:384
pft_fill_default_parameter
static void pft_fill_default_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit_type *punittype)
Definition pf_tools.c:681
pft_fill_unit_default_parameter
static void pft_fill_unit_default_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:770
pf_transport_check
static bool pf_transport_check(const struct pf_parameter *param, const struct unit *ptrans, const struct unit_type *trans_utype)
Definition pf_tools.c:177
pf_get_action
static enum pf_action pf_get_action(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:96
no_fights
enum tile_behavior no_fights(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:509
pft_fill_attack_param
static void pft_fill_attack_param(struct pf_parameter *parameter, const struct unit_type *punittype)
Definition pf_tools.c:904
pf_reverse_get_action
static enum pf_action pf_reverse_get_action(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:167
pf_attack_possible
static bool pf_attack_possible(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:45
pft_fill_utype_overlap_param
void pft_fill_utype_overlap_param(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit_type *punittype, struct tile *pstart_tile, struct player *pplayer)
Definition pf_tools.c:876
pft_enable_default_actions
static void pft_enable_default_actions(struct pf_parameter *parameter)
Definition pf_tools.c:704
amphibious_behaviour
static enum tile_behavior amphibious_behaviour(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:539
pf_move_possible
static bool pf_move_possible(const struct tile *src, enum pf_move_scope src_scope, const struct tile *dst, enum pf_move_scope dst_scope, const struct pf_parameter *param)
Definition pf_tools.c:335
amphibious_extra_cost
static unsigned amphibious_extra_cost(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:453
no_intermediate_fights
enum tile_behavior no_intermediate_fights(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:524
amphibious_move
static unsigned amphibious_move(const struct tile *ptile, enum pf_move_scope src_scope, const struct tile *ptile1, enum pf_move_scope dst_scope, const struct pf_parameter *param)
Definition pf_tools.c:403
normal_move
static unsigned normal_move(const struct tile *src, enum pf_move_scope src_scope, const struct tile *dst, enum pf_move_scope dst_scope, const struct pf_parameter *param)
Definition pf_tools.c:364
is_possible_base_fuel
static bool is_possible_base_fuel(const struct tile *ptile, const struct pf_parameter *param)
Definition pf_tools.c:559
get_closest_safe_tile_distance
static int get_closest_safe_tile_distance(const struct tile *src_tile, const struct pf_parameter *param, int max_distance)
Definition pf_tools.c:610
amphibious_is_pos_dangerous
static bool amphibious_is_pos_dangerous(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:659
no_fights_or_unknown
enum tile_behavior no_fights_or_unknown(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition pf_tools.c:493
amphibious_move_scope
static enum pf_move_scope amphibious_move_scope(const struct tile *ptile, bool *can_disembark, enum pf_move_scope previous_scope, const struct pf_parameter *param)
Definition pf_tools.c:304
pft_fill_amphibious_parameter
void pft_fill_amphibious_parameter(struct pft_amphibious *parameter)
Definition pf_tools.c:994
pft_fill_utype_parameter
void pft_fill_utype_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit_type *punittype, struct tile *pstart_tile, struct player *pplayer)
Definition pf_tools.c:826
pft_fill_parameter
static void pft_fill_parameter(struct pf_parameter *parameter, const struct unit_type *punittype)
Definition pf_tools.c:804
pf_tools.h
pplayers_at_war
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1364
pplayers_allied
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
action
Definition actions.h:379
city
Definition city.h:309
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map
Definition map_types.h:71
packet_game_info::unreachable_protects
bool unreachable_protects
Definition packets_gen.h:219
packet_game_info::citymindist
int citymindist
Definition packets_gen.h:147
pf_parameter
Definition path_finding.h:357
pf_parameter::fuel_left_initially
int fuel_left_initially
Definition path_finding.h:362
pf_parameter::transported_by_initially
const struct unit_type * transported_by_initially
Definition path_finding.h:364
pf_parameter::get_action
enum pf_action(* get_action)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition path_finding.h:410
pf_parameter::get_move_scope
enum pf_move_scope(* get_move_scope)(const struct tile *ptile, bool *can_disembark, enum pf_move_scope previous_scope, const struct pf_parameter *param)
Definition path_finding.h:389
pf_parameter::ignore_none_scopes
bool ignore_none_scopes
Definition path_finding.h:393
pf_parameter::map
const struct civ_map * map
Definition path_finding.h:358
pf_parameter::get_TB
enum tile_behavior(* get_TB)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition path_finding.h:398
pf_parameter::actions
enum pf_action_account actions
Definition path_finding.h:413
pf_parameter::owner
const struct player * owner
Definition path_finding.h:374
pf_parameter::is_pos_dangerous
bool(* is_pos_dangerous)(const struct tile *ptile, enum known_type, const struct pf_parameter *param)
Definition path_finding.h:436
pf_parameter::get_moves_left_req
int(* get_moves_left_req)(const struct tile *ptile, enum known_type, const struct pf_parameter *param)
Definition path_finding.h:441
pf_parameter::moves_left_initially
int moves_left_initially
Definition path_finding.h:361
pf_parameter::cargo_depth
int cargo_depth
Definition path_finding.h:366
pf_parameter::move_rate
int move_rate
Definition path_finding.h:370
pf_parameter::get_zoc
bool(* get_zoc)(const struct player *pplayer, const struct tile *ptile, const struct civ_map *zmap)
Definition path_finding.h:430
pf_parameter::get_MC
unsigned(* get_MC)(const struct tile *from_tile, enum pf_move_scope src_move_scope, const struct tile *to_tile, enum pf_move_scope dst_move_scope, const struct pf_parameter *param)
Definition path_finding.h:382
pf_parameter::get_costs
int(* get_costs)(const struct tile *from_tile, enum direction8 dir, const struct tile *to_tile, int from_cost, int from_extra, unsigned *to_cost, unsigned *to_extra, const struct pf_parameter *param)
Definition path_finding.h:463
pf_parameter::get_EC
unsigned(* get_EC)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition path_finding.h:405
pf_parameter::data
void * data
Definition path_finding.h:472
pf_parameter::fuel
int fuel
Definition path_finding.h:371
pf_parameter::utype
const struct unit_type * utype
Definition path_finding.h:373
pf_parameter::is_action_possible
bool(* is_action_possible)(const struct tile *from_tile, enum pf_move_scope src_move_scope, const struct tile *to_tile, enum pf_action action, const struct pf_parameter *param)
Definition path_finding.h:417
pf_parameter::cargo_types
bv_unit_types cargo_types
Definition path_finding.h:368
pf_parameter::omniscience
bool omniscience
Definition path_finding.h:376
pf_parameter::start_tile
struct tile * start_tile
Definition path_finding.h:359
pft_amphibious
Definition pf_tools.h:36
pft_amphibious::land_scale
int land_scale
Definition pf_tools.h:41
pft_amphibious::sea_scale
int sea_scale
Definition pf_tools.h:41
pft_amphibious::combined
struct pf_parameter combined
Definition pf_tools.h:42
pft_amphibious::sea
struct pf_parameter land sea
Definition pf_tools.h:38
player
Definition player.h:249
tile
Definition tile.h:49
tile::units
struct unit_list * units
Definition tile.h:57
unit_class
Definition unittype.h:136
unit_class::cache
struct unit_class::@85 cache
unit_class::refuel_extras
struct extra_type_list * refuel_extras
Definition unittype.h:155
unit_type
Definition unittype.h:481
unit_type::move_rate
int move_rate
Definition unittype.h:497
unit_type::targets
bv_unit_classes targets
Definition unittype.h:542
unit_type::hp
int hp
Definition unittype.h:505
unit
Definition unit.h:138
unit::moves_left
int moves_left
Definition unit.h:150
unit::fuel
int fuel
Definition unit.h:153
veteran_level
Definition unittype.h:467
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_has_native_base
bool tile_has_native_base(const struct tile *ptile, const struct unit_type *punittype)
Definition tile.c:318
tile_get_known
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:386
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile.h
known_type
known_type
Definition tile.h:34
TILE_KNOWN_UNSEEN
@ TILE_KNOWN_UNSEEN
Definition tile.h:36
TILE_UNKNOWN
@ TILE_UNKNOWN
Definition tile.h:35
TILE_KNOWN_SEEN
@ TILE_KNOWN_SEEN
Definition tile.h:37
tile_has_extra
#define tile_has_extra(ptile, pextra)
Definition tile.h:146
unit_type_really_ignores_zoc
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1511
is_plr_zoc_client
bool is_plr_zoc_client(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
Definition unit.c:1473
unit_transport_depth
int unit_transport_depth(const struct unit *pcargo)
Definition unit.c:2537
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2427
unit_cargo_depth
int unit_cargo_depth(const struct unit *ptrans)
Definition unit.c:2519
is_plr_zoc_srv
bool is_plr_zoc_srv(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
Definition unit.c:1414
unit_has_orders
bool unit_has_orders(const struct unit *punit)
Definition unit.c:207
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
unit_transports_iterate_end
#define unit_transports_iterate_end
Definition unit.h:552
unit_cargo_iterate_end
#define unit_cargo_iterate_end
Definition unit.h:562
unit_cargo_iterate
#define unit_cargo_iterate(_ptrans, _pcargo)
Definition unit.h:559
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unit_transports_iterate
#define unit_transports_iterate(_pcargo, _ptrans)
Definition unit.h:548
is_non_allied_unit_tile
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:423
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
can_unit_act_when_ustate_is
bool can_unit_act_when_ustate_is(const struct unit_type *punit_type, const enum ustate_prop prop, const bool is_there)
Definition unittype.c:995
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
utype_can_freely_unload
bool utype_can_freely_unload(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Definition unittype.c:294
utype_may_act_at_all
bool utype_may_act_at_all(const struct unit_type *putype)
Definition unittype.c:431
utype_can_freely_load
bool utype_can_freely_load(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Definition unittype.c:282
utype_veteran_levels
int utype_veteran_levels(const struct unit_type *punittype)
Definition unittype.c:2661
unit_class_get
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2546
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
utype_can_take_over
bool utype_can_take_over(const struct unit_type *punittype)
Definition unittype.c:270
unittype.h
uclass_has_flag
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
utype_class
#define utype_class(_t_)
Definition unittype.h:736
utype_fuel
#define utype_fuel(ptype)
Definition unittype.h:822
utype_has_flag
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
uclass_index
#define uclass_index(_c_)
Definition unittype.h:729
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845