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_BRIBE_STACK */
79 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_UNIT */
82 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CAPTURE_UNITS */
85 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FOUND_CITY */
88 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_JOIN_CITY */
91 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_STEAL_MAPS */
94 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_BOMBARD */
97 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_NUKE */
100 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE */
103 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE_UNITS */
106 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DESTROY_CITY */
109 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_EXPEL_UNIT */
112 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT_RECOVER */
115 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT */
118 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOME_CITY */
121 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UPGRADE_UNIT */
124 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP */
127 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_AIRLIFT */
130 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_ATTACK */
133 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_STRIKE_BUILDING */
136 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_STRIKE_PRODUCTION */
139 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_CITY */
142 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HEAL_UNIT */
145 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSFORM_TERRAIN */
148 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CULTIVATE */
151 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PLANT */
154 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_PILLAGE */
157 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FORTIFY */
160 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_ROAD */
163 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONVERT */
166 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_BASE */
169 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_MINE */
172 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_IRRIGATE */
175 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_COLLECT_RANSOM */
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) {
397 case ACTRES_JOIN_CITY:
399 case ACTRES_BOMBARD:
400 case ACTRES_SPY_NUKE:
405 case ACTRES_HOME_CITY:
406 case ACTRES_HOMELESS:
408 case ACTRES_PARADROP:
410 case ACTRES_AIRLIFT:
413 case ACTRES_ATTACK:
417 case ACTRES_HEAL_UNIT:
419 case ACTRES_CULTIVATE:
420 case ACTRES_PLANT:
421 case ACTRES_PILLAGE:
422 case ACTRES_CLEAN:
423 case ACTRES_FORTIFY:
424 case ACTRES_ROAD:
425 case ACTRES_CONVERT:
426 case ACTRES_BASE:
427 case ACTRES_MINE:
428 case ACTRES_IRRIGATE:
438 case ACTRES_HUT_ENTER:
440 case ACTRES_UNIT_MOVE:
443 /* Non ruleset defined action min range not supported here */
444 fc_assert_msg(FALSE, "Probably wrong value.");
446 case ACTRES_NUKE:
449 case ACTRES_TELEPORT:
452 case ACTRES_NONE:
454
456 }
457
458 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
459
460 return 0;
461}
462
463/**********************************************************************/
467{
468 switch (result) {
486 case ACTRES_JOIN_CITY:
488 case ACTRES_SPY_NUKE:
492 case ACTRES_HOME_CITY:
493 case ACTRES_HOMELESS:
495 case ACTRES_PARADROP:
499 case ACTRES_ATTACK:
503 case ACTRES_HEAL_UNIT:
505 case ACTRES_CULTIVATE:
506 case ACTRES_PLANT:
507 case ACTRES_PILLAGE:
508 case ACTRES_CLEAN:
509 case ACTRES_FORTIFY:
510 case ACTRES_ROAD:
511 case ACTRES_CONVERT:
512 case ACTRES_BASE:
513 case ACTRES_MINE:
514 case ACTRES_IRRIGATE:
524 case ACTRES_HUT_ENTER:
526 case ACTRES_UNIT_MOVE:
529 /* Non ruleset defined action max range not supported here */
530 fc_assert_msg(FALSE, "Probably wrong value.");
535 case ACTRES_BOMBARD:
537 case ACTRES_NUKE:
541 case ACTRES_AIRLIFT:
542 case ACTRES_TELEPORT:
545 case ACTRES_NONE:
547
549 }
550
551 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
552
553 return 0;
554}
555
556/**********************************************************************/
561 enum action_target_kind tgt_kind)
562{
564 FALSE);
566 FALSE);
567
568 switch (result) {
582 case ACTRES_JOIN_CITY:
584 case ACTRES_SPY_NUKE:
587 case ACTRES_HOME_CITY:
589 case ACTRES_AIRLIFT:
595 return tgt_kind == ATK_CITY;
599 case ACTRES_HEAL_UNIT:
605 return tgt_kind == ATK_UNIT;
608 case ACTRES_BOMBARD:
610 case ACTRES_ATTACK:
614 return tgt_kind == ATK_STACK;
616 case ACTRES_PARADROP:
619 case ACTRES_CULTIVATE:
620 case ACTRES_PLANT:
621 case ACTRES_CLEAN:
622 case ACTRES_ROAD:
623 case ACTRES_BASE:
624 case ACTRES_MINE:
625 case ACTRES_IRRIGATE:
627 case ACTRES_HUT_ENTER:
629 case ACTRES_UNIT_MOVE:
630 case ACTRES_TELEPORT:
632 return tgt_kind == ATK_TILE;
634 return tgt_kind == ATK_EXTRAS;
636 case ACTRES_CONVERT:
637 case ACTRES_FORTIFY:
638 case ACTRES_HOMELESS:
640 return tgt_kind == ATK_SELF;
641 case ACTRES_PILLAGE:
642 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
643 case ACTRES_NUKE:
644 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
645 case ACTRES_NONE:
646 switch (tgt_kind) {
647 case ATK_CITY:
648 case ATK_UNIT:
649 case ATK_STACK:
650 case ATK_TILE:
651 case ATK_EXTRAS:
652 case ATK_SELF:
653 /* Works with all existing target kinds. */
654 return TRUE;
655 case ATK_COUNT:
656 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
657 break;
658 }
659 break;
660
662 }
663
664 /* Should never be reached. */
665 return FALSE;
666}
667
668/**********************************************************************/
673{
675 ASTK_NONE);
676
677 switch (result) {
689 case ACTRES_JOIN_CITY:
691 case ACTRES_SPY_NUKE:
694 case ACTRES_HOME_CITY:
695 case ACTRES_HOMELESS:
697 case ACTRES_AIRLIFT:
701 return ASTK_NONE;
704 return ASTK_BUILDING;
706 return ASTK_TECH;
711 case ACTRES_HEAL_UNIT:
717 return ASTK_NONE;
719 case ACTRES_BOMBARD:
721 case ACTRES_ATTACK:
725 return ASTK_NONE;
727 case ACTRES_NUKE:
728 case ACTRES_PARADROP:
731 case ACTRES_CULTIVATE:
732 case ACTRES_PLANT:
734 case ACTRES_HUT_ENTER:
736 case ACTRES_UNIT_MOVE:
737 case ACTRES_TELEPORT:
741 return ASTK_NONE;
742 case ACTRES_PILLAGE:
743 case ACTRES_CLEAN:
744 return ASTK_EXTRA;
745 case ACTRES_ROAD:
746 case ACTRES_BASE:
747 case ACTRES_MINE:
748 case ACTRES_IRRIGATE:
751 return ASTK_NONE;
753 case ACTRES_CONVERT:
754 case ACTRES_FORTIFY:
755 return ASTK_NONE;
756 case ACTRES_NONE:
757 return ASTK_NONE;
758
760 }
761
762 /* Should never be reached. */
763 return ASTK_NONE;
764}
765
766/**********************************************************************/
781
782/**********************************************************************/
790 const struct extra_type *pextra)
791{
792 if (act_results[result].ecause == EC_NONE) {
793 return FALSE;
794 }
795
796 if (pextra == NULL || !pextra->buildable) {
797 return FALSE;
798 }
799
800 return is_extra_caused_by(pextra, act_results[result].ecause);
801}
802
803/**********************************************************************/
811 const struct extra_type *pextra)
812{
813 if (act_results[result].ermcause == ERM_NONE) {
814 return FALSE;
815 }
816
817 return is_extra_removed_by(pextra, act_results[result].ermcause);
818}
819
820/**********************************************************************/
824static bool plr_knows_tile(const struct player *plr,
825 const struct tile *ttile)
826{
827 return plr != nullptr
828 && ttile != nullptr
829 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
830}
831
832/**********************************************************************/
836 enum action_result result,
837 const struct req_context *actor,
838 const struct req_context *target,
839 const struct extra_type *target_extra,
840 enum fc_tristate def,
841 bool omniscient,
842 const struct city *homecity)
843{
844 struct terrain *pterrain;
845 bool can_see_tgt_unit;
846 bool can_see_tgt_tile;
847
848 /* Only check requirement against the target unit 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_unit = (omniscient || (target->unit
852 && can_player_see_unit(actor->player,
853 target->unit)));
854
855 /* Only check requirement against the target tile if the actor can see it
856 * or if the evaluator is omniscient. The game checking the rules is
857 * omniscient. The player asking about their odds isn't. */
859 || can_player_see_tile(actor->player, target->tile));
860
861 switch (result) {
865 /* Why this is a hard requirement: Can't transfer a unique unit if the
866 * actor player already has one. */
867 /* Info leak: This is only checked for when the actor player can see
868 * the target unit. Since the target unit is seen its type is known.
869 * The fact that a city hiding the unseen unit is occupied is known. */
870
871 if (!can_see_tgt_unit) {
872 /* An omniscient player can see the target unit. */
874
875 return TRI_MAYBE;
876 }
877
879 target->unittype)) {
880 return TRI_NO;
881 }
882
883 /* FIXME: Capture Unit may want to look for more than one unique unit
884 * of the same kind at the target tile. Currently caught by sanity
885 * check in do_capture_units(). */
886
887 break;
888
890 /* Reason: The Freeciv code don't support selecting a target tech
891 * unless it is known that the victim player has it. */
892 /* Info leak: The actor player knowns whose techs they can see. */
893 if (!can_see_techs_of_target(actor->player, target->player)) {
894 return TRI_NO;
895 }
896
897 break;
898
900 /* If actor->unit can do the action the actor->player can see how much
901 * gold target->player have. Not requiring it is therefore pointless.
902 */
903 if (target->player->economic.gold <= 0) {
904 return TRI_NO;
905 }
906
907 break;
908
911 {
912 /* Checked in action_hard_reqs_actor() */
913 fc_assert_ret_val(homecity != NULL, TRI_NO);
914
915 /* Can't establish a trade route or enter the market place if the
916 * cities can't trade at all. */
917 /* TODO: Should this restriction (and the above restriction that the
918 * actor unit must have a home city) be kept for Enter Marketplace? */
919 if (!can_cities_trade(homecity, target->city)) {
920 return TRI_NO;
921 }
922
923 /* There are more restrictions on establishing a trade route than on
924 * entering the market place. */
925 if (result == ACTRES_TRADE_ROUTE) {
926 struct goods_type *pgood = unit_current_goods(actor->unit, homecity);
927
928 if (!can_establish_trade_route(homecity, target->city,
929 pgood->replace_priority)) {
930 return TRI_NO;
931 }
932 }
933 }
934
935 break;
936
939 /* It is only possible to help the production if the production needs
940 * the help. (If not it would be possible to add shields for something
941 * that can't legally receive help if it is build later) */
942 /* Info leak: The player knows that the production in their own city has
943 * been hurried (bought or helped). The information isn't revealed when
944 * asking for action probabilities since omniscient is FALSE. */
945 if (!omniscient
946 && !can_player_see_city_internals(actor->player, target->city)) {
947 return TRI_MAYBE;
948 }
949
950 if (!(target->city->shield_stock
952 return TRI_NO;
953 }
954
955 break;
956
959 /* Reason: allow scenarios to disable city founding. */
960 /* Info leak: the setting is public knowledge. */
961 return TRI_NO;
962 }
963
964 if (can_see_tgt_tile && tile_city(target->tile)) {
965 /* Reason: a tile can have 0 or 1 cities. */
966 return TRI_NO;
967 }
968
970 if (omniscient) {
971 /* No need to check again. */
972 return TRI_NO;
973 } else {
974 square_iterate(nmap, target->tile,
975 game.info.citymindist - 1, otile) {
976 if (tile_city(otile) != NULL
977 && can_player_see_tile(actor->player, otile)) {
978 /* Known to be blocked by citymindist */
979 return TRI_NO;
980 }
982 }
983 }
984
985 /* The player may not have enough information to be certain. */
986
987 if (!can_see_tgt_tile) {
988 /* Need to know if target tile already has a city, has TER_NO_CITIES
989 * terrain, is non native to the actor or is owned by a foreigner. */
990 return TRI_MAYBE;
991 }
992
993 if (!omniscient) {
994 /* The player may not have enough information to find out if
995 * citymindist blocks or not. This doesn't depend on if it blocks. */
996 square_iterate(nmap, target->tile,
997 game.info.citymindist - 1, otile) {
998 if (!can_player_see_tile(actor->player, otile)) {
999 /* Could have a city that blocks via citymindist. Even if this
1000 * tile has TER_NO_CITIES terrain the player don't know that it
1001 * didn't change and had a city built on it. */
1002 return TRI_MAYBE;
1003 }
1005 }
1006
1007 break;
1008
1009 case ACTRES_JOIN_CITY:
1010 {
1011 int new_pop;
1012
1013 if (!omniscient
1014 && !player_can_see_city_externals(actor->player, target->city)) {
1015 return TRI_MAYBE;
1016 }
1017
1018 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1019
1021 /* Reason: Make the add_to_size_limit setting work. */
1022 return TRI_NO;
1023 }
1024
1025 if (!city_can_grow_to(target->city, new_pop)) {
1026 /* Reason: respect city size limits. */
1027 /* Info leak: when it is legal to join a foreign city is legal and
1028 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1029 * something the actor player don't have access to.
1030 * Example: depends on a building (like Aqueduct) that isn't
1031 * VisibleByOthers. */
1032 return TRI_NO;
1033 }
1034 }
1035
1036 break;
1037
1038 case ACTRES_NUKE_UNITS:
1039 /* Has only action specific requirements */
1040 break;
1041
1042 case ACTRES_HOME_CITY:
1043 /* Reason: can't change to what is. */
1044 /* Info leak: The player knows their unit's current home city. */
1045 if (homecity != NULL && homecity->id == target->city->id) {
1046 /* This is already the unit's home city. */
1047 return TRI_NO;
1048 }
1049
1050 {
1051 int slots = unit_type_get(actor->unit)->city_slots;
1052
1053 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1054 return TRI_NO;
1055 }
1056 }
1057
1058 break;
1059
1061 /* Reason: Keep the old rules. */
1062 /* Info leak: The player knows their unit's type. They know if they can
1063 * build the unit type upgraded to. If the upgrade happens in a foreign
1064 * city that fact may leak. This can be seen as a price for changing
1065 * the rules to allow upgrading in a foreign city.
1066 * The player knows how much gold they have. If the Upgrade_Price_Pct
1067 * effect depends on information they don't have that information may
1068 * leak. The player knows the location of their unit. They know if the
1069 * tile has a city and if the unit can exist there outside a transport.
1070 * The player knows their unit's cargo. By knowing the number and type
1071 * of cargo, they can predict if there will be enough room in the unit
1072 * upgraded to, as long as they know what unit type their unit will end
1073 * up as. */
1074 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1075 return TRI_NO;
1076 }
1077
1078 break;
1079
1080 case ACTRES_PARADROP:
1082 /* Reason: Keep the old rules. */
1083 /* Info leak: The player knows if they know the target tile. */
1084 if (!plr_knows_tile(actor->player, target->tile)) {
1085 return TRI_NO;
1086 }
1087
1088 /* Reason: Keep paratroopers_range working. */
1089 /* Info leak: The player knows the location of the actor and of the
1090 * target tile. */
1092 < real_map_distance(actor->tile, target->tile)) {
1093 return TRI_NO;
1094 }
1095
1096 break;
1097
1098 case ACTRES_AIRLIFT:
1099 /* Reason: Keep the old rules. */
1100 /* Info leak: same as test_unit_can_airlift_to() */
1101 switch (test_unit_can_airlift_to(nmap, omniscient ? NULL : actor->player,
1102 actor->unit, target->city)) {
1103 case AR_OK:
1104 return TRI_YES;
1105 case AR_OK_SRC_UNKNOWN:
1106 case AR_OK_DST_UNKNOWN:
1107 return TRI_MAYBE;
1108 case AR_NO_MOVES:
1109 case AR_WRONG_UNITTYPE:
1110 case AR_OCCUPIED:
1111 case AR_NOT_IN_CITY:
1112 case AR_BAD_SRC_CITY:
1113 case AR_BAD_DST_CITY:
1114 case AR_SRC_NO_FLIGHTS:
1115 case AR_DST_NO_FLIGHTS:
1116 return TRI_NO;
1117 }
1118
1119 break;
1120
1121 case ACTRES_ATTACK:
1122 break;
1123
1124 case ACTRES_WIPE_UNITS:
1125 unit_list_iterate(target->tile->units, punit) {
1126 if (get_total_defense_power(actor->unit, punit) > 0) {
1127 return TRI_NO;
1128 }
1130 break;
1131
1134 return FALSE;
1135 }
1136
1137 unit_list_iterate(target->tile->units, punit) {
1139 /* Cannot get ransom when there are other kind of units in the tile */
1140 return FALSE;
1141 }
1143 break;
1144
1146 /* Reason: "Conquer City" involves moving into the city. */
1147 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1148 FALSE, FALSE, TRUE)) {
1149 return TRI_NO;
1150 }
1151
1152 break;
1153
1155 /* Reason: "Conquer Extras" involves moving to the tile. */
1156 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1157 FALSE, FALSE, FALSE)) {
1158 return TRI_NO;
1159 }
1160 /* Reason: Must have something to claim. The more specific restriction
1161 * that the base must be native to the actor unit is hard coded in
1162 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1163 * helptext_extra(), in helptext_unit(), in do_attack() and in
1164 * diplomat_bribe(). */
1165 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1166 return TRI_NO;
1167 }
1168 break;
1169
1170 case ACTRES_HEAL_UNIT:
1171 /* Reason: It is not the healthy who need a doctor, but the sick. */
1172 /* Info leak: the actor can see the target's HP. */
1173 if (!can_see_tgt_unit) {
1174 return TRI_MAYBE;
1175 }
1176 if (!(target->unit->hp < target->unittype->hp)) {
1177 return TRI_NO;
1178 }
1179 break;
1180
1182 pterrain = tile_terrain(target->tile);
1183 if (pterrain->transform_result == T_NONE
1184 || pterrain == pterrain->transform_result
1186 pterrain->transform_result)
1188 && (tile_city(target->tile)))) {
1189 return TRI_NO;
1190 }
1191 break;
1192
1193 case ACTRES_CULTIVATE:
1194 pterrain = tile_terrain(target->tile);
1195 if (pterrain->cultivate_result == NULL) {
1196 return TRI_NO;
1197 }
1199 pterrain->cultivate_result)
1201 && tile_city(target->tile))) {
1202 return TRI_NO;
1203 }
1204 break;
1205
1206 case ACTRES_PLANT:
1207 pterrain = tile_terrain(target->tile);
1208 if (pterrain->plant_result == NULL) {
1209 return TRI_NO;
1210 }
1212 pterrain->plant_result)
1214 && tile_city(target->tile))) {
1215 return TRI_NO;
1216 }
1217 break;
1218
1219 case ACTRES_ROAD:
1220 if (target_extra == NULL) {
1221 return TRI_NO;
1222 }
1224 /* Reason: This is not a road. */
1225 return TRI_NO;
1226 }
1228 target->tile)) {
1229 return TRI_NO;
1230 }
1231 break;
1232
1233 case ACTRES_BASE:
1234 if (target_extra == NULL) {
1235 return TRI_NO;
1236 }
1238 /* Reason: This is not a base. */
1239 return TRI_NO;
1240 }
1241 if (!can_build_base(actor->unit,
1242 extra_base_get(target_extra), target->tile)) {
1243 return TRI_NO;
1244 }
1245 break;
1246
1247 case ACTRES_MINE:
1248 if (target_extra == NULL) {
1249 return TRI_NO;
1250 }
1252 /* Reason: This is not a mine. */
1253 return TRI_NO;
1254 }
1255
1256 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1257 return TRI_NO;
1258 }
1259 break;
1260
1261 case ACTRES_IRRIGATE:
1262 if (target_extra == NULL) {
1263 return TRI_NO;
1264 }
1266 /* Reason: This is not an irrigation. */
1267 return TRI_NO;
1268 }
1269
1270 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1271 return TRI_NO;
1272 }
1273 break;
1274
1275 case ACTRES_PILLAGE:
1276 pterrain = tile_terrain(target->tile);
1277 if (pterrain->pillage_time == 0) {
1278 return TRI_NO;
1279 }
1280
1281 {
1285
1287 extra_type_iterate(pextra) {
1288 int idx = extra_index(pextra);
1289
1290 /* Only one unit can pillage a given improvement at a time */
1291 if (BV_ISSET(pspresent, idx)
1292 && (!BV_ISSET(psworking, idx)
1293 || actor->unit->activity_target == pextra)
1294 && can_remove_extra(pextra, actor->unit, target->tile)) {
1295 bool required = FALSE;
1296
1300 if (pdep == pextra) {
1301 required = TRUE;
1302 break;
1303 }
1305 }
1306 if (required) {
1307 break;
1308 }
1310
1311 if (!required) {
1312 BV_SET(pspossible, idx);
1313 }
1314 }
1316
1317 if (!BV_ISSET_ANY(pspossible)) {
1318 /* Nothing available to pillage */
1319 return TRI_NO;
1320 }
1321
1322 if (target_extra != NULL) {
1323 if (!game.info.pillage_select) {
1324 /* Hobson's choice (this case mostly exists for old clients) */
1325 /* Needs to match what unit_activity_assign_target chooses */
1326 struct extra_type *tgt;
1327
1329
1330 if (tgt != target_extra) {
1331 /* Only one target allowed, which wasn't the requested one */
1332 return TRI_NO;
1333 }
1334 }
1335
1337 return TRI_NO;
1338 }
1339 }
1340 }
1341 break;
1342
1343 case ACTRES_CLEAN:
1344 {
1345 const struct extra_type *pextra = NULL;
1346
1347 pterrain = tile_terrain(target->tile);
1348
1349 if (target_extra != NULL) {
1350 if (tile_has_extra(target->tile, target_extra)
1352 pextra = target_extra;
1353 }
1354 } else {
1355 /* TODO: Make sure that all callers set target so that
1356 * we don't need this fallback. */
1357 pextra = prev_extra_in_tile(target->tile,
1358 ERM_CLEAN,
1359 actor->player,
1360 actor->unit);
1361 }
1362
1363 if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0
1364 && can_remove_extra(pextra, actor->unit, target->tile)) {
1365 return TRI_YES;
1366 }
1367
1368 return TRI_NO;
1369 }
1370
1372 if (!can_unit_unload(actor->unit, target->unit)) {
1373 /* Keep the old rules about Unreachable and disembarks. */
1374 return TRI_NO;
1375 }
1376 break;
1377
1379 if (unit_transported(actor->unit)) {
1380 if (target->unit == unit_transport_get(actor->unit)) {
1381 /* Already inside this transport. */
1382 return TRI_NO;
1383 }
1384 }
1385 if (!could_unit_load(actor->unit, target->unit)) {
1386 /* Keep the old rules. */
1387 return TRI_NO;
1388 }
1389 break;
1390
1392 if (unit_transported(target->unit)) {
1393 if (actor->unit == unit_transport_get(target->unit)) {
1394 /* Already transporting this unit. */
1395 return TRI_NO;
1396 }
1397 }
1398 if (!could_unit_load(target->unit, actor->unit)) {
1399 /* Keep the old rules. */
1400 return TRI_NO;
1401 }
1402 if (unit_transported(target->unit)) {
1403 if (!can_unit_unload(target->unit,
1404 unit_transport_get(target->unit))) {
1405 /* Can't leave current transport. */
1406 return TRI_NO;
1407 }
1408 }
1409 break;
1410
1412 if (!can_unit_unload(target->unit, actor->unit)) {
1413 /* Keep the old rules about Unreachable and disembarks. */
1414 return TRI_NO;
1415 }
1416 break;
1417
1419 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1420 FALSE, FALSE, FALSE)) {
1421 /* Reason: involves moving to the tile. */
1422 return TRI_NO;
1423 }
1424
1425 /* We cannot move a transport into a tile that holds
1426 * units or cities not allied with all of our cargo. */
1427 if (get_transporter_capacity(actor->unit) > 0) {
1428 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1429 struct player *cowner = unit_owner(pcargo);
1430
1431 if (unit_contained_in(pcargo, actor->unit)
1432 && (is_non_allied_unit_tile(target->tile, cowner,
1434 || is_non_allied_city_tile(target->tile, cowner))) {
1435 return TRI_NO;
1436 }
1438 }
1439 break;
1440
1442 if (unit_transported(actor->unit)) {
1443 if (target->unit == unit_transport_get(actor->unit)) {
1444 /* Already inside this transport. */
1445 return TRI_NO;
1446 }
1447 }
1448 if (!could_unit_load(actor->unit, target->unit)) {
1449 /* Keep the old rules. */
1450 return TRI_NO;
1451 }
1452 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1453 FALSE, TRUE, FALSE)) {
1454 /* Reason: involves moving to the tile. */
1455 return TRI_NO;
1456 }
1457 /* We cannot move a transport into a tile that holds
1458 * units or cities not allied with all of our cargo. */
1459 if (get_transporter_capacity(actor->unit) > 0) {
1460 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1461 struct player *cowner = unit_owner(pcargo);
1462
1463 if (unit_contained_in(pcargo, actor->unit)
1464 && (is_non_allied_unit_tile(target->tile, cowner,
1466 || is_non_allied_city_tile(target->tile,
1467 cowner))) {
1468 return TRI_NO;
1469 }
1471 }
1472 break;
1473
1474 case ACTRES_SPY_ATTACK:
1475 {
1476 bool found;
1477
1478 if (!omniscient
1480 target->tile)) {
1481 /* May have a hidden diplomatic defender. */
1482 return TRI_MAYBE;
1483 }
1484
1485 found = FALSE;
1486 unit_list_iterate(target->tile->units, punit) {
1487 struct player *uplayer = unit_owner(punit);
1488
1489 if (uplayer == actor->player) {
1490 /* Won't defend against its owner. */
1491 continue;
1492 }
1493
1495 /* This unbeatable diplomatic defender will defend before any
1496 * that can be beaten. */
1497 found = FALSE;
1498 break;
1499 }
1500
1502 /* Found a beatable diplomatic defender. */
1503 found = TRUE;
1504 break;
1505 }
1507
1508 if (!found) {
1509 return TRI_NO;
1510 }
1511 }
1512 break;
1513
1514 case ACTRES_HUT_ENTER:
1516 /* Reason: involves moving to the tile. */
1517 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1518 FALSE, FALSE, FALSE)) {
1519 return TRI_NO;
1520 }
1521 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1522 /* Reason: keep extra rmreqs working. */
1523 return TRI_NO;
1524 }
1525 break;
1526
1527 case ACTRES_UNIT_MOVE:
1528 case ACTRES_TELEPORT:
1530 if (result == ACTRES_UNIT_MOVE) {
1531 /* Reason: is moving to the tile. */
1532 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1533 FALSE, FALSE, FALSE)) {
1534 return TRI_NO;
1535 }
1536 } else {
1537 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1538
1539 /* Reason: is teleporting to the tile. */
1540 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1541 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1542 return TRI_NO;
1543 }
1544 }
1545
1546 /* Reason: Don't override "Transport Embark" */
1547 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1548 return TRI_NO;
1549 }
1550
1551 /* We cannot move a transport into a tile that holds
1552 * units or cities not allied with any of our cargo. */
1553 if (get_transporter_capacity(actor->unit) > 0) {
1554 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1555 struct player *cowner = unit_owner(pcargo);
1556
1557 if (unit_contained_in(pcargo, actor->unit)
1558 && (is_non_allied_unit_tile(target->tile, cowner,
1560 || is_non_allied_city_tile(target->tile, cowner))) {
1561 return TRI_NO;
1562 }
1564 }
1565 break;
1566
1567 case ACTRES_SPY_ESCAPE:
1568 /* Reason: Be merciful. */
1569 /* Info leak: The player know if they have any cities. */
1570 if (city_list_size(actor->player->cities) < 1) {
1571 return TRI_NO;
1572 }
1573 break;
1574
1576 /* Enabling this action with illness_on = FALSE prevents spread. */
1577 break;
1578 case ACTRES_BOMBARD:
1579 {
1580 /* Allow bombing only if there's reachable units in the target
1581 * tile. Bombing without anybody taking damage is certainly not
1582 * what user really wants.
1583 * Allow bombing when player does not know if there's units in
1584 * target tile. */
1585 if (tile_city(target->tile) == NULL
1586 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1587 V_MAIN)
1588 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1589 V_INVIS)
1590 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1591 V_SUBSURFACE)) {
1592 bool hiding_extra = FALSE;
1593
1594 extra_type_iterate(pextra) {
1595 if (pextra->eus == EUS_HIDDEN
1596 && tile_has_extra(target->tile, pextra)) {
1598 break;
1599 }
1601
1602 if (!hiding_extra) {
1603 bool has_target = FALSE;
1604
1605 unit_list_iterate(target->tile->units, punit) {
1606 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1607 has_target = TRUE;
1608 break;
1609 }
1611
1612 if (!has_target) {
1613 return TRI_NO;
1614 }
1615 }
1616 }
1617 }
1618 break;
1621 case ACTRES_SPY_POISON:
1628 case ACTRES_STEAL_MAPS:
1629 case ACTRES_SPY_NUKE:
1630 case ACTRES_NUKE:
1632 case ACTRES_EXPEL_UNIT:
1634 case ACTRES_CONVERT:
1637 case ACTRES_FORTIFY:
1638 case ACTRES_HOMELESS:
1640 case ACTRES_NONE:
1641 /* No known hard coded requirements. */
1642 break;
1643
1645 }
1646
1647 return def;
1648}
#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:672
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:810
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:789
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:835
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:560
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:466
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:824
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:770
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
dice_roll_type
Definition actres.h:107
@ DRT_DIPLCHANCE
Definition actres.h:107
@ DRT_NONE
Definition actres.h:107
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:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define BV_ISSET_ANY(vec)
Definition bitvector.h:117
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:767
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
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:772
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
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 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:208
#define EC_NONE
Definition fc_types.h:821
#define ACTRES_NONE
Definition fc_types.h:186
#define ERM_NONE
Definition fc_types.h:844
struct civ_game game
Definition game.c:61
#define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE
Definition game.h:896
#define RS_DEFAULT_ACTION_MIN_RANGE
Definition game.h:892
#define RS_DEFAULT_USER_ACTION_TARGET_KIND
Definition game.h:891
#define RS_DEFAULT_MOVE_MIN_RANGE
Definition game.h:895
#define RS_DEFAULT_ACTION_MAX_RANGE
Definition game.h:893
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
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:787
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:675
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:388
#define square_iterate_end
Definition map.h:391
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:112
enum unit_activity activity
Definition actres.h:113
enum action_target_kind def_tgt_kind
Definition actres.h:118
enum dice_roll_type dice
Definition actres.h:114
enum extra_rmcause ermcause
Definition actres.h:117
enum act_tgt_compl sub_tgt_compl
Definition actres.h:110
enum action_battle_kind battle_kind
Definition actres.h:111
enum extra_cause ecause
Definition actres.h:115
Definition city.h:317
int id
Definition city.h:323
int shield_stock
Definition city.h:365
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:2518
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2597
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:1167
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:2025
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
@ 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:440
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1933
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2505
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:196
int unit_pop_value(const struct unit *punit)
Definition unittype.c:1549
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773