Freeciv-3.4
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 "specialist.h"
29#include "tile.h"
30#include "traderoutes.h"
31
32#include "actres.h"
33
34static struct actres act_results[ACTRES_LAST] = {
35 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ESTABLISH_EMBASSY */
38 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_INVESTIGATE_CITY */
41 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_POISON */
44 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_GOLD */
47 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY */
50 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_SABOTAGE_CITY */
53 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY_PRODUCTION */
56 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_TECH */
59 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_STEAL_TECH */
62 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_INCITE_CITY */
65 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRADE_ROUTE */
68 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_MARKETPLACE */
71 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HELP_WONDER */
74 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_BRIBE_UNIT */
77 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_BRIBE_STACK */
80 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_UNIT */
83 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CAPTURE_UNITS */
86 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FOUND_CITY */
89 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_JOIN_CITY */
92 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_STEAL_MAPS */
95 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_BOMBARD */
98 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_NUKE */
101 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE */
104 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE_UNITS */
107 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DESTROY_CITY */
110 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_EXPEL_UNIT */
113 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT_RECOVER */
116 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT */
119 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOME_CITY */
122 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UPGRADE_UNIT */
125 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP */
128 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_AIRLIFT */
131 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_ATTACK */
134 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_STRIKE_BUILDING */
137 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_STRIKE_PRODUCTION */
140 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_CITY */
143 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HEAL_UNIT */
146 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSFORM_TERRAIN */
149 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CULTIVATE */
152 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PLANT */
155 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_PILLAGE */
158 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FORTIFY */
161 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_ROAD */
164 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONVERT */
167 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_BASE */
170 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_MINE */
173 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_IRRIGATE */
176 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_COLLECT_RANSOM */
179 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DEBOARD */
182 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_UNLOAD */
185 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DISEMBARK */
188 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_BOARD */
191 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_EMBARK */
194 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SPREAD_PLAGUE */
197 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_ATTACK */
200 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_EXTRAS */
203 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_ENTER */
206 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_FRIGHTEN */
209 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UNIT_MOVE */
212 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP_CONQUER */
213 FALSE, ACTIVITY_LAST, DRT_NONE, /* TODO: Should this be hostile? */
215 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOMELESS */
218 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_WIPE_UNITS */
221 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_ESCAPE */
224 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_LOAD */
227 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_CLEAN */
230 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT */
233 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT_CONQUER */
236 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SCOUT */
239 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */
242};
243
244/*********************************************************************/
247void actres_init(void)
248{
249}
250
251/*********************************************************************/
254void actres_free(void)
255{
256}
257
258/**********************************************************************/
263{
264 if (result == ACTRES_NONE) {
266 }
267
269
270 return act_results[result].sub_tgt_compl;
271}
272
273/**********************************************************************/
277{
278 if (result == ACTRES_NONE) {
279 return ABK_NONE;
280 }
281
283
284 return act_results[result].battle_kind;
285}
286
287/**********************************************************************/
291{
292 if (result == ACTRES_NONE) {
293 return FALSE;
294 }
295
296 return act_results[result].hostile;
297}
298
299/**********************************************************************/
306{
307 if (result == ACTRES_NONE) {
308 return ACTIVITY_LAST;
309 }
310
311 return act_results[result].activity;
312}
313
314/**********************************************************************/
321 const struct unit *actor_unit,
322 const struct tile *tgt_tile,
323 const struct extra_type *tgt_extra)
324{
326
327 if (pactivity == ACTIVITY_LAST) {
328 /* Happens instantaneously, not at turn change. */
330 }
331
332 switch (pactivity) {
333 case ACTIVITY_PILLAGE:
334 case ACTIVITY_CLEAN:
335 case ACTIVITY_BASE:
338 case ACTIVITY_MINE:
340 case ACTIVITY_PLANT:
344 return 1;
345 case ACTIVITY_CONVERT:
347 case ACTIVITY_EXPLORE:
348 case ACTIVITY_IDLE:
350 case ACTIVITY_SENTRY:
351 case ACTIVITY_GOTO:
352 case ACTIVITY_LAST:
353 /* Should not happen. Caught by the assertion below. */
354 break;
355 }
356
358
360}
361
362/**********************************************************************/
369{
370 if (result == ACTRES_NONE) {
371 return DRT_NONE;
372 }
373
374 return act_results[result].dice;
375}
376
377/**********************************************************************/
381{
382 switch (result) {
401 case ACTRES_JOIN_CITY:
403 case ACTRES_BOMBARD:
404 case ACTRES_SCOUT:
405 case ACTRES_SPY_NUKE:
410 case ACTRES_HOME_CITY:
411 case ACTRES_HOMELESS:
413 case ACTRES_PARADROP:
415 case ACTRES_AIRLIFT:
418 case ACTRES_ATTACK:
422 case ACTRES_HEAL_UNIT:
424 case ACTRES_CULTIVATE:
425 case ACTRES_PLANT:
426 case ACTRES_PILLAGE:
427 case ACTRES_CLEAN:
428 case ACTRES_FORTIFY:
429 case ACTRES_ROAD:
430 case ACTRES_CONVERT:
431 case ACTRES_BASE:
432 case ACTRES_MINE:
433 case ACTRES_IRRIGATE:
443 case ACTRES_HUT_ENTER:
445 case ACTRES_UNIT_MOVE:
448 /* Non ruleset defined action min range not supported here */
449 fc_assert_msg(FALSE, "Probably wrong value.");
451 case ACTRES_NUKE:
454 case ACTRES_TELEPORT:
457 case ACTRES_NONE:
459
461 }
462
463 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
464
465 return 0;
466}
467
468/**********************************************************************/
472{
473 switch (result) {
491 case ACTRES_JOIN_CITY:
493 case ACTRES_SPY_NUKE:
497 case ACTRES_HOME_CITY:
498 case ACTRES_HOMELESS:
500 case ACTRES_PARADROP:
504 case ACTRES_ATTACK:
508 case ACTRES_HEAL_UNIT:
510 case ACTRES_CULTIVATE:
511 case ACTRES_PLANT:
512 case ACTRES_PILLAGE:
513 case ACTRES_CLEAN:
514 case ACTRES_FORTIFY:
515 case ACTRES_ROAD:
516 case ACTRES_CONVERT:
517 case ACTRES_BASE:
518 case ACTRES_MINE:
519 case ACTRES_IRRIGATE:
529 case ACTRES_HUT_ENTER:
531 case ACTRES_UNIT_MOVE:
534 /* Non ruleset defined action max range not supported here */
535 fc_assert_msg(FALSE, "Probably wrong value.");
540 case ACTRES_BOMBARD:
541 case ACTRES_SCOUT:
543 case ACTRES_NUKE:
547 case ACTRES_AIRLIFT:
548 case ACTRES_TELEPORT:
551 case ACTRES_NONE:
553
555 }
556
557 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
558
559 return 0;
560}
561
562/**********************************************************************/
567 enum action_target_kind tgt_kind)
568{
570 FALSE);
572 FALSE);
573
574 switch (result) {
588 case ACTRES_JOIN_CITY:
590 case ACTRES_SPY_NUKE:
593 case ACTRES_HOME_CITY:
595 case ACTRES_AIRLIFT:
601 return tgt_kind == ATK_CITY;
605 case ACTRES_HEAL_UNIT:
611 return tgt_kind == ATK_UNIT;
614 case ACTRES_BOMBARD:
616 case ACTRES_ATTACK:
620 return tgt_kind == ATK_STACK;
622 case ACTRES_PARADROP:
625 case ACTRES_CULTIVATE:
626 case ACTRES_PLANT:
627 case ACTRES_CLEAN:
628 case ACTRES_ROAD:
629 case ACTRES_BASE:
630 case ACTRES_MINE:
631 case ACTRES_IRRIGATE:
633 case ACTRES_HUT_ENTER:
635 case ACTRES_UNIT_MOVE:
636 case ACTRES_TELEPORT:
638 case ACTRES_SCOUT:
639 return tgt_kind == ATK_TILE;
641 return tgt_kind == ATK_EXTRAS;
643 case ACTRES_CONVERT:
644 case ACTRES_FORTIFY:
645 case ACTRES_HOMELESS:
647 return tgt_kind == ATK_SELF;
648 case ACTRES_PILLAGE:
649 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
650 case ACTRES_NUKE:
651 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
652 case ACTRES_NONE:
653 switch (tgt_kind) {
654 case ATK_CITY:
655 case ATK_UNIT:
656 case ATK_STACK:
657 case ATK_TILE:
658 case ATK_EXTRAS:
659 case ATK_SELF:
660 /* Works with all existing target kinds. */
661 return TRUE;
662 case ATK_COUNT:
663 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
664 break;
665 }
666 break;
667
669 }
670
671 /* Should never be reached. */
672 return FALSE;
673}
674
675/**********************************************************************/
680{
682 ASTK_NONE);
683
684 switch (result) {
696 case ACTRES_JOIN_CITY:
698 case ACTRES_SPY_NUKE:
701 case ACTRES_HOME_CITY:
702 case ACTRES_HOMELESS:
704 case ACTRES_AIRLIFT:
708 return ASTK_NONE;
711 return ASTK_BUILDING;
713 return ASTK_TECH;
718 case ACTRES_HEAL_UNIT:
724 return ASTK_NONE;
726 case ACTRES_BOMBARD:
728 case ACTRES_ATTACK:
732 return ASTK_NONE;
734 case ACTRES_NUKE:
735 case ACTRES_PARADROP:
738 case ACTRES_CULTIVATE:
739 case ACTRES_PLANT:
741 case ACTRES_HUT_ENTER:
743 case ACTRES_UNIT_MOVE:
744 case ACTRES_TELEPORT:
746 case ACTRES_SCOUT:
749 return ASTK_NONE;
750 case ACTRES_PILLAGE:
751 case ACTRES_CLEAN:
752 return ASTK_EXTRA;
753 case ACTRES_ROAD:
754 case ACTRES_BASE:
755 case ACTRES_MINE:
756 case ACTRES_IRRIGATE:
759 return ASTK_NONE;
761 case ACTRES_CONVERT:
762 case ACTRES_FORTIFY:
763 return ASTK_NONE;
764 case ACTRES_NONE:
765 return ASTK_NONE;
766
768 }
769
770 /* Should never be reached. */
771 return ASTK_NONE;
772}
773
774/**********************************************************************/
789
790/**********************************************************************/
798 const struct extra_type *pextra)
799{
800 if (act_results[result].ecause == EC_NONE) {
801 return FALSE;
802 }
803
804 if (pextra == nullptr || !pextra->buildable) {
805 return FALSE;
806 }
807
808 return is_extra_caused_by(pextra, act_results[result].ecause);
809}
810
811/**********************************************************************/
819 const struct extra_type *pextra)
820{
821 if (act_results[result].ermcause == ERM_NONE) {
822 return FALSE;
823 }
824
825 return is_extra_removed_by(pextra, act_results[result].ermcause);
826}
827
828/**********************************************************************/
832static bool plr_knows_tile(const struct player *plr,
833 const struct tile *ttile)
834{
835 return plr != nullptr
836 && ttile != nullptr
837 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
838}
839
840/**********************************************************************/
844 enum action_result result,
845 const struct req_context *actor,
846 const struct req_context *target,
847 const struct extra_type *target_extra,
848 enum fc_tristate def,
849 bool omniscient,
850 const struct city *homecity)
851{
852 struct terrain *pterrain;
853 bool can_see_tgt_unit;
854 bool can_see_tgt_tile;
855
856 /* Only check requirement against the target unit if the actor can see it
857 * or if the evaluator is omniscient. The game checking the rules is
858 * omniscient. The player asking about their odds isn't. */
859 can_see_tgt_unit = (omniscient || (target->unit
860 && can_player_see_unit(actor->player,
861 target->unit)));
862
863 /* Only check requirement against the target tile if the actor can see it
864 * or if the evaluator is omniscient. The game checking the rules is
865 * omniscient. The player asking about their odds isn't. */
867 || can_player_see_tile(actor->player, target->tile));
868
869 switch (result) {
873 /* Why this is a hard requirement: Can't transfer a unique unit if the
874 * actor player already has one. */
875 /* Info leak: This is only checked for when the actor player can see
876 * the target unit. Since the target unit is seen its type is known.
877 * The fact that a city hiding the unseen unit is occupied is known. */
878
879 if (!can_see_tgt_unit) {
880 /* An omniscient player can see the target unit. */
882
883 return TRI_MAYBE;
884 }
885
887 target->unittype)) {
888 return TRI_NO;
889 }
890
891 /* FIXME: Capture Unit may want to look for more than one unique unit
892 * of the same kind at the target tile. Currently caught by sanity
893 * check in do_capture_units(). */
894
895 break;
896
898 /* Reason: The Freeciv code don't support selecting a target tech
899 * unless it is known that the victim player has it. */
900 /* Info leak: The actor player knowns whose techs they can see. */
901 if (!can_see_techs_of_target(actor->player, target->player)) {
902 return TRI_NO;
903 }
904
905 break;
906
908 /* If actor->unit can do the action the actor->player can see how much
909 * gold target->player have. Not requiring it is therefore pointless.
910 */
911 if (target->player->economic.gold <= 0) {
912 return TRI_NO;
913 }
914
915 break;
916
919 {
920 /* Checked in action_hard_reqs_actor() */
921 fc_assert_ret_val(homecity != nullptr, TRI_NO);
922
923 /* Can't establish a trade route or enter the market place if the
924 * cities can't trade at all. */
925 /* TODO: Should this restriction (and the above restriction that the
926 * actor unit must have a home city) be kept for Enter Marketplace? */
927 if (!can_cities_trade(homecity, target->city)) {
928 return TRI_NO;
929 }
930
931 /* There are more restrictions on establishing a trade route than on
932 * entering the market place. */
933 if (result == ACTRES_TRADE_ROUTE) {
934 struct goods_type *pgood = unit_current_goods(actor->unit, homecity);
935
936 if (!can_establish_trade_route(homecity, target->city,
937 pgood->replace_priority)) {
938 return TRI_NO;
939 }
940 }
941 }
942
943 break;
944
947 /* It is only possible to help the production if the production needs
948 * the help. (If not it would be possible to add shields for something
949 * that can't legally receive help if it is build later) */
950 /* Info leak: The player knows that the production in their own city has
951 * been hurried (bought or helped). The information isn't revealed when
952 * asking for action probabilities since omniscient is FALSE. */
953 if (!omniscient
954 && !can_player_see_city_internals(actor->player, target->city)) {
955 return TRI_MAYBE;
956 }
957
958 if (!(target->city->shield_stock
960 return TRI_NO;
961 }
962
963 break;
964
967 /* Reason: allow scenarios to disable city founding. */
968 /* Info leak: the setting is public knowledge. */
969 return TRI_NO;
970 }
971
972 if (can_see_tgt_tile && tile_city(target->tile)) {
973 /* Reason: a tile can have 0 or 1 cities. */
974 return TRI_NO;
975 }
976
978 if (omniscient) {
979 /* No need to check again. */
980 return TRI_NO;
981 } else {
982 square_iterate(nmap, target->tile,
983 game.info.citymindist - 1, otile) {
984 if (tile_city(otile) != nullptr
985 && can_player_see_tile(actor->player, otile)) {
986 /* Known to be blocked by citymindist */
987 return TRI_NO;
988 }
990 }
991 }
992
993 /* The player may not have enough information to be certain. */
994
995 if (!can_see_tgt_tile) {
996 /* Need to know if target tile already has a city, has TER_NO_CITIES
997 * terrain, is non native to the actor or is owned by a foreigner. */
998 return TRI_MAYBE;
999 }
1000
1001 if (!omniscient) {
1002 /* The player may not have enough information to find out if
1003 * citymindist blocks or not. This doesn't depend on if it blocks. */
1004 square_iterate(nmap, target->tile,
1005 game.info.citymindist - 1, otile) {
1006 if (!can_player_see_tile(actor->player, otile)) {
1007 /* Could have a city that blocks via citymindist. Even if this
1008 * tile has TER_NO_CITIES terrain the player don't know that it
1009 * didn't change and had a city built on it. */
1010 return TRI_MAYBE;
1011 }
1013 }
1014
1015 break;
1016
1017 case ACTRES_JOIN_CITY:
1018 {
1019 int new_pop;
1021
1022 if (!omniscient
1023 && !player_can_see_city_externals(actor->player, target->city)) {
1024 return TRI_MAYBE;
1025 }
1026
1027 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1028
1030 /* Reason: Make the add_to_size_limit setting work. */
1031 return TRI_NO;
1032 }
1033
1034 if (!city_can_grow_to(target->city, new_pop)) {
1035 /* Reason: respect city size limits. */
1036 /* Info leak: when it is legal to join a foreign city is legal and
1037 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1038 * something the actor player don't have access to.
1039 * Example: depends on a building (like Aqueduct) that isn't
1040 * VisibleByOthers. */
1041 return TRI_NO;
1042 }
1043
1045 if (DEFAULT_SPECIALIST != sid) {
1046 if (!city_can_use_specialist(target->city, sid)) {
1047 /* Respect specialist reqs */
1048 /* Potential info leak about if they are fulfilled */
1049 return TRI_NO;
1050 }
1052 && target->city->specialists[sid] >= MAX_CITY_SIZE) {
1053 /* No place to add a superspecialist */
1054 /* Info leak on city superspecialists but it happens too rarely */
1055 return TRI_NO;
1056 }
1057 }
1058 }
1059
1060 break;
1061
1062 case ACTRES_NUKE_UNITS:
1063 /* Has only action specific requirements */
1064 break;
1065
1066 case ACTRES_HOME_CITY:
1067 /* Reason: can't change to what is. */
1068 /* Info leak: The player knows their unit's current home city. */
1069 if (homecity != nullptr && homecity->id == target->city->id) {
1070 /* This is already the unit's home city. */
1071 return TRI_NO;
1072 }
1073
1074 {
1075 int slots = unit_type_get(actor->unit)->city_slots;
1076
1077 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1078 return TRI_NO;
1079 }
1080 }
1081
1082 break;
1083
1085 /* Reason: Keep the old rules. */
1086 /* Info leak: The player knows their unit's type. They know if they can
1087 * build the unit type upgraded to. If the upgrade happens in a foreign
1088 * city that fact may leak. This can be seen as a price for changing
1089 * the rules to allow upgrading in a foreign city.
1090 * The player knows how much gold they have. If the Upgrade_Price_Pct
1091 * effect depends on information they don't have that information may
1092 * leak. The player knows the location of their unit. They know if the
1093 * tile has a city and if the unit can exist there outside a transport.
1094 * The player knows their unit's cargo. By knowing the number and type
1095 * of cargo, they can predict if there will be enough room in the unit
1096 * upgraded to, as long as they know what unit type their unit will end
1097 * up as. */
1098 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1099 return TRI_NO;
1100 }
1101
1102 break;
1103
1104 case ACTRES_PARADROP:
1106 /* Reason: Keep the old rules. */
1107 /* Info leak: The player knows if they know the target tile. */
1108 if (!plr_knows_tile(actor->player, target->tile)) {
1109 return TRI_NO;
1110 }
1111
1112 /* Reason: Keep paratroopers_range working. */
1113 /* Info leak: The player knows the location of the actor and of the
1114 * target tile. */
1116 < real_map_distance(actor->tile, target->tile)) {
1117 return TRI_NO;
1118 }
1119
1120 break;
1121
1122 case ACTRES_AIRLIFT:
1123 /* Reason: Keep the old rules. */
1124 /* Info leak: same as test_unit_can_airlift_to() */
1126 omniscient ? nullptr : actor->player,
1127 actor->unit, target->city)) {
1128 case AR_OK:
1129 return TRI_YES;
1130 case AR_OK_SRC_UNKNOWN:
1131 case AR_OK_DST_UNKNOWN:
1132 return TRI_MAYBE;
1133 case AR_NO_MOVES:
1134 case AR_WRONG_UNITTYPE:
1135 case AR_OCCUPIED:
1136 case AR_NOT_IN_CITY:
1137 case AR_BAD_SRC_CITY:
1138 case AR_BAD_DST_CITY:
1139 case AR_SRC_NO_FLIGHTS:
1140 case AR_DST_NO_FLIGHTS:
1141 return TRI_NO;
1142 }
1143
1144 break;
1145
1146 case ACTRES_ATTACK:
1147 break;
1148
1149 case ACTRES_WIPE_UNITS:
1150 unit_list_iterate(target->tile->units, punit) {
1151 if (get_total_defense_power(actor->unit, punit) > 0) {
1152 return TRI_NO;
1153 }
1155 break;
1156
1159 return FALSE;
1160 }
1161
1162 unit_list_iterate(target->tile->units, punit) {
1164 /* Cannot get ransom when there are other kind of units in the tile */
1165 return FALSE;
1166 }
1168 break;
1169
1171 /* Reason: "Conquer City" involves moving into the city. */
1172 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1173 FALSE, FALSE, TRUE)) {
1174 return TRI_NO;
1175 }
1176
1177 break;
1178
1180 /* Reason: "Conquer Extras" involves moving to the tile. */
1181 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1182 FALSE, FALSE, FALSE)) {
1183 return TRI_NO;
1184 }
1185 /* Reason: Must have something to claim. The more specific restriction
1186 * that the base must be native to the actor unit is hard coded in
1187 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1188 * helptext_extra(), in helptext_unit(), in do_attack() and in
1189 * diplomat_bribe(). */
1190 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1191 return TRI_NO;
1192 }
1193 break;
1194
1195 case ACTRES_HEAL_UNIT:
1196 /* Reason: It is not the healthy who need a doctor, but the sick. */
1197 /* Info leak: the actor can see the target's HP. */
1198 if (!can_see_tgt_unit) {
1199 return TRI_MAYBE;
1200 }
1201 if (!(target->unit->hp < target->unittype->hp)) {
1202 return TRI_NO;
1203 }
1204 break;
1205
1207 pterrain = tile_terrain(target->tile);
1208 if (pterrain->transform_result == T_NONE
1209 || pterrain == pterrain->transform_result
1211 pterrain->transform_result)
1213 && (tile_city(target->tile)))) {
1214 return TRI_NO;
1215 }
1216 break;
1217
1218 case ACTRES_CULTIVATE:
1219 pterrain = tile_terrain(target->tile);
1220 if (pterrain->cultivate_result == nullptr) {
1221 return TRI_NO;
1222 }
1224 pterrain->cultivate_result)
1226 && tile_city(target->tile))) {
1227 return TRI_NO;
1228 }
1229 break;
1230
1231 case ACTRES_PLANT:
1232 pterrain = tile_terrain(target->tile);
1233 if (pterrain->plant_result == nullptr) {
1234 return TRI_NO;
1235 }
1237 pterrain->plant_result)
1239 && tile_city(target->tile))) {
1240 return TRI_NO;
1241 }
1242 break;
1243
1244 case ACTRES_ROAD:
1245 if (target_extra == nullptr) {
1246 return TRI_NO;
1247 }
1249 /* Reason: This is not a road. */
1250 return TRI_NO;
1251 }
1253 target->tile)) {
1254 return TRI_NO;
1255 }
1256 break;
1257
1258 case ACTRES_BASE:
1259 if (target_extra == nullptr) {
1260 return TRI_NO;
1261 }
1263 /* Reason: This is not a base. */
1264 return TRI_NO;
1265 }
1266 if (!can_build_base(actor->unit,
1267 extra_base_get(target_extra), target->tile)) {
1268 return TRI_NO;
1269 }
1270 break;
1271
1272 case ACTRES_MINE:
1273 if (target_extra == nullptr) {
1274 return TRI_NO;
1275 }
1277 /* Reason: This is not a mine. */
1278 return TRI_NO;
1279 }
1280
1281 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1282 return TRI_NO;
1283 }
1284 break;
1285
1286 case ACTRES_IRRIGATE:
1287 if (target_extra == nullptr) {
1288 return TRI_NO;
1289 }
1291 /* Reason: This is not an irrigation. */
1292 return TRI_NO;
1293 }
1294
1295 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1296 return TRI_NO;
1297 }
1298 break;
1299
1300 case ACTRES_PILLAGE:
1301 pterrain = tile_terrain(target->tile);
1302 if (pterrain->pillage_time == 0) {
1303 return TRI_NO;
1304 }
1305
1306 {
1310
1312 extra_type_iterate(pextra) {
1313 int idx = extra_index(pextra);
1314
1315 /* Only one unit can pillage a given improvement at a time */
1316 if (BV_ISSET(pspresent, idx)
1317 && (!BV_ISSET(psworking, idx)
1318 || actor->unit->activity_target == pextra)
1319 && can_remove_extra(pextra, actor->unit, target->tile)) {
1320 bool required = FALSE;
1321
1325 if (pdep == pextra) {
1326 required = TRUE;
1327 break;
1328 }
1330 }
1331 if (required) {
1332 break;
1333 }
1335
1336 if (!required) {
1337 BV_SET(pspossible, idx);
1338 }
1339 }
1341
1342 if (!BV_ISSET_ANY(pspossible)) {
1343 /* Nothing available to pillage */
1344 return TRI_NO;
1345 }
1346
1347 if (target_extra != nullptr) {
1348 if (!game.info.pillage_select) {
1349 /* Hobson's choice (this case mostly exists for old clients) */
1350 /* Needs to match what unit_activity_assign_target chooses */
1351 struct extra_type *tgt;
1352
1354
1355 if (tgt != target_extra) {
1356 /* Only one target allowed, which wasn't the requested one */
1357 return TRI_NO;
1358 }
1359 }
1360
1362 return TRI_NO;
1363 }
1364 }
1365 }
1366 break;
1367
1368 case ACTRES_CLEAN:
1369 {
1370 const struct extra_type *pextra = nullptr;
1371
1372 pterrain = tile_terrain(target->tile);
1373
1374 if (target_extra != nullptr) {
1375 if (tile_has_extra(target->tile, target_extra)
1377 pextra = target_extra;
1378 }
1379 } else {
1380 /* TODO: Make sure that all callers set target so that
1381 * we don't need this fallback. */
1382 pextra = prev_extra_in_tile(target->tile,
1383 ERM_CLEAN,
1384 actor->player,
1385 actor->unit);
1386 }
1387
1388 if (pextra != nullptr
1389 && pterrain->extra_removal_times[extra_index(pextra)] > 0
1390 && can_remove_extra(pextra, actor->unit, target->tile)) {
1391 return TRI_YES;
1392 }
1393
1394 return TRI_NO;
1395 }
1396
1398 if (!can_unit_unload(actor->unit, target->unit)) {
1399 /* Keep the old rules about Unreachable and disembarks. */
1400 return TRI_NO;
1401 }
1402 break;
1403
1405 if (unit_transported(actor->unit)) {
1406 if (target->unit == unit_transport_get(actor->unit)) {
1407 /* Already inside this transport. */
1408 return TRI_NO;
1409 }
1410 }
1411 if (!could_unit_load(actor->unit, target->unit)) {
1412 /* Keep the old rules. */
1413 return TRI_NO;
1414 }
1415 break;
1416
1418 if (unit_transported(target->unit)) {
1419 if (actor->unit == unit_transport_get(target->unit)) {
1420 /* Already transporting this unit. */
1421 return TRI_NO;
1422 }
1423 }
1424 if (!could_unit_load(target->unit, actor->unit)) {
1425 /* Keep the old rules. */
1426 return TRI_NO;
1427 }
1428 if (unit_transported(target->unit)) {
1429 if (!can_unit_unload(target->unit,
1430 unit_transport_get(target->unit))) {
1431 /* Can't leave current transport. */
1432 return TRI_NO;
1433 }
1434 }
1435 break;
1436
1438 if (!can_unit_unload(target->unit, actor->unit)) {
1439 /* Keep the old rules about Unreachable and disembarks. */
1440 return TRI_NO;
1441 }
1442 break;
1443
1445 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1446 FALSE, FALSE, FALSE)) {
1447 /* Reason: involves moving to the tile. */
1448 return TRI_NO;
1449 }
1450
1451 /* We cannot move a transport into a tile that holds
1452 * units or cities not allied with all of our cargo. */
1453 if (get_transporter_capacity(actor->unit) > 0) {
1454 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1455 struct player *cowner = unit_owner(pcargo);
1456
1457 if (unit_contained_in(pcargo, actor->unit)
1458 && (is_non_allied_unit_tile(target->tile, cowner,
1460 || is_non_allied_city_tile(target->tile, cowner))) {
1461 return TRI_NO;
1462 }
1464 }
1465 break;
1466
1468 if (unit_transported(actor->unit)) {
1469 if (target->unit == unit_transport_get(actor->unit)) {
1470 /* Already inside this transport. */
1471 return TRI_NO;
1472 }
1473 }
1474 if (!could_unit_load(actor->unit, target->unit)) {
1475 /* Keep the old rules. */
1476 return TRI_NO;
1477 }
1478 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1479 FALSE, TRUE, FALSE)) {
1480 /* Reason: involves moving to the tile. */
1481 return TRI_NO;
1482 }
1483 /* We cannot move a transport into a tile that holds
1484 * units or cities not allied with all of our cargo. */
1485 if (get_transporter_capacity(actor->unit) > 0) {
1486 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1487 struct player *cowner = unit_owner(pcargo);
1488
1489 if (unit_contained_in(pcargo, actor->unit)
1490 && (is_non_allied_unit_tile(target->tile, cowner,
1492 || is_non_allied_city_tile(target->tile,
1493 cowner))) {
1494 return TRI_NO;
1495 }
1497 }
1498 break;
1499
1500 case ACTRES_SPY_ATTACK:
1501 {
1502 bool found;
1503
1504 if (!omniscient
1506 target->tile)) {
1507 /* May have a hidden diplomatic defender. */
1508 return TRI_MAYBE;
1509 }
1510
1511 found = FALSE;
1512 unit_list_iterate(target->tile->units, punit) {
1513 struct player *uplayer = unit_owner(punit);
1514
1515 if (uplayer == actor->player) {
1516 /* Won't defend against its owner. */
1517 continue;
1518 }
1519
1521 /* This unbeatable diplomatic defender will defend before any
1522 * that can be beaten. */
1523 found = FALSE;
1524 break;
1525 }
1526
1528 /* Found a beatable diplomatic defender. */
1529 found = TRUE;
1530 break;
1531 }
1533
1534 if (!found) {
1535 return TRI_NO;
1536 }
1537 }
1538 break;
1539
1540 case ACTRES_HUT_ENTER:
1542 /* Reason: involves moving to the tile. */
1543 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1544 FALSE, FALSE, FALSE)) {
1545 return TRI_NO;
1546 }
1547 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1548 /* Reason: keep extra rmreqs working. */
1549 return TRI_NO;
1550 }
1551 break;
1552
1553 case ACTRES_UNIT_MOVE:
1554 case ACTRES_TELEPORT:
1556 if (result == ACTRES_UNIT_MOVE) {
1557 /* Reason: is moving to the tile. */
1558 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1559 FALSE, FALSE, FALSE)) {
1560 return TRI_NO;
1561 }
1562 } else {
1563 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1564
1565 /* Reason: is teleporting to the tile. */
1566 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1567 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1568 return TRI_NO;
1569 }
1570 }
1571
1572 /* Reason: Don't override "Transport Embark" */
1573 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1574 return TRI_NO;
1575 }
1576
1577 /* We cannot move a transport into a tile that holds
1578 * units or cities not allied with any of our cargo. */
1579 if (get_transporter_capacity(actor->unit) > 0) {
1580 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1581 struct player *cowner = unit_owner(pcargo);
1582
1583 if (unit_contained_in(pcargo, actor->unit)
1584 && (is_non_allied_unit_tile(target->tile, cowner,
1586 || is_non_allied_city_tile(target->tile, cowner))) {
1587 return TRI_NO;
1588 }
1590 }
1591 break;
1592
1593 case ACTRES_SPY_ESCAPE:
1594 /* Reason: Be merciful. */
1595 /* Info leak: The player know if they have any cities. */
1596 if (city_list_size(actor->player->cities) < 1) {
1597 return TRI_NO;
1598 }
1599 break;
1600
1602 /* Enabling this action with illness_on = FALSE prevents spread. */
1603 break;
1604 case ACTRES_BOMBARD:
1605 {
1606 /* Allow bombing only if there's reachable units in the target
1607 * tile. Bombing without anybody taking damage is certainly not
1608 * what user really wants.
1609 * Allow bombing when player does not know if there's units in
1610 * target tile. */
1611 if (tile_city(target->tile) == nullptr
1612 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1613 V_MAIN)
1614 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1615 V_INVIS)
1616 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1617 V_SUBSURFACE)) {
1618 bool hiding_extra = FALSE;
1619
1620 extra_type_iterate(pextra) {
1621 if (pextra->eus == EUS_HIDDEN
1622 && tile_has_extra(target->tile, pextra)) {
1624 break;
1625 }
1627
1628 if (!hiding_extra) {
1629 bool has_target = FALSE;
1630
1631 unit_list_iterate(target->tile->units, punit) {
1632 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1633 has_target = TRUE;
1634 break;
1635 }
1637
1638 if (!has_target) {
1639 return TRI_NO;
1640 }
1641 }
1642 }
1643 }
1644 break;
1647 case ACTRES_SPY_POISON:
1654 case ACTRES_STEAL_MAPS:
1655 case ACTRES_SPY_NUKE:
1656 case ACTRES_NUKE:
1658 case ACTRES_EXPEL_UNIT:
1660 case ACTRES_CONVERT:
1663 case ACTRES_FORTIFY:
1664 case ACTRES_HOMELESS:
1665 case ACTRES_SCOUT:
1667 case ACTRES_NONE:
1668 /* No known hard coded requirements. */
1669 break;
1670
1672 }
1673
1674 return def;
1675}
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:105
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:320
int actres_min_range_default(enum action_result result)
Definition actres.c:380
void actres_free(void)
Definition actres.c:254
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:679
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:262
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:818
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:797
void actres_init(void)
Definition actres.c:247
static struct actres act_results[ACTRES_LAST]
Definition actres.c:34
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:843
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:566
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:305
int actres_max_range_default(enum action_result result)
Definition actres.c:471
bool actres_is_hostile(enum action_result result)
Definition actres.c:290
static bool plr_knows_tile(const struct player *plr, const struct tile *ttile)
Definition actres.c:832
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:368
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:276
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:778
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
dice_roll_type
Definition actres.h:109
@ DRT_DIPLCHANCE
Definition actres.h:109
@ DRT_NONE
Definition actres.h:109
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:740
int city_unit_slots_available(const struct city *pcity)
Definition city.c:1067
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
Definition city.c:1518
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
Definition city.c:1083
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2079
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:778
static citizens city_size_get(const struct city *pcity)
Definition city.h:570
#define MAX_CITY_SIZE
Definition city.h:104
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:77
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:72
struct unit * actor_unit
Definition dialogs_g.h:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
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:372
#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:380
#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:210
#define EC_NONE
Definition fc_types.h:808
int Specialist_type_id
Definition fc_types.h:236
#define ACTRES_NONE
Definition fc_types.h:188
#define ERM_NONE
Definition fc_types.h:831
struct civ_game game
Definition game.c:62
#define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE
Definition game.h:900
#define RS_DEFAULT_ACTION_MIN_RANGE
Definition game.h:896
#define RS_DEFAULT_USER_ACTION_TARGET_KIND
Definition game.h:895
#define RS_DEFAULT_MOVE_MIN_RANGE
Definition game.h:899
#define RS_DEFAULT_ACTION_MAX_RANGE
Definition game.h:897
#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:796
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:397
#define square_iterate_end
Definition map.h:400
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:350
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:623
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:603
bool can_player_see_tile(const struct player *plr, const struct tile *ptile)
Definition player.c:1082
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1095
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1155
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:984
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:1140
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:302
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 is_super_specialist_id(Specialist_type_id sp)
Definition specialist.c:184
Specialist_type_id specialist_index(const struct specialist *sp)
Definition specialist.c:90
#define DEFAULT_SPECIALIST
Definition specialist.h:43
bool hostile
Definition actres.h:114
enum unit_activity activity
Definition actres.h:115
enum action_target_kind def_tgt_kind
Definition actres.h:120
enum dice_roll_type dice
Definition actres.h:116
enum extra_rmcause ermcause
Definition actres.h:119
enum act_tgt_compl sub_tgt_compl
Definition actres.h:112
enum action_battle_kind battle_kind
Definition actres.h:113
enum extra_cause ecause
Definition actres.h:117
Definition city.h:318
int id
Definition city.h:324
citizens specialists[SP_MAX]
Definition city.h:334
int shield_stock
Definition city.h:366
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
struct specialist * spec_type
Definition unittype.h:520
Definition unit.h:139
int hp
Definition unit.h:152
struct tile * tile
Definition unit.h:141
struct extra_type * activity_target
Definition unit.h:166
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:553
#define T_NONE
Definition terrain.h:61
#define terrain_has_flag(terr, flag)
Definition terrain.h:177
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
Definition tile.c:216
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
Definition tile.c:419
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:393
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
@ TILE_UNKNOWN
Definition tile.h:36
#define ACTIVITY_FACTOR
Definition tile.h:170
#define tile_terrain(_tile)
Definition tile.h:115
#define tile_has_extra(ptile, pextra)
Definition tile.h:152
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:2526
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2602
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:86
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:741
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1192
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:316
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:2042
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2512
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:793
#define unit_tile(_pu)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:407
@ UU_OK
Definition unit.h:61
@ 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
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:446
#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:126
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1954
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2535
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:215
int unit_pop_value(const struct unit *punit)
Definition unittype.c:1569
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773