Freeciv-3.2
Loading...
Searching...
No Matches
actres.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2023 The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "city.h"
20#include "combat.h"
21#include "fc_interface.h"
22#include "game.h"
23#include "map.h"
24#include "metaknowledge.h"
25#include "movement.h"
26#include "player.h"
27#include "requirements.h"
28#include "tile.h"
29#include "traderoutes.h"
30
31#include "actres.h"
32
33static struct actres act_results[ACTRES_LAST] = {
34 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ESTABLISH_EMBASSY */
37 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_INVESTIGATE_CITY */
40 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_POISON */
43 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_GOLD */
46 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY */
49 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_SABOTAGE_CITY */
52 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_CITY_PRODUCTION */
55 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_STEAL_TECH */
58 { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_STEAL_TECH */
61 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_INCITE_CITY */
64 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRADE_ROUTE */
67 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_MARKETPLACE */
70 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HELP_WONDER */
73 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_BRIBE_UNIT */
76 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SABOTAGE_UNIT */
79 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CAPTURE_UNITS */
82 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FOUND_CITY */
85 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_JOIN_CITY */
88 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_STEAL_MAPS */
91 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_BOMBARD */
94 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_NUKE */
97 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE */
100 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_NUKE_UNITS */
103 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DESTROY_CITY */
106 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_EXPEL_UNIT */
109 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT_RECOVER */
112 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_DISBAND_UNIT */
115 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOME_CITY */
118 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UPGRADE_UNIT */
121 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP */
124 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_AIRLIFT */
127 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_ATTACK */
130 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_STRIKE_BUILDING */
133 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_STRIKE_PRODUCTION */
136 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_CITY */
139 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HEAL_UNIT */
142 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSFORM_TERRAIN */
145 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CULTIVATE */
148 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PLANT */
151 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_PILLAGE */
154 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_FORTIFY */
157 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_ROAD */
160 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONVERT */
163 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_BASE */
166 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_MINE */
169 { ACT_TGT_COMPL_MANDATORY, ABK_NONE, /* ACTRES_IRRIGATE */
172 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_COLLECT_RANSOM */
175 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_UNUSED_1 */
178 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DEBOARD */
181 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_UNLOAD */
184 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_DISEMBARK */
187 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_BOARD */
190 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_EMBARK */
193 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_SPREAD_PLAGUE */
196 { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC, /* ACTRES_SPY_ATTACK */
199 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_CONQUER_EXTRAS */
202 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_ENTER */
205 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HUT_FRIGHTEN */
208 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_UNIT_MOVE */
211 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_PARADROP_CONQUER */
212 FALSE, ACTIVITY_LAST, DRT_NONE, /* TODO: Should this be hostile? */
214 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_HOMELESS */
217 { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD, /* ACTRES_WIPE_UNITS */
220 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SPY_ESCAPE */
223 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TRANSPORT_LOAD */
226 { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_CLEAN */
229 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT */
232 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT_CONQUER */
235 { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */
238};
239
240/*********************************************************************/
243void actres_init(void)
244{
245}
246
247/*********************************************************************/
250void actres_free(void)
251{
252}
253
254/**********************************************************************/
259{
260 if (result == ACTRES_NONE) {
262 }
263
265
266 return act_results[result].sub_tgt_compl;
267}
268
269/**********************************************************************/
273{
274 if (result == ACTRES_NONE) {
275 return ABK_NONE;
276 }
277
279
280 return act_results[result].battle_kind;
281}
282
283/**********************************************************************/
287{
288 if (result == ACTRES_NONE) {
289 return FALSE;
290 }
291
292 return act_results[result].hostile;
293}
294
295/**********************************************************************/
302{
303 if (result == ACTRES_NONE) {
304 return ACTIVITY_LAST;
305 }
306
307 return act_results[result].activity;
308}
309
310/**********************************************************************/
317 const struct unit *actor_unit,
318 const struct tile *tgt_tile,
319 const struct extra_type *tgt_extra)
320{
322
323 if (pactivity == ACTIVITY_LAST) {
324 /* Happens instantaneously, not at turn change. */
326 }
327
328 switch (pactivity) {
329 case ACTIVITY_PILLAGE:
330 case ACTIVITY_CLEAN:
331 case ACTIVITY_BASE:
334 case ACTIVITY_MINE:
336 case ACTIVITY_PLANT:
340 return 1;
341 case ACTIVITY_CONVERT:
343 case ACTIVITY_EXPLORE:
344 case ACTIVITY_IDLE:
346 case ACTIVITY_SENTRY:
347 case ACTIVITY_GOTO:
348 case ACTIVITY_LAST:
349 /* Should not happen. Caught by the assertion below. */
350 break;
351 }
352
354
356}
357
358/**********************************************************************/
365{
366 if (result == ACTRES_NONE) {
367 return DRT_NONE;
368 }
369
370 return act_results[result].dice;
371}
372
373/**********************************************************************/
377{
378 switch (result) {
396 case ACTRES_JOIN_CITY:
398 case ACTRES_BOMBARD:
399 case ACTRES_SPY_NUKE:
404 case ACTRES_HOME_CITY:
405 case ACTRES_HOMELESS:
407 case ACTRES_PARADROP:
409 case ACTRES_AIRLIFT:
412 case ACTRES_ATTACK:
416 case ACTRES_HEAL_UNIT:
418 case ACTRES_CULTIVATE:
419 case ACTRES_PLANT:
420 case ACTRES_PILLAGE:
421 case ACTRES_CLEAN:
422 case ACTRES_FORTIFY:
423 case ACTRES_ROAD:
424 case ACTRES_CONVERT:
425 case ACTRES_BASE:
426 case ACTRES_MINE:
427 case ACTRES_IRRIGATE:
437 case ACTRES_HUT_ENTER:
439 case ACTRES_UNIT_MOVE:
442 /* Non ruleset defined action min range not supported here */
443 fc_assert_msg(FALSE, "Probably wrong value.");
445 case ACTRES_NUKE:
448 case ACTRES_TELEPORT:
451 case ACTRES_NONE:
453
455 }
456
457 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
458
459 return 0;
460}
461
462/**********************************************************************/
466{
467 switch (result) {
484 case ACTRES_JOIN_CITY:
486 case ACTRES_SPY_NUKE:
490 case ACTRES_HOME_CITY:
491 case ACTRES_HOMELESS:
493 case ACTRES_PARADROP:
497 case ACTRES_ATTACK:
501 case ACTRES_HEAL_UNIT:
503 case ACTRES_CULTIVATE:
504 case ACTRES_PLANT:
505 case ACTRES_PILLAGE:
506 case ACTRES_CLEAN:
507 case ACTRES_FORTIFY:
508 case ACTRES_ROAD:
509 case ACTRES_CONVERT:
510 case ACTRES_BASE:
511 case ACTRES_MINE:
512 case ACTRES_IRRIGATE:
522 case ACTRES_HUT_ENTER:
524 case ACTRES_UNIT_MOVE:
527 /* Non ruleset defined action max range not supported here */
528 fc_assert_msg(FALSE, "Probably wrong value.");
533 case ACTRES_BOMBARD:
535 case ACTRES_NUKE:
539 case ACTRES_AIRLIFT:
540 case ACTRES_TELEPORT:
543 case ACTRES_NONE:
545
547 }
548
549 fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
550
551 return 0;
552}
553
554/**********************************************************************/
559 enum action_target_kind tgt_kind)
560{
562 FALSE);
564 FALSE);
565
566 switch (result) {
580 case ACTRES_JOIN_CITY:
582 case ACTRES_SPY_NUKE:
585 case ACTRES_HOME_CITY:
587 case ACTRES_AIRLIFT:
593 return tgt_kind == ATK_CITY;
597 case ACTRES_HEAL_UNIT:
603 return tgt_kind == ATK_UNIT;
605 case ACTRES_BOMBARD:
607 case ACTRES_ATTACK:
611 return tgt_kind == ATK_UNITS;
613 case ACTRES_PARADROP:
616 case ACTRES_CULTIVATE:
617 case ACTRES_PLANT:
618 case ACTRES_CLEAN:
619 case ACTRES_ROAD:
620 case ACTRES_BASE:
621 case ACTRES_MINE:
622 case ACTRES_IRRIGATE:
624 case ACTRES_HUT_ENTER:
626 case ACTRES_UNIT_MOVE:
627 case ACTRES_TELEPORT:
629 return tgt_kind == ATK_TILE;
631 return tgt_kind == ATK_EXTRAS;
633 case ACTRES_CONVERT:
634 case ACTRES_FORTIFY:
635 case ACTRES_HOMELESS:
637 return tgt_kind == ATK_SELF;
638 case ACTRES_PILLAGE:
639 return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS);
640 case ACTRES_NUKE:
641 return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
642 case ACTRES_NONE:
643 switch (tgt_kind) {
644 case ATK_CITY:
645 case ATK_UNIT:
646 case ATK_UNITS:
647 case ATK_TILE:
648 case ATK_EXTRAS:
649 case ATK_SELF:
650 /* Works with all existing target kinds. */
651 return TRUE;
652 case ATK_COUNT:
653 fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
654 break;
655 }
656 break;
657
659 }
660
661 /* Should never be reached. */
662 return FALSE;
663}
664
665/**********************************************************************/
670{
672 ASTK_NONE);
673
674 switch (result) {
686 case ACTRES_JOIN_CITY:
688 case ACTRES_SPY_NUKE:
691 case ACTRES_HOME_CITY:
692 case ACTRES_HOMELESS:
694 case ACTRES_AIRLIFT:
698 return ASTK_NONE;
701 return ASTK_BUILDING;
703 return ASTK_TECH;
707 case ACTRES_HEAL_UNIT:
713 return ASTK_NONE;
715 case ACTRES_BOMBARD:
717 case ACTRES_ATTACK:
721 return ASTK_NONE;
723 case ACTRES_NUKE:
724 case ACTRES_PARADROP:
727 case ACTRES_CULTIVATE:
728 case ACTRES_PLANT:
730 case ACTRES_HUT_ENTER:
732 case ACTRES_UNIT_MOVE:
733 case ACTRES_TELEPORT:
737 return ASTK_NONE;
738 case ACTRES_PILLAGE:
739 case ACTRES_CLEAN:
740 return ASTK_EXTRA;
741 case ACTRES_ROAD:
742 case ACTRES_BASE:
743 case ACTRES_MINE:
744 case ACTRES_IRRIGATE:
747 return ASTK_NONE;
749 case ACTRES_CONVERT:
750 case ACTRES_FORTIFY:
751 return ASTK_NONE;
752 case ACTRES_NONE:
753 return ASTK_NONE;
754
756 }
757
758 /* Should never be reached. */
759 return ASTK_NONE;
760}
761
762/**********************************************************************/
777
778/**********************************************************************/
786 const struct extra_type *pextra)
787{
788 if (act_results[result].ecause == EC_NONE) {
789 return FALSE;
790 }
791
792 if (pextra == NULL || !pextra->buildable) {
793 return FALSE;
794 }
795
796 return is_extra_caused_by(pextra, act_results[result].ecause);
797}
798
799/**********************************************************************/
807 const struct extra_type *pextra)
808{
809 if (act_results[result].ermcause == ERM_NONE) {
810 return FALSE;
811 }
812
813 return is_extra_removed_by(pextra, act_results[result].ermcause);
814}
815
816/**********************************************************************/
820static bool plr_knows_tile(const struct player *plr,
821 const struct tile *ttile)
822{
823 return plr != nullptr
824 && ttile != nullptr
825 && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
826}
827
828/**********************************************************************/
832 enum action_result result,
833 const struct req_context *actor,
834 const struct req_context *target,
835 const struct extra_type *target_extra,
836 enum fc_tristate def,
837 bool omniscient,
838 const struct city *homecity)
839{
840 struct terrain *pterrain;
841 bool can_see_tgt_unit;
842 bool can_see_tgt_tile;
843
844 /* Only check requirement against the target unit if the actor can see it
845 * or if the evaluator is omniscient. The game checking the rules is
846 * omniscient. The player asking about their odds isn't. */
847 can_see_tgt_unit = (omniscient || (target->unit
848 && can_player_see_unit(actor->player,
849 target->unit)));
850
851 /* Only check requirement against the target tile if the actor can see it
852 * or if the evaluator is omniscient. The game checking the rules is
853 * omniscient. The player asking about their odds isn't. */
854 can_see_tgt_tile = (omniscient
855 || can_player_see_tile(actor->player, target->tile));
856
857 switch (result) {
860 /* Why this is a hard requirement: Can't transfer a unique unit if the
861 * actor player already has one. */
862 /* Info leak: This is only checked for when the actor player can see
863 * the target unit. Since the target unit is seen its type is known.
864 * The fact that a city hiding the unseen unit is occupied is known. */
865
866 if (!can_see_tgt_unit) {
867 /* An omniscient player can see the target unit. */
868 fc_assert(!omniscient);
869
870 return TRI_MAYBE;
871 }
872
874 target->unittype)) {
875 return TRI_NO;
876 }
877
878 /* FIXME: Capture Unit may want to look for more than one unique unit
879 * of the same kind at the target tile. Currently caught by sanity
880 * check in do_capture_units(). */
881
882 break;
883
885 /* Reason: The Freeciv code don't support selecting a target tech
886 * unless it is known that the victim player has it. */
887 /* Info leak: The actor player knowns whose techs they can see. */
888 if (!can_see_techs_of_target(actor->player, target->player)) {
889 return TRI_NO;
890 }
891
892 break;
893
895 /* If actor->unit can do the action the actor->player can see how much
896 * gold target->player have. Not requiring it is therefore pointless.
897 */
898 if (target->player->economic.gold <= 0) {
899 return TRI_NO;
900 }
901
902 break;
903
906 {
907 /* Checked in action_hard_reqs_actor() */
908 fc_assert_ret_val(homecity != NULL, TRI_NO);
909
910 /* Can't establish a trade route or enter the market place if the
911 * cities can't trade at all. */
912 /* TODO: Should this restriction (and the above restriction that the
913 * actor unit must have a home city) be kept for Enter Marketplace? */
914 if (!can_cities_trade(homecity, target->city)) {
915 return TRI_NO;
916 }
917
918 /* There are more restrictions on establishing a trade route than on
919 * entering the market place. */
920 if (result == ACTRES_TRADE_ROUTE
921 && !can_establish_trade_route(homecity, target->city)) {
922 return TRI_NO;
923 }
924 }
925
926 break;
927
930 /* It is only possible to help the production if the production needs
931 * the help. (If not it would be possible to add shields for something
932 * that can't legally receive help if it is build later) */
933 /* Info leak: The player knows that the production in their own city has
934 * been hurried (bought or helped). The information isn't revealed when
935 * asking for action probabilities since omniscient is FALSE. */
936 if (!omniscient
937 && !can_player_see_city_internals(actor->player, target->city)) {
938 return TRI_MAYBE;
939 }
940
941 if (!(target->city->shield_stock
943 return TRI_NO;
944 }
945
946 break;
947
950 /* Reason: allow scenarios to disable city founding. */
951 /* Info leak: the setting is public knowledge. */
952 return TRI_NO;
953 }
954
955 if (can_see_tgt_tile && tile_city(target->tile)) {
956 /* Reason: a tile can have 0 or 1 cities. */
957 return TRI_NO;
958 }
959
961 if (omniscient) {
962 /* No need to check again. */
963 return TRI_NO;
964 } else {
965 square_iterate(nmap, target->tile,
966 game.info.citymindist - 1, otile) {
967 if (tile_city(otile) != NULL
968 && can_player_see_tile(actor->player, otile)) {
969 /* Known to be blocked by citymindist */
970 return TRI_NO;
971 }
973 }
974 }
975
976 /* The player may not have enough information to be certain. */
977
978 if (!can_see_tgt_tile) {
979 /* Need to know if target tile already has a city, has TER_NO_CITIES
980 * terrain, is non native to the actor or is owned by a foreigner. */
981 return TRI_MAYBE;
982 }
983
984 if (!omniscient) {
985 /* The player may not have enough information to find out if
986 * citymindist blocks or not. This doesn't depend on if it blocks. */
987 square_iterate(nmap, target->tile,
988 game.info.citymindist - 1, otile) {
989 if (!can_player_see_tile(actor->player, otile)) {
990 /* Could have a city that blocks via citymindist. Even if this
991 * tile has TER_NO_CITIES terrain the player don't know that it
992 * didn't change and had a city built on it. */
993 return TRI_MAYBE;
994 }
996 }
997
998 break;
999
1000 case ACTRES_JOIN_CITY:
1001 {
1002 int new_pop;
1003
1004 if (!omniscient
1005 && !player_can_see_city_externals(actor->player, target->city)) {
1006 return TRI_MAYBE;
1007 }
1008
1009 new_pop = city_size_get(target->city) + unit_pop_value(actor->unit);
1010
1012 /* Reason: Make the add_to_size_limit setting work. */
1013 return TRI_NO;
1014 }
1015
1016 if (!city_can_grow_to(target->city, new_pop)) {
1017 /* Reason: respect city size limits. */
1018 /* Info leak: when it is legal to join a foreign city is legal and
1019 * the EFT_SIZE_UNLIMIT effect or the EFT_SIZE_ADJ effect depends on
1020 * something the actor player don't have access to.
1021 * Example: depends on a building (like Aqueduct) that isn't
1022 * VisibleByOthers. */
1023 return TRI_NO;
1024 }
1025 }
1026
1027 break;
1028
1029 case ACTRES_NUKE_UNITS:
1030 /* Has only action specific requirements */
1031 break;
1032
1033 case ACTRES_HOME_CITY:
1034 /* Reason: can't change to what is. */
1035 /* Info leak: The player knows their unit's current home city. */
1036 if (homecity != NULL && homecity->id == target->city->id) {
1037 /* This is already the unit's home city. */
1038 return TRI_NO;
1039 }
1040
1041 {
1042 int slots = unit_type_get(actor->unit)->city_slots;
1043
1044 if (slots > 0 && city_unit_slots_available(target->city) < slots) {
1045 return TRI_NO;
1046 }
1047 }
1048
1049 break;
1050
1052 /* Reason: Keep the old rules. */
1053 /* Info leak: The player knows their unit's type. They know if they can
1054 * build the unit type upgraded to. If the upgrade happens in a foreign
1055 * city that fact may leak. This can be seen as a price for changing
1056 * the rules to allow upgrading in a foreign city.
1057 * The player knows how much gold they have. If the Upgrade_Price_Pct
1058 * effect depends on information they don't have that information may
1059 * leak. The player knows the location of their unit. They know if the
1060 * tile has a city and if the unit can exist there outside a transport.
1061 * The player knows their unit's cargo. By knowing the number and type
1062 * of cargo, they can predict if there will be enough room in the unit
1063 * upgraded to, as long as they know what unit type their unit will end
1064 * up as. */
1065 if (unit_upgrade_test(nmap, actor->unit, FALSE) != UU_OK) {
1066 return TRI_NO;
1067 }
1068
1069 break;
1070
1071 case ACTRES_PARADROP:
1073 /* Reason: Keep the old rules. */
1074 /* Info leak: The player knows if they know the target tile. */
1075 if (!plr_knows_tile(actor->player, target->tile)) {
1076 return TRI_NO;
1077 }
1078
1079 /* Reason: Keep paratroopers_range working. */
1080 /* Info leak: The player knows the location of the actor and of the
1081 * target tile. */
1083 < real_map_distance(actor->tile, target->tile)) {
1084 return TRI_NO;
1085 }
1086
1087 break;
1088
1089 case ACTRES_AIRLIFT:
1090 /* Reason: Keep the old rules. */
1091 /* Info leak: same as test_unit_can_airlift_to() */
1092 switch (test_unit_can_airlift_to(nmap, omniscient ? NULL : actor->player,
1093 actor->unit, target->city)) {
1094 case AR_OK:
1095 return TRI_YES;
1096 case AR_OK_SRC_UNKNOWN:
1097 case AR_OK_DST_UNKNOWN:
1098 return TRI_MAYBE;
1099 case AR_NO_MOVES:
1100 case AR_WRONG_UNITTYPE:
1101 case AR_OCCUPIED:
1102 case AR_NOT_IN_CITY:
1103 case AR_BAD_SRC_CITY:
1104 case AR_BAD_DST_CITY:
1105 case AR_SRC_NO_FLIGHTS:
1106 case AR_DST_NO_FLIGHTS:
1107 return TRI_NO;
1108 }
1109
1110 break;
1111
1112 case ACTRES_ATTACK:
1113 break;
1114
1115 case ACTRES_WIPE_UNITS:
1116 unit_list_iterate(target->tile->units, punit) {
1117 if (get_total_defense_power(actor->unit, punit) > 0) {
1118 return TRI_NO;
1119 }
1121 break;
1122
1124 if (!is_barbarian(actor->player)
1126 return FALSE;
1127 }
1128
1129 unit_list_iterate(target->tile->units, punit) {
1131 /* Cannot get ransom when there are other kind of units in the tile */
1132 return FALSE;
1133 }
1135 break;
1136
1138 /* Reason: "Conquer City" involves moving into the city. */
1139 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1140 FALSE, FALSE, TRUE)) {
1141 return TRI_NO;
1142 }
1143
1144 break;
1145
1147 /* Reason: "Conquer Extras" involves moving to the tile. */
1148 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1149 FALSE, FALSE, FALSE)) {
1150 return TRI_NO;
1151 }
1152 /* Reason: Must have something to claim. The more specific restriction
1153 * that the base must be native to the actor unit is hard coded in
1154 * unit_move(), in action_actor_utype_hard_reqs_ok_full(), in
1155 * helptext_extra(), in helptext_unit(), in do_attack() and in
1156 * diplomat_bribe(). */
1157 if (!tile_has_claimable_base(target->tile, actor->unittype)) {
1158 return TRI_NO;
1159 }
1160 break;
1161
1162 case ACTRES_HEAL_UNIT:
1163 /* Reason: It is not the healthy who need a doctor, but the sick. */
1164 /* Info leak: the actor can see the target's HP. */
1165 if (!can_see_tgt_unit) {
1166 return TRI_MAYBE;
1167 }
1168 if (!(target->unit->hp < target->unittype->hp)) {
1169 return TRI_NO;
1170 }
1171 break;
1172
1174 pterrain = tile_terrain(target->tile);
1175 if (pterrain->transform_result == T_NONE
1176 || pterrain == pterrain->transform_result
1178 pterrain->transform_result)
1180 && (tile_city(target->tile)))) {
1181 return TRI_NO;
1182 }
1183 break;
1184
1185 case ACTRES_CULTIVATE:
1186 pterrain = tile_terrain(target->tile);
1187 if (pterrain->cultivate_result == NULL) {
1188 return TRI_NO;
1189 }
1191 pterrain->cultivate_result)
1193 && tile_city(target->tile))) {
1194 return TRI_NO;
1195 }
1196 break;
1197
1198 case ACTRES_PLANT:
1199 pterrain = tile_terrain(target->tile);
1200 if (pterrain->plant_result == NULL) {
1201 return TRI_NO;
1202 }
1204 pterrain->plant_result)
1206 && tile_city(target->tile))) {
1207 return TRI_NO;
1208 }
1209 break;
1210
1211 case ACTRES_ROAD:
1212 if (target_extra == NULL) {
1213 return TRI_NO;
1214 }
1216 /* Reason: This is not a road. */
1217 return TRI_NO;
1218 }
1220 target->tile)) {
1221 return TRI_NO;
1222 }
1223 break;
1224
1225 case ACTRES_BASE:
1226 if (target_extra == NULL) {
1227 return TRI_NO;
1228 }
1230 /* Reason: This is not a base. */
1231 return TRI_NO;
1232 }
1233 if (!can_build_base(actor->unit,
1234 extra_base_get(target_extra), target->tile)) {
1235 return TRI_NO;
1236 }
1237 break;
1238
1239 case ACTRES_MINE:
1240 if (target_extra == NULL) {
1241 return TRI_NO;
1242 }
1244 /* Reason: This is not a mine. */
1245 return TRI_NO;
1246 }
1247
1248 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1249 return TRI_NO;
1250 }
1251 break;
1252
1253 case ACTRES_IRRIGATE:
1254 if (target_extra == NULL) {
1255 return TRI_NO;
1256 }
1258 /* Reason: This is not an irrigation. */
1259 return TRI_NO;
1260 }
1261
1262 if (!can_build_extra(target_extra, actor->unit, target->tile)) {
1263 return TRI_NO;
1264 }
1265 break;
1266
1267 case ACTRES_PILLAGE:
1268 pterrain = tile_terrain(target->tile);
1269 if (pterrain->pillage_time == 0) {
1270 return TRI_NO;
1271 }
1272
1273 {
1277
1279 extra_type_iterate(pextra) {
1280 int idx = extra_index(pextra);
1281
1282 /* Only one unit can pillage a given improvement at a time */
1283 if (BV_ISSET(pspresent, idx)
1284 && (!BV_ISSET(psworking, idx)
1285 || actor->unit->activity_target == pextra)
1286 && can_remove_extra(pextra, actor->unit, target->tile)) {
1287 bool required = FALSE;
1288
1292 if (pdep == pextra) {
1293 required = TRUE;
1294 break;
1295 }
1297 }
1298 if (required) {
1299 break;
1300 }
1302
1303 if (!required) {
1304 BV_SET(pspossible, idx);
1305 }
1306 }
1308
1309 if (!BV_ISSET_ANY(pspossible)) {
1310 /* Nothing available to pillage */
1311 return TRI_NO;
1312 }
1313
1314 if (target_extra != NULL) {
1315 if (!game.info.pillage_select) {
1316 /* Hobson's choice (this case mostly exists for old clients) */
1317 /* Needs to match what unit_activity_assign_target chooses */
1318 struct extra_type *tgt;
1319
1321
1322 if (tgt != target_extra) {
1323 /* Only one target allowed, which wasn't the requested one */
1324 return TRI_NO;
1325 }
1326 }
1327
1329 return TRI_NO;
1330 }
1331 }
1332 }
1333 break;
1334
1335 case ACTRES_CLEAN:
1336 {
1337 const struct extra_type *pextra = NULL;
1338
1339 pterrain = tile_terrain(target->tile);
1340
1341 if (target_extra != NULL) {
1342 if (tile_has_extra(target->tile, target_extra)
1344 pextra = target_extra;
1345 }
1346 } else {
1347 /* TODO: Make sure that all callers set target so that
1348 * we don't need this fallback. */
1349 pextra = prev_extra_in_tile(target->tile,
1350 ERM_CLEAN,
1351 actor->player,
1352 actor->unit);
1353 }
1354
1355 if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0
1356 && can_remove_extra(pextra, actor->unit, target->tile)) {
1357 return TRI_YES;
1358 }
1359
1360 return TRI_NO;
1361 }
1362
1364 if (!can_unit_unload(actor->unit, target->unit)) {
1365 /* Keep the old rules about Unreachable and disembarks. */
1366 return TRI_NO;
1367 }
1368 break;
1369
1371 if (unit_transported(actor->unit)) {
1372 if (target->unit == unit_transport_get(actor->unit)) {
1373 /* Already inside this transport. */
1374 return TRI_NO;
1375 }
1376 }
1377 if (!could_unit_load(actor->unit, target->unit)) {
1378 /* Keep the old rules. */
1379 return TRI_NO;
1380 }
1381 break;
1382
1384 if (unit_transported(target->unit)) {
1385 if (actor->unit == unit_transport_get(target->unit)) {
1386 /* Already transporting this unit. */
1387 return TRI_NO;
1388 }
1389 }
1390 if (!could_unit_load(target->unit, actor->unit)) {
1391 /* Keep the old rules. */
1392 return TRI_NO;
1393 }
1394 if (unit_transported(target->unit)) {
1395 if (!can_unit_unload(target->unit,
1396 unit_transport_get(target->unit))) {
1397 /* Can't leave current transport. */
1398 return TRI_NO;
1399 }
1400 }
1401 break;
1402
1404 if (!can_unit_unload(target->unit, actor->unit)) {
1405 /* Keep the old rules about Unreachable and disembarks. */
1406 return TRI_NO;
1407 }
1408 break;
1409
1411 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1412 FALSE, FALSE, FALSE)) {
1413 /* Reason: involves moving to the tile. */
1414 return TRI_NO;
1415 }
1416
1417 /* We cannot move a transport into a tile that holds
1418 * units or cities not allied with all of our cargo. */
1419 if (get_transporter_capacity(actor->unit) > 0) {
1420 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1421 if (unit_contained_in(pcargo, actor->unit)
1423 || is_non_allied_city_tile(target->tile,
1424 unit_owner(pcargo)))) {
1425 return TRI_NO;
1426 }
1428 }
1429 break;
1430
1432 if (unit_transported(actor->unit)) {
1433 if (target->unit == unit_transport_get(actor->unit)) {
1434 /* Already inside this transport. */
1435 return TRI_NO;
1436 }
1437 }
1438 if (!could_unit_load(actor->unit, target->unit)) {
1439 /* Keep the old rules. */
1440 return TRI_NO;
1441 }
1442 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1443 FALSE, TRUE, FALSE)) {
1444 /* Reason: involves moving to the tile. */
1445 return TRI_NO;
1446 }
1447 /* We cannot move a transport into a tile that holds
1448 * units or cities not allied with all of our cargo. */
1449 if (get_transporter_capacity(actor->unit) > 0) {
1450 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1451 if (unit_contained_in(pcargo, actor->unit)
1453 || is_non_allied_city_tile(target->tile,
1454 unit_owner(pcargo)))) {
1455 return TRI_NO;
1456 }
1458 }
1459 break;
1460
1461 case ACTRES_SPY_ATTACK:
1462 {
1463 bool found;
1464
1465 if (!omniscient
1467 target->tile)) {
1468 /* May have a hidden diplomatic defender. */
1469 return TRI_MAYBE;
1470 }
1471
1472 found = FALSE;
1473 unit_list_iterate(target->tile->units, punit) {
1474 struct player *uplayer = unit_owner(punit);
1475
1476 if (uplayer == actor->player) {
1477 /* Won't defend against its owner. */
1478 continue;
1479 }
1480
1482 /* This unbeatable diplomatic defender will defend before any
1483 * that can be beaten. */
1484 found = FALSE;
1485 break;
1486 }
1487
1489 /* Found a beatable diplomatic defender. */
1490 found = TRUE;
1491 break;
1492 }
1494
1495 if (!found) {
1496 return TRI_NO;
1497 }
1498 }
1499 break;
1500
1501 case ACTRES_HUT_ENTER:
1503 /* Reason: involves moving to the tile. */
1504 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1505 FALSE, FALSE, FALSE)) {
1506 return TRI_NO;
1507 }
1508 if (!unit_can_displace_hut(actor->unit, target->tile)) {
1509 /* Reason: keep extra rmreqs working. */
1510 return TRI_NO;
1511 }
1512 break;
1513
1514 case ACTRES_UNIT_MOVE:
1515 case ACTRES_TELEPORT:
1517 if (result == ACTRES_UNIT_MOVE) {
1518 /* Reason: is moving to the tile. */
1519 if (!unit_can_move_to_tile(nmap, actor->unit, target->tile,
1520 FALSE, FALSE, FALSE)) {
1521 return TRI_NO;
1522 }
1523 } else {
1524 fc_assert(result == ACTRES_TELEPORT || result == ACTRES_TELEPORT_CONQUER);
1525
1526 /* Reason: is teleporting to the tile. */
1527 if (!unit_can_teleport_to_tile(nmap, actor->unit, target->tile,
1528 FALSE, result == ACTRES_TELEPORT_CONQUER)) {
1529 return TRI_NO;
1530 }
1531 }
1532
1533 /* Reason: Don't override "Transport Embark" */
1534 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)) {
1535 return TRI_NO;
1536 }
1537
1538 /* We cannot move a transport into a tile that holds
1539 * units or cities not allied with any of our cargo. */
1540 if (get_transporter_capacity(actor->unit) > 0) {
1541 unit_list_iterate(unit_tile(actor->unit)->units, pcargo) {
1542 if (unit_contained_in(pcargo, actor->unit)
1544 || is_non_allied_city_tile(target->tile,
1545 unit_owner(pcargo)))) {
1546 return TRI_NO;
1547 }
1549 }
1550 break;
1551
1552 case ACTRES_SPY_ESCAPE:
1553 /* Reason: Be merciful. */
1554 /* Info leak: The player know if they have any cities. */
1555 if (city_list_size(actor->player->cities) < 1) {
1556 return TRI_NO;
1557 }
1558 break;
1559
1561 /* Enabling this action with illness_on = FALSE prevents spread. */
1562 break;
1563 case ACTRES_BOMBARD:
1564 {
1565 /* Allow bombing only if there's reachable units in the target
1566 * tile. Bombing without anybody taking damage is certainly not
1567 * what user really wants.
1568 * Allow bombing when player does not know if there's units in
1569 * target tile. */
1570 if (tile_city(target->tile) == NULL
1571 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1572 V_MAIN)
1573 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1574 V_INVIS)
1575 && fc_funcs->player_tile_vision_get(target->tile, actor->player,
1576 V_SUBSURFACE)) {
1577 bool hiding_extra = FALSE;
1578
1579 extra_type_iterate(pextra) {
1580 if (pextra->eus == EUS_HIDDEN
1581 && tile_has_extra(target->tile, pextra)) {
1583 break;
1584 }
1586
1587 if (!hiding_extra) {
1588 bool has_target = FALSE;
1589
1590 unit_list_iterate(target->tile->units, punit) {
1591 if (is_unit_reachable_at(punit, actor->unit, target->tile)) {
1592 has_target = TRUE;
1593 break;
1594 }
1596
1597 if (!has_target) {
1598 return TRI_NO;
1599 }
1600 }
1601 }
1602 }
1603 break;
1606 case ACTRES_SPY_POISON:
1613 case ACTRES_STEAL_MAPS:
1614 case ACTRES_SPY_NUKE:
1615 case ACTRES_NUKE:
1617 case ACTRES_EXPEL_UNIT:
1619 case ACTRES_CONVERT:
1622 case ACTRES_FORTIFY:
1623 case ACTRES_HOMELESS:
1625 case ACTRES_NONE:
1626 /* No known hard coded requirements. */
1627 break;
1628
1630 }
1631
1632 return def;
1633}
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:355
int actres_get_act_time(enum action_result result, const struct unit *actor_unit, const struct tile *tgt_tile, const struct extra_type *tgt_extra)
Definition actres.c:316
int actres_min_range_default(enum action_result result)
Definition actres.c:376
void actres_free(void)
Definition actres.c:250
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:669
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:258
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:806
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:785
void actres_init(void)
Definition actres.c:243
static struct actres act_results[ACTRES_LAST]
Definition actres.c:33
enum fc_tristate actres_possible(const struct civ_map *nmap, enum action_result result, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, enum fc_tristate def, bool omniscient, const struct city *homecity)
Definition actres.c:831
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:558
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:301
int actres_max_range_default(enum action_result result)
Definition actres.c:465
bool actres_is_hostile(enum action_result result)
Definition actres.c:286
static bool plr_knows_tile(const struct player *plr, const struct tile *ttile)
Definition actres.c:820
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:364
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:272
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:766
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
dice_roll_type
Definition actres.h:110
@ DRT_DIPLCHANCE
Definition actres.h:110
@ DRT_NONE
Definition actres.h:110
bool can_build_base(const struct unit *punit, const struct base_type *pbase, const struct tile *ptile)
Definition base.c:53
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_ISSET_ANY(vec)
Definition bitvector.h:109
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:736
int city_unit_slots_available(const struct city *pcity)
Definition city.c:1040
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
Definition city.c:1456
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2004
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:762
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
bool is_unit_reachable_at(const struct unit *defender, const struct unit *attacker, const struct tile *location)
Definition combat.c:85
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
Definition combat.c:765
char * incite_cost
Definition comments.c:74
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
bool unit_can_displace_hut(const struct unit *punit, const struct tile *ptile)
Definition extras.c:738
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:790
bool can_remove_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:612
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:533
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_deps_iterate(_reqs, _dep)
Definition extras.h:371
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_deps_iterate_end
Definition extras.h:379
#define extra_base_get(_e_)
Definition extras.h:190
#define extra_road_get(_e_)
Definition extras.h:191
const struct functions * fc_funcs
#define ACT_TIME_INSTANTANEOUS
Definition fc_types.h:352
#define EC_NONE
Definition fc_types.h:1114
#define ACTRES_NONE
Definition fc_types.h:330
#define ERM_NONE
Definition fc_types.h:1137
struct civ_game game
Definition game.c:62
#define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE
Definition game.h:886
#define RS_DEFAULT_ACTION_MIN_RANGE
Definition game.h:882
#define RS_DEFAULT_USER_ACTION_TARGET_KIND
Definition game.h:881
#define RS_DEFAULT_MOVE_MIN_RANGE
Definition game.h:885
#define RS_DEFAULT_ACTION_MAX_RANGE
Definition game.h:883
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
bv_extras get_tile_infrastructure_set(const struct tile *ptile, int *pcount)
Definition map.c:101
bool terrain_surroundings_allow_change(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain)
Definition map.c:742
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:630
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:391
#define square_iterate_end
Definition map.h:394
bool can_see_techs_of_target(const struct player *pow_player, const struct player *target_player)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:319
bool unit_can_teleport_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool enter_transport, bool enter_enemy_city)
Definition movement.c:592
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_transport, bool enter_enemy_city)
Definition movement.c:572
bool can_player_see_tile(const struct player *plr, const struct tile *ptile)
Definition player.c:1091
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1104
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1164
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:993
struct player_slot * slots
Definition player.c:51
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
static bool is_barbarian(const struct player *pplayer)
Definition player.h:489
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
fc_tristate
Definition shared.h:46
@ TRI_YES
Definition shared.h:46
@ TRI_NO
Definition shared.h:46
@ TRI_MAYBE
Definition shared.h:46
bool hostile
Definition actres.h:115
enum unit_activity activity
Definition actres.h:116
enum action_target_kind def_tgt_kind
Definition actres.h:121
enum dice_roll_type dice
Definition actres.h:117
enum extra_rmcause ermcause
Definition actres.h:120
enum act_tgt_compl sub_tgt_compl
Definition actres.h:113
enum action_battle_kind battle_kind
Definition actres.h:114
enum extra_cause ecause
Definition actres.h:118
Definition city.h:320
int id
Definition city.h:326
int shield_stock
Definition city.h:368
struct packet_game_info info
Definition game.h:89
struct packet_scenario_info scenario
Definition game.h:87
bool buildable
Definition extras.h:116
bool(* player_tile_vision_get)(const struct tile *ptile, const struct player *pplayer, enum vision_layer vision)
struct player_economic economic
Definition player.h:282
const struct tile * tile
const struct player * player
const struct unit_type * unittype
const struct unit * unit
const struct city * city
struct terrain * cultivate_result
Definition terrain.h:215
struct terrain * plant_result
Definition terrain.h:218
int pillage_time
Definition terrain.h:232
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:235
struct terrain * transform_result
Definition terrain.h:229
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
int paratroopers_range
Definition unittype.h:541
int convert_time
Definition unittype.h:531
int city_slots
Definition unittype.h:552
Definition unit.h:138
int hp
Definition unit.h:151
struct tile * tile
Definition unit.h:140
struct extra_type * activity_target
Definition unit.h:164
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
#define T_NONE
Definition terrain.h:56
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
Definition tile.c:215
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
Definition tile.c:418
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
@ TILE_UNKNOWN
Definition tile.h:36
#define ACTIVITY_FACTOR
Definition tile.h:165
#define tile_terrain(_tile)
Definition tile.h:110
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2437
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2516
enum unit_airlift_result test_unit_can_airlift_to(const struct civ_map *nmap, const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Definition unit.c:81
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:696
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1135
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:299
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1984
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2421
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:748
#define unit_tile(_pu)
Definition unit.h:390
#define unit_owner(_pu)
Definition unit.h:389
@ UU_OK
Definition unit.h:61
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:425
@ AR_SRC_NO_FLIGHTS
Definition unit.h:84
@ AR_OK_SRC_UNKNOWN
Definition unit.h:75
@ AR_OK_DST_UNKNOWN
Definition unit.h:76
@ AR_NO_MOVES
Definition unit.h:78
@ AR_BAD_DST_CITY
Definition unit.h:83
@ AR_NOT_IN_CITY
Definition unit.h:81
@ AR_OCCUPIED
Definition unit.h:80
@ AR_OK
Definition unit.h:74
@ AR_DST_NO_FLIGHTS
Definition unit.h:85
@ AR_WRONG_UNITTYPE
Definition unit.h:79
@ AR_BAD_SRC_CITY
Definition unit.h:82
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1927
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2498
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
Definition unittype.c:208
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
int unit_pop_value(const struct unit *punit)
Definition unittype.c:1543
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:766