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_ENABLER_CHECK */
239};
240
241/*********************************************************************/
244void actres_init(void)
245{
246}
247
248/*********************************************************************/
251void actres_free(void)
252{
253}
254
255/**********************************************************************/
260{
261 if (result == ACTRES_NONE) {
263 }
264
266
267 return act_results[result].sub_tgt_compl;
268}
269
270/**********************************************************************/
274{
275 if (result == ACTRES_NONE) {
276 return ABK_NONE;
277 }
278
280
281 return act_results[result].battle_kind;
282}
283
284/**********************************************************************/
288{
289 if (result == ACTRES_NONE) {
290 return FALSE;
291 }
292
293 return act_results[result].hostile;
294}
295
296/**********************************************************************/
303{
304 if (result == ACTRES_NONE) {
305 return ACTIVITY_LAST;
306 }
307
308 return act_results[result].activity;
309}
310
311/**********************************************************************/
318 const struct unit *actor_unit,
319 const struct tile *tgt_tile,
320 const struct extra_type *tgt_extra)
321{
323
324 if (pactivity == ACTIVITY_LAST) {
325 /* Happens instantaneously, not at turn change. */
327 }
328
329 switch (pactivity) {
330 case ACTIVITY_PILLAGE:
331 case ACTIVITY_CLEAN:
332 case ACTIVITY_BASE:
335 case ACTIVITY_MINE:
337 case ACTIVITY_PLANT:
341 return 1;
342 case ACTIVITY_CONVERT:
344 case ACTIVITY_EXPLORE:
345 case ACTIVITY_IDLE:
347 case ACTIVITY_SENTRY:
348 case ACTIVITY_GOTO:
349 case ACTIVITY_LAST:
350 /* Should not happen. Caught by the assertion below. */
351 break;
352 }
353
355
357}
358
359/**********************************************************************/
366{
367 if (result == ACTRES_NONE) {
368 return DRT_NONE;
369 }
370
371 return act_results[result].dice;
372}
373
374/**********************************************************************/
378{
379 switch (result) {
398 case ACTRES_JOIN_CITY:
400 case ACTRES_BOMBARD:
401 case ACTRES_SPY_NUKE:
406 case ACTRES_HOME_CITY:
407 case ACTRES_HOMELESS:
409 case ACTRES_PARADROP:
411 case ACTRES_AIRLIFT:
414 case ACTRES_ATTACK:
418 case ACTRES_HEAL_UNIT:
420 case ACTRES_CULTIVATE:
421 case ACTRES_PLANT:
422 case ACTRES_PILLAGE:
423 case ACTRES_CLEAN:
424 case ACTRES_FORTIFY:
425 case ACTRES_ROAD:
426 case ACTRES_CONVERT:
427 case ACTRES_BASE:
428 case ACTRES_MINE:
429 case ACTRES_IRRIGATE:
439 case ACTRES_HUT_ENTER:
441 case ACTRES_UNIT_MOVE:
444 /* Non ruleset defined action min range not supported here */
445 fc_assert_msg(FALSE, "Probably wrong value.");
447 case ACTRES_NUKE:
450 case ACTRES_TELEPORT:
453 case ACTRES_NONE:
455
457 }
458
459 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
460
461 return 0;
462}
463
464/**********************************************************************/
468{
469 switch (result) {
487 case ACTRES_JOIN_CITY:
489 case ACTRES_SPY_NUKE:
493 case ACTRES_HOME_CITY:
494 case ACTRES_HOMELESS:
496 case ACTRES_PARADROP:
500 case ACTRES_ATTACK:
504 case ACTRES_HEAL_UNIT:
506 case ACTRES_CULTIVATE:
507 case ACTRES_PLANT:
508 case ACTRES_PILLAGE:
509 case ACTRES_CLEAN:
510 case ACTRES_FORTIFY:
511 case ACTRES_ROAD:
512 case ACTRES_CONVERT:
513 case ACTRES_BASE:
514 case ACTRES_MINE:
515 case ACTRES_IRRIGATE:
525 case ACTRES_HUT_ENTER:
527 case ACTRES_UNIT_MOVE:
530 /* Non ruleset defined action max range not supported here */
531 fc_assert_msg(FALSE, "Probably wrong value.");
536 case ACTRES_BOMBARD:
538 case ACTRES_NUKE:
542 case ACTRES_AIRLIFT:
543 case ACTRES_TELEPORT:
546 case ACTRES_NONE:
548
550 }
551
552 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
553
554 return 0;
555}
556
557/**********************************************************************/
562 enum action_target_kind tgt_kind)
563{
565 FALSE);
567 FALSE);
568
569 switch (result) {
583 case ACTRES_JOIN_CITY:
585 case ACTRES_SPY_NUKE:
588 case ACTRES_HOME_CITY:
590 case ACTRES_AIRLIFT:
596 return tgt_kind == ATK_CITY;
600 case ACTRES_HEAL_UNIT:
606 return tgt_kind == ATK_UNIT;
609 case ACTRES_BOMBARD:
611 case ACTRES_ATTACK:
615 return tgt_kind == ATK_STACK;
617 case ACTRES_PARADROP:
620 case ACTRES_CULTIVATE:
621 case ACTRES_PLANT:
622 case ACTRES_CLEAN:
623 case ACTRES_ROAD:
624 case ACTRES_BASE:
625 case ACTRES_MINE:
626 case ACTRES_IRRIGATE:
628 case ACTRES_HUT_ENTER:
630 case ACTRES_UNIT_MOVE:
631 case ACTRES_TELEPORT:
633 return tgt_kind == ATK_TILE;
635 return tgt_kind == ATK_EXTRAS;
637 case ACTRES_CONVERT:
638 case ACTRES_FORTIFY:
639 case ACTRES_HOMELESS:
641 return tgt_kind == ATK_SELF;
642 case ACTRES_PILLAGE:
643 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
644 case ACTRES_NUKE:
645 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
646 case ACTRES_NONE:
647 switch (tgt_kind) {
648 case ATK_CITY:
649 case ATK_UNIT:
650 case ATK_STACK:
651 case ATK_TILE:
652 case ATK_EXTRAS:
653 case ATK_SELF:
654 /* Works with all existing target kinds. */
655 return TRUE;
656 case ATK_COUNT:
657 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
658 break;
659 }
660 break;
661
663 }
664
665 /* Should never be reached. */
666 return FALSE;
667}
668
669/**********************************************************************/
674{
676 ASTK_NONE);
677
678 switch (result) {
690 case ACTRES_JOIN_CITY:
692 case ACTRES_SPY_NUKE:
695 case ACTRES_HOME_CITY:
696 case ACTRES_HOMELESS:
698 case ACTRES_AIRLIFT:
702 return ASTK_NONE;
705 return ASTK_BUILDING;
707 return ASTK_TECH;
712 case ACTRES_HEAL_UNIT:
718 return ASTK_NONE;
720 case ACTRES_BOMBARD:
722 case ACTRES_ATTACK:
726 return ASTK_NONE;
728 case ACTRES_NUKE:
729 case ACTRES_PARADROP:
732 case ACTRES_CULTIVATE:
733 case ACTRES_PLANT:
735 case ACTRES_HUT_ENTER:
737 case ACTRES_UNIT_MOVE:
738 case ACTRES_TELEPORT:
742 return ASTK_NONE;
743 case ACTRES_PILLAGE:
744 case ACTRES_CLEAN:
745 return ASTK_EXTRA;
746 case ACTRES_ROAD:
747 case ACTRES_BASE:
748 case ACTRES_MINE:
749 case ACTRES_IRRIGATE:
752 return ASTK_NONE;
754 case ACTRES_CONVERT:
755 case ACTRES_FORTIFY:
756 return ASTK_NONE;
757 case ACTRES_NONE:
758 return ASTK_NONE;
759
761 }
762
763 /* Should never be reached. */
764 return ASTK_NONE;
765}
766
767/**********************************************************************/
782
783/**********************************************************************/
791 const struct extra_type *pextra)
792{
793 if (act_results[result].ecause == EC_NONE) {
794 return FALSE;
795 }
796
797 if (pextra == NULL || !pextra->buildable) {
798 return FALSE;
799 }
800
801 return is_extra_caused_by(pextra, act_results[result].ecause);
802}
803
804/**********************************************************************/
812 const struct extra_type *pextra)
813{
814 if (act_results[result].ermcause == ERM_NONE) {
815 return FALSE;
816 }
817
818 return is_extra_removed_by(pextra, act_results[result].ermcause);
819}
820
821/**********************************************************************/
825static bool plr_knows_tile(const struct player *plr,
826 const struct tile *ttile)
827{
828 return plr != nullptr
829 && ttile != nullptr
830 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
831}
832
833/**********************************************************************/
837 enum action_result result,
838 const struct req_context *actor,
839 const struct req_context *target,
840 const struct extra_type *target_extra,
841 enum fc_tristate def,
842 bool omniscient,
843 const struct city *homecity)
844{
845 struct terrain *pterrain;
846 bool can_see_tgt_unit;
847 bool can_see_tgt_tile;
848
849 /* Only check requirement against the target unit if the actor can see it
850 * or if the evaluator is omniscient. The game checking the rules is
851 * omniscient. The player asking about their odds isn't. */
852 can_see_tgt_unit = (omniscient || (target->unit
853 && can_player_see_unit(actor->player,
854 target->unit)));
855
856 /* Only check requirement against the target tile 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. */
860 || can_player_see_tile(actor->player, target->tile));
861
862 switch (result) {
866 /* Why this is a hard requirement: Can't transfer a unique unit if the
867 * actor player already has one. */
868 /* Info leak: This is only checked for when the actor player can see
869 * the target unit. Since the target unit is seen its type is known.
870 * The fact that a city hiding the unseen unit is occupied is known. */
871
872 if (!can_see_tgt_unit) {
873 /* An omniscient player can see the target unit. */
875
876 return TRI_MAYBE;
877 }
878
880 target->unittype)) {
881 return TRI_NO;
882 }
883
884 /* FIXME: Capture Unit may want to look for more than one unique unit
885 * of the same kind at the target tile. Currently caught by sanity
886 * check in do_capture_units(). */
887
888 break;
889
891 /* Reason: The Freeciv code don't support selecting a target tech
892 * unless it is known that the victim player has it. */
893 /* Info leak: The actor player knowns whose techs they can see. */
894 if (!can_see_techs_of_target(actor->player, target->player)) {
895 return TRI_NO;
896 }
897
898 break;
899
901 /* If actor->unit can do the action the actor->player can see how much
902 * gold target->player have. Not requiring it is therefore pointless.
903 */
904 if (target->player->economic.gold <= 0) {
905 return TRI_NO;
906 }
907
908 break;
909
912 {
913 /* Checked in action_hard_reqs_actor() */
914 fc_assert_ret_val(homecity != NULL, TRI_NO);
915
916 /* Can't establish a trade route or enter the market place if the
917 * cities can't trade at all. */
918 /* TODO: Should this restriction (and the above restriction that the
919 * actor unit must have a home city) be kept for Enter Marketplace? */
920 if (!can_cities_trade(homecity, target->city)) {
921 return TRI_NO;
922 }
923
924 /* There are more restrictions on establishing a trade route than on
925 * entering the market place. */
926 if (result == ACTRES_TRADE_ROUTE) {
927 struct goods_type *pgood = unit_current_goods(actor->unit, homecity);
928
929 if (!can_establish_trade_route(homecity, target->city,
930 pgood->replace_priority)) {
931 return TRI_NO;
932 }
933 }
934 }
935
936 break;
937
940 /* It is only possible to help the production if the production needs
941 * the help. (If not it would be possible to add shields for something
942 * that can't legally receive help if it is build later) */
943 /* Info leak: The player knows that the production in their own city has
944 * been hurried (bought or helped). The information isn't revealed when
945 * asking for action probabilities since omniscient is FALSE. */
946 if (!omniscient
947 && !can_player_see_city_internals(actor->player, target->city)) {
948 return TRI_MAYBE;
949 }
950
951 if (!(target->city->shield_stock
953 return TRI_NO;
954 }
955
956 break;
957
960 /* Reason: allow scenarios to disable city founding. */
961 /* Info leak: the setting is public knowledge. */
962 return TRI_NO;
963 }
964
965 if (can_see_tgt_tile && tile_city(target->tile)) {
966 /* Reason: a tile can have 0 or 1 cities. */
967 return TRI_NO;
968 }
969
971 if (omniscient) {
972 /* No need to check again. */
973 return TRI_NO;
974 } else {
975 square_iterate(nmap, target->tile,
976 game.info.citymindist - 1, otile) {
977 if (tile_city(otile) != NULL
978 && can_player_see_tile(actor->player, otile)) {
979 /* Known to be blocked by citymindist */
980 return TRI_NO;
981 }
983 }
984 }
985
986 /* The player may not have enough information to be certain. */
987
988 if (!can_see_tgt_tile) {
989 /* Need to know if target tile already has a city, has TER_NO_CITIES
990 * terrain, is non native to the actor or is owned by a foreigner. */
991 return TRI_MAYBE;
992 }
993
994 if (!omniscient) {
995 /* The player may not have enough information to find out if
996 * citymindist blocks or not. This doesn't depend on if it blocks. */
997 square_iterate(nmap, target->tile,
998 game.info.citymindist - 1, otile) {
999 if (!can_player_see_tile(actor->player, otile)) {
1000 /* Could have a city that blocks via citymindist. Even if this
1001 * tile has TER_NO_CITIES terrain the player don't know that it
1002 * didn't change and had a city built on it. */
1003 return TRI_MAYBE;
1004 }
1006 }
1007
1008 break;
1009
1010 case ACTRES_JOIN_CITY:
1011 {
1012 int new_pop;
1014
1015 if (!omniscient
1016 && !player_can_see_city_externals(actor->player, target->city)) {
1017 return TRI_MAYBE;
1018 }
1019
1020 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1021
1023 /* Reason: Make the add_to_size_limit setting work. */
1024 return TRI_NO;
1025 }
1026
1027 if (!city_can_grow_to(target->city, new_pop)) {
1028 /* Reason: respect city size limits. */
1029 /* Info leak: when it is legal to join a foreign city is legal and
1030 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1031 * something the actor player don't have access to.
1032 * Example: depends on a building (like Aqueduct) that isn't
1033 * VisibleByOthers. */
1034 return TRI_NO;
1035 }
1036
1038 if (DEFAULT_SPECIALIST != sid) {
1039 if (!city_can_use_specialist(target->city, sid)) {
1040 /* Respect specialist reqs */
1041 /* Potential info leak about if they are fulfilled */
1042 return TRI_NO;
1043 }
1045 && target->city->specialists[sid] >= MAX_CITY_SIZE) {
1046 /* No place to add a superspecialist */
1047 /* Info leak on city superspecialists but it happens too rarely */
1048 return TRI_NO;
1049 }
1050 }
1051 }
1052
1053 break;
1054
1055 case ACTRES_NUKE_UNITS:
1056 /* Has only action specific requirements */
1057 break;
1058
1059 case ACTRES_HOME_CITY:
1060 /* Reason: can't change to what is. */
1061 /* Info leak: The player knows their unit's current home city. */
1062 if (homecity != NULL && homecity->id == target->city->id) {
1063 /* This is already the unit's home city. */
1064 return TRI_NO;
1065 }
1066
1067 {
1068 int slots = unit_type_get(actor->unit)->city_slots;
1069
1070 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1071 return TRI_NO;
1072 }
1073 }
1074
1075 break;
1076
1078 /* Reason: Keep the old rules. */
1079 /* Info leak: The player knows their unit's type. They know if they can
1080 * build the unit type upgraded to. If the upgrade happens in a foreign
1081 * city that fact may leak. This can be seen as a price for changing
1082 * the rules to allow upgrading in a foreign city.
1083 * The player knows how much gold they have. If the Upgrade_Price_Pct
1084 * effect depends on information they don't have that information may
1085 * leak. The player knows the location of their unit. They know if the
1086 * tile has a city and if the unit can exist there outside a transport.
1087 * The player knows their unit's cargo. By knowing the number and type
1088 * of cargo, they can predict if there will be enough room in the unit
1089 * upgraded to, as long as they know what unit type their unit will end
1090 * up as. */
1091 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1092 return TRI_NO;
1093 }
1094
1095 break;
1096
1097 case ACTRES_PARADROP:
1099 /* Reason: Keep the old rules. */
1100 /* Info leak: The player knows if they know the target tile. */
1101 if (!plr_knows_tile(actor->player, target->tile)) {
1102 return TRI_NO;
1103 }
1104
1105 /* Reason: Keep paratroopers_range working. */
1106 /* Info leak: The player knows the location of the actor and of the
1107 * target tile. */
1109 < real_map_distance(actor->tile, target->tile)) {
1110 return TRI_NO;
1111 }
1112
1113 break;
1114
1115 case ACTRES_AIRLIFT:
1116 /* Reason: Keep the old rules. */
1117 /* Info leak: same as test_unit_can_airlift_to() */
1118 switch (test_unit_can_airlift_to(nmap, omniscient ? NULL : actor->player,
1119 actor->unit, target->city)) {
1120 case AR_OK:
1121 return TRI_YES;
1122 case AR_OK_SRC_UNKNOWN:
1123 case AR_OK_DST_UNKNOWN:
1124 return TRI_MAYBE;
1125 case AR_NO_MOVES:
1126 case AR_WRONG_UNITTYPE:
1127 case AR_OCCUPIED:
1128 case AR_NOT_IN_CITY:
1129 case AR_BAD_SRC_CITY:
1130 case AR_BAD_DST_CITY:
1131 case AR_SRC_NO_FLIGHTS:
1132 case AR_DST_NO_FLIGHTS:
1133 return TRI_NO;
1134 }
1135
1136 break;
1137
1138 case ACTRES_ATTACK:
1139 break;
1140
1141 case ACTRES_WIPE_UNITS:
1142 unit_list_iterate(target->tile->units, punit) {
1143 if (get_total_defense_power(actor->unit, punit) > 0) {
1144 return TRI_NO;
1145 }
1147 break;
1148
1151 return FALSE;
1152 }
1153
1154 unit_list_iterate(target->tile->units, punit) {
1156 /* Cannot get ransom when there are other kind of units in the tile */
1157 return FALSE;
1158 }
1160 break;
1161
1163 /* Reason: "Conquer City" involves moving into the city. */
1164 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1165 FALSE, FALSE, TRUE)) {
1166 return TRI_NO;
1167 }
1168
1169 break;
1170
1172 /* Reason: "Conquer Extras" involves moving to the tile. */
1173 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1174 FALSE, FALSE, FALSE)) {
1175 return TRI_NO;
1176 }
1177 /* Reason: Must have something to claim. The more specific restriction
1178 * that the base must be native to the actor unit is hard coded in
1179 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1180 * helptext_extra(), in helptext_unit(), in do_attack() and in
1181 * diplomat_bribe(). */
1182 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1183 return TRI_NO;
1184 }
1185 break;
1186
1187 case ACTRES_HEAL_UNIT:
1188 /* Reason: It is not the healthy who need a doctor, but the sick. */
1189 /* Info leak: the actor can see the target's HP. */
1190 if (!can_see_tgt_unit) {
1191 return TRI_MAYBE;
1192 }
1193 if (!(target->unit->hp < target->unittype->hp)) {
1194 return TRI_NO;
1195 }
1196 break;
1197
1199 pterrain = tile_terrain(target->tile);
1200 if (pterrain->transform_result == T_NONE
1201 || pterrain == pterrain->transform_result
1203 pterrain->transform_result)
1205 && (tile_city(target->tile)))) {
1206 return TRI_NO;
1207 }
1208 break;
1209
1210 case ACTRES_CULTIVATE:
1211 pterrain = tile_terrain(target->tile);
1212 if (pterrain->cultivate_result == NULL) {
1213 return TRI_NO;
1214 }
1216 pterrain->cultivate_result)
1218 && tile_city(target->tile))) {
1219 return TRI_NO;
1220 }
1221 break;
1222
1223 case ACTRES_PLANT:
1224 pterrain = tile_terrain(target->tile);
1225 if (pterrain->plant_result == NULL) {
1226 return TRI_NO;
1227 }
1229 pterrain->plant_result)
1231 && tile_city(target->tile))) {
1232 return TRI_NO;
1233 }
1234 break;
1235
1236 case ACTRES_ROAD:
1237 if (target_extra == NULL) {
1238 return TRI_NO;
1239 }
1241 /* Reason: This is not a road. */
1242 return TRI_NO;
1243 }
1245 target->tile)) {
1246 return TRI_NO;
1247 }
1248 break;
1249
1250 case ACTRES_BASE:
1251 if (target_extra == NULL) {
1252 return TRI_NO;
1253 }
1255 /* Reason: This is not a base. */
1256 return TRI_NO;
1257 }
1258 if (!can_build_base(actor->unit,
1259 extra_base_get(target_extra), target->tile)) {
1260 return TRI_NO;
1261 }
1262 break;
1263
1264 case ACTRES_MINE:
1265 if (target_extra == NULL) {
1266 return TRI_NO;
1267 }
1269 /* Reason: This is not a mine. */
1270 return TRI_NO;
1271 }
1272
1273 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1274 return TRI_NO;
1275 }
1276 break;
1277
1278 case ACTRES_IRRIGATE:
1279 if (target_extra == NULL) {
1280 return TRI_NO;
1281 }
1283 /* Reason: This is not an irrigation. */
1284 return TRI_NO;
1285 }
1286
1287 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1288 return TRI_NO;
1289 }
1290 break;
1291
1292 case ACTRES_PILLAGE:
1293 pterrain = tile_terrain(target->tile);
1294 if (pterrain->pillage_time == 0) {
1295 return TRI_NO;
1296 }
1297
1298 {
1302
1304 extra_type_iterate(pextra) {
1305 int idx = extra_index(pextra);
1306
1307 /* Only one unit can pillage a given improvement at a time */
1308 if (BV_ISSET(pspresent, idx)
1309 && (!BV_ISSET(psworking, idx)
1310 || actor->unit->activity_target == pextra)
1311 && can_remove_extra(pextra, actor->unit, target->tile)) {
1312 bool required = FALSE;
1313
1317 if (pdep == pextra) {
1318 required = TRUE;
1319 break;
1320 }
1322 }
1323 if (required) {
1324 break;
1325 }
1327
1328 if (!required) {
1329 BV_SET(pspossible, idx);
1330 }
1331 }
1333
1334 if (!BV_ISSET_ANY(pspossible)) {
1335 /* Nothing available to pillage */
1336 return TRI_NO;
1337 }
1338
1339 if (target_extra != NULL) {
1340 if (!game.info.pillage_select) {
1341 /* Hobson's choice (this case mostly exists for old clients) */
1342 /* Needs to match what unit_activity_assign_target chooses */
1343 struct extra_type *tgt;
1344
1346
1347 if (tgt != target_extra) {
1348 /* Only one target allowed, which wasn't the requested one */
1349 return TRI_NO;
1350 }
1351 }
1352
1354 return TRI_NO;
1355 }
1356 }
1357 }
1358 break;
1359
1360 case ACTRES_CLEAN:
1361 {
1362 const struct extra_type *pextra = NULL;
1363
1364 pterrain = tile_terrain(target->tile);
1365
1366 if (target_extra != NULL) {
1367 if (tile_has_extra(target->tile, target_extra)
1369 pextra = target_extra;
1370 }
1371 } else {
1372 /* TODO: Make sure that all callers set target so that
1373 * we don't need this fallback. */
1374 pextra = prev_extra_in_tile(target->tile,
1375 ERM_CLEAN,
1376 actor->player,
1377 actor->unit);
1378 }
1379
1380 if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0
1381 && can_remove_extra(pextra, actor->unit, target->tile)) {
1382 return TRI_YES;
1383 }
1384
1385 return TRI_NO;
1386 }
1387
1389 if (!can_unit_unload(actor->unit, target->unit)) {
1390 /* Keep the old rules about Unreachable and disembarks. */
1391 return TRI_NO;
1392 }
1393 break;
1394
1396 if (unit_transported(actor->unit)) {
1397 if (target->unit == unit_transport_get(actor->unit)) {
1398 /* Already inside this transport. */
1399 return TRI_NO;
1400 }
1401 }
1402 if (!could_unit_load(actor->unit, target->unit)) {
1403 /* Keep the old rules. */
1404 return TRI_NO;
1405 }
1406 break;
1407
1409 if (unit_transported(target->unit)) {
1410 if (actor->unit == unit_transport_get(target->unit)) {
1411 /* Already transporting this unit. */
1412 return TRI_NO;
1413 }
1414 }
1415 if (!could_unit_load(target->unit, actor->unit)) {
1416 /* Keep the old rules. */
1417 return TRI_NO;
1418 }
1419 if (unit_transported(target->unit)) {
1420 if (!can_unit_unload(target->unit,
1421 unit_transport_get(target->unit))) {
1422 /* Can't leave current transport. */
1423 return TRI_NO;
1424 }
1425 }
1426 break;
1427
1429 if (!can_unit_unload(target->unit, actor->unit)) {
1430 /* Keep the old rules about Unreachable and disembarks. */
1431 return TRI_NO;
1432 }
1433 break;
1434
1436 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1437 FALSE, FALSE, FALSE)) {
1438 /* Reason: involves moving to the tile. */
1439 return TRI_NO;
1440 }
1441
1442 /* We cannot move a transport into a tile that holds
1443 * units or cities not allied with all of our cargo. */
1444 if (get_transporter_capacity(actor->unit) > 0) {
1445 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1446 struct player *cowner = unit_owner(pcargo);
1447
1448 if (unit_contained_in(pcargo, actor->unit)
1449 && (is_non_allied_unit_tile(target->tile, cowner,
1451 || is_non_allied_city_tile(target->tile, cowner))) {
1452 return TRI_NO;
1453 }
1455 }
1456 break;
1457
1459 if (unit_transported(actor->unit)) {
1460 if (target->unit == unit_transport_get(actor->unit)) {
1461 /* Already inside this transport. */
1462 return TRI_NO;
1463 }
1464 }
1465 if (!could_unit_load(actor->unit, target->unit)) {
1466 /* Keep the old rules. */
1467 return TRI_NO;
1468 }
1469 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1470 FALSE, TRUE, FALSE)) {
1471 /* Reason: involves moving to the tile. */
1472 return TRI_NO;
1473 }
1474 /* We cannot move a transport into a tile that holds
1475 * units or cities not allied with all of our cargo. */
1476 if (get_transporter_capacity(actor->unit) > 0) {
1477 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1478 struct player *cowner = unit_owner(pcargo);
1479
1480 if (unit_contained_in(pcargo, actor->unit)
1481 && (is_non_allied_unit_tile(target->tile, cowner,
1483 || is_non_allied_city_tile(target->tile,
1484 cowner))) {
1485 return TRI_NO;
1486 }
1488 }
1489 break;
1490
1491 case ACTRES_SPY_ATTACK:
1492 {
1493 bool found;
1494
1495 if (!omniscient
1497 target->tile)) {
1498 /* May have a hidden diplomatic defender. */
1499 return TRI_MAYBE;
1500 }
1501
1502 found = FALSE;
1503 unit_list_iterate(target->tile->units, punit) {
1504 struct player *uplayer = unit_owner(punit);
1505
1506 if (uplayer == actor->player) {
1507 /* Won't defend against its owner. */
1508 continue;
1509 }
1510
1512 /* This unbeatable diplomatic defender will defend before any
1513 * that can be beaten. */
1514 found = FALSE;
1515 break;
1516 }
1517
1519 /* Found a beatable diplomatic defender. */
1520 found = TRUE;
1521 break;
1522 }
1524
1525 if (!found) {
1526 return TRI_NO;
1527 }
1528 }
1529 break;
1530
1531 case ACTRES_HUT_ENTER:
1533 /* Reason: involves moving to the tile. */
1534 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1535 FALSE, FALSE, FALSE)) {
1536 return TRI_NO;
1537 }
1538 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1539 /* Reason: keep extra rmreqs working. */
1540 return TRI_NO;
1541 }
1542 break;
1543
1544 case ACTRES_UNIT_MOVE:
1545 case ACTRES_TELEPORT:
1547 if (result == ACTRES_UNIT_MOVE) {
1548 /* Reason: is moving to the tile. */
1549 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1550 FALSE, FALSE, FALSE)) {
1551 return TRI_NO;
1552 }
1553 } else {
1554 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1555
1556 /* Reason: is teleporting to the tile. */
1557 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1558 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1559 return TRI_NO;
1560 }
1561 }
1562
1563 /* Reason: Don't override "Transport Embark" */
1564 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1565 return TRI_NO;
1566 }
1567
1568 /* We cannot move a transport into a tile that holds
1569 * units or cities not allied with any of our cargo. */
1570 if (get_transporter_capacity(actor->unit) > 0) {
1571 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1572 struct player *cowner = unit_owner(pcargo);
1573
1574 if (unit_contained_in(pcargo, actor->unit)
1575 && (is_non_allied_unit_tile(target->tile, cowner,
1577 || is_non_allied_city_tile(target->tile, cowner))) {
1578 return TRI_NO;
1579 }
1581 }
1582 break;
1583
1584 case ACTRES_SPY_ESCAPE:
1585 /* Reason: Be merciful. */
1586 /* Info leak: The player know if they have any cities. */
1587 if (city_list_size(actor->player->cities) < 1) {
1588 return TRI_NO;
1589 }
1590 break;
1591
1593 /* Enabling this action with illness_on = FALSE prevents spread. */
1594 break;
1595 case ACTRES_BOMBARD:
1596 {
1597 /* Allow bombing only if there's reachable units in the target
1598 * tile. Bombing without anybody taking damage is certainly not
1599 * what user really wants.
1600 * Allow bombing when player does not know if there's units in
1601 * target tile. */
1602 if (tile_city(target->tile) == NULL
1603 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1604 V_MAIN)
1605 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1606 V_INVIS)
1607 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1608 V_SUBSURFACE)) {
1609 bool hiding_extra = FALSE;
1610
1611 extra_type_iterate(pextra) {
1612 if (pextra->eus == EUS_HIDDEN
1613 && tile_has_extra(target->tile, pextra)) {
1615 break;
1616 }
1618
1619 if (!hiding_extra) {
1620 bool has_target = FALSE;
1621
1622 unit_list_iterate(target->tile->units, punit) {
1623 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1624 has_target = TRUE;
1625 break;
1626 }
1628
1629 if (!has_target) {
1630 return TRI_NO;
1631 }
1632 }
1633 }
1634 }
1635 break;
1638 case ACTRES_SPY_POISON:
1645 case ACTRES_STEAL_MAPS:
1646 case ACTRES_SPY_NUKE:
1647 case ACTRES_NUKE:
1649 case ACTRES_EXPEL_UNIT:
1651 case ACTRES_CONVERT:
1654 case ACTRES_FORTIFY:
1655 case ACTRES_HOMELESS:
1657 case ACTRES_NONE:
1658 /* No known hard coded requirements. */
1659 break;
1660
1662 }
1663
1664 return def;
1665}
#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:317
int actres_min_range_default(enum action_result result)
Definition actres.c:377
void actres_free(void)
Definition actres.c:251
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:673
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:259
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:811
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:790
void actres_init(void)
Definition actres.c:244
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:836
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:561
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:302
int actres_max_range_default(enum action_result result)
Definition actres.c:467
bool actres_is_hostile(enum action_result result)
Definition actres.c:287
static bool plr_knows_tile(const struct player *plr, const struct tile *ttile)
Definition actres.c:825
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:365
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:273
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:771
#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: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_use_specialist(const struct city *pcity, Specialist_type_id type)
Definition city.c:1065
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:771
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
#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: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:209
#define EC_NONE
Definition fc_types.h:806
int Specialist_type_id
Definition fc_types.h:235
#define ACTRES_NONE
Definition fc_types.h:187
#define ERM_NONE
Definition fc_types.h:829
struct civ_game game
Definition game.c:62
#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: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:1099
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1112
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1172
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:1001
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:1157
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 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: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:554
#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: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:2545
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2624
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:743
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1194
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:2052
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2529
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:795
#define unit_tile(_pu)
Definition unit.h:407
#define unit_owner(_pu)
Definition unit.h:406
@ 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:443
#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:1953
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2530
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