Freeciv-3.3
Loading...
Searching...
No Matches
actres.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2023 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/* common */
19#include "city.h"
20#include "combat.h"
21#include "fc_interface.h"
22#include "game.h"
23#include "map.h"
24#include "metaknowledge.h"
25#include "movement.h"
26#include "player.h"
27#include "requirements.h"
28#include "tile.h"
29#include "traderoutes.h"
30
31#include "actres.h"
32
33static struct actres act_results[ACTRES_LAST] = {
34 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ESTABLISH_EMBASSY */
37 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_INVESTIGATE_CITY */
40 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_POISON */
43 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_GOLD */
46 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY */
49 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_SABOTAGE_CITY */
52 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY_PRODUCTION */
55 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_TECH */
58 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_STEAL_TECH */
61 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_INCITE_CITY */
64 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRADE_ROUTE */
67 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_MARKETPLACE */
70 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HELP_WONDER */
73 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_BRIBE_UNIT */
76 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_UNIT */
79 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CAPTURE_UNITS */
82 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FOUND_CITY */
85 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_JOIN_CITY */
88 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_STEAL_MAPS */
91 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_BOMBARD */
94 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_NUKE */
97 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE */
100 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE_UNITS */
103 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DESTROY_CITY */
106 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_EXPEL_UNIT */
109 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT_RECOVER */
112 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT */
115 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOME_CITY */
118 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UPGRADE_UNIT */
121 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP */
124 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_AIRLIFT */
127 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_ATTACK */
130 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_STRIKE_BUILDING */
133 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_STRIKE_PRODUCTION */
136 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_CITY */
139 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HEAL_UNIT */
142 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSFORM_TERRAIN */
145 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CULTIVATE */
148 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PLANT */
151 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_PILLAGE */
154 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FORTIFY */
157 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_ROAD */
160 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONVERT */
163 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_BASE */
166 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_MINE */
169 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_IRRIGATE */
172 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_COLLECT_RANSOM */
175 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_UNUSED_1 */
178 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DEBOARD */
181 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_UNLOAD */
184 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DISEMBARK */
187 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_BOARD */
190 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_EMBARK */
193 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SPREAD_PLAGUE */
196 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_ATTACK */
199 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_EXTRAS */
202 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_ENTER */
205 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_FRIGHTEN */
208 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UNIT_MOVE */
211 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP_CONQUER */
212 FALSE, ACTIVITY_LAST, DRT_NONE, /* TODO: Should this be hostile? */
214 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOMELESS */
217 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_WIPE_UNITS */
220 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_ESCAPE */
223 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_LOAD */
226 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_CLEAN */
229 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT */
232 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT_CONQUER */
235 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */
238};
239
240/*********************************************************************/
243void actres_init(void)
244{
245}
246
247/*********************************************************************/
250void actres_free(void)
251{
252}
253
254/**********************************************************************/
259{
260 if (result == ACTRES_NONE) {
262 }
263
265
266 return act_results[result].sub_tgt_compl;
267}
268
269/**********************************************************************/
273{
274 if (result == ACTRES_NONE) {
275 return ABK_NONE;
276 }
277
279
280 return act_results[result].battle_kind;
281}
282
283/**********************************************************************/
287{
288 if (result == ACTRES_NONE) {
289 return FALSE;
290 }
291
292 return act_results[result].hostile;
293}
294
295/**********************************************************************/
302{
303 if (result == ACTRES_NONE) {
304 return ACTIVITY_LAST;
305 }
306
307 return act_results[result].activity;
308}
309
310/**********************************************************************/
317 const struct unit *actor_unit,
318 const struct tile *tgt_tile,
319 const struct extra_type *tgt_extra)
320{
322
323 if (pactivity == ACTIVITY_LAST) {
324 /* Happens instantaneously, not at turn change. */
326 }
327
328 switch (pactivity) {
329 case ACTIVITY_PILLAGE:
330 case ACTIVITY_CLEAN:
331 case ACTIVITY_BASE:
334 case ACTIVITY_MINE:
336 case ACTIVITY_PLANT:
340 return 1;
341 case ACTIVITY_CONVERT:
343 case ACTIVITY_EXPLORE:
344 case ACTIVITY_IDLE:
346 case ACTIVITY_SENTRY:
347 case ACTIVITY_GOTO:
348 case ACTIVITY_LAST:
349 /* Should not happen. Caught by the assertion below. */
350 break;
351 }
352
354
356}
357
358/**********************************************************************/
365{
366 if (result == ACTRES_NONE) {
367 return DRT_NONE;
368 }
369
370 return act_results[result].dice;
371}
372
373/**********************************************************************/
377{
378 switch (result) {
396 case ACTRES_JOIN_CITY:
398 case ACTRES_BOMBARD:
399 case ACTRES_SPY_NUKE:
404 case ACTRES_HOME_CITY:
405 case ACTRES_HOMELESS:
407 case ACTRES_PARADROP:
409 case ACTRES_AIRLIFT:
412 case ACTRES_ATTACK:
416 case ACTRES_HEAL_UNIT:
418 case ACTRES_CULTIVATE:
419 case ACTRES_PLANT:
420 case ACTRES_PILLAGE:
421 case ACTRES_CLEAN:
422 case ACTRES_FORTIFY:
423 case ACTRES_ROAD:
424 case ACTRES_CONVERT:
425 case ACTRES_BASE:
426 case ACTRES_MINE:
427 case ACTRES_IRRIGATE:
437 case ACTRES_HUT_ENTER:
439 case ACTRES_UNIT_MOVE:
442 /* Non ruleset defined action min range not supported here */
443 fc_assert_msg(FALSE, "Probably wrong value.");
445 case ACTRES_NUKE:
448 case ACTRES_TELEPORT:
451 case ACTRES_NONE:
453
455 }
456
457 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
458
459 return 0;
460}
461
462/**********************************************************************/
466{
467 switch (result) {
484 case ACTRES_JOIN_CITY:
486 case ACTRES_SPY_NUKE:
490 case ACTRES_HOME_CITY:
491 case ACTRES_HOMELESS:
493 case ACTRES_PARADROP:
497 case ACTRES_ATTACK:
501 case ACTRES_HEAL_UNIT:
503 case ACTRES_CULTIVATE:
504 case ACTRES_PLANT:
505 case ACTRES_PILLAGE:
506 case ACTRES_CLEAN:
507 case ACTRES_FORTIFY:
508 case ACTRES_ROAD:
509 case ACTRES_CONVERT:
510 case ACTRES_BASE:
511 case ACTRES_MINE:
512 case ACTRES_IRRIGATE:
522 case ACTRES_HUT_ENTER:
524 case ACTRES_UNIT_MOVE:
527 /* Non ruleset defined action max range not supported here */
528 fc_assert_msg(FALSE, "Probably wrong value.");
533 case ACTRES_BOMBARD:
535 case ACTRES_NUKE:
539 case ACTRES_AIRLIFT:
540 case ACTRES_TELEPORT:
543 case ACTRES_NONE:
545
547 }
548
549 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
550
551 return 0;
552}
553
554/**********************************************************************/
559 enum action_target_kind tgt_kind)
560{
562 FALSE);
564 FALSE);
565
566 switch (result) {
580 case ACTRES_JOIN_CITY:
582 case ACTRES_SPY_NUKE:
585 case ACTRES_HOME_CITY:
587 case ACTRES_AIRLIFT:
593 return tgt_kind == ATK_CITY;
597 case ACTRES_HEAL_UNIT:
603 return tgt_kind == ATK_UNIT;
605 case ACTRES_BOMBARD:
607 case ACTRES_ATTACK:
611 return tgt_kind == ATK_UNITS;
613 case ACTRES_PARADROP:
616 case ACTRES_CULTIVATE:
617 case ACTRES_PLANT:
618 case ACTRES_CLEAN:
619 case ACTRES_ROAD:
620 case ACTRES_BASE:
621 case ACTRES_MINE:
622 case ACTRES_IRRIGATE:
624 case ACTRES_HUT_ENTER:
626 case ACTRES_UNIT_MOVE:
627 case ACTRES_TELEPORT:
629 return tgt_kind == ATK_TILE;
631 return tgt_kind == ATK_EXTRAS;
633 case ACTRES_CONVERT:
634 case ACTRES_FORTIFY:
635 case ACTRES_HOMELESS:
637 return tgt_kind == ATK_SELF;
638 case ACTRES_PILLAGE:
639 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
640 case ACTRES_NUKE:
641 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
642 case ACTRES_NONE:
643 switch (tgt_kind) {
644 case ATK_CITY:
645 case ATK_UNIT:
646 case ATK_UNITS:
647 case ATK_TILE:
648 case ATK_EXTRAS:
649 case ATK_SELF:
650 /* Works with all existing target kinds. */
651 return TRUE;
652 case ATK_COUNT:
653 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
654 break;
655 }
656 break;
657
659 }
660
661 /* Should never be reached. */
662 return FALSE;
663}
664
665/**********************************************************************/
670{
672 ASTK_NONE);
673
674 switch (result) {
686 case ACTRES_JOIN_CITY:
688 case ACTRES_SPY_NUKE:
691 case ACTRES_HOME_CITY:
692 case ACTRES_HOMELESS:
694 case ACTRES_AIRLIFT:
698 return ASTK_NONE;
701 return ASTK_BUILDING;
703 return ASTK_TECH;
707 case ACTRES_HEAL_UNIT:
713 return ASTK_NONE;
715 case ACTRES_BOMBARD:
717 case ACTRES_ATTACK:
721 return ASTK_NONE;
723 case ACTRES_NUKE:
724 case ACTRES_PARADROP:
727 case ACTRES_CULTIVATE:
728 case ACTRES_PLANT:
730 case ACTRES_HUT_ENTER:
732 case ACTRES_UNIT_MOVE:
733 case ACTRES_TELEPORT:
737 return ASTK_NONE;
738 case ACTRES_PILLAGE:
739 case ACTRES_CLEAN:
740 return ASTK_EXTRA;
741 case ACTRES_ROAD:
742 case ACTRES_BASE:
743 case ACTRES_MINE:
744 case ACTRES_IRRIGATE:
747 return ASTK_NONE;
749 case ACTRES_CONVERT:
750 case ACTRES_FORTIFY:
751 return ASTK_NONE;
752 case ACTRES_NONE:
753 return ASTK_NONE;
754
756 }
757
758 /* Should never be reached. */
759 return ASTK_NONE;
760}
761
762/**********************************************************************/
777
778/**********************************************************************/
786 const struct extra_type *pextra)
787{
788 if (act_results[result].ecause == EC_NONE) {
789 return FALSE;
790 }
791
792 if (pextra == NULL || !pextra->buildable) {
793 return FALSE;
794 }
795
796 return is_extra_caused_by(pextra, act_results[result].ecause);
797}
798
799/**********************************************************************/
807 const struct extra_type *pextra)
808{
809 if (act_results[result].ermcause == ERM_NONE) {
810 return FALSE;
811 }
812
813 return is_extra_removed_by(pextra, act_results[result].ermcause);
814}
815
816/**********************************************************************/
820static bool plr_knows_tile(const struct player *plr,
821 const struct tile *ttile)
822{
823 return plr != nullptr
824 && ttile != nullptr
825 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
826}
827
828/**********************************************************************/
832 enum action_result result,
833 const struct req_context *actor,
834 const struct req_context *target,
835 const struct extra_type *target_extra,
836 enum fc_tristate def,
837 bool omniscient,
838 const struct city *homecity)
839{
840 struct terrain *pterrain;
841 bool can_see_tgt_unit;
842 bool can_see_tgt_tile;
843
844 /* Only check requirement against the target unit if the actor can see it
845 * or if the evaluator is omniscient. The game checking the rules is
846 * omniscient. The player asking about their odds isn't. */
847 can_see_tgt_unit = (omniscient || (target->unit
848 && can_player_see_unit(actor->player,
849 target->unit)));
850
851 /* Only check requirement against the target tile if the actor can see it
852 * or if the evaluator is omniscient. The game checking the rules is
853 * omniscient. The player asking about their odds isn't. */
855 || can_player_see_tile(actor->player, target->tile));
856
857 switch (result) {
860 /* Why this is a hard requirement: Can't transfer a unique unit if the
861 * actor player already has one. */
862 /* Info leak: This is only checked for when the actor player can see
863 * the target unit. Since the target unit is seen its type is known.
864 * The fact that a city hiding the unseen unit is occupied is known. */
865
866 if (!can_see_tgt_unit) {
867 /* An omniscient player can see the target unit. */
869
870 return TRI_MAYBE;
871 }
872
874 target->unittype)) {
875 return TRI_NO;
876 }
877
878 /* FIXME: Capture Unit may want to look for more than one unique unit
879 * of the same kind at the target tile. Currently caught by sanity
880 * check in do_capture_units(). */
881
882 break;
883
885 /* Reason: The Freeciv code don't support selecting a target tech
886 * unless it is known that the victim player has it. */
887 /* Info leak: The actor player knowns whose techs they can see. */
888 if (!can_see_techs_of_target(actor->player, target->player)) {
889 return TRI_NO;
890 }
891
892 break;
893
895 /* If actor->unit can do the action the actor->player can see how much
896 * gold target->player have. Not requiring it is therefore pointless.
897 */
898 if (target->player->economic.gold <= 0) {
899 return TRI_NO;
900 }
901
902 break;
903
906 {
907 /* Checked in action_hard_reqs_actor() */
908 fc_assert_ret_val(homecity != NULL, TRI_NO);
909
910 /* Can't establish a trade route or enter the market place if the
911 * cities can't trade at all. */
912 /* TODO: Should this restriction (and the above restriction that the
913 * actor unit must have a home city) be kept for Enter Marketplace? */
914 if (!can_cities_trade(homecity, target->city)) {
915 return TRI_NO;
916 }
917
918 /* There are more restrictions on establishing a trade route than on
919 * entering the market place. */
920 if (result == ACTRES_TRADE_ROUTE) {
921 struct goods_type *pgood = unit_current_goods(actor->unit, homecity);
922
923 if (!can_establish_trade_route(homecity, target->city,
924 pgood->priority)) {
925 return TRI_NO;
926 }
927 }
928 }
929
930 break;
931
934 /* It is only possible to help the production if the production needs
935 * the help. (If not it would be possible to add shields for something
936 * that can't legally receive help if it is build later) */
937 /* Info leak: The player knows that the production in their own city has
938 * been hurried (bought or helped). The information isn't revealed when
939 * asking for action probabilities since omniscient is FALSE. */
940 if (!omniscient
941 && !can_player_see_city_internals(actor->player, target->city)) {
942 return TRI_MAYBE;
943 }
944
945 if (!(target->city->shield_stock
947 return TRI_NO;
948 }
949
950 break;
951
954 /* Reason: allow scenarios to disable city founding. */
955 /* Info leak: the setting is public knowledge. */
956 return TRI_NO;
957 }
958
959 if (can_see_tgt_tile && tile_city(target->tile)) {
960 /* Reason: a tile can have 0 or 1 cities. */
961 return TRI_NO;
962 }
963
965 if (omniscient) {
966 /* No need to check again. */
967 return TRI_NO;
968 } else {
969 square_iterate(nmap, target->tile,
970 game.info.citymindist - 1, otile) {
971 if (tile_city(otile) != NULL
972 && can_player_see_tile(actor->player, otile)) {
973 /* Known to be blocked by citymindist */
974 return TRI_NO;
975 }
977 }
978 }
979
980 /* The player may not have enough information to be certain. */
981
982 if (!can_see_tgt_tile) {
983 /* Need to know if target tile already has a city, has TER_NO_CITIES
984 * terrain, is non native to the actor or is owned by a foreigner. */
985 return TRI_MAYBE;
986 }
987
988 if (!omniscient) {
989 /* The player may not have enough information to find out if
990 * citymindist blocks or not. This doesn't depend on if it blocks. */
991 square_iterate(nmap, target->tile,
992 game.info.citymindist - 1, otile) {
993 if (!can_player_see_tile(actor->player, otile)) {
994 /* Could have a city that blocks via citymindist. Even if this
995 * tile has TER_NO_CITIES terrain the player don't know that it
996 * didn't change and had a city built on it. */
997 return TRI_MAYBE;
998 }
1000 }
1001
1002 break;
1003
1004 case ACTRES_JOIN_CITY:
1005 {
1006 int new_pop;
1007
1008 if (!omniscient
1009 && !player_can_see_city_externals(actor->player, target->city)) {
1010 return TRI_MAYBE;
1011 }
1012
1013 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1014
1016 /* Reason: Make the add_to_size_limit setting work. */
1017 return TRI_NO;
1018 }
1019
1020 if (!city_can_grow_to(target->city, new_pop)) {
1021 /* Reason: respect city size limits. */
1022 /* Info leak: when it is legal to join a foreign city is legal and
1023 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1024 * something the actor player don't have access to.
1025 * Example: depends on a building (like Aqueduct) that isn't
1026 * VisibleByOthers. */
1027 return TRI_NO;
1028 }
1029 }
1030
1031 break;
1032
1033 case ACTRES_NUKE_UNITS:
1034 /* Has only action specific requirements */
1035 break;
1036
1037 case ACTRES_HOME_CITY:
1038 /* Reason: can't change to what is. */
1039 /* Info leak: The player knows their unit's current home city. */
1040 if (homecity != NULL && homecity->id == target->city->id) {
1041 /* This is already the unit's home city. */
1042 return TRI_NO;
1043 }
1044
1045 {
1046 int slots = unit_type_get(actor->unit)->city_slots;
1047
1048 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1049 return TRI_NO;
1050 }
1051 }
1052
1053 break;
1054
1056 /* Reason: Keep the old rules. */
1057 /* Info leak: The player knows their unit's type. They know if they can
1058 * build the unit type upgraded to. If the upgrade happens in a foreign
1059 * city that fact may leak. This can be seen as a price for changing
1060 * the rules to allow upgrading in a foreign city.
1061 * The player knows how much gold they have. If the Upgrade_Price_Pct
1062 * effect depends on information they don't have that information may
1063 * leak. The player knows the location of their unit. They know if the
1064 * tile has a city and if the unit can exist there outside a transport.
1065 * The player knows their unit's cargo. By knowing the number and type
1066 * of cargo, they can predict if there will be enough room in the unit
1067 * upgraded to, as long as they know what unit type their unit will end
1068 * up as. */
1069 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1070 return TRI_NO;
1071 }
1072
1073 break;
1074
1075 case ACTRES_PARADROP:
1077 /* Reason: Keep the old rules. */
1078 /* Info leak: The player knows if they know the target tile. */
1079 if (!plr_knows_tile(actor->player, target->tile)) {
1080 return TRI_NO;
1081 }
1082
1083 /* Reason: Keep paratroopers_range working. */
1084 /* Info leak: The player knows the location of the actor and of the
1085 * target tile. */
1087 < real_map_distance(actor->tile, target->tile)) {
1088 return TRI_NO;
1089 }
1090
1091 break;
1092
1093 case ACTRES_AIRLIFT:
1094 /* Reason: Keep the old rules. */
1095 /* Info leak: same as test_unit_can_airlift_to() */
1096 switch (test_unit_can_airlift_to(nmap, omniscient ? NULL : actor->player,
1097 actor->unit, target->city)) {
1098 case AR_OK:
1099 return TRI_YES;
1100 case AR_OK_SRC_UNKNOWN:
1101 case AR_OK_DST_UNKNOWN:
1102 return TRI_MAYBE;
1103 case AR_NO_MOVES:
1104 case AR_WRONG_UNITTYPE:
1105 case AR_OCCUPIED:
1106 case AR_NOT_IN_CITY:
1107 case AR_BAD_SRC_CITY:
1108 case AR_BAD_DST_CITY:
1109 case AR_SRC_NO_FLIGHTS:
1110 case AR_DST_NO_FLIGHTS:
1111 return TRI_NO;
1112 }
1113
1114 break;
1115
1116 case ACTRES_ATTACK:
1117 break;
1118
1119 case ACTRES_WIPE_UNITS:
1120 unit_list_iterate(target->tile->units, punit) {
1121 if (get_total_defense_power(actor->unit, punit) > 0) {
1122 return TRI_NO;
1123 }
1125 break;
1126
1129 return FALSE;
1130 }
1131
1132 unit_list_iterate(target->tile->units, punit) {
1134 /* Cannot get ransom when there are other kind of units in the tile */
1135 return FALSE;
1136 }
1138 break;
1139
1141 /* Reason: "Conquer City" involves moving into the city. */
1142 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1143 FALSE, FALSE, TRUE)) {
1144 return TRI_NO;
1145 }
1146
1147 break;
1148
1150 /* Reason: "Conquer Extras" involves moving to the tile. */
1151 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1152 FALSE, FALSE, FALSE)) {
1153 return TRI_NO;
1154 }
1155 /* Reason: Must have something to claim. The more specific restriction
1156 * that the base must be native to the actor unit is hard coded in
1157 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1158 * helptext_extra(), in helptext_unit(), in do_attack() and in
1159 * diplomat_bribe(). */
1160 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1161 return TRI_NO;
1162 }
1163 break;
1164
1165 case ACTRES_HEAL_UNIT:
1166 /* Reason: It is not the healthy who need a doctor, but the sick. */
1167 /* Info leak: the actor can see the target's HP. */
1168 if (!can_see_tgt_unit) {
1169 return TRI_MAYBE;
1170 }
1171 if (!(target->unit->hp < target->unittype->hp)) {
1172 return TRI_NO;
1173 }
1174 break;
1175
1177 pterrain = tile_terrain(target->tile);
1178 if (pterrain->transform_result == T_NONE
1179 || pterrain == pterrain->transform_result
1181 pterrain->transform_result)
1183 && (tile_city(target->tile)))) {
1184 return TRI_NO;
1185 }
1186 break;
1187
1188 case ACTRES_CULTIVATE:
1189 pterrain = tile_terrain(target->tile);
1190 if (pterrain->cultivate_result == NULL) {
1191 return TRI_NO;
1192 }
1194 pterrain->cultivate_result)
1196 && tile_city(target->tile))) {
1197 return TRI_NO;
1198 }
1199 break;
1200
1201 case ACTRES_PLANT:
1202 pterrain = tile_terrain(target->tile);
1203 if (pterrain->plant_result == NULL) {
1204 return TRI_NO;
1205 }
1207 pterrain->plant_result)
1209 && tile_city(target->tile))) {
1210 return TRI_NO;
1211 }
1212 break;
1213
1214 case ACTRES_ROAD:
1215 if (target_extra == NULL) {
1216 return TRI_NO;
1217 }
1219 /* Reason: This is not a road. */
1220 return TRI_NO;
1221 }
1223 target->tile)) {
1224 return TRI_NO;
1225 }
1226 break;
1227
1228 case ACTRES_BASE:
1229 if (target_extra == NULL) {
1230 return TRI_NO;
1231 }
1233 /* Reason: This is not a base. */
1234 return TRI_NO;
1235 }
1236 if (!can_build_base(actor->unit,
1237 extra_base_get(target_extra), target->tile)) {
1238 return TRI_NO;
1239 }
1240 break;
1241
1242 case ACTRES_MINE:
1243 if (target_extra == NULL) {
1244 return TRI_NO;
1245 }
1247 /* Reason: This is not a mine. */
1248 return TRI_NO;
1249 }
1250
1251 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1252 return TRI_NO;
1253 }
1254 break;
1255
1256 case ACTRES_IRRIGATE:
1257 if (target_extra == NULL) {
1258 return TRI_NO;
1259 }
1261 /* Reason: This is not an irrigation. */
1262 return TRI_NO;
1263 }
1264
1265 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1266 return TRI_NO;
1267 }
1268 break;
1269
1270 case ACTRES_PILLAGE:
1271 pterrain = tile_terrain(target->tile);
1272 if (pterrain->pillage_time == 0) {
1273 return TRI_NO;
1274 }
1275
1276 {
1280
1282 extra_type_iterate(pextra) {
1283 int idx = extra_index(pextra);
1284
1285 /* Only one unit can pillage a given improvement at a time */
1286 if (BV_ISSET(pspresent, idx)
1287 && (!BV_ISSET(psworking, idx)
1288 || actor->unit->activity_target == pextra)
1289 && can_remove_extra(pextra, actor->unit, target->tile)) {
1290 bool required = FALSE;
1291
1295 if (pdep == pextra) {
1296 required = TRUE;
1297 break;
1298 }
1300 }
1301 if (required) {
1302 break;
1303 }
1305
1306 if (!required) {
1307 BV_SET(pspossible, idx);
1308 }
1309 }
1311
1312 if (!BV_ISSET_ANY(pspossible)) {
1313 /* Nothing available to pillage */
1314 return TRI_NO;
1315 }
1316
1317 if (target_extra != NULL) {
1318 if (!game.info.pillage_select) {
1319 /* Hobson's choice (this case mostly exists for old clients) */
1320 /* Needs to match what unit_activity_assign_target chooses */
1321 struct extra_type *tgt;
1322
1324
1325 if (tgt != target_extra) {
1326 /* Only one target allowed, which wasn't the requested one */
1327 return TRI_NO;
1328 }
1329 }
1330
1332 return TRI_NO;
1333 }
1334 }
1335 }
1336 break;
1337
1338 case ACTRES_CLEAN:
1339 {
1340 const struct extra_type *pextra = NULL;
1341
1342 pterrain = tile_terrain(target->tile);
1343
1344 if (target_extra != NULL) {
1345 if (tile_has_extra(target->tile, target_extra)
1347 pextra = target_extra;
1348 }
1349 } else {
1350 /* TODO: Make sure that all callers set target so that
1351 * we don't need this fallback. */
1352 pextra = prev_extra_in_tile(target->tile,
1353 ERM_CLEAN,
1354 actor->player,
1355 actor->unit);
1356 }
1357
1358 if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0
1359 && can_remove_extra(pextra, actor->unit, target->tile)) {
1360 return TRI_YES;
1361 }
1362
1363 return TRI_NO;
1364 }
1365
1367 if (!can_unit_unload(actor->unit, target->unit)) {
1368 /* Keep the old rules about Unreachable and disembarks. */
1369 return TRI_NO;
1370 }
1371 break;
1372
1374 if (unit_transported(actor->unit)) {
1375 if (target->unit == unit_transport_get(actor->unit)) {
1376 /* Already inside this transport. */
1377 return TRI_NO;
1378 }
1379 }
1380 if (!could_unit_load(actor->unit, target->unit)) {
1381 /* Keep the old rules. */
1382 return TRI_NO;
1383 }
1384 break;
1385
1387 if (unit_transported(target->unit)) {
1388 if (actor->unit == unit_transport_get(target->unit)) {
1389 /* Already transporting this unit. */
1390 return TRI_NO;
1391 }
1392 }
1393 if (!could_unit_load(target->unit, actor->unit)) {
1394 /* Keep the old rules. */
1395 return TRI_NO;
1396 }
1397 if (unit_transported(target->unit)) {
1398 if (!can_unit_unload(target->unit,
1399 unit_transport_get(target->unit))) {
1400 /* Can't leave current transport. */
1401 return TRI_NO;
1402 }
1403 }
1404 break;
1405
1407 if (!can_unit_unload(target->unit, actor->unit)) {
1408 /* Keep the old rules about Unreachable and disembarks. */
1409 return TRI_NO;
1410 }
1411 break;
1412
1414 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1415 FALSE, FALSE, FALSE)) {
1416 /* Reason: involves moving to the tile. */
1417 return TRI_NO;
1418 }
1419
1420 /* We cannot move a transport into a tile that holds
1421 * units or cities not allied with all of our cargo. */
1422 if (get_transporter_capacity(actor->unit) > 0) {
1423 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1424 struct player *cowner = unit_owner(pcargo);
1425
1426 if (unit_contained_in(pcargo, actor->unit)
1427 && (is_non_allied_unit_tile(target->tile, cowner,
1429 || is_non_allied_city_tile(target->tile, cowner))) {
1430 return TRI_NO;
1431 }
1433 }
1434 break;
1435
1437 if (unit_transported(actor->unit)) {
1438 if (target->unit == unit_transport_get(actor->unit)) {
1439 /* Already inside this transport. */
1440 return TRI_NO;
1441 }
1442 }
1443 if (!could_unit_load(actor->unit, target->unit)) {
1444 /* Keep the old rules. */
1445 return TRI_NO;
1446 }
1447 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1448 FALSE, TRUE, FALSE)) {
1449 /* Reason: involves moving to the tile. */
1450 return TRI_NO;
1451 }
1452 /* We cannot move a transport into a tile that holds
1453 * units or cities not allied with all of our cargo. */
1454 if (get_transporter_capacity(actor->unit) > 0) {
1455 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1456 struct player *cowner = unit_owner(pcargo);
1457
1458 if (unit_contained_in(pcargo, actor->unit)
1459 && (is_non_allied_unit_tile(target->tile, cowner,
1461 || is_non_allied_city_tile(target->tile,
1462 cowner))) {
1463 return TRI_NO;
1464 }
1466 }
1467 break;
1468
1469 case ACTRES_SPY_ATTACK:
1470 {
1471 bool found;
1472
1473 if (!omniscient
1475 target->tile)) {
1476 /* May have a hidden diplomatic defender. */
1477 return TRI_MAYBE;
1478 }
1479
1480 found = FALSE;
1481 unit_list_iterate(target->tile->units, punit) {
1482 struct player *uplayer = unit_owner(punit);
1483
1484 if (uplayer == actor->player) {
1485 /* Won't defend against its owner. */
1486 continue;
1487 }
1488
1490 /* This unbeatable diplomatic defender will defend before any
1491 * that can be beaten. */
1492 found = FALSE;
1493 break;
1494 }
1495
1497 /* Found a beatable diplomatic defender. */
1498 found = TRUE;
1499 break;
1500 }
1502
1503 if (!found) {
1504 return TRI_NO;
1505 }
1506 }
1507 break;
1508
1509 case ACTRES_HUT_ENTER:
1511 /* Reason: involves moving to the tile. */
1512 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1513 FALSE, FALSE, FALSE)) {
1514 return TRI_NO;
1515 }
1516 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1517 /* Reason: keep extra rmreqs working. */
1518 return TRI_NO;
1519 }
1520 break;
1521
1522 case ACTRES_UNIT_MOVE:
1523 case ACTRES_TELEPORT:
1525 if (result == ACTRES_UNIT_MOVE) {
1526 /* Reason: is moving to the tile. */
1527 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1528 FALSE, FALSE, FALSE)) {
1529 return TRI_NO;
1530 }
1531 } else {
1532 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1533
1534 /* Reason: is teleporting to the tile. */
1535 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1536 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1537 return TRI_NO;
1538 }
1539 }
1540
1541 /* Reason: Don't override "Transport Embark" */
1542 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1543 return TRI_NO;
1544 }
1545
1546 /* We cannot move a transport into a tile that holds
1547 * units or cities not allied with any of our cargo. */
1548 if (get_transporter_capacity(actor->unit) > 0) {
1549 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1550 struct player *cowner = unit_owner(pcargo);
1551
1552 if (unit_contained_in(pcargo, actor->unit)
1553 && (is_non_allied_unit_tile(target->tile, cowner,
1555 || is_non_allied_city_tile(target->tile, cowner))) {
1556 return TRI_NO;
1557 }
1559 }
1560 break;
1561
1562 case ACTRES_SPY_ESCAPE:
1563 /* Reason: Be merciful. */
1564 /* Info leak: The player know if they have any cities. */
1565 if (city_list_size(actor->player->cities) < 1) {
1566 return TRI_NO;
1567 }
1568 break;
1569
1571 /* Enabling this action with illness_on = FALSE prevents spread. */
1572 break;
1573 case ACTRES_BOMBARD:
1574 {
1575 /* Allow bombing only if there's reachable units in the target
1576 * tile. Bombing without anybody taking damage is certainly not
1577 * what user really wants.
1578 * Allow bombing when player does not know if there's units in
1579 * target tile. */
1580 if (tile_city(target->tile) == NULL
1581 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1582 V_MAIN)
1583 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1584 V_INVIS)
1585 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1586 V_SUBSURFACE)) {
1587 bool hiding_extra = FALSE;
1588
1589 extra_type_iterate(pextra) {
1590 if (pextra->eus == EUS_HIDDEN
1591 && tile_has_extra(target->tile, pextra)) {
1593 break;
1594 }
1596
1597 if (!hiding_extra) {
1598 bool has_target = FALSE;
1599
1600 unit_list_iterate(target->tile->units, punit) {
1601 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1602 has_target = TRUE;
1603 break;
1604 }
1606
1607 if (!has_target) {
1608 return TRI_NO;
1609 }
1610 }
1611 }
1612 }
1613 break;
1616 case ACTRES_SPY_POISON:
1623 case ACTRES_STEAL_MAPS:
1624 case ACTRES_SPY_NUKE:
1625 case ACTRES_NUKE:
1627 case ACTRES_EXPEL_UNIT:
1629 case ACTRES_CONVERT:
1632 case ACTRES_FORTIFY:
1633 case ACTRES_HOMELESS:
1635 case ACTRES_NONE:
1636 /* No known hard coded requirements. */
1637 break;
1638
1640 }
1641
1642 return def;
1643}
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:101
int actres_get_act_time(enum action_result result, const struct unit *actor_unit, const struct tile *tgt_tile, const struct extra_type *tgt_extra)
Definition actres.c:316
int actres_min_range_default(enum action_result result)
Definition actres.c:376
void actres_free(void)
Definition actres.c:250
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:669
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:258
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:806
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:785
void actres_init(void)
Definition actres.c:243
static struct actres act_results[ACTRES_LAST]
Definition actres.c:33
enum fc_tristate actres_possible(const struct civ_map *nmap, enum action_result result, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, enum fc_tristate def, bool omniscient, const struct city *homecity)
Definition actres.c:831
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:558
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:301
int actres_max_range_default(enum action_result result)
Definition actres.c:465
bool actres_is_hostile(enum action_result result)
Definition actres.c:286
static bool plr_knows_tile(const struct player *plr, const struct tile *ttile)
Definition actres.c:820
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:364
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:272
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:766
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
dice_roll_type
Definition actres.h:110
@ DRT_DIPLCHANCE
Definition actres.h:110
@ DRT_NONE
Definition actres.h:110
bool can_build_base(const struct unit *punit, const struct base_type *pbase, const struct tile *ptile)
Definition base.c:55
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_ISSET_ANY(vec)
Definition bitvector.h:109
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
int city_unit_slots_available(const struct city *pcity)
Definition city.c:1045
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
Definition city.c:1461
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2008
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:763
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
bool is_unit_reachable_at(const struct unit *defender, const struct unit *attacker, const struct tile *location)
Definition combat.c:86
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
Definition combat.c:770
char * incite_cost
Definition comments.c:74
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
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 * target_extra
Definition dialogs_g.h:57
bool unit_can_displace_hut(const struct unit *punit, const struct tile *ptile)
Definition extras.c:749
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
bool can_remove_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:618
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:535
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_deps_iterate(_reqs, _dep)
Definition extras.h:371
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_deps_iterate_end
Definition extras.h:379
#define extra_base_get(_e_)
Definition extras.h:190
#define extra_road_get(_e_)
Definition extras.h:191
const struct functions * fc_funcs
#define ACT_TIME_INSTANTANEOUS
Definition fc_types.h:353
#define EC_NONE
Definition fc_types.h:1093
#define ACTRES_NONE
Definition fc_types.h:331
#define ERM_NONE
Definition fc_types.h:1116
struct civ_game game
Definition game.c:61
#define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE
Definition game.h:887
#define RS_DEFAULT_ACTION_MIN_RANGE
Definition game.h:883
#define RS_DEFAULT_USER_ACTION_TARGET_KIND
Definition game.h:882
#define RS_DEFAULT_MOVE_MIN_RANGE
Definition game.h:886
#define RS_DEFAULT_ACTION_MAX_RANGE
Definition game.h:884
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
bv_extras get_tile_infrastructure_set(const struct tile *ptile, int *pcount)
Definition map.c:100
bool terrain_surroundings_allow_change(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain)
Definition map.c:748
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:636
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:377
#define square_iterate_end
Definition map.h:380
bool can_see_techs_of_target(const struct player *pow_player, const struct player *target_player)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:318
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 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_player_see_tile(const struct player *plr, const struct tile *ptile)
Definition player.c:1091
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1104
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1164
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:993
struct player_slot * slots
Definition player.c:51
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:301
fc_tristate
Definition shared.h:46
@ TRI_YES
Definition shared.h:46
@ TRI_NO
Definition shared.h:46
@ TRI_MAYBE
Definition shared.h:46
bool hostile
Definition actres.h:115
enum unit_activity activity
Definition actres.h:116
enum action_target_kind def_tgt_kind
Definition actres.h:121
enum dice_roll_type dice
Definition actres.h:117
enum extra_rmcause ermcause
Definition actres.h:120
enum act_tgt_compl sub_tgt_compl
Definition actres.h:113
enum action_battle_kind battle_kind
Definition actres.h:114
enum extra_cause ecause
Definition actres.h:118
Definition city.h:320
int id
Definition city.h:326
int shield_stock
Definition city.h:368
struct packet_game_info info
Definition game.h:89
struct packet_scenario_info scenario
Definition game.h:87
bool buildable
Definition extras.h:116
bool(* player_tile_vision_get)(const struct tile *ptile, const struct player *pplayer, enum vision_layer vision)
struct player_economic economic
Definition player.h:284
const struct tile * tile
const struct player * player
const struct unit_type * unittype
const struct unit * unit
const struct city * city
struct terrain * cultivate_result
Definition terrain.h:108
struct terrain * plant_result
Definition terrain.h:111
int pillage_time
Definition terrain.h:125
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:128
struct terrain * transform_result
Definition terrain.h:122
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
int paratroopers_range
Definition unittype.h:548
int convert_time
Definition unittype.h:538
int city_slots
Definition unittype.h:559
Definition unit.h:140
int hp
Definition unit.h:153
struct tile * tile
Definition unit.h:142
struct extra_type * activity_target
Definition unit.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
#define T_NONE
Definition terrain.h:61
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
Definition tile.c:215
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
Definition tile.c:418
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
@ TILE_UNKNOWN
Definition tile.h:36
#define ACTIVITY_FACTOR
Definition tile.h:166
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
struct goods_type * unit_current_goods(const struct unit *punit, const struct city *homecity)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2499
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2578
enum unit_airlift_result test_unit_can_airlift_to(const struct civ_map *nmap, const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Definition unit.c:81
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1168
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:300
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:2026
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2483
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
@ UU_OK
Definition unit.h:62
@ AR_SRC_NO_FLIGHTS
Definition unit.h:85
@ AR_OK_SRC_UNKNOWN
Definition unit.h:76
@ AR_OK_DST_UNKNOWN
Definition unit.h:77
@ AR_NO_MOVES
Definition unit.h:79
@ AR_BAD_DST_CITY
Definition unit.h:84
@ AR_NOT_IN_CITY
Definition unit.h:82
@ AR_OCCUPIED
Definition unit.h:81
@ AR_OK
Definition unit.h:75
@ AR_DST_NO_FLIGHTS
Definition unit.h:86
@ AR_WRONG_UNITTYPE
Definition unit.h:80
@ AR_BAD_SRC_CITY
Definition unit.h:83
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:433
#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
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1927
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2498
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
int unit_pop_value(const struct unit *punit)
Definition unittype.c:1543
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773