Freeciv-3.2
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_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_LOAD */
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_FLEXIBLE, ABK_NONE, /* ACTRES_CLEAN */
226 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT */
229 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT_CONQUER */
232 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */
235};
236
237/*********************************************************************/
240void actres_init(void)
241{
242}
243
244/*********************************************************************/
247void actres_free(void)
248{
249}
250
251/**********************************************************************/
256{
257 if (result == ACTRES_NONE) {
259 }
260
262
263 return act_results[result].sub_tgt_compl;
264}
265
266/**********************************************************************/
270{
271 if (result == ACTRES_NONE) {
272 return ABK_NONE;
273 }
274
276
277 return act_results[result].battle_kind;
278}
279
280/**********************************************************************/
284{
285 if (result == ACTRES_NONE) {
286 return FALSE;
287 }
288
289 return act_results[result].hostile;
290}
291
292/**********************************************************************/
299{
300 if (result == ACTRES_NONE) {
301 return ACTIVITY_LAST;
302 }
303
304 return act_results[result].activity;
305}
306
307/**********************************************************************/
314 const struct unit *actor_unit,
315 const struct tile *tgt_tile,
316 const struct extra_type *tgt_extra)
317{
319
320 if (pactivity == ACTIVITY_LAST) {
321 /* Happens instantaneously, not at turn change. */
323 }
324
325 switch (pactivity) {
326 case ACTIVITY_PILLAGE:
327 case ACTIVITY_CLEAN:
328 case ACTIVITY_BASE:
331 case ACTIVITY_MINE:
333 case ACTIVITY_PLANT:
337 return 1;
338 case ACTIVITY_CONVERT:
340 case ACTIVITY_EXPLORE:
341 case ACTIVITY_IDLE:
343 case ACTIVITY_SENTRY:
344 case ACTIVITY_GOTO:
345 case ACTIVITY_LAST:
346 /* Should not happen. Caught by the assertion below. */
347 break;
348 }
349
351
353}
354
355/**********************************************************************/
362{
363 if (result == ACTRES_NONE) {
364 return DRT_NONE;
365 }
366
367 return act_results[result].dice;
368}
369
370/**********************************************************************/
374{
375 switch (result) {
393 case ACTRES_JOIN_CITY:
395 case ACTRES_BOMBARD:
396 case ACTRES_SPY_NUKE:
401 case ACTRES_HOME_CITY:
402 case ACTRES_HOMELESS:
404 case ACTRES_PARADROP:
406 case ACTRES_AIRLIFT:
409 case ACTRES_ATTACK:
413 case ACTRES_HEAL_UNIT:
415 case ACTRES_CULTIVATE:
416 case ACTRES_PLANT:
417 case ACTRES_PILLAGE:
418 case ACTRES_CLEAN:
419 case ACTRES_FORTIFY:
420 case ACTRES_ROAD:
421 case ACTRES_CONVERT:
422 case ACTRES_BASE:
423 case ACTRES_MINE:
424 case ACTRES_IRRIGATE:
434 case ACTRES_HUT_ENTER:
436 case ACTRES_UNIT_MOVE:
439 /* Non ruleset defined action min range not supported here */
440 fc_assert_msg(FALSE, "Probably wrong value.");
442 case ACTRES_NUKE:
445 case ACTRES_TELEPORT:
448 case ACTRES_NONE:
450
452 }
453
454 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
455
456 return 0;
457}
458
459/**********************************************************************/
463{
464 switch (result) {
481 case ACTRES_JOIN_CITY:
483 case ACTRES_SPY_NUKE:
487 case ACTRES_HOME_CITY:
488 case ACTRES_HOMELESS:
490 case ACTRES_PARADROP:
494 case ACTRES_ATTACK:
498 case ACTRES_HEAL_UNIT:
500 case ACTRES_CULTIVATE:
501 case ACTRES_PLANT:
502 case ACTRES_PILLAGE:
503 case ACTRES_CLEAN:
504 case ACTRES_FORTIFY:
505 case ACTRES_ROAD:
506 case ACTRES_CONVERT:
507 case ACTRES_BASE:
508 case ACTRES_MINE:
509 case ACTRES_IRRIGATE:
519 case ACTRES_HUT_ENTER:
521 case ACTRES_UNIT_MOVE:
524 /* Non ruleset defined action max range not supported here */
525 fc_assert_msg(FALSE, "Probably wrong value.");
530 case ACTRES_BOMBARD:
532 case ACTRES_NUKE:
536 case ACTRES_AIRLIFT:
537 case ACTRES_TELEPORT:
540 case ACTRES_NONE:
542
544 }
545
546 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
547
548 return 0;
549}
550
551/**********************************************************************/
556 enum action_target_kind tgt_kind)
557{
559 FALSE);
561 FALSE);
562
563 switch (result) {
577 case ACTRES_JOIN_CITY:
579 case ACTRES_SPY_NUKE:
582 case ACTRES_HOME_CITY:
584 case ACTRES_AIRLIFT:
590 return tgt_kind == ATK_CITY;
594 case ACTRES_HEAL_UNIT:
600 return tgt_kind == ATK_UNIT;
602 case ACTRES_BOMBARD:
604 case ACTRES_ATTACK:
608 return tgt_kind == ATK_UNITS;
610 case ACTRES_PARADROP:
613 case ACTRES_CULTIVATE:
614 case ACTRES_PLANT:
615 case ACTRES_CLEAN:
616 case ACTRES_ROAD:
617 case ACTRES_BASE:
618 case ACTRES_MINE:
619 case ACTRES_IRRIGATE:
621 case ACTRES_HUT_ENTER:
623 case ACTRES_UNIT_MOVE:
624 case ACTRES_TELEPORT:
626 return tgt_kind == ATK_TILE;
628 return tgt_kind == ATK_EXTRAS;
630 case ACTRES_CONVERT:
631 case ACTRES_FORTIFY:
632 case ACTRES_HOMELESS:
634 return tgt_kind == ATK_SELF;
635 case ACTRES_PILLAGE:
636 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
637 case ACTRES_NUKE:
638 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
639 case ACTRES_NONE:
640 switch (tgt_kind) {
641 case ATK_CITY:
642 case ATK_UNIT:
643 case ATK_UNITS:
644 case ATK_TILE:
645 case ATK_EXTRAS:
646 case ATK_SELF:
647 /* Works with all existing target kinds. */
648 return TRUE;
649 case ATK_COUNT:
650 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
651 break;
652 }
653 break;
654
656 }
657
658 /* Should never be reached. */
659 return FALSE;
660}
661
662/**********************************************************************/
667{
669 ASTK_NONE);
670
671 switch (result) {
683 case ACTRES_JOIN_CITY:
685 case ACTRES_SPY_NUKE:
688 case ACTRES_HOME_CITY:
689 case ACTRES_HOMELESS:
691 case ACTRES_AIRLIFT:
695 return ASTK_NONE;
698 return ASTK_BUILDING;
700 return ASTK_TECH;
704 case ACTRES_HEAL_UNIT:
710 return ASTK_NONE;
712 case ACTRES_BOMBARD:
714 case ACTRES_ATTACK:
718 return ASTK_NONE;
720 case ACTRES_NUKE:
721 case ACTRES_PARADROP:
724 case ACTRES_CULTIVATE:
725 case ACTRES_PLANT:
727 case ACTRES_HUT_ENTER:
729 case ACTRES_UNIT_MOVE:
730 case ACTRES_TELEPORT:
734 return ASTK_NONE;
735 case ACTRES_PILLAGE:
736 case ACTRES_CLEAN:
737 return ASTK_EXTRA;
738 case ACTRES_ROAD:
739 case ACTRES_BASE:
740 case ACTRES_MINE:
741 case ACTRES_IRRIGATE:
744 return ASTK_NONE;
746 case ACTRES_CONVERT:
747 case ACTRES_FORTIFY:
748 return ASTK_NONE;
749 case ACTRES_NONE:
750 return ASTK_NONE;
751
753 }
754
755 /* Should never be reached. */
756 return ASTK_NONE;
757}
758
759/**********************************************************************/
774
775/**********************************************************************/
783 const struct extra_type *pextra)
784{
785 if (act_results[result].ecause == EC_NONE) {
786 return FALSE;
787 }
788
789 if (pextra == NULL || !pextra->buildable) {
790 return FALSE;
791 }
792
793 return is_extra_caused_by(pextra, act_results[result].ecause);
794}
795
796/**********************************************************************/
804 const struct extra_type *pextra)
805{
806 if (act_results[result].ermcause == ERM_NONE) {
807 return FALSE;
808 }
809
810 return is_extra_removed_by(pextra, act_results[result].ermcause);
811}
812
813/**********************************************************************/
817static bool plr_knows_tile(const struct player *plr,
818 const struct tile *ttile)
819{
820 return plr != nullptr
821 && ttile != nullptr
822 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
823}
824
825/**********************************************************************/
829 enum action_result result,
830 const struct req_context *actor,
831 const struct req_context *target,
832 const struct extra_type *target_extra,
833 enum fc_tristate def,
834 bool omniscient,
835 const struct city *homecity)
836{
837 struct terrain *pterrain;
838 bool can_see_tgt_unit;
839 bool can_see_tgt_tile;
840
841 /* Only check requirement against the target unit if the actor can see it
842 * or if the evaluator is omniscient. The game checking the rules is
843 * omniscient. The player asking about their odds isn't. */
844 can_see_tgt_unit = (omniscient || (target->unit
845 && can_player_see_unit(actor->player,
846 target->unit)));
847
848 /* Only check requirement against the target tile if the actor can see it
849 * or if the evaluator is omniscient. The game checking the rules is
850 * omniscient. The player asking about their odds isn't. */
851 can_see_tgt_tile = (omniscient
852 || can_player_see_tile(actor->player, target->tile));
853
854 switch (result) {
857 /* Why this is a hard requirement: Can't transfer a unique unit if the
858 * actor player already has one. */
859 /* Info leak: This is only checked for when the actor player can see
860 * the target unit. Since the target unit is seen its type is known.
861 * The fact that a city hiding the unseen unit is occupied is known. */
862
863 if (!can_see_tgt_unit) {
864 /* An omniscient player can see the target unit. */
865 fc_assert(!omniscient);
866
867 return TRI_MAYBE;
868 }
869
871 target->unittype)) {
872 return TRI_NO;
873 }
874
875 /* FIXME: Capture Unit may want to look for more than one unique unit
876 * of the same kind at the target tile. Currently caught by sanity
877 * check in do_capture_units(). */
878
879 break;
880
882 /* Reason: The Freeciv code don't support selecting a target tech
883 * unless it is known that the victim player has it. */
884 /* Info leak: The actor player knowns whose techs they can see. */
885 if (!can_see_techs_of_target(actor->player, target->player)) {
886 return TRI_NO;
887 }
888
889 break;
890
892 /* If actor->unit can do the action the actor->player can see how much
893 * gold target->player have. Not requiring it is therefore pointless.
894 */
895 if (target->player->economic.gold <= 0) {
896 return TRI_NO;
897 }
898
899 break;
900
903 {
904 /* Checked in action_hard_reqs_actor() */
905 fc_assert_ret_val(homecity != NULL, TRI_NO);
906
907 /* Can't establish a trade route or enter the market place if the
908 * cities can't trade at all. */
909 /* TODO: Should this restriction (and the above restriction that the
910 * actor unit must have a home city) be kept for Enter Marketplace? */
911 if (!can_cities_trade(homecity, target->city)) {
912 return TRI_NO;
913 }
914
915 /* There are more restrictions on establishing a trade route than on
916 * entering the market place. */
917 if (result == ACTRES_TRADE_ROUTE
918 && !can_establish_trade_route(homecity, target->city)) {
919 return TRI_NO;
920 }
921 }
922
923 break;
924
927 /* It is only possible to help the production if the production needs
928 * the help. (If not it would be possible to add shields for something
929 * that can't legally receive help if it is build later) */
930 /* Info leak: The player knows that the production in their own city has
931 * been hurried (bought or helped). The information isn't revealed when
932 * asking for action probabilities since omniscient is FALSE. */
933 if (!omniscient
934 && !can_player_see_city_internals(actor->player, target->city)) {
935 return TRI_MAYBE;
936 }
937
938 if (!(target->city->shield_stock
940 return TRI_NO;
941 }
942
943 break;
944
947 /* Reason: allow scenarios to disable city founding. */
948 /* Info leak: the setting is public knowledge. */
949 return TRI_NO;
950 }
951
952 if (can_see_tgt_tile && tile_city(target->tile)) {
953 /* Reason: a tile can have 0 or 1 cities. */
954 return TRI_NO;
955 }
956
958 if (omniscient) {
959 /* No need to check again. */
960 return TRI_NO;
961 } else {
962 square_iterate(nmap, target->tile,
963 game.info.citymindist - 1, otile) {
964 if (tile_city(otile) != NULL
965 && can_player_see_tile(actor->player, otile)) {
966 /* Known to be blocked by citymindist */
967 return TRI_NO;
968 }
970 }
971 }
972
973 /* The player may not have enough information to be certain. */
974
975 if (!can_see_tgt_tile) {
976 /* Need to know if target tile already has a city, has TER_NO_CITIES
977 * terrain, is non native to the actor or is owned by a foreigner. */
978 return TRI_MAYBE;
979 }
980
981 if (!omniscient) {
982 /* The player may not have enough information to find out if
983 * citymindist blocks or not. This doesn't depend on if it blocks. */
984 square_iterate(nmap, target->tile,
985 game.info.citymindist - 1, otile) {
986 if (!can_player_see_tile(actor->player, otile)) {
987 /* Could have a city that blocks via citymindist. Even if this
988 * tile has TER_NO_CITIES terrain the player don't know that it
989 * didn't change and had a city built on it. */
990 return TRI_MAYBE;
991 }
993 }
994
995 break;
996
997 case ACTRES_JOIN_CITY:
998 {
999 int new_pop;
1000
1001 if (!omniscient
1002 && !player_can_see_city_externals(actor->player, target->city)) {
1003 return TRI_MAYBE;
1004 }
1005
1006 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1007
1009 /* Reason: Make the add_to_size_limit setting work. */
1010 return TRI_NO;
1011 }
1012
1013 if (!city_can_grow_to(target->city, new_pop)) {
1014 /* Reason: respect city size limits. */
1015 /* Info leak: when it is legal to join a foreign city is legal and
1016 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1017 * something the actor player don't have access to.
1018 * Example: depends on a building (like Aqueduct) that isn't
1019 * VisibleByOthers. */
1020 return TRI_NO;
1021 }
1022 }
1023
1024 break;
1025
1026 case ACTRES_NUKE_UNITS:
1027 /* Has only action specific requirements */
1028 break;
1029
1030 case ACTRES_HOME_CITY:
1031 /* Reason: can't change to what is. */
1032 /* Info leak: The player knows their unit's current home city. */
1033 if (homecity != NULL && homecity->id == target->city->id) {
1034 /* This is already the unit's home city. */
1035 return TRI_NO;
1036 }
1037
1038 {
1039 int slots = unit_type_get(actor->unit)->city_slots;
1040
1041 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1042 return TRI_NO;
1043 }
1044 }
1045
1046 break;
1047
1049 /* Reason: Keep the old rules. */
1050 /* Info leak: The player knows their unit's type. They know if they can
1051 * build the unit type upgraded to. If the upgrade happens in a foreign
1052 * city that fact may leak. This can be seen as a price for changing
1053 * the rules to allow upgrading in a foreign city.
1054 * The player knows how much gold they have. If the Upgrade_Price_Pct
1055 * effect depends on information they don't have that information may
1056 * leak. The player knows the location of their unit. They know if the
1057 * tile has a city and if the unit can exist there outside a transport.
1058 * The player knows their unit's cargo. By knowing the number and type
1059 * of cargo, they can predict if there will be enough room in the unit
1060 * upgraded to, as long as they know what unit type their unit will end
1061 * up as. */
1062 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1063 return TRI_NO;
1064 }
1065
1066 break;
1067
1068 case ACTRES_PARADROP:
1070 /* Reason: Keep the old rules. */
1071 /* Info leak: The player knows if they know the target tile. */
1072 if (!plr_knows_tile(actor->player, target->tile)) {
1073 return TRI_NO;
1074 }
1075
1076 /* Reason: Keep paratroopers_range working. */
1077 /* Info leak: The player knows the location of the actor and of the
1078 * target tile. */
1080 < real_map_distance(actor->tile, target->tile)) {
1081 return TRI_NO;
1082 }
1083
1084 break;
1085
1086 case ACTRES_AIRLIFT:
1087 /* Reason: Keep the old rules. */
1088 /* Info leak: same as test_unit_can_airlift_to() */
1089 switch (test_unit_can_airlift_to(nmap, omniscient ? NULL : actor->player,
1090 actor->unit, target->city)) {
1091 case AR_OK:
1092 return TRI_YES;
1093 case AR_OK_SRC_UNKNOWN:
1094 case AR_OK_DST_UNKNOWN:
1095 return TRI_MAYBE;
1096 case AR_NO_MOVES:
1097 case AR_WRONG_UNITTYPE:
1098 case AR_OCCUPIED:
1099 case AR_NOT_IN_CITY:
1100 case AR_BAD_SRC_CITY:
1101 case AR_BAD_DST_CITY:
1102 case AR_SRC_NO_FLIGHTS:
1103 case AR_DST_NO_FLIGHTS:
1104 return TRI_NO;
1105 }
1106
1107 break;
1108
1109 case ACTRES_ATTACK:
1110 break;
1111
1112 case ACTRES_WIPE_UNITS:
1113 unit_list_iterate(target->tile->units, punit) {
1114 if (get_total_defense_power(actor->unit, punit) > 0) {
1115 return TRI_NO;
1116 }
1118 break;
1119
1121 if (!is_barbarian(actor->player)
1123 return FALSE;
1124 }
1125
1126 unit_list_iterate(target->tile->units, punit) {
1128 /* Cannot get ransom when there are other kind of units in the tile */
1129 return FALSE;
1130 }
1132 break;
1133
1135 /* Reason: "Conquer City" involves moving into the city. */
1136 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1137 FALSE, FALSE, TRUE)) {
1138 return TRI_NO;
1139 }
1140
1141 break;
1142
1144 /* Reason: "Conquer Extras" involves moving to the tile. */
1145 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1146 FALSE, FALSE, FALSE)) {
1147 return TRI_NO;
1148 }
1149 /* Reason: Must have something to claim. The more specific restriction
1150 * that the base must be native to the actor unit is hard coded in
1151 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1152 * helptext_extra(), in helptext_unit(), in do_attack() and in
1153 * diplomat_bribe(). */
1154 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1155 return TRI_NO;
1156 }
1157 break;
1158
1159 case ACTRES_HEAL_UNIT:
1160 /* Reason: It is not the healthy who need a doctor, but the sick. */
1161 /* Info leak: the actor can see the target's HP. */
1162 if (!can_see_tgt_unit) {
1163 return TRI_MAYBE;
1164 }
1165 if (!(target->unit->hp < target->unittype->hp)) {
1166 return TRI_NO;
1167 }
1168 break;
1169
1171 pterrain = tile_terrain(target->tile);
1172 if (pterrain->transform_result == T_NONE
1173 || pterrain == pterrain->transform_result
1175 pterrain->transform_result)
1177 && (tile_city(target->tile)))) {
1178 return TRI_NO;
1179 }
1180 break;
1181
1182 case ACTRES_CULTIVATE:
1183 pterrain = tile_terrain(target->tile);
1184 if (pterrain->cultivate_result == NULL) {
1185 return TRI_NO;
1186 }
1188 pterrain->cultivate_result)
1190 && tile_city(target->tile))) {
1191 return TRI_NO;
1192 }
1193 break;
1194
1195 case ACTRES_PLANT:
1196 pterrain = tile_terrain(target->tile);
1197 if (pterrain->plant_result == NULL) {
1198 return TRI_NO;
1199 }
1201 pterrain->plant_result)
1203 && tile_city(target->tile))) {
1204 return TRI_NO;
1205 }
1206 break;
1207
1208 case ACTRES_ROAD:
1209 if (target_extra == NULL) {
1210 return TRI_NO;
1211 }
1213 /* Reason: This is not a road. */
1214 return TRI_NO;
1215 }
1217 target->tile)) {
1218 return TRI_NO;
1219 }
1220 break;
1221
1222 case ACTRES_BASE:
1223 if (target_extra == NULL) {
1224 return TRI_NO;
1225 }
1227 /* Reason: This is not a base. */
1228 return TRI_NO;
1229 }
1230 if (!can_build_base(actor->unit,
1231 extra_base_get(target_extra), target->tile)) {
1232 return TRI_NO;
1233 }
1234 break;
1235
1236 case ACTRES_MINE:
1237 if (target_extra == NULL) {
1238 return TRI_NO;
1239 }
1241 /* Reason: This is not a mine. */
1242 return TRI_NO;
1243 }
1244
1245 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1246 return TRI_NO;
1247 }
1248 break;
1249
1250 case ACTRES_IRRIGATE:
1251 if (target_extra == NULL) {
1252 return TRI_NO;
1253 }
1255 /* Reason: This is not an irrigation. */
1256 return TRI_NO;
1257 }
1258
1259 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1260 return TRI_NO;
1261 }
1262 break;
1263
1264 case ACTRES_PILLAGE:
1265 pterrain = tile_terrain(target->tile);
1266 if (pterrain->pillage_time == 0) {
1267 return TRI_NO;
1268 }
1269
1270 {
1274
1276 extra_type_iterate(pextra) {
1277 int idx = extra_index(pextra);
1278
1279 /* Only one unit can pillage a given improvement at a time */
1280 if (BV_ISSET(pspresent, idx)
1281 && (!BV_ISSET(psworking, idx)
1282 || actor->unit->activity_target == pextra)
1283 && can_remove_extra(pextra, actor->unit, target->tile)) {
1284 bool required = FALSE;
1285
1289 if (pdep == pextra) {
1290 required = TRUE;
1291 break;
1292 }
1294 }
1295 if (required) {
1296 break;
1297 }
1299
1300 if (!required) {
1301 BV_SET(pspossible, idx);
1302 }
1303 }
1305
1306 if (!BV_ISSET_ANY(pspossible)) {
1307 /* Nothing available to pillage */
1308 return TRI_NO;
1309 }
1310
1311 if (target_extra != NULL) {
1312 if (!game.info.pillage_select) {
1313 /* Hobson's choice (this case mostly exists for old clients) */
1314 /* Needs to match what unit_activity_assign_target chooses */
1315 struct extra_type *tgt;
1316
1318
1319 if (tgt != target_extra) {
1320 /* Only one target allowed, which wasn't the requested one */
1321 return TRI_NO;
1322 }
1323 }
1324
1326 return TRI_NO;
1327 }
1328 }
1329 }
1330 break;
1331
1332 case ACTRES_CLEAN:
1333 {
1334 const struct extra_type *pextra = NULL;
1335
1336 pterrain = tile_terrain(target->tile);
1337
1338 if (target_extra != NULL) {
1339 if (tile_has_extra(target->tile, target_extra)
1341 pextra = target_extra;
1342 }
1343 } else {
1344 /* TODO: Make sure that all callers set target so that
1345 * we don't need this fallback. */
1346 pextra = prev_extra_in_tile(target->tile,
1347 ERM_CLEAN,
1348 actor->player,
1349 actor->unit);
1350 }
1351
1352 if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0
1353 && can_remove_extra(pextra, actor->unit, target->tile)) {
1354 return TRI_YES;
1355 }
1356
1357 return TRI_NO;
1358 }
1359
1361 if (!can_unit_unload(actor->unit, target->unit)) {
1362 /* Keep the old rules about Unreachable and disembarks. */
1363 return TRI_NO;
1364 }
1365 break;
1366
1368 if (unit_transported(actor->unit)) {
1369 if (target->unit == unit_transport_get(actor->unit)) {
1370 /* Already inside this transport. */
1371 return TRI_NO;
1372 }
1373 }
1374 if (!could_unit_load(actor->unit, target->unit)) {
1375 /* Keep the old rules. */
1376 return TRI_NO;
1377 }
1378 break;
1379
1381 if (unit_transported(target->unit)) {
1382 if (actor->unit == unit_transport_get(target->unit)) {
1383 /* Already transporting this unit. */
1384 return TRI_NO;
1385 }
1386 }
1387 if (!could_unit_load(target->unit, actor->unit)) {
1388 /* Keep the old rules. */
1389 return TRI_NO;
1390 }
1391 if (unit_transported(target->unit)) {
1392 if (!can_unit_unload(target->unit,
1393 unit_transport_get(target->unit))) {
1394 /* Can't leave current transport. */
1395 return TRI_NO;
1396 }
1397 }
1398 break;
1399
1401 if (!can_unit_unload(target->unit, actor->unit)) {
1402 /* Keep the old rules about Unreachable and disembarks. */
1403 return TRI_NO;
1404 }
1405 break;
1406
1408 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1409 FALSE, FALSE, FALSE)) {
1410 /* Reason: involves moving to the tile. */
1411 return TRI_NO;
1412 }
1413
1414 /* We cannot move a transport into a tile that holds
1415 * units or cities not allied with all of our cargo. */
1416 if (get_transporter_capacity(actor->unit) > 0) {
1417 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1418 if (unit_contained_in(pcargo, actor->unit)
1420 || is_non_allied_city_tile(target->tile,
1421 unit_owner(pcargo)))) {
1422 return TRI_NO;
1423 }
1425 }
1426 break;
1427
1429 if (unit_transported(actor->unit)) {
1430 if (target->unit == unit_transport_get(actor->unit)) {
1431 /* Already inside this transport. */
1432 return TRI_NO;
1433 }
1434 }
1435 if (!could_unit_load(actor->unit, target->unit)) {
1436 /* Keep the old rules. */
1437 return TRI_NO;
1438 }
1439 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1440 FALSE, TRUE, FALSE)) {
1441 /* Reason: involves moving to the tile. */
1442 return TRI_NO;
1443 }
1444 /* We cannot move a transport into a tile that holds
1445 * units or cities not allied with all of our cargo. */
1446 if (get_transporter_capacity(actor->unit) > 0) {
1447 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1448 if (unit_contained_in(pcargo, actor->unit)
1450 || is_non_allied_city_tile(target->tile,
1451 unit_owner(pcargo)))) {
1452 return TRI_NO;
1453 }
1455 }
1456 break;
1457
1458 case ACTRES_SPY_ATTACK:
1459 {
1460 bool found;
1461
1462 if (!omniscient
1464 target->tile)) {
1465 /* May have a hidden diplomatic defender. */
1466 return TRI_MAYBE;
1467 }
1468
1469 found = FALSE;
1470 unit_list_iterate(target->tile->units, punit) {
1471 struct player *uplayer = unit_owner(punit);
1472
1473 if (uplayer == actor->player) {
1474 /* Won't defend against its owner. */
1475 continue;
1476 }
1477
1479 /* This unbeatable diplomatic defender will defend before any
1480 * that can be beaten. */
1481 found = FALSE;
1482 break;
1483 }
1484
1486 /* Found a beatable diplomatic defender. */
1487 found = TRUE;
1488 break;
1489 }
1491
1492 if (!found) {
1493 return TRI_NO;
1494 }
1495 }
1496 break;
1497
1498 case ACTRES_HUT_ENTER:
1500 /* Reason: involves moving to the tile. */
1501 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1502 FALSE, FALSE, FALSE)) {
1503 return TRI_NO;
1504 }
1505 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1506 /* Reason: keep extra rmreqs working. */
1507 return TRI_NO;
1508 }
1509 break;
1510
1511 case ACTRES_UNIT_MOVE:
1512 case ACTRES_TELEPORT:
1514 if (result == ACTRES_UNIT_MOVE) {
1515 /* Reason: is moving to the tile. */
1516 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1517 FALSE, FALSE, FALSE)) {
1518 return TRI_NO;
1519 }
1520 } else {
1521 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1522
1523 /* Reason: is teleporting to the tile. */
1524 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1525 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1526 return TRI_NO;
1527 }
1528 }
1529
1530 /* Reason: Don't override "Transport Embark" */
1531 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1532 return TRI_NO;
1533 }
1534
1535 /* We cannot move a transport into a tile that holds
1536 * units or cities not allied with any of our cargo. */
1537 if (get_transporter_capacity(actor->unit) > 0) {
1538 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1539 if (unit_contained_in(pcargo, actor->unit)
1541 || is_non_allied_city_tile(target->tile,
1542 unit_owner(pcargo)))) {
1543 return TRI_NO;
1544 }
1546 }
1547 break;
1548
1549 case ACTRES_SPY_ESCAPE:
1550 /* Reason: Be merciful. */
1551 /* Info leak: The player know if they have any cities. */
1552 if (city_list_size(actor->player->cities) < 1) {
1553 return TRI_NO;
1554 }
1555 break;
1556
1558 /* Enabling this action with illness_on = FALSE prevents spread. */
1559 break;
1560 case ACTRES_BOMBARD:
1561 {
1562 /* Allow bombing only if there's reachable units in the target
1563 * tile. Bombing without anybody taking damage is certainly not
1564 * what user really wants.
1565 * Allow bombing when player does not know if there's units in
1566 * target tile. */
1567 if (tile_city(target->tile) == NULL
1568 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1569 V_MAIN)
1570 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1571 V_INVIS)
1572 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1573 V_SUBSURFACE)) {
1574 bool hiding_extra = FALSE;
1575
1576 extra_type_iterate(pextra) {
1577 if (pextra->eus == EUS_HIDDEN
1578 && tile_has_extra(target->tile, pextra)) {
1580 break;
1581 }
1583
1584 if (!hiding_extra) {
1585 bool has_target = FALSE;
1586
1587 unit_list_iterate(target->tile->units, punit) {
1588 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1589 has_target = TRUE;
1590 break;
1591 }
1593
1594 if (!has_target) {
1595 return TRI_NO;
1596 }
1597 }
1598 }
1599 }
1600 break;
1603 case ACTRES_SPY_POISON:
1610 case ACTRES_STEAL_MAPS:
1611 case ACTRES_SPY_NUKE:
1612 case ACTRES_NUKE:
1614 case ACTRES_EXPEL_UNIT:
1616 case ACTRES_CONVERT:
1619 case ACTRES_FORTIFY:
1620 case ACTRES_HOMELESS:
1622 case ACTRES_NONE:
1623 /* No known hard coded requirements. */
1624 break;
1625
1627 }
1628
1629 return def;
1630}
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:357
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:313
int actres_min_range_default(enum action_result result)
Definition actres.c:373
void actres_free(void)
Definition actres.c:247
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:666
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:255
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:803
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:782
void actres_init(void)
Definition actres.c:240
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:828
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:555
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:298
int actres_max_range_default(enum action_result result)
Definition actres.c:462
bool actres_is_hostile(enum action_result result)
Definition actres.c:283
static bool plr_knows_tile(const struct player *plr, const struct tile *ttile)
Definition actres.c:817
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:361
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:269
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:763
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
dice_roll_type
Definition actres.h:108
@ DRT_DIPLCHANCE
Definition actres.h:108
@ DRT_NONE
Definition actres.h:108
bool can_build_base(const struct unit *punit, const struct base_type *pbase, const struct tile *ptile)
Definition base.c:53
#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:1049
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
Definition city.c:1465
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2012
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:770
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:85
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
Definition combat.c:767
char * incite_cost
Definition comments.c:75
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:738
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:790
bool can_remove_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:612
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:533
#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:349
#define EC_NONE
Definition fc_types.h:1113
#define ACTRES_NONE
Definition fc_types.h:327
#define ERM_NONE
Definition fc_types.h:1136
struct civ_game game
Definition game.c:62
#define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE
Definition game.h:894
#define RS_DEFAULT_ACTION_MIN_RANGE
Definition game.h:890
#define RS_DEFAULT_USER_ACTION_TARGET_KIND
Definition game.h:889
#define RS_DEFAULT_MOVE_MIN_RANGE
Definition game.h:893
#define RS_DEFAULT_ACTION_MAX_RANGE
Definition game.h:891
#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:101
bool terrain_surroundings_allow_change(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain)
Definition map.c:742
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:630
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:391
#define square_iterate_end
Definition map.h:394
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:319
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:592
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:572
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
static bool is_barbarian(const struct player *pplayer)
Definition player.h:489
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
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:113
enum unit_activity activity
Definition actres.h:114
enum action_target_kind def_tgt_kind
Definition actres.h:119
enum dice_roll_type dice
Definition actres.h:115
enum extra_rmcause ermcause
Definition actres.h:118
enum act_tgt_compl sub_tgt_compl
Definition actres.h:111
enum action_battle_kind battle_kind
Definition actres.h:112
enum extra_cause ecause
Definition actres.h:116
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:282
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:215
struct terrain * plant_result
Definition terrain.h:218
int pillage_time
Definition terrain.h:232
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:235
struct terrain * transform_result
Definition terrain.h:229
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
int paratroopers_range
Definition unittype.h:541
int convert_time
Definition unittype.h:531
int city_slots
Definition unittype.h:552
Definition unit.h:138
int hp
Definition unit.h:151
struct tile * tile
Definition unit.h:140
struct extra_type * activity_target
Definition unit.h:164
#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:56
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
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:165
#define tile_terrain(_tile)
Definition tile.h:110
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2441
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2520
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:700
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1138
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:297
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1988
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2425
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:752
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
@ UU_OK
Definition unit.h:61
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
@ AR_SRC_NO_FLIGHTS
Definition unit.h:84
@ AR_OK_SRC_UNKNOWN
Definition unit.h:75
@ AR_OK_DST_UNKNOWN
Definition unit.h:76
@ AR_NO_MOVES
Definition unit.h:78
@ AR_BAD_DST_CITY
Definition unit.h:83
@ AR_NOT_IN_CITY
Definition unit.h:81
@ AR_OCCUPIED
Definition unit.h:80
@ AR_OK
Definition unit.h:74
@ AR_DST_NO_FLIGHTS
Definition unit.h:85
@ AR_WRONG_UNITTYPE
Definition unit.h:79
@ AR_BAD_SRC_CITY
Definition unit.h:82
#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:2499
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
Definition unittype.c:208
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:766