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 == nullptr || !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 != nullptr, 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) != nullptr
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 != nullptr && 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() */
1119 omniscient ? nullptr : actor->player,
1120 actor->unit, target->city)) {
1121 case AR_OK:
1122 return TRI_YES;
1123 case AR_OK_SRC_UNKNOWN:
1124 case AR_OK_DST_UNKNOWN:
1125 return TRI_MAYBE;
1126 case AR_NO_MOVES:
1127 case AR_WRONG_UNITTYPE:
1128 case AR_OCCUPIED:
1129 case AR_NOT_IN_CITY:
1130 case AR_BAD_SRC_CITY:
1131 case AR_BAD_DST_CITY:
1132 case AR_SRC_NO_FLIGHTS:
1133 case AR_DST_NO_FLIGHTS:
1134 return TRI_NO;
1135 }
1136
1137 break;
1138
1139 case ACTRES_ATTACK:
1140 break;
1141
1142 case ACTRES_WIPE_UNITS:
1143 unit_list_iterate(target->tile->units, punit) {
1144 if (get_total_defense_power(actor->unit, punit) > 0) {
1145 return TRI_NO;
1146 }
1148 break;
1149
1152 return FALSE;
1153 }
1154
1155 unit_list_iterate(target->tile->units, punit) {
1157 /* Cannot get ransom when there are other kind of units in the tile */
1158 return FALSE;
1159 }
1161 break;
1162
1164 /* Reason: "Conquer City" involves moving into the city. */
1165 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1166 FALSE, FALSE, TRUE)) {
1167 return TRI_NO;
1168 }
1169
1170 break;
1171
1173 /* Reason: "Conquer Extras" involves moving to the tile. */
1174 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1175 FALSE, FALSE, FALSE)) {
1176 return TRI_NO;
1177 }
1178 /* Reason: Must have something to claim. The more specific restriction
1179 * that the base must be native to the actor unit is hard coded in
1180 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1181 * helptext_extra(), in helptext_unit(), in do_attack() and in
1182 * diplomat_bribe(). */
1183 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1184 return TRI_NO;
1185 }
1186 break;
1187
1188 case ACTRES_HEAL_UNIT:
1189 /* Reason: It is not the healthy who need a doctor, but the sick. */
1190 /* Info leak: the actor can see the target's HP. */
1191 if (!can_see_tgt_unit) {
1192 return TRI_MAYBE;
1193 }
1194 if (!(target->unit->hp < target->unittype->hp)) {
1195 return TRI_NO;
1196 }
1197 break;
1198
1200 pterrain = tile_terrain(target->tile);
1201 if (pterrain->transform_result == T_NONE
1202 || pterrain == pterrain->transform_result
1204 pterrain->transform_result)
1206 && (tile_city(target->tile)))) {
1207 return TRI_NO;
1208 }
1209 break;
1210
1211 case ACTRES_CULTIVATE:
1212 pterrain = tile_terrain(target->tile);
1213 if (pterrain->cultivate_result == nullptr) {
1214 return TRI_NO;
1215 }
1217 pterrain->cultivate_result)
1219 && tile_city(target->tile))) {
1220 return TRI_NO;
1221 }
1222 break;
1223
1224 case ACTRES_PLANT:
1225 pterrain = tile_terrain(target->tile);
1226 if (pterrain->plant_result == nullptr) {
1227 return TRI_NO;
1228 }
1230 pterrain->plant_result)
1232 && tile_city(target->tile))) {
1233 return TRI_NO;
1234 }
1235 break;
1236
1237 case ACTRES_ROAD:
1238 if (target_extra == nullptr) {
1239 return TRI_NO;
1240 }
1242 /* Reason: This is not a road. */
1243 return TRI_NO;
1244 }
1246 target->tile)) {
1247 return TRI_NO;
1248 }
1249 break;
1250
1251 case ACTRES_BASE:
1252 if (target_extra == nullptr) {
1253 return TRI_NO;
1254 }
1256 /* Reason: This is not a base. */
1257 return TRI_NO;
1258 }
1259 if (!can_build_base(actor->unit,
1260 extra_base_get(target_extra), target->tile)) {
1261 return TRI_NO;
1262 }
1263 break;
1264
1265 case ACTRES_MINE:
1266 if (target_extra == nullptr) {
1267 return TRI_NO;
1268 }
1270 /* Reason: This is not a mine. */
1271 return TRI_NO;
1272 }
1273
1274 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1275 return TRI_NO;
1276 }
1277 break;
1278
1279 case ACTRES_IRRIGATE:
1280 if (target_extra == nullptr) {
1281 return TRI_NO;
1282 }
1284 /* Reason: This is not an irrigation. */
1285 return TRI_NO;
1286 }
1287
1288 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1289 return TRI_NO;
1290 }
1291 break;
1292
1293 case ACTRES_PILLAGE:
1294 pterrain = tile_terrain(target->tile);
1295 if (pterrain->pillage_time == 0) {
1296 return TRI_NO;
1297 }
1298
1299 {
1303
1305 extra_type_iterate(pextra) {
1306 int idx = extra_index(pextra);
1307
1308 /* Only one unit can pillage a given improvement at a time */
1309 if (BV_ISSET(pspresent, idx)
1310 && (!BV_ISSET(psworking, idx)
1311 || actor->unit->activity_target == pextra)
1312 && can_remove_extra(pextra, actor->unit, target->tile)) {
1313 bool required = FALSE;
1314
1318 if (pdep == pextra) {
1319 required = TRUE;
1320 break;
1321 }
1323 }
1324 if (required) {
1325 break;
1326 }
1328
1329 if (!required) {
1330 BV_SET(pspossible, idx);
1331 }
1332 }
1334
1335 if (!BV_ISSET_ANY(pspossible)) {
1336 /* Nothing available to pillage */
1337 return TRI_NO;
1338 }
1339
1340 if (target_extra != nullptr) {
1341 if (!game.info.pillage_select) {
1342 /* Hobson's choice (this case mostly exists for old clients) */
1343 /* Needs to match what unit_activity_assign_target chooses */
1344 struct extra_type *tgt;
1345
1347
1348 if (tgt != target_extra) {
1349 /* Only one target allowed, which wasn't the requested one */
1350 return TRI_NO;
1351 }
1352 }
1353
1355 return TRI_NO;
1356 }
1357 }
1358 }
1359 break;
1360
1361 case ACTRES_CLEAN:
1362 {
1363 const struct extra_type *pextra = nullptr;
1364
1365 pterrain = tile_terrain(target->tile);
1366
1367 if (target_extra != nullptr) {
1368 if (tile_has_extra(target->tile, target_extra)
1370 pextra = target_extra;
1371 }
1372 } else {
1373 /* TODO: Make sure that all callers set target so that
1374 * we don't need this fallback. */
1375 pextra = prev_extra_in_tile(target->tile,
1376 ERM_CLEAN,
1377 actor->player,
1378 actor->unit);
1379 }
1380
1381 if (pextra != nullptr
1382 && pterrain->extra_removal_times[extra_index(pextra)] > 0
1383 && can_remove_extra(pextra, actor->unit, target->tile)) {
1384 return TRI_YES;
1385 }
1386
1387 return TRI_NO;
1388 }
1389
1391 if (!can_unit_unload(actor->unit, target->unit)) {
1392 /* Keep the old rules about Unreachable and disembarks. */
1393 return TRI_NO;
1394 }
1395 break;
1396
1398 if (unit_transported(actor->unit)) {
1399 if (target->unit == unit_transport_get(actor->unit)) {
1400 /* Already inside this transport. */
1401 return TRI_NO;
1402 }
1403 }
1404 if (!could_unit_load(actor->unit, target->unit)) {
1405 /* Keep the old rules. */
1406 return TRI_NO;
1407 }
1408 break;
1409
1411 if (unit_transported(target->unit)) {
1412 if (actor->unit == unit_transport_get(target->unit)) {
1413 /* Already transporting this unit. */
1414 return TRI_NO;
1415 }
1416 }
1417 if (!could_unit_load(target->unit, actor->unit)) {
1418 /* Keep the old rules. */
1419 return TRI_NO;
1420 }
1421 if (unit_transported(target->unit)) {
1422 if (!can_unit_unload(target->unit,
1423 unit_transport_get(target->unit))) {
1424 /* Can't leave current transport. */
1425 return TRI_NO;
1426 }
1427 }
1428 break;
1429
1431 if (!can_unit_unload(target->unit, actor->unit)) {
1432 /* Keep the old rules about Unreachable and disembarks. */
1433 return TRI_NO;
1434 }
1435 break;
1436
1438 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1439 FALSE, FALSE, FALSE)) {
1440 /* Reason: involves moving to the tile. */
1441 return TRI_NO;
1442 }
1443
1444 /* We cannot move a transport into a tile that holds
1445 * units or cities not allied with all of our cargo. */
1446 if (get_transporter_capacity(actor->unit) > 0) {
1447 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1448 struct player *cowner = unit_owner(pcargo);
1449
1450 if (unit_contained_in(pcargo, actor->unit)
1451 && (is_non_allied_unit_tile(target->tile, cowner,
1453 || is_non_allied_city_tile(target->tile, cowner))) {
1454 return TRI_NO;
1455 }
1457 }
1458 break;
1459
1461 if (unit_transported(actor->unit)) {
1462 if (target->unit == unit_transport_get(actor->unit)) {
1463 /* Already inside this transport. */
1464 return TRI_NO;
1465 }
1466 }
1467 if (!could_unit_load(actor->unit, target->unit)) {
1468 /* Keep the old rules. */
1469 return TRI_NO;
1470 }
1471 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1472 FALSE, TRUE, FALSE)) {
1473 /* Reason: involves moving to the tile. */
1474 return TRI_NO;
1475 }
1476 /* We cannot move a transport into a tile that holds
1477 * units or cities not allied with all of our cargo. */
1478 if (get_transporter_capacity(actor->unit) > 0) {
1479 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1480 struct player *cowner = unit_owner(pcargo);
1481
1482 if (unit_contained_in(pcargo, actor->unit)
1483 && (is_non_allied_unit_tile(target->tile, cowner,
1485 || is_non_allied_city_tile(target->tile,
1486 cowner))) {
1487 return TRI_NO;
1488 }
1490 }
1491 break;
1492
1493 case ACTRES_SPY_ATTACK:
1494 {
1495 bool found;
1496
1497 if (!omniscient
1499 target->tile)) {
1500 /* May have a hidden diplomatic defender. */
1501 return TRI_MAYBE;
1502 }
1503
1504 found = FALSE;
1505 unit_list_iterate(target->tile->units, punit) {
1506 struct player *uplayer = unit_owner(punit);
1507
1508 if (uplayer == actor->player) {
1509 /* Won't defend against its owner. */
1510 continue;
1511 }
1512
1514 /* This unbeatable diplomatic defender will defend before any
1515 * that can be beaten. */
1516 found = FALSE;
1517 break;
1518 }
1519
1521 /* Found a beatable diplomatic defender. */
1522 found = TRUE;
1523 break;
1524 }
1526
1527 if (!found) {
1528 return TRI_NO;
1529 }
1530 }
1531 break;
1532
1533 case ACTRES_HUT_ENTER:
1535 /* Reason: involves moving to the tile. */
1536 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1537 FALSE, FALSE, FALSE)) {
1538 return TRI_NO;
1539 }
1540 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1541 /* Reason: keep extra rmreqs working. */
1542 return TRI_NO;
1543 }
1544 break;
1545
1546 case ACTRES_UNIT_MOVE:
1547 case ACTRES_TELEPORT:
1549 if (result == ACTRES_UNIT_MOVE) {
1550 /* Reason: is moving to the tile. */
1551 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1552 FALSE, FALSE, FALSE)) {
1553 return TRI_NO;
1554 }
1555 } else {
1556 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1557
1558 /* Reason: is teleporting to the tile. */
1559 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1560 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1561 return TRI_NO;
1562 }
1563 }
1564
1565 /* Reason: Don't override "Transport Embark" */
1566 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1567 return TRI_NO;
1568 }
1569
1570 /* We cannot move a transport into a tile that holds
1571 * units or cities not allied with any of our cargo. */
1572 if (get_transporter_capacity(actor->unit) > 0) {
1573 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1574 struct player *cowner = unit_owner(pcargo);
1575
1576 if (unit_contained_in(pcargo, actor->unit)
1577 && (is_non_allied_unit_tile(target->tile, cowner,
1579 || is_non_allied_city_tile(target->tile, cowner))) {
1580 return TRI_NO;
1581 }
1583 }
1584 break;
1585
1586 case ACTRES_SPY_ESCAPE:
1587 /* Reason: Be merciful. */
1588 /* Info leak: The player know if they have any cities. */
1589 if (city_list_size(actor->player->cities) < 1) {
1590 return TRI_NO;
1591 }
1592 break;
1593
1595 /* Enabling this action with illness_on = FALSE prevents spread. */
1596 break;
1597 case ACTRES_BOMBARD:
1598 {
1599 /* Allow bombing only if there's reachable units in the target
1600 * tile. Bombing without anybody taking damage is certainly not
1601 * what user really wants.
1602 * Allow bombing when player does not know if there's units in
1603 * target tile. */
1604 if (tile_city(target->tile) == nullptr
1605 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1606 V_MAIN)
1607 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1608 V_INVIS)
1609 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1610 V_SUBSURFACE)) {
1611 bool hiding_extra = FALSE;
1612
1613 extra_type_iterate(pextra) {
1614 if (pextra->eus == EUS_HIDDEN
1615 && tile_has_extra(target->tile, pextra)) {
1617 break;
1618 }
1620
1621 if (!hiding_extra) {
1622 bool has_target = FALSE;
1623
1624 unit_list_iterate(target->tile->units, punit) {
1625 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1626 has_target = TRUE;
1627 break;
1628 }
1630
1631 if (!has_target) {
1632 return TRI_NO;
1633 }
1634 }
1635 }
1636 }
1637 break;
1640 case ACTRES_SPY_POISON:
1647 case ACTRES_STEAL_MAPS:
1648 case ACTRES_SPY_NUKE:
1649 case ACTRES_NUKE:
1651 case ACTRES_EXPEL_UNIT:
1653 case ACTRES_CONVERT:
1656 case ACTRES_FORTIFY:
1657 case ACTRES_HOMELESS:
1659 case ACTRES_NONE:
1660 /* No known hard coded requirements. */
1661 break;
1662
1664 }
1665
1666 return def;
1667}
#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:740
int city_unit_slots_available(const struct city *pcity)
Definition city.c:1053
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
Definition city.c:1506
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
Definition city.c:1069
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2053
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:772
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: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: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: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: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: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: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: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