Freeciv-3.3
Loading...
Searching...
No Matches
actions.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2013 - Freeciv Development 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#include <math.h> /* ceil(), floor() */
19
20/* utility */
21#include "astring.h"
22
23/* common */
24#include "actions.h"
25#include "city.h"
26#include "combat.h"
27#include "fc_interface.h"
28#include "game.h"
29#include "map.h"
30#include "metaknowledge.h"
31#include "movement.h"
32#include "oblig_reqs.h"
33#include "research.h"
34#include "server_settings.h"
35#include "unit.h"
36
37
38/* Values used to interpret action probabilities.
39 *
40 * Action probabilities are sent over the network. A change in a value here
41 * will therefore change the network protocol.
42 *
43 * A change in a value here should also update the action probability
44 * format documentation in fc_types.h */
45/* The lowest possible probability value (0%) */
46#define ACTPROB_VAL_MIN 0
47/* The highest possible probability value (100%) */
48#define ACTPROB_VAL_MAX 200
49/* A probability increase of 1% corresponds to this increase. */
50#define ACTPROB_VAL_1_PCT (ACTPROB_VAL_MAX / 100)
51/* Action probability doesn't apply when min is this. */
52#define ACTPROB_VAL_NA 253
53/* Action probability unsupported when min is this. */
54#define ACTPROB_VAL_NOT_IMPL 254
55
60
62
64
65static struct action *
68 bool rare_pop_up,
71 const int min_distance,
72 const int max_distance,
74static struct action *
77
78static bool is_enabler_active(const struct action_enabler *enabler,
79 const struct req_context *actor,
80 const struct req_context *target);
81
82static inline bool
84static inline bool
86static inline bool
88
90 const struct unit *pvictim,
91 const struct tile *tgt_tile,
92 const struct action *paction)
94
95/* Make sure that an action distance can target the whole map. */
98
101
102
103/**********************************************************************/
106static void hard_code_actions(void)
107{
110 FALSE, TRUE,
111 MAK_ESCAPE, 0, 1, TRUE);
114 FALSE, TRUE,
115 MAK_ESCAPE, 0, 1, FALSE);
118 FALSE, TRUE,
119 MAK_ESCAPE, 0, 1, TRUE);
122 FALSE, TRUE,
123 MAK_ESCAPE, 0, 1, FALSE);
126 FALSE, TRUE,
127 /* Tries a forced move if the target unit is alone at
128 * its tile and not in a city. Takes all movement if
129 * the forced move fails. */
131 0, 1, FALSE);
134 FALSE, TRUE,
136 0, 1, FALSE);
139 FALSE, TRUE,
140 MAK_ESCAPE, 0, 1, TRUE);
143 FALSE, TRUE,
144 MAK_ESCAPE, 0, 1, FALSE);
148 FALSE, TRUE,
149 MAK_ESCAPE, 0, 1, TRUE);
153 FALSE, TRUE,
154 MAK_ESCAPE, 0, 1, TRUE);
158 FALSE, TRUE,
159 MAK_ESCAPE, 0, 1, FALSE);
163 FALSE, TRUE,
164 MAK_ESCAPE, 0, 1, FALSE);
167 FALSE, TRUE,
168 MAK_ESCAPE, 0, 1, TRUE);
171 FALSE, TRUE,
172 MAK_ESCAPE, 0, 1, FALSE);
176 FALSE, TRUE,
177 MAK_STAYS, 0, 1, FALSE);
181 FALSE, TRUE,
182 MAK_STAYS, 0, 1, TRUE);
186 FALSE, TRUE,
187 MAK_ESCAPE, 0, 1, TRUE);
191 FALSE, TRUE,
192 MAK_ESCAPE, 0, 1, FALSE);
196 FALSE, TRUE,
197 MAK_ESCAPE, 0, 1, TRUE);
201 FALSE, TRUE,
202 MAK_ESCAPE, 0, 1, FALSE);
206 FALSE, TRUE,
207 MAK_STAYS, 0, 1, FALSE);
211 FALSE, TRUE,
212 MAK_STAYS, 0, 1, TRUE);
216 FALSE, TRUE,
217 MAK_ESCAPE, 0, 1, TRUE);
221 FALSE, TRUE,
222 MAK_ESCAPE, 0, 1, FALSE);
226 FALSE, TRUE,
227 MAK_ESCAPE, 0, 1, FALSE);
231 FALSE, TRUE,
232 MAK_ESCAPE, 0, 1, FALSE);
235 FALSE, TRUE,
236 MAK_STAYS, 0, 1, TRUE);
239 FALSE, TRUE,
240 MAK_STAYS, 0, 1, TRUE);
243 FALSE, TRUE,
244 MAK_STAYS, 0, 1, TRUE);
248 /* A single domestic unit at the target tile will make
249 * the action illegal. It must therefore be performed
250 * from another tile. */
251 1, 1,
252 FALSE);
256 /* Illegal to perform to a target on another tile.
257 * Reason: The Freeciv code assumes that the city
258 * founding unit is located at the tile were the new
259 * city is founded. */
260 0, 0,
261 TRUE);
264 TRUE, TRUE,
265 MAK_STAYS, 0, 1, TRUE);
268 FALSE, TRUE,
269 MAK_ESCAPE, 0, 1, TRUE);
272 FALSE, TRUE,
273 MAK_ESCAPE, 0, 1, FALSE);
277 /* A single domestic unit at the target tile will make
278 * the action illegal. It must therefore be performed
279 * from another tile. */
280 1,
281 /* Overwritten by the ruleset's bombard_max_range */
282 1,
283 FALSE);
286 FALSE, TRUE,
287 MAK_STAYS,
288 /* A single domestic unit at the target tile will make
289 * the action illegal. It must therefore be performed
290 * from another tile. */
291 1,
292 /* Overwritten by the ruleset's bombard_2_max_range */
293 1,
294 FALSE);
298 /* A single domestic unit at the target tile will make
299 * the action illegal. It must therefore be performed
300 * from another tile. */
301 1,
302 /* Overwritten by the ruleset's bombard_3_max_range */
303 1,
304 FALSE);
308 /* A single domestic unit at the target tile will make
309 * the action illegal. It must therefore be performed
310 * from another tile. */
311 1,
312 /* Overwritten by the ruleset's bombard_4_max_range */
313 1,
314 FALSE);
318 /* A single domestic unit at the target tile will make
319 * the action illegal. It must therefore be performed
320 * from another tile. */
321 1,
322 /* Overwritten by the ruleset's bombard_lethal_max_range */
323 1,
324 FALSE);
328 /* A single domestic unit at the target tile will make
329 * the action illegal. It must therefore be performed
330 * from another tile. */
331 1,
332 /* Overwritten by the ruleset's bombard_lethal_2_max_range */
333 1,
334 FALSE);
337 FALSE, TRUE,
338 MAK_ESCAPE, 0, 1, TRUE);
341 FALSE, TRUE,
342 MAK_ESCAPE, 0, 1, FALSE);
345 TRUE, TRUE,
346 MAK_STAYS, 0,
347 /* Overwritten by the ruleset's
348 * explode_nuclear_max_range */
349 0,
350 TRUE);
353 TRUE, TRUE,
354 MAK_STAYS, 1, 1, TRUE);
357 TRUE, TRUE,
358 MAK_STAYS, 1, 1, TRUE);
361 TRUE, TRUE,
362 MAK_STAYS, 0, 1, FALSE);
365 FALSE, TRUE,
366 MAK_STAYS, 0, 1, FALSE);
370 /* Illegal to perform to a target on another tile to
371 * keep the rules exactly as they were for now. */
372 0, 1,
373 TRUE);
376 /* Can't be ACTRES_NONE because
377 * action_success_actor_consume() sets unit lost
378 * reason based on action result. */
380 TRUE, TRUE,
381 MAK_STAYS, 0, 0, TRUE);
384 TRUE, FALSE,
385 /* Illegal to perform to a target on another tile to
386 * keep the rules exactly as they were for now. */
387 MAK_STAYS, 0, 0, FALSE);
390 TRUE, FALSE,
391 MAK_STAYS, 0, 0, FALSE);
395 /* Illegal to perform to a target on another tile to
396 * keep the rules exactly as they were for now. */
397 0, 0,
398 FALSE);
401 TRUE, TRUE,
403 1,
404 /* Still limited by each unit type's
405 * paratroopers_range field. */
407 FALSE);
410 TRUE, TRUE,
412 1,
413 /* Still limited by each unit type's
414 * paratroopers_range field. */
416 FALSE);
419 TRUE, TRUE,
421 1,
422 /* Still limited by each unit type's
423 * paratroopers_range field. */
425 FALSE);
429 TRUE, TRUE,
431 1,
432 /* Still limited by each unit type's
433 * paratroopers_range field. */
435 FALSE);
438 TRUE, TRUE,
440 1,
441 /* Still limited by each unit type's
442 * paratroopers_range field. */
444 FALSE);
448 TRUE, TRUE,
450 1,
451 /* Still limited by each unit type's
452 * paratroopers_range field. */
454 FALSE);
457 TRUE, TRUE,
459 1,
460 /* Overwritten by the ruleset's airlift_max_range. */
462 FALSE);
465 FALSE, TRUE,
466 /* Tries a forced move if the target unit's tile has
467 * no non-allied units and the occupychance dice roll
468 * tells it to move. */
470 1, 1, FALSE);
473 FALSE, TRUE,
474 /* Tries a forced move if the target unit's tile has
475 * no non-allied units and the occupychance dice roll
476 * tells it to move. */
478 1, 1, FALSE);
481 FALSE, TRUE,
482 MAK_FORCED, 1, 1, TRUE);
485 FALSE, TRUE,
486 MAK_FORCED, 1, 1, TRUE);
489 FALSE, TRUE,
491 1, 1, FALSE);
494 FALSE, FALSE,
495 MAK_STAYS, 1, 1, FALSE);
498 FALSE, FALSE,
499 MAK_STAYS, 1, 1, FALSE);
502 FALSE, TRUE,
503 MAK_REGULAR, 1, 1, FALSE);
506 FALSE, TRUE,
507 MAK_REGULAR, 1, 1, FALSE);
510 FALSE, TRUE,
511 MAK_REGULAR, 1, 1, FALSE);
514 FALSE, TRUE,
515 MAK_REGULAR, 1, 1, FALSE);
518 FALSE, TRUE,
519 MAK_REGULAR, 1, 1, FALSE);
522 FALSE, TRUE,
523 MAK_REGULAR, 1, 1, FALSE);
526 FALSE, TRUE,
527 MAK_REGULAR, 1, 1, FALSE);
530 FALSE, TRUE,
531 MAK_REGULAR, 1, 1, FALSE);
534 FALSE, TRUE,
535 MAK_STAYS, 0, 1, FALSE);
538 FALSE, TRUE,
539 MAK_STAYS, 0, 1, FALSE);
542 TRUE, FALSE,
543 MAK_STAYS, 0, 0, FALSE);
546 TRUE, FALSE,
547 MAK_STAYS, 0, 0, FALSE);
550 TRUE, FALSE,
551 MAK_STAYS, 0, 0, FALSE);
554 TRUE, FALSE,
555 MAK_STAYS, 0, 0, FALSE);
558 TRUE, FALSE,
559 MAK_STAYS, 0, 0, FALSE);
562 TRUE, FALSE,
563 MAK_STAYS, 0, 0, FALSE);
566 TRUE, FALSE,
567 MAK_STAYS, 0, 0, FALSE);
570 TRUE, FALSE,
571 MAK_STAYS, 0, 0, FALSE);
574 TRUE, FALSE,
575 MAK_STAYS, 0, 0, FALSE);
578 TRUE, FALSE,
579 MAK_STAYS, 0, 0, FALSE);
582 TRUE, FALSE,
583 MAK_STAYS, 0, 0, FALSE);
586 TRUE, FALSE,
587 MAK_STAYS, 0, 0, FALSE);
590 TRUE, FALSE,
591 MAK_STAYS, 0, 0, FALSE);
594 TRUE, FALSE,
595 MAK_STAYS, 0, 0, FALSE);
598 TRUE, FALSE,
599 MAK_STAYS, 0, 0, FALSE);
602 TRUE, FALSE,
603 MAK_STAYS, 0, 0, FALSE);
606 TRUE, FALSE,
607 MAK_STAYS, 0, 0, FALSE);
610 TRUE, FALSE,
611 MAK_STAYS, 0, 0, FALSE);
614 TRUE, FALSE,
615 MAK_STAYS, 0, 0, FALSE);
618 TRUE, FALSE,
619 MAK_STAYS, 0, 0, FALSE);
622 TRUE, FALSE,
623 MAK_STAYS, 0, 0, FALSE);
626 TRUE, FALSE,
627 MAK_STAYS, 0, 0, FALSE);
630 TRUE, FALSE,
631 MAK_STAYS, 0, 0, FALSE);
634 TRUE, FALSE,
635 MAK_STAYS, 0, 0, FALSE);
638 TRUE, FALSE,
639 MAK_STAYS, 0, 0, FALSE);
642 TRUE, FALSE,
643 MAK_STAYS, 0, 0, FALSE);
646 TRUE, FALSE,
647 MAK_STAYS, 0, 0, FALSE);
650 TRUE, FALSE,
651 MAK_STAYS, 0, 0, FALSE);
654 TRUE, FALSE,
655 MAK_STAYS, 0, 0, FALSE);
659 FALSE, TRUE,
660 MAK_REGULAR, 1, 1, FALSE);
664 FALSE, TRUE,
665 MAK_REGULAR, 1, 1, FALSE);
669 FALSE, TRUE,
670 MAK_REGULAR, 1, 1, FALSE);
674 FALSE, TRUE,
675 MAK_REGULAR, 1, 1, FALSE);
678 TRUE, TRUE,
679 MAK_REGULAR, 1, 1, FALSE);
682 TRUE, TRUE,
683 MAK_REGULAR, 1, 1, FALSE);
686 TRUE, TRUE,
687 MAK_REGULAR, 1, 1, FALSE);
690 TRUE, TRUE,
691 MAK_REGULAR, 1, 1, FALSE);
694 FALSE, TRUE,
695 MAK_STAYS, 1, 1, FALSE);
698 FALSE, TRUE,
699 MAK_REGULAR, 1, 1, FALSE);
702 FALSE, TRUE,
703 MAK_REGULAR, 1, 1, FALSE);
706 FALSE, TRUE,
707 MAK_REGULAR, 1, 1, FALSE);
710 FALSE, TRUE,
711 MAK_REGULAR, 1, 1, FALSE);
714 FALSE, TRUE,
715 MAK_REGULAR, 1, 1, FALSE);
718 FALSE, TRUE,
719 MAK_REGULAR, 1, 1, FALSE);
722 FALSE, TRUE,
723 MAK_REGULAR, 1, 1, FALSE);
726 FALSE, TRUE,
727 MAK_REGULAR, 1, 1, FALSE);
730 TRUE, TRUE,
731 MAK_REGULAR, 1, 1, FALSE);
734 TRUE, TRUE,
735 MAK_REGULAR, 1, 1, FALSE);
738 TRUE, TRUE,
739 MAK_REGULAR, 1, 1, FALSE);
742 TRUE, TRUE,
743 MAK_TELEPORT, 1, 1, FALSE);
746 TRUE, TRUE,
747 MAK_TELEPORT, 1, 1, FALSE);
750 TRUE, TRUE,
751 MAK_TELEPORT, 1, 1, FALSE);
754 TRUE, TRUE,
755 MAK_TELEPORT, 1,
760 TRUE, TRUE,
761 MAK_TELEPORT, 1,
766 TRUE, TRUE,
767 MAK_TELEPORT, 1,
772 TRUE, TRUE,
773 MAK_TELEPORT, 1,
778 TRUE, TRUE,
779 MAK_TELEPORT, 1,
783 TRUE, FALSE,
784 MAK_STAYS, 0, 0, FALSE);
787 TRUE, FALSE,
788 MAK_STAYS, 0, 0, FALSE);
791 FALSE, TRUE,
793 /* Overwritten by the ruleset */
794 0, 1, FALSE);
797 FALSE, TRUE,
799 /* Overwritten by the ruleset */
800 0, 1, FALSE);
803 FALSE, TRUE,
805 /* Overwritten by the ruleset */
806 0, 1, FALSE);
809 FALSE, TRUE,
811 /* Overwritten by the ruleset */
812 0, 1, FALSE);
815 FALSE, TRUE,
816 /* Tries a forced move if the target unit's tile has
817 * no non-allied units and the occupychance dice roll
818 * tells it to move. */
820 1, 1, FALSE);
821
824
825 /* The structure even for these need to be created, for
826 * the action_id_rule_name() to work on iterations. */
827
828 /*
829 actions[ACTION_UNUSED_1]
830 = unit_action_new(ACTION_UNUSED_1, ACTRES_NONE,
831 FALSE, FALSE,
832 MAK_UNREPRESENTABLE,
833 0, 0, FALSE);
834 */
835}
836
837/**********************************************************************/
840void actions_init(void)
841{
842 int i, j;
843
844 for (i = 0; i < ACTRES_LAST; i++) {
846 }
847 for (i = 0; i < ACTIVITY_LAST; i++) {
849 }
850
851 /* Hard code the actions */
853
854 /* Initialize the action enabler list */
855 action_iterate_all(act) {
858
859 /* Initialize action obligatory hard requirements. */
861
862 /* Obligatory hard requirements are sorted by requirement in the source
863 * code. This makes it easy to read, modify and explain it. */
865
866 /* Initialize the action auto performers. */
867 for (i = 0; i < MAX_NUM_ACTION_AUTO_PERFORMERS; i++) {
868 /* Nothing here. Nothing after this point. */
870
871 /* The criteria to pick *this* auto performer for its cause. */
873
874 for (j = 0; j < MAX_NUM_ACTIONS; j++) {
875 /* Nothing here. Nothing after this point. */
877 }
878 }
879
880 /* The actions them self are now initialized. */
882}
883
884/**********************************************************************/
890{
891 /* Some obligatory hard requirements needs access to the rest of the
892 * ruleset. */
894}
895
896/**********************************************************************/
899void actions_free(void)
900{
901 int i;
902
903 /* Don't consider the actions to be initialized any longer. */
905
906 action_iterate_all(act) {
910
912
913 FC_FREE(actions[act]);
915
916 /* Free the obligatory hard action requirements. */
918
919 /* Free the action auto performers. */
920 for (i = 0; i < MAX_NUM_ACTION_AUTO_PERFORMERS; i++) {
922 }
923
925
926 for (i = 0; i < ACTRES_LAST; i++) {
929 }
930 for (i = 0; i < ACTIVITY_LAST; i++) {
933 }
934}
935
936/**********************************************************************/
942{
943 if (!actions_initialized) {
944 /* The actions them self aren't initialized yet. */
945 return FALSE;
946 }
947
949 if (actions[act]->ui_name[0] == '\0') {
950 /* A noninternal action without a UI name exists means that
951 * the ruleset haven't loaded yet. The ruleset loading will assign
952 * a default name to any actions not named by the ruleset.
953 * The client will get this name from the server. */
954 return FALSE;
955 }
957
958 /* The actions should be ready for use. */
959 return TRUE;
960}
961
962/**********************************************************************/
965static struct action *action_new(action_id id,
968 const int min_distance,
969 const int max_distance,
971{
972 struct action *action;
973
974 action = fc_malloc(sizeof(*action));
975
976 action->id = id;
978
980
981 if (result != ACTRES_LAST) {
983
985
986 if (act != ACTIVITY_LAST) {
988 }
989 }
990
991 /* Not set here */
993
998
999 /* ASTK_NONE implies ACT_TGT_COMPL_SIMPLE and
1000 * !ASTK_NONE implies !ACT_TGT_COMPL_SIMPLE */
1005 "%s contradicts itself regarding sub targets.",
1007
1008 /* The distance between the actor and itself is always 0. */
1010 || (min_distance == 0 && max_distance == 0));
1011
1014
1016
1017 /* Loaded from the ruleset. Until generalized actions are ready it has to
1018 * be defined separately from other action data. */
1019 action->ui_name[0] = '\0';
1020 action->quiet = FALSE;
1022
1023 return action;
1024}
1025
1026/**********************************************************************/
1029static struct action *
1031 enum action_result result,
1032 bool rare_pop_up,
1035 const int min_distance,
1036 const int max_distance,
1038{
1039 struct action *act = action_new(id, AAK_UNIT, result,
1042
1044
1046
1048
1049 return act;
1050}
1051
1052/**********************************************************************/
1055static struct action *
1057 enum action_result result)
1058{
1059 struct action *act = action_new(id, AAK_PLAYER, result,
1060 0, 0, FALSE);
1061
1062 return act;
1063}
1064
1065/**********************************************************************/
1068bool action_id_exists(const action_id act_id)
1069{
1070 /* Actions are still hard coded. */
1071 return gen_action_is_valid(act_id) && actions[act_id];
1072}
1073
1074/**********************************************************************/
1079struct action *action_by_rule_name(const char *name)
1080{
1081 /* Actions are still hard coded in the gen_action enum. */
1083
1084 if (!action_id_exists(act_id)) {
1085 /* Nothing to return. */
1086
1087 log_verbose("Asked for non existing action named %s", name);
1088
1089 return NULL;
1090 }
1091
1092 return action_by_number(act_id);
1093}
1094
1095/**********************************************************************/
1099{
1100 fc_assert_ret_val_msg(paction, AAK_COUNT, "Action doesn't exist.");
1101
1102 return paction->actor_kind;
1103}
1104
1105/**********************************************************************/
1109 const struct action *paction)
1110{
1111 fc_assert_ret_val_msg(paction, ATK_COUNT, "Action doesn't exist.");
1112
1113 return paction->target_kind;
1114}
1115
1116/**********************************************************************/
1120 const struct action *paction)
1121{
1122 fc_assert_ret_val_msg(paction, ASTK_COUNT, "Action doesn't exist.");
1123
1124 return paction->sub_target_kind;
1125}
1126
1127/**********************************************************************/
1133{
1135
1136 return paction->target_complexity >= ACT_TGT_COMPL_FLEXIBLE;
1137}
1138
1139/**********************************************************************/
1146{
1148
1149 return paction->target_complexity >= ACT_TGT_COMPL_MANDATORY;
1150}
1151
1152/**********************************************************************/
1161{
1163 FALSE, "Action %d don't exist.", act_id);
1165
1166 return actions[act_id]->actor.is_unit.rare_pop_up;
1167}
1168
1169/**********************************************************************/
1174 const int distance)
1175{
1178}
1179
1180/**********************************************************************/
1185 const int distance)
1186{
1188
1189 return (distance >= action->min_distance
1190 && action_distance_inside_max(action, distance));
1191}
1192
1193/**********************************************************************/
1196bool action_would_be_blocked_by(const struct action *blocked,
1197 const struct action *blocker)
1198{
1199 fc_assert_ret_val(blocked, FALSE);
1200 fc_assert_ret_val(blocker, FALSE);
1201
1202 return BV_ISSET(blocked->blocked_by, action_number(blocker));
1203}
1204
1205/**********************************************************************/
1208int action_number(const struct action *action)
1209{
1210 return action->id;
1211}
1212
1213/**********************************************************************/
1216const char *action_rule_name(const struct action *action)
1217{
1218 /* Rule name is still hard coded. */
1219 return action_id_rule_name(action->id);
1220}
1221
1222/**********************************************************************/
1230const char *action_name_translation(const struct action *paction)
1231{
1232 /* Use action_id_name_translation() to format the UI name. */
1234}
1235
1236/**********************************************************************/
1240{
1241 fc_assert_msg(actions[act_id], "Action %d don't exist.", act_id);
1242
1243 return gen_action_name(act_id);
1244}
1245
1246/**********************************************************************/
1251{
1252 return action_prepare_ui_name(act_id, "", ACTPROB_NA, NULL);
1253}
1254
1255/**********************************************************************/
1259 const char *mnemonic)
1260{
1262}
1263
1264/**********************************************************************/
1271static const char *action_prob_to_text(const struct act_prob prob)
1272{
1273 static struct astring chance = ASTRING_INIT;
1274
1275 /* How to interpret action probabilities like prob is documented in
1276 * fc_types.h */
1277 if (action_prob_is_signal(prob)) {
1279 || action_prob_not_relevant(prob));
1280
1281 /* Unknown because of missing server support or should not exits. */
1282 return NULL;
1283 }
1284
1285 if (prob.min == prob.max) {
1286 /* Only one probability in range. */
1287
1288 /* TRANS: the probability that an action will succeed. Given in
1289 * percentage. Resolution is 0.5%. */
1290 astr_set(&chance, _("%.1f%%"), (double)prob.max / ACTPROB_VAL_1_PCT);
1291 } else {
1292 /* TRANS: the interval (end points included) where the probability of
1293 * the action's success is. Given in percentage. Resolution is 0.5%. */
1294 astr_set(&chance, _("[%.1f%%, %.1f%%]"),
1295 (double)prob.min / ACTPROB_VAL_1_PCT,
1296 (double)prob.max / ACTPROB_VAL_1_PCT);
1297 }
1298
1299 return astr_str(&chance);
1300}
1301
1302/**********************************************************************/
1312const char *action_prepare_ui_name(action_id act_id, const char *mnemonic,
1313 const struct act_prob prob,
1314 const char *custom)
1315{
1316 struct astring chance = ASTRING_INIT;
1317
1318 /* Text representation of the probability. */
1319 const char *probtxt;
1320
1321 if (!actions_are_ready()) {
1322 /* Could be a client who haven't gotten the ruleset yet */
1323
1324 /* so there shouldn't be any action probability to show */
1326
1327 /* but the action should be valid */
1329 "Invalid action",
1330 "Invalid action %d", act_id);
1331
1332 /* and no custom text will be inserted */
1333 fc_assert(custom == NULL || custom[0] == '\0');
1334
1335 /* Make the best of what is known */
1336 astr_set(&ui_name_str, _("%s%s (name may be wrong)"),
1337 mnemonic, action_id_rule_name(act_id));
1338
1339 /* Return the guess. */
1340 return astr_str(&ui_name_str);
1341 }
1342
1344
1345 /* Format the info part of the action's UI name. */
1346 if (probtxt != NULL && custom != NULL) {
1347 /* TRANS: action UI name's info part with custom info and probability.
1348 * Hint: you can move the paren handling from this string to the action
1349 * names if you need to add extra information (like a mnemonic letter
1350 * that doesn't appear in the action UI name) to it. In that case you
1351 * must do so for all strings with this comment and for every action
1352 * name. To avoid a `()` when no UI name info part is added you have
1353 * to add the extra information to every action name or remove the
1354 * surrounding parens. */
1355 astr_set(&chance, _(" (%s; %s)"), custom, probtxt);
1356 } else if (probtxt != NULL) {
1357 /* TRANS: action UI name's info part with probability.
1358 * Hint: you can move the paren handling from this string to the action
1359 * names if you need to add extra information (like a mnemonic letter
1360 * that doesn't appear in the action UI name) to it. In that case you
1361 * must do so for all strings with this comment and for every action
1362 * name. To avoid a `()` when no UI name info part is added you have
1363 * to add the extra information to every action name or remove the
1364 * surrounding parens. */
1365 astr_set(&chance, _(" (%s)"), probtxt);
1366 } else if (custom != NULL) {
1367 /* TRANS: action UI name's info part with custom info.
1368 * Hint: you can move the paren handling from this string to the action
1369 * names if you need to add extra information (like a mnemonic letter
1370 * that doesn't appear in the action UI name) to it. In that case you
1371 * must do so for all strings with this comment and for every action
1372 * name. To avoid a `()` when no UI name info part is added you have
1373 * to add the extra information to every action name or remove the
1374 * surrounding parens. */
1375 astr_set(&chance, _(" (%s)"), custom);
1376 } else {
1377 /* No info part to display. */
1379 }
1380
1381 fc_assert_msg(actions[act_id], "Action %d don't exist.", act_id);
1382
1383 /* Escape any instances of the mnemonic in the action's UI format string.
1384 * (Assumes any mnemonic can be escaped by doubling, and that they are
1385 * unlikely to appear in a format specifier. True for clients seen so
1386 * far: Gtk's _ and Qt's &) */
1387 {
1388 struct astring fmtstr = ASTRING_INIT;
1389 const char *ui_name = _(actions[act_id]->ui_name);
1390
1391 if (mnemonic[0] != '\0') {
1392 const char *hit;
1393
1394 fc_assert(!strchr(mnemonic, '%'));
1395 while ((hit = strstr(ui_name, mnemonic))) {
1396 astr_add(&fmtstr, "%.*s%s%s", (int)(hit - ui_name), ui_name,
1398 ui_name = hit + strlen(mnemonic);
1399 }
1400 }
1401 astr_add(&fmtstr, "%s", ui_name);
1402
1403 /* Use the modified format string */
1405 astr_str(&chance));
1406
1407 astr_free(&fmtstr);
1408 }
1409
1410 astr_free(&chance);
1411
1412 return astr_str(&ui_name_str);
1413}
1414
1415/**********************************************************************/
1423const char *action_prob_explain(const struct act_prob prob)
1424{
1425 static struct astring tool_tip = ASTRING_INIT;
1426
1427 if (action_prob_is_signal(prob)) {
1429
1430 /* Missing server support. No in game action will change this. */
1432 } else if (prob.min == prob.max) {
1433 /* TRANS: action probability of success. Given in percentage.
1434 * Resolution is 0.5%. */
1435 astr_set(&tool_tip, _("The probability of success is %.1f%%."),
1436 (double)prob.max / ACTPROB_VAL_1_PCT);
1437 } else {
1439 /* TRANS: action probability interval (min to max). Given in
1440 * percentage. Resolution is 0.5%. The string at the end is
1441 * shown when the interval is wide enough to not be caused by
1442 * rounding. It explains that the interval is imprecise because
1443 * the player doesn't have enough information. */
1444 _("The probability of success is %.1f%%, %.1f%% or somewhere"
1445 " in between.%s"),
1446 (double)prob.min / ACTPROB_VAL_1_PCT,
1447 (double)prob.max / ACTPROB_VAL_1_PCT,
1448 prob.max - prob.min > 1 ?
1449 /* TRANS: explanation used in the action probability tooltip
1450 * above. Preserve leading space. */
1451 _(" (This is the most precise interval I can calculate "
1452 "given the information our nation has access to.)") :
1453 "");
1454 }
1455
1456 return astr_str(&tool_tip);
1457}
1458
1459/**********************************************************************/
1464{
1466 "Action %s isn't performed by a unit",
1468
1469 return paction->id + L_LAST;
1470}
1471
1472/**********************************************************************/
1476{
1477 struct action_enabler *enabler;
1478
1479 enabler = fc_malloc(sizeof(*enabler));
1480 enabler->rulesave.ruledit_disabled = FALSE;
1481 enabler->rulesave.comment = nullptr;
1482 requirement_vector_init(&enabler->actor_reqs);
1483 requirement_vector_init(&enabler->target_reqs);
1484
1485 /* Make sure that action doesn't end up as a random value that happens to
1486 * be a valid action id. */
1487 enabler->action = ACTION_NONE;
1488
1489 return enabler;
1490}
1491
1492/**********************************************************************/
1496{
1497 if (enabler->rulesave.comment != nullptr) {
1498 free(enabler->rulesave.comment);
1499 }
1500
1501 requirement_vector_free(&enabler->actor_reqs);
1502 requirement_vector_free(&enabler->target_reqs);
1503
1504 free(enabler);
1505}
1506
1507/**********************************************************************/
1510struct action_enabler *
1512{
1514
1515 enabler->action = original->action;
1516
1517 requirement_vector_copy(&enabler->actor_reqs, &original->actor_reqs);
1518 requirement_vector_copy(&enabler->target_reqs, &original->target_reqs);
1519
1520 return enabler;
1521}
1522
1523/**********************************************************************/
1527{
1528 /* Sanity check: a non existing action enabler can't be added. */
1530 /* Sanity check: a non existing action doesn't have enablers. */
1532
1535 enabler);
1536}
1537
1538/**********************************************************************/
1544{
1545 /* Sanity check: a non existing action enabler can't be removed. */
1547 /* Sanity check: a non existing action doesn't have enablers. */
1549
1552 enabler);
1553}
1554
1555/**********************************************************************/
1558struct action_enabler_list *
1560{
1561 /* Sanity check: a non existing action doesn't have enablers. */
1563
1565}
1566
1567/**********************************************************************/
1578static struct req_vec_problem *
1580 const struct obligatory_req_vector *oblig)
1581{
1582 struct action *paction;
1583
1584 /* Sanity check: a non existing action enabler is missing but it doesn't
1585 * miss any obligatory hard requirements. */
1587
1588 /* Sanity check: a non existing action doesn't have any obligatory hard
1589 * requirements. */
1592
1593 /* No obligatory hard requirements. */
1595
1597 struct req_vec_problem *out;
1598 int i;
1599 bool fulfilled = FALSE;
1600
1601 /* Check each alternative. */
1602 for (i = 0; i < obreq->contras->alternatives; i++) {
1603 const struct requirement_vector *ae_vec;
1604
1605 /* Select action enabler requirement vector. */
1606 ae_vec = (obreq->contras->alternative[i].is_target
1607 ? &enabler->target_reqs
1608 : &enabler->actor_reqs);
1609
1610 if (does_req_contradicts_reqs(&obreq->contras->alternative[i].req,
1611 ae_vec)
1612 /* Consider the hard requirement fulfilled since a universal that
1613 * never is there always will be absent in this ruleset. */
1614 || (obreq->contras->alternative[i].req.present
1616 &obreq->contras->alternative[i].req.source))) {
1617 /* It is enough that one alternative accepts the enabler. */
1618 fulfilled = TRUE;
1619 break;
1620 }
1621
1622 /* Fall back to the next alternative */
1623 }
1624
1625 if (fulfilled) {
1626 /* This obligatory hard requirement isn't a problem. */
1627 continue;
1628 }
1629
1630 /* Missing hard obligatory requirement detected */
1631
1632 out = req_vec_problem_new(obreq->contras->alternatives,
1633 obreq->error_msg,
1635
1636 for (i = 0; i < obreq->contras->alternatives; i++) {
1637 const struct requirement_vector *ae_vec;
1638
1639 /* Select action enabler requirement vector. */
1640 ae_vec = (obreq->contras->alternative[i].is_target
1641 ? &enabler->target_reqs
1642 : &enabler->actor_reqs);
1643
1644 /* The suggested fix is to append a requirement that makes the enabler
1645 * contradict the missing hard obligatory requirement detector. */
1646 out->suggested_solutions[i].operation = RVCO_APPEND;
1647 out->suggested_solutions[i].vector_number
1649
1650 /* Change the requirement from what should conflict to what is
1651 * wanted. */
1652 out->suggested_solutions[i].req.present
1653 = !obreq->contras->alternative[i].req.present;
1654 out->suggested_solutions[i].req.source
1655 = obreq->contras->alternative[i].req.source;
1656 out->suggested_solutions[i].req.range
1657 = obreq->contras->alternative[i].req.range;
1658 out->suggested_solutions[i].req.survives
1659 = obreq->contras->alternative[i].req.survives;
1660 out->suggested_solutions[i].req.quiet
1661 = obreq->contras->alternative[i].req.quiet;
1662 }
1663
1664 /* Return the first problem found. The next problem will be detected
1665 * during the next call. */
1666 return out;
1668
1669 /* No obligatory req problems found. */
1670 return NULL;
1671}
1672
1673/**********************************************************************/
1682struct req_vec_problem *
1684{
1685 struct action *paction;
1687 struct req_vec_problem *out;
1688
1689 /* Sanity check: a non existing action enabler is missing but it doesn't
1690 * miss any obligatory hard requirements. */
1692
1693 /* Sanity check: a non existing action doesn't have any obligatory hard
1694 * requirements. */
1697
1698 if (paction->result != ACTRES_NONE) {
1699 /* A hard coded action result may mean obligatory requirements. */
1701 if (out != NULL) {
1702 return out;
1703 }
1704 }
1705
1709 if (!BV_ISSET(paction->sub_results, sub_res)) {
1710 /* Not relevant */
1711 continue;
1712 }
1713
1714 /* The action has this sub result. Check its hard requirements. */
1717 if (out != NULL) {
1718 return out;
1719 }
1720 }
1721
1722 /* No obligatory req problems found. */
1723 return NULL;
1724}
1725
1726/**********************************************************************/
1732static struct requirement *
1734{
1736 if (preq->source.kind == VUT_DIPLREL
1737 && preq->range == REQ_RANGE_LOCAL) {
1738 return preq;
1739 }
1741
1742 return NULL;
1743}
1744
1745/**********************************************************************/
1751static struct req_vec_problem *
1753 const struct action_enabler *enabler)
1754{
1755 struct req_vec_problem *out;
1756 struct requirement *local_diplrel;
1757 struct requirement *claimed_req;
1761 struct astring astr;
1762
1764 /* Not tile targeted */
1765 return NULL;
1766 }
1767
1769 if (local_diplrel == NULL) {
1770 /* No local diplrel */
1771 return NULL;
1772 }
1773
1774 /* Tile is unclaimed as a requirement. */
1776 tile_is_unclaimed.survives = FALSE;
1777 tile_is_unclaimed.source.kind = VUT_CITYTILE;
1778 tile_is_unclaimed.present = FALSE;
1779 tile_is_unclaimed.source.value.citytile = CITYT_CLAIMED;
1780
1782 &enabler->target_reqs);
1783
1784 if (claimed_req) {
1785 /* Already clear */
1786 return NULL;
1787 }
1788
1789 /* Tile is claimed as a requirement. */
1791 tile_is_claimed.survives = FALSE;
1792 tile_is_claimed.source.kind = VUT_CITYTILE;
1793 tile_is_claimed.present = TRUE;
1794 tile_is_claimed.source.value.citytile = CITYT_CLAIMED;
1795
1797 1,
1798 /* TRANS: ruledit shows this when an enabler for a tile targeted
1799 * action requires that the actor has a diplomatic relationship to
1800 * the target but doesn't require that the target tile is claimed.
1801 * (DiplRel requirements to an unclaimed tile are never fulfilled
1802 * so this is implicit.) */
1803 N_("Requirement {%s} of action \"%s\" implies a claimed "
1804 "tile. No diplomatic relation to Nature."),
1806
1807 astr_free(&astr);
1808
1809 /* The solution is to add the requirement that the tile is claimed */
1810 out->suggested_solutions[0].req = tile_is_claimed;
1811 out->suggested_solutions[0].vector_number
1813 out->suggested_solutions[0].operation = RVCO_APPEND;
1814
1815 return out;
1816}
1817
1818/**********************************************************************/
1824static struct req_vec_problem *
1826{
1827 struct req_vec_problem *out;
1828 struct requirement *local_diplrel;
1829 struct requirement *unclaimed_req;
1832 struct astring astr1;
1833 struct astring astr2;
1834
1836 /* Not tile targeted */
1837 return NULL;
1838 }
1839
1841 if (local_diplrel == NULL) {
1842 /* No local diplrel */
1843 return NULL;
1844 }
1845
1846 /* Tile is claimed as a requirement. */
1848 tile_is_claimed.survives = FALSE;
1849 tile_is_claimed.source.kind = VUT_CITYTILE;
1850 tile_is_claimed.present = TRUE;
1851 tile_is_claimed.source.value.citytile = CITYT_CLAIMED;
1852
1854 &enabler->target_reqs);
1855
1856 if (unclaimed_req == NULL) {
1857 /* No unclaimed req */
1858 return NULL;
1859 }
1860
1862 2,
1863 /* TRANS: ruledit shows this when an enabler for a tile targeted
1864 * action requires that the target tile is unclaimed and that the
1865 * actor has a diplomatic relationship to the target. (DiplRel
1866 * requirements to an unclaimed tile are never fulfilled.) */
1867 N_("In enabler for \"%s\": No diplomatic relation to Nature."
1868 " Requirements {%s} and {%s} contradict each other."),
1872
1873 astr_free(&astr1);
1874 astr_free(&astr2);
1875
1876 /* The first suggestion is to remove the diplrel */
1877 out->suggested_solutions[0].req = *local_diplrel;
1878 out->suggested_solutions[0].vector_number
1880 out->suggested_solutions[0].operation = RVCO_REMOVE;
1881
1882 /* The 2nd is to remove the requirement that the tile is unclaimed */
1883 out->suggested_solutions[1].req = *unclaimed_req;
1884 out->suggested_solutions[1].vector_number
1886 out->suggested_solutions[1].operation = RVCO_REMOVE;
1887
1888 return out;
1889}
1890
1891/**********************************************************************/
1896struct req_vec_problem *
1898{
1899 struct req_vec_problem *out;
1900
1902 if (out != NULL) {
1903 return out;
1904 }
1905
1906 /* Look for errors in the requirement vectors. */
1907 out = req_vec_suggest_repair(&enabler->actor_reqs,
1909 enabler);
1910 if (out != NULL) {
1911 return out;
1912 }
1913
1914 out = req_vec_suggest_repair(&enabler->target_reqs,
1916 enabler);
1917 if (out != NULL) {
1918 return out;
1919 }
1920
1921 /* Enabler specific contradictions. */
1923 if (out != NULL) {
1924 return out;
1925 }
1926
1927 /* Needed in action not enabled explanation finding. */
1929 if (out != NULL) {
1930 return out;
1931 }
1932
1933 /* No problems found. */
1934 return NULL;
1935}
1936
1937/**********************************************************************/
1944static struct req_vec_problem *
1946{
1947 struct req_vec_problem *out;
1948
1949 out = NULL;
1950
1951 return out;
1952}
1953
1954/**********************************************************************/
1962struct req_vec_problem *
1964{
1965 struct action *paction;
1966 struct req_vec_problem *out;
1967
1969 if (out) {
1970 /* A bug, not just a potential improvement */
1971 return out;
1972 }
1973
1975
1976 /* Look for improvement suggestions to the requirement vectors. */
1979 enabler);
1980 if (out) {
1981 return out;
1982 }
1983 out = req_vec_suggest_improvement(&enabler->target_reqs,
1985 enabler);
1986 if (out) {
1987 return out;
1988 }
1989
1990 /* Detect unused action enablers. */
1992 bool has_user = FALSE;
1993
1997 &(enabler->actor_reqs))) {
1998 has_user = TRUE;
1999 break;
2000 }
2002
2003 if (!has_user) {
2004 /* TRANS: ruledit warns a user about an unused action enabler */
2005 out = req_vec_problem_new(0, N_("Action enabler for \"%s\" is never"
2006 " used by any unit."),
2008 }
2009 }
2010 if (out != NULL) {
2011 return out;
2012 }
2013
2015
2016 return out;
2017}
2018
2019/**********************************************************************/
2028 const struct requirement_vector *vec)
2029{
2030 struct action_enabler *ae = (struct action_enabler *)enabler;
2031
2032 if (vec == &ae->actor_reqs) {
2033 return 0;
2034 } else if (vec == &ae->target_reqs) {
2035 return 1;
2036 } else {
2037 return -1;
2038 }
2039}
2040
2041/********************************************************************/
2049struct requirement_vector *
2051 req_vec_num_in_item number)
2052{
2053 struct action_enabler *ae = (struct action_enabler *)enabler;
2054
2055 fc_assert_ret_val(number >= 0, NULL);
2056
2057 switch (number) {
2058 case 0:
2059 return &ae->actor_reqs;
2060 case 1:
2061 return &ae->target_reqs;
2062 default:
2063 return NULL;
2064 }
2065}
2066
2067/*********************************************************************/
2075{
2076 switch (vec) {
2077 case 0:
2078 /* TRANS: requirement vector in an action enabler (ruledit) */
2079 return _("actor_reqs");
2080 case 1:
2081 /* TRANS: requirement vector in an action enabler (ruledit) */
2082 return _("target_reqs");
2083 default:
2084 return NULL;
2085 }
2086}
2087
2088/**********************************************************************/
2093static const struct impr_type *
2095{
2096 /* Only used with city targets */
2098
2099 if (target_city->production.kind == VUT_IMPROVEMENT) {
2100 /* The local building is what the target city currently is building. */
2101 return target_city->production.value.building;
2102 } else {
2103 /* In the current semantic the local building is always the building
2104 * being built. */
2105 /* TODO: Consider making the local building the target building for
2106 * actions that allows specifying a building target. */
2107 return NULL;
2108 }
2109}
2110
2111/**********************************************************************/
2116static const struct unit_type *
2118{
2119 /* Only used with city targets */
2121
2122 if (target_city->production.kind == VUT_UTYPE) {
2123 /* The local unit type is what the target city currently is
2124 * building. */
2125 return target_city->production.value.utype;
2126 } else {
2127 /* In the current semantic the local utype is always the type of the
2128 * unit being built. */
2129 return NULL;
2130 }
2131}
2132
2133/**********************************************************************/
2141static const struct tile *
2143 const struct unit *actor_unit,
2144 const struct tile *target_tile_arg,
2145 const struct city *target_city,
2146 const struct unit *target_unit)
2147{
2148 if (target_tile_arg != NULL) {
2149 /* Trust the caller. */
2150 return target_tile_arg;
2151 }
2152
2153 /* Action should always be set */
2154 fc_assert_ret_val(act, NULL);
2155
2156 switch (action_get_target_kind(act)) {
2157 case ATK_CITY:
2159 return city_tile(target_city);
2160 case ATK_UNIT:
2161 if (target_unit == NULL) {
2163 return NULL;
2164 }
2165 return unit_tile(target_unit);
2166 case ATK_STACK:
2168 if (target_unit) {
2169 return unit_tile(target_unit);
2170 }
2171
2173 case ATK_TILE:
2174 case ATK_EXTRAS:
2176 return target_tile_arg;
2177 case ATK_SELF:
2178 if (actor_unit != nullptr) {
2179 return unit_tile(actor_unit);
2180 }
2181 return nullptr;
2182 case ATK_COUNT:
2183 /* Handled below. */
2184 break;
2185 }
2186
2187 fc_assert_msg(FALSE, "Bad action target kind %d for action %s",
2189 return nullptr;
2190}
2191
2192/**********************************************************************/
2201static const struct city *
2203 const struct unit *actor_unit,
2204 const struct tile *target_tile,
2205 const struct city *target_city_arg,
2206 const struct unit *target_unit)
2207{
2208 if (target_city_arg != NULL) {
2209 /* Trust the caller. */
2210 return target_city_arg;
2211 }
2212
2213 /* action should always be set */
2214 fc_assert_ret_val(act, NULL);
2215
2216 switch (action_get_target_kind(act)) {
2217 case ATK_CITY:
2219 return target_city_arg;
2220 case ATK_UNIT:
2224 case ATK_STACK:
2226 if (target_unit) {
2229 }
2230
2232 case ATK_TILE:
2233 case ATK_EXTRAS:
2235 return tile_city(target_tile);
2236 case ATK_SELF:
2237 if (actor_unit != nullptr) {
2238 struct tile *ptile = unit_tile(actor_unit);
2239
2240 if (ptile != nullptr) {
2241 return tile_city(ptile);
2242 }
2243 }
2244 return nullptr;
2245 case ATK_COUNT:
2246 /* Handled below. */
2247 break;
2248 }
2249
2250 fc_assert_msg(FALSE, "Bad action target kind %d for action %s",
2252 return NULL;
2253}
2254
2255/**********************************************************************/
2262 const struct action *act,
2263 const struct unit *actor_unit,
2264 const struct tile *target_tile_arg,
2265 const struct city *target_city_arg,
2266 const struct unit *target_unit)
2267{
2268 const struct tile *target_tile
2271 const struct city *target_city
2274
2276 struct action *blocker = action_by_number(blocker_id);
2277
2278 if (action_get_actor_kind(blocker) != AAK_UNIT) {
2279 /* Currently, only unit's actions may block each other */
2280 continue;
2281 }
2282
2283 if (!action_would_be_blocked_by(act, blocker)) {
2284 /* It doesn't matter if it is legal. It won't block the action. */
2285 continue;
2286 }
2287
2288 switch (action_get_target_kind(blocker)) {
2289 case ATK_CITY:
2290 if (!target_city) {
2291 /* Can't be enabled. No target. */
2292 continue;
2293 }
2296 return blocker;
2297 }
2298 break;
2299 case ATK_UNIT:
2300 if (!target_unit) {
2301 /* Can't be enabled. No target. */
2302 continue;
2303 }
2306 return blocker;
2307 }
2308 break;
2309 case ATK_STACK:
2310 if (!target_tile) {
2311 /* Can't be enabled. No target. */
2312 continue;
2313 }
2316 return blocker;
2317 }
2318 break;
2319 case ATK_TILE:
2320 if (!target_tile) {
2321 /* Can't be enabled. No target. */
2322 continue;
2323 }
2326 return blocker;
2327 }
2328 break;
2329 case ATK_EXTRAS:
2330 if (!target_tile) {
2331 /* Can't be enabled. No target. */
2332 continue;
2333 }
2336 return blocker;
2337 }
2338 break;
2339 case ATK_SELF:
2341 return blocker;
2342 }
2343 break;
2344 case ATK_COUNT:
2346 continue);
2347 break;
2348 }
2350
2351 /* Not blocked. */
2352 return NULL;
2353}
2354
2355/**********************************************************************/
2375static bool
2377 const struct unit_type *actor_unittype,
2378 bool ignore_third_party)
2379{
2380 switch (paction->result) {
2381 case ACTRES_JOIN_CITY:
2382 if (actor_unittype->pop_cost <= 0) {
2383 /* Reason: Must have population to add. */
2384 return FALSE;
2385 }
2386 break;
2387
2388 case ACTRES_BOMBARD:
2389 if (actor_unittype->bombard_rate <= 0) {
2390 /* Reason: Can't bombard if it never fires. */
2391 return FALSE;
2392 }
2393
2394 if (actor_unittype->attack_strength <= 0) {
2395 /* Reason: Can't bombard without attack strength. */
2396 return FALSE;
2397 }
2398
2399 break;
2400
2402 if (actor_unittype->obsoleted_by == U_NOT_OBSOLETED) {
2403 /* Reason: Nothing to upgrade to. */
2404 return FALSE;
2405 }
2406 break;
2407
2408 case ACTRES_ATTACK:
2409 case ACTRES_WIPE_UNITS:
2411 if (actor_unittype->attack_strength <= 0) {
2412 /* Reason: Can't attack without strength. */
2413 return FALSE;
2414 }
2415 break;
2416
2417 case ACTRES_CONVERT:
2418 if (!actor_unittype->converted_to) {
2419 /* Reason: must be able to convert to something. */
2420 return FALSE;
2421 }
2422 break;
2423
2425 if (actor_unittype->transport_capacity < 1) {
2426 /* Reason: can't transport anything to unload. */
2427 return FALSE;
2428 }
2429 break;
2430
2432 if (actor_unittype->transport_capacity < 1) {
2433 /* Reason: can't transport anything to load. */
2434 return FALSE;
2435 }
2436 break;
2437
2442 if (!ignore_third_party) {
2443 bool has_transporter = FALSE;
2444
2448 break;
2449 }
2451
2452 if (!has_transporter) {
2453 /* Reason: no other unit can transport this unit. */
2454 return FALSE;
2455 }
2456 }
2457 break;
2458
2460 if (!ignore_third_party) {
2461 bool has_target = FALSE;
2463
2464 /* Use cache when it has been initialized */
2465 if (pclass->cache.native_bases != NULL) {
2466 /* Extra being native one is a hard requirement */
2467 extra_type_list_iterate(pclass->cache.native_bases, pextra) {
2468 if (!territory_claiming_base(pextra->data.base)) {
2469 /* Hard requirement */
2470 continue;
2471 }
2472
2473 has_target = TRUE;
2474 break;
2476 } else {
2478
2480 if (!is_native_extra_to_uclass(pextra, pclass)) {
2481 /* Hard requirement */
2482 continue;
2483 }
2484
2485 has_target = TRUE;
2486 break;
2488 }
2489
2490 if (!has_target) {
2491 /* Reason: no extras can be conquered by this unit. */
2492 return FALSE;
2493 }
2494 }
2495 break;
2496
2497 case ACTRES_PARADROP:
2499 if (actor_unittype->paratroopers_range <= 0) {
2500 /* Reason: Can't paradrop 0 tiles. */
2501 return FALSE;
2502 }
2503 break;
2504
2505 case ACTRES_HUT_ENTER:
2509 case ACTRES_SPY_POISON:
2518 case ACTRES_SPY_ESCAPE:
2519 case ACTRES_TRADE_ROUTE:
2520 case ACTRES_MARKETPLACE:
2521 case ACTRES_HELP_WONDER:
2526 case ACTRES_FOUND_CITY:
2527 case ACTRES_STEAL_MAPS:
2528 case ACTRES_SPY_NUKE:
2529 case ACTRES_NUKE:
2530 case ACTRES_NUKE_UNITS:
2532 case ACTRES_EXPEL_UNIT:
2535 case ACTRES_HOME_CITY:
2536 case ACTRES_HOMELESS:
2537 case ACTRES_AIRLIFT:
2541 case ACTRES_HEAL_UNIT:
2542 case ACTRES_PILLAGE:
2543 case ACTRES_CLEAN:
2544 case ACTRES_FORTIFY:
2546 case ACTRES_CULTIVATE:
2547 case ACTRES_PLANT:
2548 case ACTRES_ROAD:
2549 case ACTRES_BASE:
2550 case ACTRES_MINE:
2551 case ACTRES_IRRIGATE:
2552 case ACTRES_SPY_ATTACK:
2553 case ACTRES_UNIT_MOVE:
2554 case ACTRES_TELEPORT:
2557 case ACTRES_NONE:
2558 /* No hard unit type requirements. */
2559 break;
2560
2562 }
2563
2564 return TRUE;
2565}
2566
2567/**********************************************************************/
2583bool
2590
2591/**********************************************************************/
2603static enum fc_tristate
2605 const struct action *paction,
2606 const struct req_context *actor,
2607 const bool omniscient,
2608 const struct city *homecity)
2609{
2610 enum action_result result = paction->result;
2611
2612 if (actor == NULL) {
2614 }
2615
2617 TRUE)) {
2618 /* Info leak: The actor player knows the type of their unit. */
2619 /* The actor unit type can't perform the action because of hard
2620 * unit type requirements. */
2621 return TRI_NO;
2622 }
2623
2624 switch (result) {
2625 case ACTRES_PARADROP:
2627 /* Reason: Keep the old rules. */
2628 /* Info leak: The player knows if their unit already has paradropped this
2629 * turn. */
2630 if (actor->unit->paradropped) {
2631 return TRI_NO;
2632 }
2633
2634 break;
2635
2636 case ACTRES_AIRLIFT:
2637 {
2638 /* Obligatory hard requirement. Checked here too since
2639 * action_hard_reqs_actor() may be called before any
2640 * action enablers are checked. */
2641 if (actor->city == NULL) {
2642 /* No city to airlift from. */
2643 return TRI_NO;
2644 }
2645
2646 if (actor->player != city_owner(actor->city)
2648 && pplayers_allied(actor->player,
2649 city_owner(actor->city)))) {
2650 /* Not allowed to airlift from this source. */
2651 return TRI_NO;
2652 }
2653
2654 if (!(omniscient || city_owner(actor->city) == actor->player)) {
2655 /* Can't check for airlifting capacity. */
2656 return TRI_MAYBE;
2657 }
2658
2659 if (0 >= actor->city->airlift
2662 /* The source cannot airlift for this turn (maybe already airlifted
2663 * or no airport).
2664 *
2665 * See also do_airline() in server/unittools.h. */
2666 return TRI_NO;
2667 }
2668 }
2669 break;
2670
2671 case ACTRES_CONVERT:
2672 /* Reason: Keep the old rules. */
2673 /* Info leak: The player knows their unit's cargo and location. */
2674 if (!unit_can_convert(nmap, actor->unit)) {
2675 return TRI_NO;
2676 }
2677 break;
2678
2681 if (unit_transported(actor->unit)) {
2682 if (!can_unit_unload(actor->unit, unit_transport_get(actor->unit))) {
2683 /* Can't leave current transport. */
2684 return TRI_NO;
2685 }
2686 }
2687 break;
2688
2690 if (!can_unit_unload(actor->unit, unit_transport_get(actor->unit))) {
2691 /* Keep the old rules about Unreachable and disembarks. */
2692 return TRI_NO;
2693 }
2694 break;
2695
2696 case ACTRES_HOMELESS:
2697 case ACTRES_UNIT_MOVE:
2698 case ACTRES_TELEPORT:
2702 case ACTRES_SPY_POISON:
2711 case ACTRES_SPY_ESCAPE:
2712 case ACTRES_TRADE_ROUTE:
2713 case ACTRES_MARKETPLACE:
2714 case ACTRES_HELP_WONDER:
2719 case ACTRES_FOUND_CITY:
2720 case ACTRES_JOIN_CITY:
2721 case ACTRES_STEAL_MAPS:
2722 case ACTRES_BOMBARD:
2723 case ACTRES_SPY_NUKE:
2724 case ACTRES_NUKE:
2725 case ACTRES_NUKE_UNITS:
2727 case ACTRES_EXPEL_UNIT:
2730 case ACTRES_HOME_CITY:
2732 case ACTRES_ATTACK:
2733 case ACTRES_WIPE_UNITS:
2739 case ACTRES_HEAL_UNIT:
2741 case ACTRES_CULTIVATE:
2742 case ACTRES_PLANT:
2743 case ACTRES_PILLAGE:
2744 case ACTRES_CLEAN:
2745 case ACTRES_FORTIFY:
2746 case ACTRES_ROAD:
2747 case ACTRES_BASE:
2748 case ACTRES_MINE:
2749 case ACTRES_IRRIGATE:
2753 case ACTRES_SPY_ATTACK:
2754 case ACTRES_HUT_ENTER:
2757 case ACTRES_NONE:
2758 /* No hard unit requirements. */
2759 break;
2760
2762 }
2763
2764 return TRI_YES;
2765}
2766
2767/**********************************************************************/
2790static enum fc_tristate
2793 const struct req_context *actor,
2794 const struct req_context *target,
2795 const struct extra_type *target_extra,
2796 const bool omniscient,
2797 const struct city *homecity)
2798{
2799 enum fc_tristate out;
2802
2803 if (actor == NULL) {
2805 }
2806 if (target == NULL) {
2807 target = req_context_empty();
2808 }
2809
2810 fc_assert_msg((tkind == ATK_CITY && target->city != NULL)
2811 || (tkind == ATK_TILE && target->tile != NULL)
2812 || (tkind == ATK_EXTRAS && target->tile != NULL)
2813 || (tkind == ATK_UNIT && target->unit != NULL)
2814 /* At this level each individual unit is tested. */
2815 || (tkind == ATK_STACK && target->unit != NULL)
2816 || (tkind == ATK_SELF),
2817 "Missing target!");
2818
2819 /* Info leak: The player knows where their unit is. */
2820 if (tkind != ATK_SELF
2823 target->tile))) {
2824 /* The distance between the actor and the target isn't inside the
2825 * action's accepted range. */
2826 return TRI_NO;
2827 }
2828
2829 switch (tkind) {
2830 case ATK_UNIT:
2831 /* The Freeciv code for all actions that is controlled by action
2832 * enablers and targets a unit assumes that the acting
2833 * player can see the target unit.
2834 * Examples:
2835 * - action_prob_vs_unit()'s quick check that the distance between actor
2836 * and target is acceptable would leak distance to target unit if the
2837 * target unit can't be seen.
2838 */
2839 if (!can_player_see_unit(actor->player, target->unit)) {
2840 return TRI_NO;
2841 }
2842 break;
2843 case ATK_CITY:
2844 /* The Freeciv code assumes that the player is aware of the target
2845 * city's existence. (How can you order an airlift to a city when you
2846 * don't know its city ID?) */
2848 actor->player)
2849 != target->city->id) {
2850 return TRI_NO;
2851 }
2852 break;
2853 case ATK_STACK:
2854 case ATK_TILE:
2855 case ATK_EXTRAS:
2856 case ATK_SELF:
2857 /* No special player knowledge checks. */
2858 break;
2859 case ATK_COUNT:
2861 break;
2862 }
2863
2865 target->tile, target->city, target->unit)) {
2866 /* Allows an action to block an other action. If a blocking action is
2867 * legal the actions it blocks becomes illegal. */
2868 return TRI_NO;
2869 }
2870
2871 /* Actor specific hard requirements. */
2873
2874 if (out == TRI_NO) {
2875 /* Illegal because of a hard actor requirement. */
2876 return TRI_NO;
2877 }
2878
2879 /* Quick checks for action itself */
2880 if (paction->result == ACTRES_ATTACK
2881 || paction->result == ACTRES_WIPE_UNITS
2882 || paction->result == ACTRES_COLLECT_RANSOM) {
2883 /* Reason: Keep the old rules. */
2884 if (!can_unit_attack_tile(actor->unit, paction, target->tile)) {
2885 return TRI_NO;
2886 }
2887 }
2888
2889 /* Hard requirements for results. */
2891 paction->result, actor,
2892 target, target_extra, out, omniscient,
2893 homecity);
2894
2895 if (out == TRI_NO) {
2896 /* Illegal because of a hard actor requirement. */
2897 return TRI_NO;
2898 }
2899
2900 if (paction->result == ACTRES_NUKE_UNITS) {
2902 target->tile)
2903 != ATT_OK) {
2904 /* Unreachable. */
2905 return TRI_NO;
2906 }
2907 } else if (paction->result == ACTRES_PARADROP
2908 || paction->result == ACTRES_PARADROP_CONQUER) {
2909 if (can_player_see_tile(actor->player, target->tile)) {
2910 /* Check for seen stuff that may kill the actor unit. */
2911
2912 /* Reason: Keep the old rules. Be merciful. */
2913 /* Info leak: The player sees the target tile. */
2914 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)
2915 && (!BV_ISSET(paction->sub_results, ACT_SUB_RES_MAY_EMBARK)
2916 || !unit_could_load_at(actor->unit, target->tile))) {
2917 return TRI_NO;
2918 }
2919
2920 /* Reason: Keep the old rules. Be merciful. */
2921 /* Info leak: The player sees the target tile. */
2922 if (is_non_attack_city_tile(target->tile, actor->player)) {
2923 return TRI_NO;
2924 }
2925
2926 /* Reason: Be merciful. */
2927 /* Info leak: The player sees all units checked. Invisible units are
2928 * ignored. */
2929 unit_list_iterate(target->tile->units, pother) {
2930 if (can_player_see_unit(actor->player, pother)
2931 && !pplayers_allied(actor->player, unit_owner(pother))) {
2932 return TRI_NO;
2933 }
2935 }
2936 }
2937
2938 return out;
2939}
2940
2941/**********************************************************************/
2947static bool is_enabler_active(const struct action_enabler *enabler,
2948 const struct req_context *actor,
2949 const struct req_context *target)
2950{
2951 return are_reqs_active(actor, target, &enabler->actor_reqs, RPT_CERTAIN)
2952 && are_reqs_active(target, actor, &enabler->target_reqs, RPT_CERTAIN);
2953}
2954
2955/**********************************************************************/
2964static bool is_action_enabled(const struct civ_map *nmap,
2966 const struct req_context *actor,
2967 const struct req_context *target,
2968 const struct extra_type *target_extra,
2969 const struct city *actor_home)
2970{
2971 enum fc_tristate possible;
2972
2974 TRUE, actor_home);
2975
2976 if (possible != TRI_YES) {
2977 /* This context is omniscient. Should be yes or no. */
2979 "Is omniscient, should get yes or no.");
2980
2981 /* The action enablers are irrelevant since the action it self is
2982 * impossible. */
2983 return FALSE;
2984 }
2985
2987 enabler) {
2988 if (is_enabler_active(enabler, actor, target)) {
2989 return TRUE;
2990 }
2992
2993 return FALSE;
2994}
2995
2996/**********************************************************************/
3002static bool
3005 const struct unit *actor_unit,
3006 const struct city *actor_home,
3007 const struct tile *actor_tile,
3008 const struct city *target_city)
3009{
3010 const struct impr_type *target_building;
3011 const struct unit_type *target_utype;
3012
3013 if (actor_unit == NULL || target_city == NULL) {
3014 /* Can't do an action when actor or target are missing. */
3015 return FALSE;
3016 }
3017
3019 FALSE, "Action %s is performed by %s not %s",
3024
3027 FALSE, "Action %s is against %s not %s",
3032
3034
3036 /* No point in continuing. */
3037 return FALSE;
3038 }
3039
3042
3044 &(const struct req_context) {
3045 .player = unit_owner(actor_unit),
3046 .city = tile_city(actor_tile),
3047 .tile = actor_tile,
3048 .unit = actor_unit,
3049 .unittype = unit_type_get(actor_unit),
3050 },
3051 &(const struct req_context) {
3052 .player = city_owner(target_city),
3053 .city = target_city,
3054 .building = target_building,
3056 .unittype = target_utype,
3057 },
3058 NULL,
3059 actor_home);
3060}
3061
3062/**********************************************************************/
3078
3079/**********************************************************************/
3085static bool
3088 const struct unit *actor_unit,
3089 const struct city *actor_home,
3090 const struct tile *actor_tile,
3091 const struct unit *target_unit)
3092{
3093 if (actor_unit == NULL || target_unit == NULL) {
3094 /* Can't do an action when actor or target are missing. */
3095 return FALSE;
3096 }
3097
3099 FALSE, "Action %s is performed by %s not %s",
3104
3107 FALSE, "Action %s is against %s not %s",
3112
3114
3116 /* No point in continuing. */
3117 return FALSE;
3118 }
3119
3121 &(const struct req_context) {
3122 .player = unit_owner(actor_unit),
3123 .city = tile_city(actor_tile),
3124 .tile = actor_tile,
3125 .unit = actor_unit,
3126 .unittype = unit_type_get(actor_unit),
3127 },
3128 &(const struct req_context) {
3129 .player = unit_owner(target_unit),
3132 .unit = target_unit,
3133 .unittype = unit_type_get(target_unit),
3134 },
3135 NULL,
3136 actor_home);
3137}
3138
3139/**********************************************************************/
3155
3156/**********************************************************************/
3162static bool
3165 const struct unit *actor_unit,
3166 const struct city *actor_home,
3167 const struct tile *actor_tile,
3168 const struct tile *target_tile)
3169{
3170 const struct req_context *actor_ctxt;
3171
3172 if (actor_unit == NULL || target_tile == NULL
3173 || unit_list_size(target_tile->units) == 0) {
3174 /* Can't do an action when actor or target are missing. */
3175 return FALSE;
3176 }
3177
3179 FALSE, "Action %s is performed by %s not %s",
3184
3187 FALSE, "Action %s is against %s not %s",
3192
3194
3196 /* No point in continuing. */
3197 return FALSE;
3198 }
3199
3200 actor_ctxt = &(const struct req_context) {
3201 .player = unit_owner(actor_unit),
3202 .city = tile_city(actor_tile),
3203 .tile = actor_tile,
3204 .unit = actor_unit,
3205 .unittype = unit_type_get(actor_unit),
3206 };
3207
3210 &(const struct req_context) {
3211 .player = unit_owner(target_unit),
3214 .unit = target_unit,
3215 .unittype = unit_type_get(target_unit),
3216 },
3217 NULL, actor_home)) {
3218 /* One unit makes it impossible for all units. */
3219 return FALSE;
3220 }
3222
3223 /* Not impossible for any of the units at the tile. */
3224 return TRUE;
3225}
3226
3227/**********************************************************************/
3243
3244/**********************************************************************/
3250static bool
3253 const struct unit *actor_unit,
3254 const struct city *actor_home,
3255 const struct tile *actor_tile,
3256 const struct tile *target_tile,
3257 const struct extra_type *target_extra)
3258{
3259 if (actor_unit == NULL || target_tile == NULL) {
3260 /* Can't do an action when actor or target are missing. */
3261 return FALSE;
3262 }
3263
3265 FALSE, "Action %s is performed by %s not %s",
3270
3273 FALSE, "Action %s is against %s not %s",
3278
3280
3282 /* No point in continuing. */
3283 return FALSE;
3284 }
3285
3287 &(const struct req_context) {
3288 .player = unit_owner(actor_unit),
3289 .city = tile_city(actor_tile),
3290 .tile = actor_tile,
3291 .unit = actor_unit,
3292 .unittype = unit_type_get(actor_unit),
3293 },
3294 &(const struct req_context) {
3295 .player = tile_owner(target_tile),
3296 .city = tile_city(target_tile),
3297 .tile = target_tile,
3298 },
3300 actor_home);
3301}
3302
3303/**********************************************************************/
3311 const struct unit *actor_unit,
3312 const struct tile *target_tile,
3313 const struct extra_type *target_extra)
3314{
3319}
3320
3321/**********************************************************************/
3327static bool
3330 const struct unit *actor_unit,
3331 const struct city *actor_home,
3332 const struct tile *actor_tile,
3333 const struct tile *target_tile,
3334 const struct extra_type *target_extra)
3335{
3336 if (actor_unit == NULL || target_tile == NULL) {
3337 /* Can't do an action when actor or target are missing. */
3338 return FALSE;
3339 }
3340
3342 FALSE, "Action %s is performed by %s not %s",
3347
3350 FALSE, "Action %s is against %s not %s",
3355
3357
3359 /* No point in continuing. */
3360 return FALSE;
3361 }
3362
3364 &(const struct req_context) {
3365 .player = unit_owner(actor_unit),
3366 .city = tile_city(actor_tile),
3367 .tile = actor_tile,
3368 .unit = actor_unit,
3369 .unittype = unit_type_get(actor_unit),
3370 },
3371 &(const struct req_context) {
3372 .player = target_tile->extras_owner,
3373 .city = tile_city(target_tile),
3374 .tile = target_tile,
3375 },
3377 actor_home);
3378}
3379
3380/**********************************************************************/
3397
3398/**********************************************************************/
3405static bool
3408 const struct unit *actor_unit,
3409 const struct city *actor_home,
3410 const struct tile *actor_tile)
3411{
3412 if (actor_unit == NULL) {
3413 /* Can't do an action when the actor is missing. */
3414 return FALSE;
3415 }
3416
3418 FALSE, "Action %s is performed by %s not %s",
3423
3426 FALSE, "Action %s is against %s not %s",
3431
3433
3435 /* No point in continuing. */
3436 return FALSE;
3437 }
3438
3440 &(const struct req_context) {
3441 .player = unit_owner(actor_unit),
3442 .city = tile_city(actor_tile),
3443 .tile = actor_tile,
3444 .unit = actor_unit,
3445 .unittype = unit_type_get(actor_unit),
3446 },
3447 NULL, NULL,
3448 actor_home);
3449}
3450
3451/**********************************************************************/
3466
3467/**********************************************************************/
3473 const struct player *actor_plr)
3474{
3476 &(const struct req_context) {
3477 .player = actor_plr,
3478 },
3479 nullptr, nullptr, nullptr);
3480}
3481
3482/**********************************************************************/
3500static enum fc_tristate
3502 const struct req_context *actor,
3503 const struct req_context *target)
3504{
3505 enum fc_tristate current;
3506 enum fc_tristate result;
3507
3508 if (actor == NULL || actor->player == NULL) {
3509 /* Need actor->player for point of view */
3510 return TRI_MAYBE;
3511 }
3512
3513 if (target == NULL) {
3514 target = req_context_empty();
3515 }
3516
3517 result = TRI_NO;
3519 enabler) {
3520 current = fc_tristate_and(mke_eval_reqs(actor->player,
3521 actor, target,
3522 &enabler->actor_reqs,
3523 RPT_CERTAIN),
3524 mke_eval_reqs(actor->player,
3525 target, actor,
3526 &enabler->target_reqs,
3527 RPT_CERTAIN));
3528 if (current == TRI_YES) {
3529 return TRI_YES;
3530 } else if (current == TRI_MAYBE) {
3531 result = TRI_MAYBE;
3532 }
3534
3535 return result;
3536}
3537
3538/**********************************************************************/
3548static bool is_effect_val_known(enum effect_type effect_type,
3549 const struct player *pov_player,
3550 const struct req_context *context,
3551 const struct req_context *other_context)
3552{
3553 effect_list_iterate(get_effects(effect_type), peffect) {
3555 &(peffect->reqs), RPT_CERTAIN)) {
3556 return FALSE;
3557 }
3559
3560 return TRUE;
3561}
3562
3563/**********************************************************************/
3566static enum fc_tristate
3594
3595/**********************************************************************/
3604 const struct unit *pdefender)
3605{
3606 /* Keep unconverted until the end to avoid scaling each step */
3607 int chance;
3608 struct act_prob out;
3609
3610 /* Superspy always win */
3612 /* A defending UTYF_SUPERSPY will defeat every possible attacker. */
3613 return ACTPROB_IMPOSSIBLE;
3614 }
3616 /* An attacking UTYF_SUPERSPY will defeat every possible defender
3617 * except another UTYF_SUPERSPY. */
3618 return ACTPROB_CERTAIN;
3619 }
3620
3621 /* Base chance is 50% */
3622 chance = 50;
3623
3624 /* Spy attack bonus */
3626 chance += 25;
3627 }
3628
3629 /* Spy defense bonus */
3631 chance -= 25;
3632 }
3633
3634 /* Veteran attack and defense bonus */
3635 {
3636 const struct veteran_level *vatt
3638 const struct veteran_level *vdef
3640
3641 chance += vatt->power_fact - vdef->power_fact;
3642 }
3643
3644 /* Defense bonus. */
3645 {
3646 const struct req_context defender_ctxt = {
3647 .player = tile_owner(pdefender->tile),
3648 .city = tile_city(pdefender->tile),
3649 .tile = pdefender->tile,
3650 };
3653 NULL)) {
3654 return ACTPROB_NOT_KNOWN;
3655 }
3656
3657 /* Reduce the chance of an attack by EFT_SPY_RESISTANT percent. */
3659 NULL,
3661 NULL,
3663 ) / 100;
3664 }
3665
3666 chance = CLIP(0, chance, 100);
3667
3668 /* Convert to action probability */
3671
3672 return out;
3673}
3674
3675/**********************************************************************/
3681 const struct unit *pvictim,
3682 const struct tile *tgt_tile,
3683 const struct action *paction)
3684{
3685 struct unit *pdefender;
3686
3688 tgt_tile)) {
3689 /* Don't leak information about unseen defenders. */
3690 return ACTPROB_NOT_KNOWN;
3691 }
3692
3694 paction);
3695
3696 if (pdefender) {
3697 /* There will be a diplomatic battle instead of an action. */
3699 };
3700
3701 /* No diplomatic battle will occur. */
3702 return ACTPROB_CERTAIN;
3703}
3704
3705/**********************************************************************/
3709 action_id act_id,
3710 const struct unit *actor_unit)
3711{
3713 /* Unknown because the target is unseen. */
3714 return ACTPROB_NOT_KNOWN;
3715 } else {
3716 /* The actor it self can't do this. */
3717 return ACTPROB_IMPOSSIBLE;
3718 }
3719}
3720
3721/**********************************************************************/
3725static struct act_prob
3727 const struct unit *act_unit,
3728 const struct city *tgt_city,
3729 const struct player *tgt_player,
3730 const struct action *paction)
3731{
3733 &(const struct req_context) {
3734 .player = act_player,
3735 .city = tgt_city,
3736 .unit = act_unit,
3737 .unittype = unit_type_get(act_unit),
3738 },
3739 &(const struct req_context) {
3740 .player = tgt_player,
3741 })
3743 &(const struct req_context) {
3744 .player = tgt_player,
3745 .city = tgt_city,
3746 .unit = act_unit,
3747 },
3748 &(const struct req_context) {
3749 .player = act_player,
3750 })) {
3753 struct act_prob result = { .min = unconverted * ACTPROB_VAL_1_PCT,
3754 .max = unconverted * ACTPROB_VAL_1_PCT };
3755
3756 return result;
3757 } else {
3758 /* Could be improved to return a more exact probability in some cases.
3759 * Example: The player has enough information to know that the
3760 * probability always will be above 25% and always under 75% because
3761 * the only effect with unknown requirements that may apply adds (or
3762 * subtracts) 50% while all the requirements of the other effects that
3763 * may apply are known. */
3764 return ACTPROB_NOT_KNOWN;
3765 }
3766}
3767
3768/**********************************************************************/
3773static struct act_prob
3775 const struct unit *act_unit,
3776 const struct city *tgt_city,
3777 const struct unit *tgt_unit,
3778 const struct tile *tgt_tile,
3779 const struct player *tgt_player,
3780 const struct action *paction)
3781{
3782 struct act_prob battle;
3783 struct act_prob dice_roll;
3784
3785 battle = ACTPROB_CERTAIN;
3786 switch (actres_get_battle_kind(paction->result)) {
3787 case ABK_NONE:
3788 /* No pre action battle. */
3789 break;
3790 case ABK_DIPLOMATIC:
3792 paction);
3793 break;
3794 case ABK_STANDARD:
3795 /* Not supported here yet. Implement when users appear. */
3797 break;
3798 case ABK_COUNT:
3800 break;
3801 }
3802
3805 paction);
3806
3807 return action_prob_and(&battle, &dice_roll);
3808}
3809
3810/**********************************************************************/
3821static struct act_prob
3824 const struct req_context *actor,
3825 const struct city *actor_home,
3826 const struct req_context *target,
3827 const struct extra_type *target_extra)
3828{
3829 enum fc_tristate known;
3830 struct act_prob chance;
3832
3833 if (actor == NULL) {
3835 }
3836 if (target == NULL) {
3837 target = req_context_empty();
3838 }
3839
3840 known = is_action_possible(nmap, wanted_action, actor, target,
3842 FALSE, actor_home);
3843
3844 if (known == TRI_NO) {
3845 /* The action enablers are irrelevant since the action it self is
3846 * impossible. */
3847 return ACTPROB_IMPOSSIBLE;
3848 }
3849
3851
3852 known = fc_tristate_and(known,
3854 actor, target));
3855
3856 switch (paction->result) {
3857 case ACTRES_SPY_POISON:
3858 /* All uncertainty comes from potential diplomatic battles and the
3859 * (diplchance server setting and the) Action_Odds_Pct effect controlled
3860 * dice roll before the action. */
3862 target->city, target->unit,
3863 target->tile, target->player,
3864 paction);
3865 break;
3867 /* TODO */
3868 break;
3870 /* TODO */
3871 break;
3872 case ACTRES_STEAL_MAPS:
3873 /* TODO */
3874 break;
3876 /* All uncertainty comes from potential diplomatic battles. */
3877 chance = ap_diplomat_battle(actor->unit, target->unit, target->tile,
3878 paction);
3879 break;
3882 /* All uncertainty comes from potential diplomatic battles. */
3883 chance = ap_diplomat_battle(actor->unit, target->unit, target->tile,
3884 paction);
3885 break;
3886 case ACTRES_SPY_ATTACK:
3887 /* All uncertainty comes from potential diplomatic battles. */
3888 chance = ap_diplomat_battle(actor->unit, NULL, target->tile,
3889 paction);
3890 break;
3892 /* TODO */
3893 break;
3895 /* TODO */
3896 break;
3898 /* TODO */
3899 break;
3901 /* TODO */
3902 break;
3905 break;
3907 /* Do the victim have anything worth taking? */
3908 known = fc_tristate_and(known,
3909 tech_can_be_stolen(actor->player,
3910 target->player));
3911
3912 /* TODO: Calculate actual chance */
3913
3914 break;
3916 /* Do the victim have anything worth taking? */
3917 known = fc_tristate_and(known,
3918 tech_can_be_stolen(actor->player,
3919 target->player));
3920
3921 /* TODO: Calculate actual chance */
3922
3923 break;
3925 /* There is no risk that the city won't get investigated. */
3927 break;
3928 case ACTRES_SPY_ESCAPE:
3929 /* TODO */
3930 break;
3931 case ACTRES_TRADE_ROUTE:
3932 /* TODO */
3933 break;
3934 case ACTRES_MARKETPLACE:
3935 /* Possible when not blocked by is_action_possible() */
3937 break;
3938 case ACTRES_HELP_WONDER:
3939 /* Possible when not blocked by is_action_possible() */
3941 break;
3943 /* No battle is fought first. */
3945 break;
3946 case ACTRES_EXPEL_UNIT:
3947 /* No battle is fought first. */
3949 break;
3950 case ACTRES_BOMBARD:
3951 /* No battle is fought first. */
3953 break;
3954 case ACTRES_FOUND_CITY:
3955 /* Possible when not blocked by is_action_possible() */
3957 break;
3958 case ACTRES_JOIN_CITY:
3959 /* Possible when not blocked by is_action_possible() */
3961 break;
3962 case ACTRES_SPY_NUKE:
3963 /* All uncertainty comes from potential diplomatic battles and the
3964 * (diplchance server setting and the) Action_Odds_Pct effect controlled
3965 * dice roll before the action. */
3967 target->city, target->unit,
3968 target->tile,
3969 target->player,
3970 paction);
3971 break;
3972 case ACTRES_NUKE:
3973 /* TODO */
3974 break;
3975 case ACTRES_NUKE_UNITS:
3976 /* TODO */
3977 break;
3979 /* No battle is fought first. */
3981 break;
3983 /* No battle is fought first. */
3985 break;
3987 /* No battle is fought first. */
3989 break;
3990 case ACTRES_HOME_CITY:
3991 /* No battle is fought first. */
3993 break;
3994 case ACTRES_HOMELESS:
3995 /* No battle is fought first. */
3997 break;
3999 /* No battle is fought first. */
4001 break;
4002 case ACTRES_PARADROP:
4004 /* TODO */
4005 break;
4006 case ACTRES_AIRLIFT:
4007 /* Possible when not blocked by is_action_possible() */
4009 break;
4010 case ACTRES_ATTACK:
4012 {
4013 struct unit *defender_unit = get_defender(nmap, actor->unit,
4014 target->tile, paction);
4015
4016 if (can_player_see_unit(actor->player, defender_unit)) {
4017 double unconverted = unit_win_chance(nmap, actor->unit,
4019
4021 floor((double)ACTPROB_VAL_MAX * unconverted));
4023 ceil((double)ACTPROB_VAL_MAX * unconverted));
4024 } else if (known == TRI_YES) {
4025 known = TRI_MAYBE;
4026 }
4027 }
4028 break;
4029 case ACTRES_WIPE_UNITS:
4031 break;
4033 /* TODO: not implemented yet because:
4034 * - dice roll 100% * Action_Odds_Pct could be handled with
4035 * action_prob_pre_action_dice_roll().
4036 * - sub target building may be missing. May be missing without player
4037 * knowledge if it isn't visible. See is_improvement_visible() and
4038 * can_player_see_city_internals(). */
4039 break;
4041 /* All uncertainty comes from the (diplchance server setting and the)
4042 * Action_Odds_Pct effect controlled dice roll before the action. */
4044 target->city, target->player,
4045 paction);
4046 break;
4048 /* No battle is fought first. */
4050 break;
4052 /* No battle is fought first. */
4054 break;
4055 case ACTRES_HEAL_UNIT:
4056 /* No battle is fought first. */
4058 break;
4060 case ACTRES_CULTIVATE:
4061 case ACTRES_PLANT:
4062 case ACTRES_PILLAGE:
4063 case ACTRES_CLEAN:
4064 case ACTRES_FORTIFY:
4065 case ACTRES_ROAD:
4066 case ACTRES_CONVERT:
4067 case ACTRES_BASE:
4068 case ACTRES_MINE:
4069 case ACTRES_IRRIGATE:
4071 break;
4074 break;
4077 break;
4080 break;
4083 break;
4086 break;
4089 break;
4090 case ACTRES_HUT_ENTER:
4092 /* Entering the hut happens with a probability of 100%. What happens
4093 * next is probably up to dice rolls in Lua. */
4095 break;
4096 case ACTRES_UNIT_MOVE:
4097 case ACTRES_TELEPORT:
4100 break;
4101 /* Not UI action, so chance is meaningless */
4104 break;
4105 case ACTRES_NONE:
4106 /* Accommodate ruleset authors that wishes to roll the dice in Lua.
4107 * Would be ACTPROB_CERTAIN if not for that. */
4108 /* TODO: maybe allow the ruleset author to give a probability from
4109 * Lua? */
4111 break;
4112 }
4113
4114 /* Non signal action probabilities should be in range. */
4116 || chance.max <= ACTPROB_VAL_MAX),
4117 chance.max = ACTPROB_VAL_MAX);
4119 || chance.min >= ACTPROB_VAL_MIN),
4120 chance.min = ACTPROB_VAL_MIN);
4121
4122 switch (known) {
4123 case TRI_NO:
4124 return ACTPROB_IMPOSSIBLE;
4125 break;
4126 case TRI_MAYBE:
4127 return ACTPROB_NOT_KNOWN;
4128 break;
4129 case TRI_YES:
4130 return chance;
4131 break;
4132 };
4133
4134 fc_assert_msg(FALSE, "Should be yes, maybe or no");
4135
4137}
4138
4139/**********************************************************************/
4143static struct act_prob
4145 const struct unit *actor_unit,
4146 const struct city *actor_home,
4147 const struct tile *actor_tile,
4148 const action_id act_id,
4149 const struct city *target_city)
4150{
4151 const struct impr_type *target_building;
4152 const struct unit_type *target_utype;
4153 const struct action *act = action_by_number(act_id);
4154
4155 if (actor_unit == NULL || target_city == NULL) {
4156 /* Can't do an action when actor or target are missing. */
4157 return ACTPROB_IMPOSSIBLE;
4158 }
4159
4162 "Action %s is performed by %s not %s",
4163 action_id_rule_name(act_id),
4165 action_id_get_actor_kind(act_id)),
4167
4170 "Action %s is against %s not %s",
4171 action_id_rule_name(act_id),
4175
4177
4178 if (!unit_can_do_action(actor_unit, act_id)) {
4179 /* No point in continuing. */
4180 return ACTPROB_IMPOSSIBLE;
4181 }
4182
4183 /* Doesn't leak information about city position since an unknown city
4184 * can't be targeted and a city can't move. */
4185 if (!action_id_distance_accepted(act_id,
4188 /* No point in continuing. */
4189 return ACTPROB_IMPOSSIBLE;
4190 }
4191
4192 /* Doesn't leak information since it must be 100% certain from the
4193 * player's perspective that the blocking action is legal. */
4196 /* Don't offer to perform an action known to be blocked. */
4197 return ACTPROB_IMPOSSIBLE;
4198 }
4199
4201 /* The invisible city at this tile may, as far as the player knows, not
4202 * exist anymore. */
4203 return act_prob_unseen_target(nmap, act_id, actor_unit);
4204 }
4205
4208
4209 return action_prob(nmap, act_id,
4210 &(const struct req_context) {
4211 .player = unit_owner(actor_unit),
4212 .city = tile_city(actor_tile),
4213 .tile = actor_tile,
4214 .unit = actor_unit,
4215 .unittype = unit_type_get(actor_unit),
4216 },
4217 actor_home,
4218 &(const struct req_context) {
4219 .player = city_owner(target_city),
4220 .city = target_city,
4221 .building = target_building,
4223 .unittype = target_utype,
4224 }, NULL);
4225}
4226
4227/**********************************************************************/
4232 const struct unit *actor_unit,
4233 const action_id act_id,
4234 const struct city *target_city)
4235{
4239 act_id, target_city);
4240}
4241
4242/**********************************************************************/
4246static struct act_prob
4248 const struct unit *actor_unit,
4249 const struct city *actor_home,
4250 const struct tile *actor_tile,
4251 const action_id act_id,
4252 const struct unit *target_unit)
4253{
4254 if (actor_unit == NULL || target_unit == NULL) {
4255 /* Can't do an action when actor or target are missing. */
4256 return ACTPROB_IMPOSSIBLE;
4257 }
4258
4261 "Action %s is performed by %s not %s",
4262 action_id_rule_name(act_id),
4264 action_id_get_actor_kind(act_id)),
4266
4269 "Action %s is against %s not %s",
4270 action_id_rule_name(act_id),
4274
4276
4277 if (!unit_can_do_action(actor_unit, act_id)) {
4278 /* No point in continuing. */
4279 return ACTPROB_IMPOSSIBLE;
4280 }
4281
4282 /* Doesn't leak information about unit position since an unseen unit can't
4283 * be targeted. */
4284 if (!action_id_distance_accepted(act_id,
4287 /* No point in continuing. */
4288 return ACTPROB_IMPOSSIBLE;
4289 }
4290
4291 return action_prob(nmap, act_id,
4292 &(const struct req_context) {
4293 .player = unit_owner(actor_unit),
4294 .city = tile_city(actor_tile),
4295 .tile = actor_tile,
4296 .unit = actor_unit,
4297 .unittype = unit_type_get(actor_unit),
4298 },
4299 actor_home,
4300 &(const struct req_context) {
4301 .player = unit_owner(target_unit),
4304 .unit = target_unit,
4305 .unittype = unit_type_get(target_unit),
4306 },
4307 NULL);
4308}
4309
4310/**********************************************************************/
4315 const struct unit *actor_unit,
4316 const action_id act_id,
4317 const struct unit *target_unit)
4318{
4322 act_id,
4323 target_unit);
4324}
4325
4326/**********************************************************************/
4330static struct act_prob
4332 const struct unit *actor_unit,
4333 const struct city *actor_home,
4334 const struct tile *actor_tile,
4335 const action_id act_id,
4336 const struct tile *target_tile)
4337{
4338 struct act_prob prob_all;
4339 const struct req_context *actor_ctxt;
4340 const struct action *act = action_by_number(act_id);
4341
4342 if (actor_unit == NULL || target_tile == NULL) {
4343 /* Can't do an action when actor or target are missing. */
4344 return ACTPROB_IMPOSSIBLE;
4345 }
4346
4349 "Action %s is performed by %s not %s",
4350 action_id_rule_name(act_id),
4352 action_id_get_actor_kind(act_id)),
4354
4357 "Action %s is against %s not %s",
4358 action_id_rule_name(act_id),
4362
4364
4365 if (!unit_can_do_action(actor_unit, act_id)) {
4366 /* No point in continuing. */
4367 return ACTPROB_IMPOSSIBLE;
4368 }
4369
4370 /* Doesn't leak information about unit stack position since it is
4371 * specified as a tile and an unknown tile's position is known. */
4372 if (!action_id_distance_accepted(act_id,
4374 target_tile))) {
4375 /* No point in continuing. */
4376 return ACTPROB_IMPOSSIBLE;
4377 }
4378
4379 /* Doesn't leak information since the actor player can see the target
4380 * tile. */
4384 act_id,
4385 CITYT_CENTER, TRUE)) {
4386 /* Don't offer to perform actions that never can target a unit stack in
4387 * a city. */
4388 return ACTPROB_IMPOSSIBLE;
4389 }
4390
4391 /* Doesn't leak information since it must be 100% certain from the
4392 * player's perspective that the blocking action is legal. */
4396 target_unit)) {
4397 /* Don't offer to perform an action known to be blocked. */
4398 return ACTPROB_IMPOSSIBLE;
4399 }
4401
4402 /* Must be done here since an empty unseen tile will result in
4403 * ACTPROB_IMPOSSIBLE. */
4404 if (unit_list_size(target_tile->units) == 0) {
4405 /* Can't act against an empty tile. */
4406
4408 target_tile)) {
4409 /* Known empty tile. */
4410 return ACTPROB_IMPOSSIBLE;
4411 } else {
4412 /* The player doesn't know that the tile is empty. */
4413 return act_prob_unseen_target(nmap, act_id, actor_unit);
4414 }
4415 }
4416
4423 /* Hard coded rule: can't "Bombard", "Suicide Attack", or "Attack"
4424 * units in non enemy cities. */
4425 return ACTPROB_IMPOSSIBLE;
4426 }
4427
4434 /* Hard coded rule: can't "Nuke Units", "Wipe Units", "Suicide Attack",
4435 * or "Attack" units on non native tile without "AttackNonNative" and
4436 * not "Only_Native_Attack". */
4437 return ACTPROB_IMPOSSIBLE;
4438 }
4439
4440 /* Invisible units at this tile can make the action legal or illegal.
4441 * Invisible units can be stacked with visible units. The possible
4442 * existence of invisible units therefore makes the result uncertain. */
4446
4447 actor_ctxt = &(const struct req_context) {
4448 .player = unit_owner(actor_unit),
4449 .city = tile_city(actor_tile),
4450 .tile = actor_tile,
4451 .unit = actor_unit,
4452 .unittype = unit_type_get(actor_unit),
4453 };
4454
4456 struct act_prob prob_unit;
4457
4459 /* Only visible units are considered. The invisible units contributed
4460 * their uncertainty to prob_all above. */
4461 continue;
4462 }
4463
4465 &(const struct req_context) {
4466 .player = unit_owner(target_unit),
4469 .unit = target_unit,
4470 .unittype = unit_type_get(target_unit),
4471 },
4472 NULL);
4473
4475 /* One unit makes it impossible for all units. */
4476 return ACTPROB_IMPOSSIBLE;
4477 } else if (action_prob_not_impl(prob_unit)) {
4478 /* Not implemented dominates all except impossible. */
4480 } else {
4482 "Invalid probability [%d, %d]",
4483 prob_unit.min, prob_unit.max);
4484
4486 /* Special values dominate regular values. */
4487 continue;
4488 }
4489
4490 /* Probability against all target units considered until this moment
4491 * and the probability against this target unit. */
4492 prob_all.min = (prob_all.min * prob_unit.min) / ACTPROB_VAL_MAX;
4493 prob_all.max = (prob_all.max * prob_unit.max) / ACTPROB_VAL_MAX;
4494 break;
4495 }
4497
4498 /* Not impossible for any of the units at the tile. */
4499 return prob_all;
4500}
4501
4502/**********************************************************************/
4507 const struct unit *actor_unit,
4508 const action_id act_id,
4509 const struct tile *target_tile)
4510{
4514 act_id,
4515 target_tile);
4516}
4517
4518/**********************************************************************/
4522static struct act_prob
4524 const struct unit *actor_unit,
4525 const struct city *actor_home,
4526 const struct tile *actor_tile,
4527 const action_id act_id,
4528 const struct tile *target_tile,
4529 const struct extra_type *target_extra)
4530{
4531 if (actor_unit == NULL || target_tile == NULL) {
4532 /* Can't do an action when actor or target are missing. */
4533 return ACTPROB_IMPOSSIBLE;
4534 }
4535
4538 "Action %s is performed by %s not %s",
4539 action_id_rule_name(act_id),
4541 action_id_get_actor_kind(act_id)),
4543
4546 "Action %s is against %s not %s",
4547 action_id_rule_name(act_id),
4551
4553
4554 if (!unit_can_do_action(actor_unit, act_id)) {
4555 /* No point in continuing. */
4556 return ACTPROB_IMPOSSIBLE;
4557 }
4558
4559 /* Doesn't leak information about tile position since an unknown tile's
4560 * position is known. */
4561 if (!action_id_distance_accepted(act_id,
4563 target_tile))) {
4564 /* No point in continuing. */
4565 return ACTPROB_IMPOSSIBLE;
4566 }
4567
4568 return action_prob(nmap, act_id,
4569 &(const struct req_context) {
4570 .player = unit_owner(actor_unit),
4571 .city = tile_city(actor_tile),
4572 .tile = actor_tile,
4573 .unit = actor_unit,
4574 .unittype = unit_type_get(actor_unit),
4575 },
4576 actor_home,
4577 &(const struct req_context) {
4578 .player = tile_owner(target_tile),
4579 .city = tile_city(target_tile),
4580 .tile = target_tile,
4581 },
4582 target_extra);
4583}
4584
4585/**********************************************************************/
4590 const struct unit *actor_unit,
4591 const action_id act_id,
4592 const struct tile *target_tile,
4593 const struct extra_type *target_extra)
4594{
4598 act_id, target_tile, target_extra);
4599}
4600
4601/**********************************************************************/
4605static struct act_prob
4607 const struct unit *actor_unit,
4608 const struct city *actor_home,
4609 const struct tile *actor_tile,
4610 const action_id act_id,
4611 const struct tile *target_tile,
4612 const struct extra_type *target_extra)
4613{
4614 if (actor_unit == NULL || target_tile == NULL) {
4615 /* Can't do an action when actor or target are missing. */
4616 return ACTPROB_IMPOSSIBLE;
4617 }
4618
4621 "Action %s is performed by %s not %s",
4622 action_id_rule_name(act_id),
4624 action_id_get_actor_kind(act_id)),
4626
4629 "Action %s is against %s not %s",
4630 action_id_rule_name(act_id),
4634
4636
4637 if (!unit_can_do_action(actor_unit, act_id)) {
4638 /* No point in continuing. */
4639 return ACTPROB_IMPOSSIBLE;
4640 }
4641
4642 /* Doesn't leak information about tile position since an unknown tile's
4643 * position is known. */
4644 if (!action_id_distance_accepted(act_id,
4646 target_tile))) {
4647 /* No point in continuing. */
4648 return ACTPROB_IMPOSSIBLE;
4649 }
4650
4651 return action_prob(nmap, act_id,
4652 &(const struct req_context) {
4653 .player = unit_owner(actor_unit),
4654 .city = tile_city(actor_tile),
4655 .tile = actor_tile,
4656 .unit = actor_unit,
4657 .unittype = unit_type_get(actor_unit),
4658 },
4659 actor_home,
4660 &(const struct req_context) {
4661 .player = target_tile->extras_owner,
4662 .city = tile_city(target_tile),
4663 .tile = target_tile,
4664 },
4665 target_extra);
4666}
4667
4668/**********************************************************************/
4673 const struct unit *actor_unit,
4674 const action_id act_id,
4675 const struct tile *target_tile,
4676 const struct extra_type *target_extra)
4677{
4681 act_id, target_tile, target_extra);
4682}
4683
4684/**********************************************************************/
4688static struct act_prob
4690 const struct unit *actor_unit,
4691 const struct city *actor_home,
4692 const struct tile *actor_tile,
4693 const action_id act_id)
4694{
4695 if (actor_unit == NULL) {
4696 /* Can't do the action when the actor is missing. */
4697 return ACTPROB_IMPOSSIBLE;
4698 }
4699
4700 /* No point in checking distance to target. It is always 0. */
4701
4704 "Action %s is performed by %s not %s",
4705 action_id_rule_name(act_id),
4707 action_id_get_actor_kind(act_id)),
4709
4712 "Action %s is against %s not %s",
4713 action_id_rule_name(act_id),
4717
4719
4720 if (!unit_can_do_action(actor_unit, act_id)) {
4721 /* No point in continuing. */
4722 return ACTPROB_IMPOSSIBLE;
4723 }
4724
4725 return action_prob(nmap, act_id,
4726 &(const struct req_context) {
4727 .player = unit_owner(actor_unit),
4728 .city = tile_city(actor_tile),
4729 .tile = actor_tile,
4730 .unit = actor_unit,
4731 .unittype = unit_type_get(actor_unit),
4732 },
4733 actor_home,
4734 NULL,
4735 NULL);
4736}
4737
4738/**********************************************************************/
4743 const struct unit *actor_unit,
4744 const action_id act_id)
4745{
4749 act_id);
4750}
4751
4752/**********************************************************************/
4765 const struct action *paction,
4766 const struct unit *act_unit,
4767 const struct city *tgt_city,
4768 const struct unit *tgt_unit,
4769 const struct tile *tgt_tile,
4770 const struct extra_type *extra_tgt)
4771{
4772 /* Assume impossible until told otherwise. */
4773 struct act_prob prob = ACTPROB_IMPOSSIBLE;
4774
4777
4779 case ATK_STACK:
4780 if (tgt_tile) {
4782 }
4783 break;
4784 case ATK_TILE:
4785 if (tgt_tile) {
4787 }
4788 break;
4789 case ATK_EXTRAS:
4790 if (tgt_tile) {
4793 }
4794 break;
4795 case ATK_CITY:
4796 if (tgt_city) {
4798 }
4799 break;
4800 case ATK_UNIT:
4801 if (tgt_unit) {
4803 }
4804 break;
4805 case ATK_SELF:
4806 prob = action_prob_self(nmap, act_unit, paction->id);
4807 break;
4808 case ATK_COUNT:
4809 log_error("Invalid action target kind");
4810 break;
4811 }
4812
4813 return prob;
4814}
4815
4816/**********************************************************************/
4822 const action_id act_id,
4823 const struct unit *actor,
4824 const struct city *actor_home,
4825 const struct tile *actor_tile,
4826 const bool omniscient_cheat,
4827 const struct city* target)
4828{
4829 /* FIXME: some unit state requirements still depend on the actor unit's
4830 * current position rather than on actor_tile. Maybe this function should
4831 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4832 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4833
4834 if (omniscient_cheat) {
4837 target)) {
4838 return ACTPROB_CERTAIN;
4839 } else {
4840 return ACTPROB_IMPOSSIBLE;
4841 }
4842 } else {
4843 /* FIXME: this branch result depends _directly_ on actor's position.
4844 * I.e., like, not adjacent, no action. Other branch ignores radius. */
4846 act_id, target);
4847 }
4848}
4849
4850/**********************************************************************/
4855struct act_prob
4857 action_id act_id,
4858 const struct unit *actor,
4859 const struct city *actor_home,
4860 const struct tile *actor_tile,
4861 bool omniscient_cheat,
4862 const struct unit *target)
4863{
4864 /* FIXME: some unit state requirements still depend on the actor unit's
4865 * current position rather than on actor_tile. Maybe this function should
4866 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4867 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4868
4869 if (omniscient_cheat) {
4872 target)) {
4873 return ACTPROB_CERTAIN;
4874 } else {
4875 return ACTPROB_IMPOSSIBLE;
4876 }
4877 } else {
4879 act_id, target);
4880 }
4881}
4882
4883/**********************************************************************/
4888struct act_prob
4890 action_id act_id,
4891 const struct unit *actor,
4892 const struct city *actor_home,
4893 const struct tile *actor_tile,
4894 bool omniscient_cheat,
4895 const struct tile *target)
4896{
4897 /* FIXME: some unit state requirements still depend on the actor unit's
4898 * current position rather than on actor_tile. Maybe this function should
4899 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4900 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4901
4902 if (omniscient_cheat) {
4905 target)) {
4906 return ACTPROB_CERTAIN;
4907 } else {
4908 return ACTPROB_IMPOSSIBLE;
4909 }
4910 } else {
4912 act_id, target);
4913 }
4914}
4915
4916/**********************************************************************/
4921struct act_prob
4923 action_id act_id,
4924 const struct unit *actor,
4925 const struct city *actor_home,
4926 const struct tile *actor_tile,
4927 bool omniscient_cheat,
4928 const struct tile *target_tile,
4929 const struct extra_type *target_extra)
4930{
4931 /* FIXME: some unit state requirements still depend on the actor unit's
4932 * current position rather than on actor_tile. Maybe this function should
4933 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4934 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4935
4936 if (omniscient_cheat) {
4940 return ACTPROB_CERTAIN;
4941 } else {
4942 return ACTPROB_IMPOSSIBLE;
4943 }
4944 } else {
4946 act_id, target_tile, target_extra);
4947 }
4948}
4949
4950/**********************************************************************/
4955struct act_prob
4957 action_id act_id,
4958 const struct unit *actor,
4959 const struct city *actor_home,
4960 const struct tile *actor_tile,
4961 bool omniscient_cheat,
4962 const struct tile *target_tile,
4963 const struct extra_type *target_extra)
4964{
4965 /* FIXME: some unit state requirements still depend on the actor unit's
4966 * current position rather than on actor_tile. Maybe this function should
4967 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4968 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4969
4970 if (omniscient_cheat) {
4974 return ACTPROB_CERTAIN;
4975 } else {
4976 return ACTPROB_IMPOSSIBLE;
4977 }
4978 } else {
4980 act_id, target_tile, target_extra);
4981 }
4982}
4983
4984/**********************************************************************/
4989struct act_prob
4991 action_id act_id,
4992 const struct unit *actor,
4993 const struct city *actor_home,
4994 const struct tile *actor_tile,
4995 bool omniscient_cheat)
4996{
4997 /* FIXME: some unit state requirements still depend on the actor unit's
4998 * current position rather than on actor_tile. Maybe this function should
4999 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
5000 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
5001 if (omniscient_cheat) {
5004 return ACTPROB_CERTAIN;
5005 } else {
5006 return ACTPROB_IMPOSSIBLE;
5007 }
5008 } else {
5010 act_id);
5011 }
5012}
5013
5014/**********************************************************************/
5018{
5020
5021 return out;
5022}
5023
5024/**********************************************************************/
5028{
5030
5031 return out;
5032}
5033
5034/**********************************************************************/
5038{
5040
5041 return out;
5042}
5043
5044/**********************************************************************/
5048{
5050
5051 return out;
5052}
5053
5054/**********************************************************************/
5058{
5060
5061 return out;
5062}
5063
5064/**********************************************************************/
5069{
5070 return (ACTPROB_VAL_MIN < probability.max
5072}
5073
5074/**********************************************************************/
5079{
5080 return (ACTPROB_VAL_MAX == probability.min
5081 && ACTPROB_VAL_MAX == probability.max);
5082}
5083
5084/**********************************************************************/
5088static inline bool
5094
5095/**********************************************************************/
5099static inline bool
5101{
5102 return probability.min == ACTPROB_VAL_NOT_IMPL
5103 && probability.max == ACTPROB_VAL_MIN;
5104}
5105
5106/**********************************************************************/
5110static inline bool
5112{
5113 return probability.max < probability.min;
5114}
5115
5116/**********************************************************************/
5120 const struct act_prob *ap2)
5121{
5122 return ap1->min == ap2->min && ap1->max == ap2->max;
5123}
5124
5125/**********************************************************************/
5129 const struct act_prob ap2)
5130{
5131 struct act_prob my_ap1;
5132 struct act_prob my_ap2;
5133
5134 /* The action probabilities are real. */
5137
5138 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5140 /* Assert that it is OK to convert the signal. */
5142
5144 } else {
5145 my_ap1 = ap1;
5146 }
5147
5149 /* Assert that it is OK to convert the signal. */
5151
5153 } else {
5154 my_ap2 = ap2;
5155 }
5156
5157 /* The action probabilities now have a comparison friendly form. */
5160
5161 /* Do the comparison. Start with min. Continue with max. */
5162 if (my_ap1.min < my_ap2.min) {
5163 return -1;
5164 } else if (my_ap1.min > my_ap2.min) {
5165 return 1;
5166 } else if (my_ap1.max < my_ap2.max) {
5167 return -1;
5168 } else if (my_ap1.max > my_ap2.max) {
5169 return 1;
5170 } else {
5171 return 0;
5172 }
5173}
5174
5175/**********************************************************************/
5180{
5181 struct act_prob my_ap;
5182
5183 /* The action probability is real. */
5185
5186 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5188 /* Assert that it is OK to convert the signal. */
5190
5192 } else {
5193 my_ap = ap;
5194 }
5195
5196 /* The action probability now has a math friendly form. */
5198
5199 return (double)my_ap.min / (double) ACTPROB_VAL_MAX;
5200}
5201
5202/**********************************************************************/
5207 const struct act_prob *ap2)
5208{
5209 struct act_prob my_ap1;
5210 struct act_prob my_ap2;
5211 struct act_prob out;
5212
5213 /* The action probabilities are real. */
5216
5219 /* Keep the information rather than converting the signal to
5220 * ACTPROB_NOT_KNOWN. */
5221
5222 /* Assert that it is OK to convert the signal. */
5224
5225 out.min = ap1->min;
5226 out.max = ap2->max;
5227
5228 return out;
5229 }
5230
5231 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5232 if (action_prob_is_signal(*ap1)) {
5233 /* Assert that it is OK to convert the signal. */
5235
5236 my_ap1.min = ACTPROB_VAL_MIN;
5237 my_ap1.max = ACTPROB_VAL_MAX;
5238 } else {
5239 my_ap1.min = ap1->min;
5240 my_ap1.max = ap1->max;
5241 }
5242
5243 if (action_prob_is_signal(*ap2)) {
5244 /* Assert that it is OK to convert the signal. */
5246
5247 my_ap2.min = ACTPROB_VAL_MIN;
5248 my_ap2.max = ACTPROB_VAL_MAX;
5249 } else {
5250 my_ap2.min = ap2->min;
5251 my_ap2.max = ap2->max;
5252 }
5253
5254 /* The action probabilities now have a math friendly form. */
5257
5258 /* Do the math. */
5259 out.min = (my_ap1.min * my_ap2.min) / ACTPROB_VAL_MAX;
5260 out.max = (my_ap1.max * my_ap2.max) / ACTPROB_VAL_MAX;
5261
5262 /* Cap at 100%. */
5263 out.min = MIN(out.min, ACTPROB_VAL_MAX);
5264 out.max = MIN(out.max, ACTPROB_VAL_MAX);
5265
5266 return out;
5267}
5268
5269/**********************************************************************/
5277 const struct act_prob *ap2)
5278{
5279 struct act_prob my_ap1;
5280 struct act_prob my_ap2;
5281 struct act_prob out;
5282
5283 /* The action probabilities are real. */
5286
5289 /* Keep the information rather than converting the signal to
5290 * ACTPROB_NOT_KNOWN. */
5291
5292 /* Assert that it is OK to convert the signal. */
5294
5295 out.min = ap1->min;
5296 out.max = ap2->max;
5297
5298 return out;
5299 }
5300
5301 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5302 if (action_prob_is_signal(*ap1)) {
5303 /* Assert that it is OK to convert the signal. */
5305
5306 my_ap1.min = ACTPROB_VAL_MIN;
5307 my_ap1.max = ACTPROB_VAL_MAX;
5308 } else {
5309 my_ap1.min = ap1->min;
5310 my_ap1.max = ap1->max;
5311 }
5312
5313 if (action_prob_is_signal(*ap2)) {
5314 /* Assert that it is OK to convert the signal. */
5316
5317 my_ap2.min = ACTPROB_VAL_MIN;
5318 my_ap2.max = ACTPROB_VAL_MAX;
5319 } else {
5320 my_ap2.min = ap2->min;
5321 my_ap2.max = ap2->max;
5322 }
5323
5324 /* The action probabilities now have a math friendly form. */
5327
5328 /* Do the math. */
5329 out.min = my_ap1.min + (((ACTPROB_VAL_MAX - my_ap1.min) * my_ap2.min)
5330 / ACTPROB_VAL_MAX);
5331 out.max = my_ap1.max + (((ACTPROB_VAL_MAX - my_ap1.max) * my_ap2.max)
5332 / ACTPROB_VAL_MAX);
5333
5334 /* Cap at 100%. */
5335 out.min = MIN(out.min, ACTPROB_VAL_MAX);
5336 out.max = MIN(out.max, ACTPROB_VAL_MAX);
5337
5338 return out;
5339}
5340
5341/**********************************************************************/
5345{
5346 switch (actres_dice_type(paction->result)) {
5347 case DRT_DIPLCHANCE:
5349 /* Take the initial odds from the diplchance setting. */
5351 server_setting_by_name("diplchance"));
5352 }
5354 case DRT_CERTAIN:
5355 return 100;
5356 case DRT_NONE:
5357 break;
5358 }
5359
5360 /* The odds of the action not being stopped by its dice roll when the dice
5361 * isn't thrown is 100%. ACTION_ODDS_PCT_DICE_ROLL_NA is above 100% */
5363}
5364
5365/**********************************************************************/
5369 const struct unit *act_unit,
5370 const struct city *tgt_city,
5371 const struct player *tgt_player,
5372 const struct action *paction)
5373{
5375 const struct unit_type *actu_type = unit_type_get(act_unit);
5376
5377 fc_assert_action_msg(odds >= 0 && odds <= 100,
5378 odds = 100,
5379 "Bad initial odds for action number %d."
5380 " Does it roll the dice at all?",
5381 paction->id);
5382
5383 /* Let the Action_Odds_Pct effect modify the odds. The advantage of doing
5384 * it this way instead of rolling twice is that Action_Odds_Pct can
5385 * increase the odds. */
5386 odds = odds
5387 + ((odds
5389 &(const struct req_context) {
5390 .player = act_player,
5391 .city = tgt_city,
5392 .unit = act_unit,
5393 .unittype = actu_type,
5394 .action = paction,
5395 },
5396 &(const struct req_context) {
5397 .player = tgt_player,
5398 },
5400 / 100)
5401 - ((odds
5403 &(const struct req_context) {
5404 .player = tgt_player,
5405 .city = tgt_city,
5406 .unit = act_unit,
5407 .unittype = actu_type,
5408 .action = paction,
5409 },
5410 &(const struct req_context) {
5411 .player = act_player,
5412 },
5414 / 100);
5415
5416
5417 /* Odds are between 0% and 100%. */
5418 return CLIP(0, odds, 100);
5419}
5420
5421/**********************************************************************/
5425{
5426 struct action *paction = action_by_number(act);
5427
5428 /* Always immune since its not enabled. Doesn't count. */
5429 if (!action_is_in_use(paction)) {
5430 return FALSE;
5431 }
5432
5434 if (requirement_fulfilled_by_government(gov, &(enabler->target_reqs))) {
5435 return FALSE;
5436 }
5438
5439 return TRUE;
5440}
5441
5442/**********************************************************************/
5448 const struct player *actor_player,
5449 const struct req_context *target)
5450{
5452 enabler) {
5453 if (are_reqs_active(target,
5454 &(const struct req_context) {
5456 },
5457 &enabler->target_reqs, RPT_POSSIBLE)) {
5458 return TRUE;
5459 }
5461
5462 return FALSE;
5463}
5464
5465/**********************************************************************/
5469 const struct player *actor_player,
5470 const struct city* target_city)
5471{
5473 FALSE, "Action %s is against %s not cities",
5474 action_id_rule_name(act_id),
5476 action_id_get_target_kind(act_id)));
5477
5478 return is_target_possible(act_id, actor_player,
5479 &(const struct req_context) {
5480 .player = city_owner(target_city),
5481 .city = target_city,
5483 });
5484}
5485
5486/**********************************************************************/
5492 const action_id act_id,
5493 const struct unit *actor_unit)
5494{
5495 const struct player *actor_player = unit_owner(actor_unit);
5496 const struct req_context actor_ctxt = {
5498 .city = tile_city(unit_tile(actor_unit)),
5500 .unit = actor_unit,
5501 .unittype = unit_type_get(actor_unit),
5502 };
5503 const struct action *paction = action_by_number(act_id);
5504
5505 enum fc_tristate result;
5506
5508
5509 if (!utype_can_do_action(actor_unit->utype, act_id)) {
5510 /* The unit type can't perform the action. */
5511 return FALSE;
5512 }
5513
5516
5517 if (result == TRI_NO) {
5518 /* The hard requirements aren't fulfilled. */
5519 return FALSE;
5520 }
5521
5523 enabler) {
5524 const enum fc_tristate current
5526 &enabler->actor_reqs,
5527 /* Needed since no player to evaluate DiplRel
5528 * requirements against. */
5529 RPT_POSSIBLE);
5530
5531 if (current == TRI_YES
5532 || current == TRI_MAYBE) {
5533 /* The ruleset requirements may be fulfilled. */
5534 return TRUE;
5535 }
5537
5538 /* No action enabler allows this action. */
5539 return FALSE;
5540}
5541
5542/**********************************************************************/
5547 const action_id act_id)
5548{
5549 fc_assert(action_id_exists(act_id) || act_id == ACTION_ANY);
5550
5551 /* Check if full movement points may enable the specified action. */
5553 act_id,
5556 act_id,
5558}
5559
5560/**********************************************************************/
5585
5586/**********************************************************************/
5597{
5598 const struct action *paction = enabler_get_action(ae);
5599
5600 switch (action_get_actor_kind(paction)) {
5601 case AAK_UNIT:
5604 /* A possible actor unit type has been found. */
5605 return TRUE;
5606 }
5608
5609 /* No actor detected. */
5610 return FALSE;
5611 case AAK_CITY:
5612 case AAK_PLAYER:
5613 /* Currently can't detect */
5614 return TRUE;
5615 case AAK_COUNT:
5617 break;
5618 }
5619
5620 /* No actor detected. */
5621 return FALSE;
5622}
5623
5624/**********************************************************************/
5632{
5633 switch (action_get_actor_kind(paction)) {
5634 case AAK_UNIT:
5637 return TRUE;
5638 }
5640 break;
5641 case AAK_CITY:
5642 case AAK_PLAYER:
5643 /* No ruleset hard reqs atm */
5644 return TRUE;
5645 case AAK_COUNT:
5647 break;
5648 }
5649
5650 /* No actor detected. */
5651 return FALSE;
5652}
5653
5654/**********************************************************************/
5662{
5664
5666 /* Hard requirements not fulfilled. */
5667 return FALSE;
5668 }
5669
5671
5673 /* If this iteration finds any entries, action is enabled. */
5674 return TRUE;
5676
5677 /* No non deleted action enabler. */
5678 return FALSE;
5679}
5680
5681/**********************************************************************/
5688{
5689 return paction != nullptr
5691}
5692
5693/**********************************************************************/
5703
5704/**********************************************************************/
5708{
5709 fc_assert_ret_val(num >= 0, NULL);
5711
5712 return &auto_perfs[num];
5713}
5714
5715/**********************************************************************/
5724{
5725 return action_auto_perf_slot_number(num);
5726}
5727
5728/**********************************************************************/
5732 struct universal *actor_uni,
5733 struct universal *target_uni)
5734{
5736 enab) {
5737 if ((actor_uni == NULL
5738 || universal_fulfills_requirements(FALSE, &(enab->actor_reqs),
5739 actor_uni))
5740 && (target_uni == NULL
5741 || universal_fulfills_requirements(FALSE, &(enab->target_reqs),
5742 target_uni))) {
5743 return TRUE;
5744 }
5746
5747 return FALSE;
5748}
5749
5750/**********************************************************************/
5756{
5758
5759 if (size < MAX_NUM_ACTIONS) {
5760 /* An action array is terminated by ACTION_NONE */
5762 }
5763}
5764
5765/**********************************************************************/
5773 int *position,
5774 enum action_result result)
5775{
5776 action_iterate(act) {
5777 struct action *paction = action_by_number(act);
5778 if (paction->result == result) {
5779 /* Assume one result for each action. */
5780 fc_assert_ret(*position < MAX_NUM_ACTIONS);
5781
5782 act_array[(*position)++] = paction->id;
5783 }
5785}
5786
5787/**********************************************************************/
5793{
5794 switch ((enum gen_action)act) {
5795 case ACTION_SPY_POISON:
5796 return "ui_name_poison_city";
5798 return "ui_name_poison_city_escape";
5800 return "ui_name_sabotage_unit";
5802 return "ui_name_sabotage_unit_escape";
5804 return "ui_name_bribe_unit";
5806 return "ui_name_bribe_stack";
5808 return "ui_name_sabotage_city";
5810 return "ui_name_sabotage_city_escape";
5812 return "ui_name_targeted_sabotage_city";
5814 return "ui_name_sabotage_city_production";
5816 return "ui_name_targeted_sabotage_city_escape";
5818 return "ui_name_sabotage_city_production_escape";
5820 return "ui_name_incite_city";
5822 return "ui_name_incite_city_escape";
5824 return "ui_name_establish_embassy";
5826 return "ui_name_establish_embassy_stay";
5828 return "ui_name_steal_tech";
5830 return "ui_name_steal_tech_escape";
5832 return "ui_name_targeted_steal_tech";
5834 return "ui_name_targeted_steal_tech_escape";
5836 return "ui_name_investigate_city";
5838 return "ui_name_investigate_city_spend_unit";
5840 return "ui_name_steal_gold";
5842 return "ui_name_steal_gold_escape";
5844 return "ui_name_spread_plague";
5845 case ACTION_STEAL_MAPS:
5846 return "ui_name_steal_maps";
5848 return "ui_name_steal_maps_escape";
5849 case ACTION_TRADE_ROUTE:
5850 return "ui_name_establish_trade_route";
5851 case ACTION_MARKETPLACE:
5852 return "ui_name_enter_marketplace";
5853 case ACTION_HELP_WONDER:
5854 return "ui_name_help_wonder";
5856 return "ui_name_capture_units";
5857 case ACTION_EXPEL_UNIT:
5858 return "ui_name_expel_unit";
5859 case ACTION_FOUND_CITY:
5860 return "ui_name_found_city";
5861 case ACTION_JOIN_CITY:
5862 return "ui_name_join_city";
5863 case ACTION_BOMBARD:
5864 return "ui_name_bombard";
5865 case ACTION_BOMBARD2:
5866 return "ui_name_bombard_2";
5867 case ACTION_BOMBARD3:
5868 return "ui_name_bombard_3";
5869 case ACTION_BOMBARD4:
5870 return "ui_name_bombard_4";
5872 return "ui_name_bombard_lethal";
5874 return "ui_name_bombard_lethal_2";
5875 case ACTION_SPY_NUKE:
5876 return "ui_name_suitcase_nuke";
5878 return "ui_name_suitcase_nuke_escape";
5879 case ACTION_NUKE:
5880 return "ui_name_explode_nuclear";
5881 case ACTION_NUKE_CITY:
5882 return "ui_name_nuke_city";
5883 case ACTION_NUKE_UNITS:
5884 return "ui_name_nuke_units";
5886 return "ui_name_destroy_city";
5888 return "ui_name_disband_unit_recover";
5890 return "ui_name_disband_unit";
5891 case ACTION_HOME_CITY:
5892 return "ui_name_home_city";
5893 case ACTION_HOMELESS:
5894 return "ui_name_homeless";
5896 return "ui_name_upgrade_unit";
5897 case ACTION_PARADROP:
5898 return "ui_name_paradrop_unit";
5900 return "ui_name_paradrop_unit_conquer";
5902 return "ui_name_paradrop_unit_frighten";
5904 return "ui_name_paradrop_unit_frighten_conquer";
5906 return "ui_name_paradrop_unit_enter";
5908 return "ui_name_paradrop_unit_enter_conquer";
5909 case ACTION_AIRLIFT:
5910 return "ui_name_airlift_unit";
5911 case ACTION_ATTACK:
5912 return "ui_name_attack";
5913 case ACTION_ATTACK2:
5914 return "ui_name_attack_2";
5916 return "ui_name_suicide_attack";
5918 return "ui_name_suicide_attack_2";
5919 case ACTION_WIPE_UNITS:
5920 return "ui_name_wipe_units";
5922 return "ui_name_collect_ransom";
5924 return "ui_name_surgical_strike_building";
5926 return "ui_name_surgical_strike_production";
5928 return "ui_name_conquer_city_shrink";
5930 return "ui_name_conquer_city_shrink2";
5932 return "ui_name_conquer_city_shrink3";
5934 return "ui_name_conquer_city_shrink4";
5936 return "ui_name_conquer_extras";
5938 return "ui_name_conquer_extras_2";
5940 return "ui_name_conquer_extras_3";
5942 return "ui_name_conquer_extras_4";
5943 case ACTION_HEAL_UNIT:
5944 return "ui_name_heal_unit";
5945 case ACTION_HEAL_UNIT2:
5946 return "ui_name_heal_unit_2";
5948 return "ui_name_transform_terrain";
5950 return "ui_name_transform_terrain_2";
5951 case ACTION_CULTIVATE:
5952 return "ui_name_cultivate";
5953 case ACTION_CULTIVATE2:
5954 return "ui_name_cultivate_2";
5955 case ACTION_PLANT:
5956 return "ui_name_plant";
5957 case ACTION_PLANT2:
5958 return "ui_name_plant_2";
5959 case ACTION_PILLAGE:
5960 return "ui_name_pillage";
5961 case ACTION_PILLAGE2:
5962 return "ui_name_pillage_2";
5963 case ACTION_CLEAN:
5964 return "ui_name_clean";
5965 case ACTION_CLEAN2:
5966 return "ui_name_clean_2";
5967 case ACTION_FORTIFY:
5968 return "ui_name_fortify";
5969 case ACTION_FORTIFY2:
5970 return "ui_name_fortify_2";
5971 case ACTION_ROAD:
5972 return "ui_name_build_road";
5973 case ACTION_ROAD2:
5974 return "ui_name_build_road_2";
5975 case ACTION_CONVERT:
5976 return "ui_name_convert_unit";
5977 case ACTION_BASE:
5978 return "ui_name_build_base";
5979 case ACTION_BASE2:
5980 return "ui_name_build_base_2";
5981 case ACTION_MINE:
5982 return "ui_name_build_mine";
5983 case ACTION_MINE2:
5984 return "ui_name_build_mine_2";
5985 case ACTION_IRRIGATE:
5986 return "ui_name_irrigate";
5987 case ACTION_IRRIGATE2:
5988 return "ui_name_irrigate_2";
5990 return "ui_name_transport_deboard";
5992 return "ui_name_transport_board";
5994 return "ui_name_transport_board_2";
5996 return "ui_name_transport_board_3";
5998 return "ui_name_transport_embark";
6000 return "ui_name_transport_embark_2";
6002 return "ui_name_transport_embark_3";
6004 return "ui_name_transport_embark_4";
6006 return "ui_name_transport_unload";
6008 return "ui_name_transport_load";
6010 return "ui_name_transport_load_2";
6012 return "ui_name_transport_load_3";
6014 return "ui_name_transport_disembark";
6016 return "ui_name_transport_disembark_2";
6018 return "ui_name_transport_disembark_3";
6020 return "ui_name_transport_disembark_4";
6021 case ACTION_HUT_ENTER:
6022 return "ui_name_enter_hut";
6023 case ACTION_HUT_ENTER2:
6024 return "ui_name_enter_hut_2";
6025 case ACTION_HUT_ENTER3:
6026 return "ui_name_enter_hut_3";
6027 case ACTION_HUT_ENTER4:
6028 return "ui_name_enter_hut_4";
6030 return "ui_name_frighten_hut";
6032 return "ui_name_frighten_hut_2";
6034 return "ui_name_frighten_hut_3";
6036 return "ui_name_frighten_hut_4";
6037 case ACTION_SPY_ATTACK:
6038 return "ui_name_spy_attack";
6039 case ACTION_UNIT_MOVE:
6040 return "ui_name_unit_move";
6041 case ACTION_UNIT_MOVE2:
6042 return "ui_name_unit_move_2";
6043 case ACTION_UNIT_MOVE3:
6044 return "ui_name_unit_move_3";
6045 case ACTION_TELEPORT:
6046 return "ui_name_teleport";
6047 case ACTION_TELEPORT2:
6048 return "ui_name_teleport_2";
6049 case ACTION_TELEPORT3:
6050 return "ui_name_teleport_3";
6052 return "ui_name_teleport_conquer";
6054 return "ui_name_teleport_frighten";
6056 return "ui_name_teleport_frighten_conquer";
6058 return "ui_name_teleport_enter";
6060 return "ui_name_teleport_enter_conquer";
6061 case ACTION_SPY_ESCAPE:
6062 return "ui_name_escape";
6064 return "ui_name_user_action_1";
6066 return "ui_name_user_action_2";
6068 return "ui_name_user_action_3";
6070 return "ui_name_user_action_4";
6072 case ACTION_ESCAPE:
6073 case ACTION_CIVIL_WAR:
6074 fc_assert(!action_id_is_internal(act)); /* Fail always */
6075 break;
6076 case ACTION_COUNT:
6077 break;
6078
6080 }
6081
6082 fc_assert(act >= 0 && act < ACTION_COUNT);
6083
6084 return NULL;
6085}
6086
6087/**********************************************************************/
6090const char *action_ui_name_default(int act)
6091{
6092 switch ((enum gen_action)act) {
6093 case ACTION_SPY_POISON:
6094 /* TRANS: _Poison City (3% chance of success). */
6095 return N_("%sPoison City%s");
6097 /* TRANS: _Poison City and Escape (3% chance of success). */
6098 return N_("%sPoison City and Escape%s");
6100 /* TRANS: S_abotage Enemy Unit (3% chance of success). */
6101 return N_("S%sabotage Enemy Unit%s");
6103 /* TRANS: S_abotage Enemy Unit and Escape (3% chance of success). */
6104 return N_("S%sabotage Enemy Unit and Escape%s");
6106 /* TRANS: Bribe Enemy _Unit (3% chance of success). */
6107 return N_("Bribe Enemy %sUnit%s");
6109 /* TRANS: Bribe Enemy _Stack (3% chance of success). */
6110 return N_("Bribe Enemy %sStack%s");
6112 /* TRANS: _Sabotage City (3% chance of success). */
6113 return N_("%sSabotage City%s");
6115 /* TRANS: _Sabotage City and Escape (3% chance of success). */
6116 return N_("%sSabotage City and Escape%s");
6118 /* TRANS: Industria_l Sabotage (3% chance of success). */
6119 return N_("Industria%sl Sabotage%s");
6121 /* TRANS: Industria_l Sabotage Production (3% chance of success). */
6122 return N_("Industria%sl Sabotage Production%s");
6124 /* TRANS: Industria_l Sabotage and Escape (3% chance of success). */
6125 return N_("Industria%sl Sabotage and Escape%s");
6127 /* TRANS: Industria_l Sabotage Production and Escape (3% chance of success). */
6128 return N_("Industria%sl Sabotage Production and Escape%s");
6130 /* TRANS: Incite a Re_volt (3% chance of success). */
6131 return N_("Incite a Re%svolt%s");
6133 /* TRANS: Incite a Re_volt and Escape (3% chance of success). */
6134 return N_("Incite a Re%svolt and Escape%s");
6136 /* TRANS: Establish _Embassy (100% chance of success). */
6137 return N_("Establish %sEmbassy%s");
6139 /* TRANS: Becom_e Ambassador (100% chance of success). */
6140 return N_("Becom%se Ambassador%s");
6142 /* TRANS: Steal _Technology (3% chance of success). */
6143 return N_("Steal %sTechnology%s");
6145 /* TRANS: Steal _Technology and Escape (3% chance of success). */
6146 return N_("Steal %sTechnology and Escape%s");
6148 /* TRANS: In_dustrial Espionage (3% chance of success). */
6149 return N_("In%sdustrial Espionage%s");
6151 /* TRANS: In_dustrial Espionage and Escape (3% chance of success). */
6152 return N_("In%sdustrial Espionage and Escape%s");
6154 /* TRANS: _Investigate City (100% chance of success). */
6155 return N_("%sInvestigate City%s");
6157 /* TRANS: _Investigate City (spends the unit) (100% chance of
6158 * success). */
6159 return N_("%sInvestigate City (spends the unit)%s");
6161 /* TRANS: Steal _Gold (100% chance of success). */
6162 return N_("Steal %sGold%s");
6164 /* TRANS: Steal _Gold and Escape (100% chance of success). */
6165 return N_("Steal %sGold and Escape%s");
6167 /* TRANS: Spread _Plague (100% chance of success). */
6168 return N_("Spread %sPlague%s");
6169 case ACTION_STEAL_MAPS:
6170 /* TRANS: Steal _Maps (100% chance of success). */
6171 return N_("Steal %sMaps%s");
6173 /* TRANS: Steal _Maps and Escape (100% chance of success). */
6174 return N_("Steal %sMaps and Escape%s");
6175 case ACTION_TRADE_ROUTE:
6176 /* TRANS: Establish Trade _Route (100% chance of success). */
6177 return N_("Establish Trade %sRoute%s");
6178 case ACTION_MARKETPLACE:
6179 /* TRANS: Enter _Marketplace (100% chance of success). */
6180 return N_("Enter %sMarketplace%s");
6181 case ACTION_HELP_WONDER:
6182 /* TRANS: Help _build Wonder (100% chance of success). */
6183 return N_("Help %sbuild Wonder%s");
6185 /* TRANS: _Capture Units (100% chance of success). */
6186 return N_("%sCapture Units%s");
6187 case ACTION_EXPEL_UNIT:
6188 /* TRANS: _Expel Unit (100% chance of success). */
6189 return N_("%sExpel Unit%s");
6190 case ACTION_FOUND_CITY:
6191 /* TRANS: _Found City (100% chance of success). */
6192 return N_("%sFound City%s");
6193 case ACTION_JOIN_CITY:
6194 /* TRANS: _Join City (100% chance of success). */
6195 return N_("%sJoin City%s");
6196 case ACTION_BOMBARD:
6197 /* TRANS: B_ombard (100% chance of success). */
6198 return N_("B%sombard%s");
6199 case ACTION_BOMBARD2:
6200 /* TRANS: B_ombard 2 (100% chance of success). */
6201 return N_("B%sombard 2%s");
6202 case ACTION_BOMBARD3:
6203 /* TRANS: B_ombard 3 (100% chance of success). */
6204 return N_("B%sombard 3%s");
6205 case ACTION_BOMBARD4:
6206 /* TRANS: B_ombard 4 (100% chance of success). */
6207 return N_("B%sombard 4%s");
6210 /* TRANS: Lethal B_ombard (100% chance of success). */
6211 return N_("Lethal B%sombard%s");
6212 case ACTION_SPY_NUKE:
6213 /* TRANS: Suitcase _Nuke (100% chance of success). */
6214 return N_("Suitcase %sNuke%s");
6216 /* TRANS: Suitcase _Nuke and Escape (100% chance of success). */
6217 return N_("Suitcase %sNuke and Escape%s");
6218 case ACTION_NUKE:
6219 /* TRANS: Explode _Nuclear (100% chance of success). */
6220 return N_("Explode %sNuclear%s");
6221 case ACTION_NUKE_CITY:
6222 /* TRANS: _Nuke City (100% chance of success). */
6223 return N_("%sNuke City%s");
6224 case ACTION_NUKE_UNITS:
6225 /* TRANS: _Nuke Units (100% chance of success). */
6226 return N_("%sNuke Units%s");
6228 /* TRANS: Destroy _City (100% chance of success). */
6229 return N_("Destroy %sCity%s");
6231 /* TRANS: Dis_band recovering production (100% chance of success). */
6232 return N_("Dis%sband recovering production%s");
6234 /* TRANS: Dis_band without recovering production (100% chance of success). */
6235 return N_("Dis%sband without recovering production%s");
6236 case ACTION_HOME_CITY:
6237 /* TRANS: Set _Home City (100% chance of success). */
6238 return N_("Set %sHome City%s");
6239 case ACTION_HOMELESS:
6240 /* TRANS: Make _Homeless (100% chance of success). */
6241 return N_("Make %sHomeless%s");
6243 /* TRANS: _Upgrade Unit (100% chance of success). */
6244 return N_("%sUpgrade Unit%s");
6245 case ACTION_PARADROP:
6246 /* TRANS: Drop _Paratrooper (100% chance of success). */
6247 return N_("Drop %sParatrooper%s");
6249 /* TRANS: Drop _Paratrooper (100% chance of success). */
6250 return N_("Drop %sParatrooper%s");
6252 /* TRANS: Drop _Paratrooper (100% chance of success). */
6253 return N_("Drop %sParatrooper%s");
6255 /* TRANS: Drop _Paratrooper (100% chance of success). */
6256 return N_("Drop %sParatrooper%s");
6258 /* TRANS: Drop _Paratrooper (100% chance of success). */
6259 return N_("Drop %sParatrooper%s");
6261 /* TRANS: Drop _Paratrooper (100% chance of success). */
6262 return N_("Drop %sParatrooper%s");
6263 case ACTION_AIRLIFT:
6264 /* TRANS: _Airlift to City (100% chance of success). */
6265 return N_("%sAirlift to City%s");
6266 case ACTION_ATTACK:
6267 case ACTION_ATTACK2:
6268 /* TRANS: _Attack (100% chance of success). */
6269 return N_("%sAttack%s");
6272 /* TRANS: _Suicide Attack (100% chance of success). */
6273 return N_("%sSuicide Attack%s");
6274 case ACTION_WIPE_UNITS:
6275 /* TRANS: _Wipe Units (100% chance of success). */
6276 return N_("%sWipe Units%s");
6278 /* TRANS: Collect _Ransom (100% chance of success). */
6279 return N_("Collect %sRansom%s");
6281 /* TRANS: Surgical Str_ike Building (100% chance of success). */
6282 return N_("Surgical Str%sike Building%s");
6284 /* TRANS: Surgical Str_ike Production (100% chance of success). */
6285 return N_("Surgical Str%sike Production%s");
6289 /* TRANS: _Conquer City (100% chance of success). */
6290 return N_("%sConquer City%s");
6292 /* TRANS: _Conquer City 2 (100% chance of success). */
6293 return N_("%sConquer City 2%s");
6297 /* TRANS: _Conquer Extras (100% chance of success). */
6298 return N_("%sConquer Extras%s");
6300 /* TRANS: _Conquer Extras 2 (100% chance of success). */
6301 return N_("%sConquer Extras 2%s");
6302 case ACTION_HEAL_UNIT:
6303 case ACTION_HEAL_UNIT2:
6304 /* TRANS: Heal _Unit (3% chance of success). */
6305 return N_("Heal %sUnit%s");
6308 /* TRANS: _Transform Terrain (3% chance of success). */
6309 return N_("%sTransform Terrain%s");
6310 case ACTION_CULTIVATE:
6311 case ACTION_CULTIVATE2:
6312 /* TRANS: Transform by _Cultivating (3% chance of success). */
6313 return N_("Transform by %sCultivating%s");
6314 case ACTION_PLANT:
6315 case ACTION_PLANT2:
6316 /* TRANS: Transform by _Planting (3% chance of success). */
6317 return N_("Transform by %sPlanting%s");
6318 case ACTION_PILLAGE:
6319 case ACTION_PILLAGE2:
6320 /* TRANS: Pilla_ge (100% chance of success). */
6321 return N_("Pilla%sge%s");
6322 case ACTION_CLEAN:
6323 case ACTION_CLEAN2:
6324 /* TRANS: Clean (100% chance of success). */
6325 return N_("%sClean%s");
6326 case ACTION_FORTIFY:
6327 case ACTION_FORTIFY2:
6328 /* TRANS: _Fortify (100% chance of success). */
6329 return N_("%sFortify%s");
6330 case ACTION_ROAD:
6331 case ACTION_ROAD2:
6332 /* TRANS: Build _Road (100% chance of success). */
6333 return N_("Build %sRoad%s");
6334 case ACTION_CONVERT:
6335 /* TRANS: _Convert Unit (100% chance of success). */
6336 return N_("%sConvert Unit%s");
6337 case ACTION_BASE:
6338 case ACTION_BASE2:
6339 /* TRANS: _Build Base (100% chance of success). */
6340 return N_("%sBuild Base%s");
6341 case ACTION_MINE:
6342 case ACTION_MINE2:
6343 /* TRANS: Build _Mine (100% chance of success). */
6344 return N_("Build %sMine%s");
6345 case ACTION_IRRIGATE:
6346 case ACTION_IRRIGATE2:
6347 /* TRANS: Build _Irrigation (100% chance of success). */
6348 return N_("Build %sIrrigation%s");
6350 /* TRANS: _Deboard (100% chance of success). */
6351 return N_("%sDeboard%s");
6355 /* TRANS: _Board (100% chance of success). */
6356 return N_("%sBoard%s");
6361 /* TRANS: _Embark (100% chance of success). */
6362 return N_("%sEmbark%s");
6364 /* TRANS: _Unload (100% chance of success). */
6365 return N_("%sUnload%s");
6369 /* TRANS: _Load (100% chance of success). */
6370 return N_("%sLoad%s");
6374 /* TRANS: _Disembark (100% chance of success). */
6375 return N_("%sDisembark%s");
6377 /* TRANS: _Disembark 2 (100% chance of success). */
6378 return N_("%sDisembark 2%s");
6379 case ACTION_SPY_ATTACK:
6380 /* TRANS: _Eliminate Diplomat (100% chance of success). */
6381 return N_("%sEliminate Diplomat%s");
6382 case ACTION_HUT_ENTER:
6383 case ACTION_HUT_ENTER2:
6384 case ACTION_HUT_ENTER3:
6385 case ACTION_HUT_ENTER4:
6386 /* TRANS: Enter _Hut (100% chance of success). */
6387 return N_("Enter %sHut%s");
6392 /* TRANS: Frighten _Hut (100% chance of success). */
6393 return N_("Frighten %sHut%s");
6394 case ACTION_UNIT_MOVE:
6395 case ACTION_UNIT_MOVE2:
6396 case ACTION_UNIT_MOVE3:
6397 /* TRANS: Regular _Move (100% chance of success). */
6398 return N_("Regular %sMove%s");
6399 case ACTION_TELEPORT:
6400 case ACTION_TELEPORT2:
6401 case ACTION_TELEPORT3:
6402 /* TRANS: _Teleport (100% chance of success). */
6403 return N_("%sTeleport%s");
6405 /* TRANS: _Teleport (100% chance of success). */
6406 return N_("%sTeleport%s");
6408 /* TRANS: _Teleport (100% chance of success). */
6409 return N_("%sTeleport%s");
6411 /* TRANS: _Teleport (100% chance of success). */
6412 return N_("%sTeleport%s");
6414 /* TRANS: _Teleport (100% chance of success). */
6415 return N_("%sTeleport%s");
6417 /* TRANS: _Teleport (100% chance of success). */
6418 return N_("%sTeleport%s");
6419 case ACTION_SPY_ESCAPE:
6420 /* TRANS: _Escape To Nearest City (100% chance of success). */
6421 return N_("%sEscape To Nearest City%s");
6423 /* TRANS: _User Action 1 (100% chance of success). */
6424 return N_("%sUser Action 1%s");
6426 /* TRANS: _User Action 2 (100% chance of success). */
6427 return N_("%sUser Action 2%s");
6429 /* TRANS: _User Action 3 (100% chance of success). */
6430 return N_("%sUser Action 3%s");
6432 /* TRANS: _User Action 4 (100% chance of success). */
6433 return N_("%sUser Action 4%s");
6435 return N_("%sGain Veterancy%s");
6436 case ACTION_ESCAPE:
6437 return N_("%sEscape%s");
6438 case ACTION_CIVIL_WAR:
6439 return N_("%sCivil War%s");
6440 case ACTION_COUNT:
6441 fc_assert(act != ACTION_COUNT);
6442 break;
6443 }
6444
6445 return NULL;
6446}
6447
6448/**********************************************************************/
6455{
6456 switch ((enum gen_action)act) {
6457 case ACTION_SPY_POISON:
6482 case ACTION_STEAL_MAPS:
6484 case ACTION_TRADE_ROUTE:
6485 case ACTION_MARKETPLACE:
6486 case ACTION_HELP_WONDER:
6488 case ACTION_EXPEL_UNIT:
6489 case ACTION_FOUND_CITY:
6490 case ACTION_JOIN_CITY:
6491 case ACTION_SPY_NUKE:
6496 case ACTION_HOME_CITY:
6497 case ACTION_HOMELESS:
6499 case ACTION_PARADROP:
6505 case ACTION_AIRLIFT:
6506 case ACTION_ATTACK:
6507 case ACTION_ATTACK2:
6510 case ACTION_WIPE_UNITS:
6518 case ACTION_HEAL_UNIT:
6519 case ACTION_HEAL_UNIT2:
6522 case ACTION_CULTIVATE:
6523 case ACTION_CULTIVATE2:
6524 case ACTION_PLANT:
6525 case ACTION_PLANT2:
6526 case ACTION_PILLAGE:
6527 case ACTION_PILLAGE2:
6528 case ACTION_CLEAN:
6529 case ACTION_CLEAN2:
6530 case ACTION_FORTIFY:
6531 case ACTION_FORTIFY2:
6532 case ACTION_ROAD:
6533 case ACTION_ROAD2:
6534 case ACTION_CONVERT:
6535 case ACTION_BASE:
6536 case ACTION_BASE2:
6537 case ACTION_MINE:
6538 case ACTION_MINE2:
6539 case ACTION_IRRIGATE:
6540 case ACTION_IRRIGATE2:
6557 case ACTION_BOMBARD:
6558 case ACTION_BOMBARD2:
6559 case ACTION_BOMBARD3:
6560 case ACTION_BOMBARD4:
6563 case ACTION_SPY_ATTACK:
6568 case ACTION_HUT_ENTER:
6569 case ACTION_HUT_ENTER2:
6570 case ACTION_HUT_ENTER3:
6571 case ACTION_HUT_ENTER4:
6576 case ACTION_UNIT_MOVE:
6577 case ACTION_UNIT_MOVE2:
6578 case ACTION_UNIT_MOVE3:
6579 case ACTION_SPY_ESCAPE:
6581 case ACTION_ESCAPE:
6582 case ACTION_CIVIL_WAR:
6583 /* Min range is not ruleset changeable */
6584 return NULL;
6585 case ACTION_NUKE:
6586 return "explode_nuclear_min_range";
6587 case ACTION_NUKE_CITY:
6588 return "nuke_city_min_range";
6589 case ACTION_NUKE_UNITS:
6590 return "nuke_units_min_range";
6591 case ACTION_TELEPORT:
6592 return "teleport_min_range";
6593 case ACTION_TELEPORT2:
6594 return "teleport_2_min_range";
6595 case ACTION_TELEPORT3:
6596 return "teleport_3_min_range";
6598 return "teleport_conquer_min_range";
6600 return "teleport_frighten_min_range";
6602 return "teleport_frighten_conquer_min_range";
6604 return "teleport_enter_min_range";
6606 return "teleport_enter_conquer_min_range";
6608 return "user_action_1_min_range";
6610 return "user_action_2_min_range";
6612 return "user_action_3_min_range";
6614 return "user_action_4_min_range";
6615 case ACTION_COUNT:
6616 break;
6617
6619 }
6620
6621 fc_assert(act >= 0 && act < ACTION_COUNT);
6622
6623 return NULL;
6624}
6625
6626/**********************************************************************/
6633{
6634 switch ((enum gen_action)act) {
6635 case ACTION_SPY_POISON:
6660 case ACTION_STEAL_MAPS:
6662 case ACTION_TRADE_ROUTE:
6663 case ACTION_MARKETPLACE:
6665 case ACTION_EXPEL_UNIT:
6666 case ACTION_FOUND_CITY:
6667 case ACTION_JOIN_CITY:
6668 case ACTION_SPY_NUKE:
6672 case ACTION_HOME_CITY:
6673 case ACTION_HOMELESS:
6675 case ACTION_PARADROP:
6681 case ACTION_ATTACK:
6682 case ACTION_ATTACK2:
6685 case ACTION_WIPE_UNITS:
6693 case ACTION_HEAL_UNIT:
6694 case ACTION_HEAL_UNIT2:
6697 case ACTION_CULTIVATE:
6698 case ACTION_CULTIVATE2:
6699 case ACTION_PLANT:
6700 case ACTION_PLANT2:
6701 case ACTION_PILLAGE:
6702 case ACTION_PILLAGE2:
6703 case ACTION_CLEAN:
6704 case ACTION_CLEAN2:
6705 case ACTION_FORTIFY:
6706 case ACTION_FORTIFY2:
6707 case ACTION_ROAD:
6708 case ACTION_ROAD2:
6709 case ACTION_CONVERT:
6710 case ACTION_BASE:
6711 case ACTION_BASE2:
6712 case ACTION_MINE:
6713 case ACTION_MINE2:
6714 case ACTION_IRRIGATE:
6715 case ACTION_IRRIGATE2:
6732 case ACTION_SPY_ATTACK:
6737 case ACTION_HUT_ENTER:
6738 case ACTION_HUT_ENTER2:
6739 case ACTION_HUT_ENTER3:
6740 case ACTION_HUT_ENTER4:
6745 case ACTION_UNIT_MOVE:
6746 case ACTION_UNIT_MOVE2:
6747 case ACTION_UNIT_MOVE3:
6748 case ACTION_SPY_ESCAPE:
6750 case ACTION_ESCAPE:
6751 case ACTION_CIVIL_WAR:
6752 /* Max range is not ruleset changeable */
6753 return NULL;
6754 case ACTION_HELP_WONDER:
6755 return "help_wonder_max_range";
6757 return "disband_unit_recover_max_range";
6758 case ACTION_BOMBARD:
6759 return "bombard_max_range";
6760 case ACTION_BOMBARD2:
6761 return "bombard_2_max_range";
6762 case ACTION_BOMBARD3:
6763 return "bombard_3_max_range";
6764 case ACTION_BOMBARD4:
6765 return "bombard_4_max_range";
6767 return "bombard_lethal_max_range";
6769 return "bombard_lethal_2_max_range";
6770 case ACTION_NUKE:
6771 return "explode_nuclear_max_range";
6772 case ACTION_NUKE_CITY:
6773 return "nuke_city_max_range";
6774 case ACTION_NUKE_UNITS:
6775 return "nuke_units_max_range";
6776 case ACTION_AIRLIFT:
6777 return "airlift_max_range";
6778 case ACTION_TELEPORT:
6779 return "teleport_max_range";
6780 case ACTION_TELEPORT2:
6781 return "teleport_2_max_range";
6782 case ACTION_TELEPORT3:
6783 return "teleport_3_max_range";
6785 return "teleport_conquer_max_range";
6787 return "teleport_frighten_max_range";
6789 return "teleport_frighten_conquer_max_range";
6791 return "teleport_enter_max_range";
6793 return "teleport_enter_conquer_max_range";
6795 return "user_action_1_max_range";
6797 return "user_action_2_max_range";
6799 return "user_action_3_max_range";
6801 return "user_action_4_max_range";
6802 case ACTION_COUNT:
6803 break;
6804
6806 }
6807
6808 fc_assert(act >= 0 && act < ACTION_COUNT);
6809
6810 return NULL;
6811}
6812
6813/**********************************************************************/
6820{
6821 switch ((enum gen_action)act) {
6822 case ACTION_SPY_POISON:
6847 case ACTION_STEAL_MAPS:
6849 case ACTION_TRADE_ROUTE:
6850 case ACTION_MARKETPLACE:
6851 case ACTION_HELP_WONDER:
6853 case ACTION_EXPEL_UNIT:
6854 case ACTION_FOUND_CITY:
6855 case ACTION_JOIN_CITY:
6856 case ACTION_SPY_NUKE:
6858 case ACTION_NUKE_UNITS:
6862 case ACTION_HOME_CITY:
6863 case ACTION_HOMELESS:
6865 case ACTION_PARADROP:
6871 case ACTION_AIRLIFT:
6872 case ACTION_ATTACK:
6873 case ACTION_ATTACK2:
6876 case ACTION_WIPE_UNITS:
6884 case ACTION_HEAL_UNIT:
6885 case ACTION_HEAL_UNIT2:
6888 case ACTION_CULTIVATE:
6889 case ACTION_CULTIVATE2:
6890 case ACTION_PLANT:
6891 case ACTION_PLANT2:
6892 case ACTION_CLEAN:
6893 case ACTION_CLEAN2:
6894 case ACTION_FORTIFY:
6895 case ACTION_FORTIFY2:
6896 case ACTION_ROAD:
6897 case ACTION_ROAD2:
6898 case ACTION_CONVERT:
6899 case ACTION_BASE:
6900 case ACTION_BASE2:
6901 case ACTION_MINE:
6902 case ACTION_MINE2:
6903 case ACTION_IRRIGATE:
6904 case ACTION_IRRIGATE2:
6921 case ACTION_BOMBARD:
6922 case ACTION_BOMBARD2:
6923 case ACTION_BOMBARD3:
6924 case ACTION_BOMBARD4:
6927 case ACTION_SPY_ATTACK:
6932 case ACTION_HUT_ENTER:
6933 case ACTION_HUT_ENTER2:
6934 case ACTION_HUT_ENTER3:
6935 case ACTION_HUT_ENTER4:
6940 case ACTION_UNIT_MOVE:
6941 case ACTION_UNIT_MOVE2:
6942 case ACTION_UNIT_MOVE3:
6943 case ACTION_TELEPORT:
6944 case ACTION_TELEPORT2:
6945 case ACTION_TELEPORT3:
6951 case ACTION_SPY_ESCAPE:
6953 case ACTION_ESCAPE:
6954 case ACTION_CIVIL_WAR:
6955 /* Target kind is not ruleset changeable */
6956 return NULL;
6957 case ACTION_NUKE:
6958 return "explode_nuclear_target_kind";
6959 case ACTION_NUKE_CITY:
6960 return "nuke_city_target_kind";
6961 case ACTION_PILLAGE:
6962 return "pillage_target_kind";
6963 case ACTION_PILLAGE2:
6964 return "pillage_2_target_kind";
6966 return "user_action_1_target_kind";
6968 return "user_action_2_target_kind";
6970 return "user_action_3_target_kind";
6972 return "user_action_4_target_kind";
6973 case ACTION_COUNT:
6974 break;
6975
6977 }
6978
6979 fc_assert(act >= 0 && act < ACTION_COUNT);
6980
6981 return NULL;
6982}
6983
6984/**********************************************************************/
6992{
6993 switch ((enum gen_action)act) {
6994 case ACTION_SPY_POISON:
7018 case ACTION_STEAL_MAPS:
7020 case ACTION_TRADE_ROUTE:
7021 case ACTION_MARKETPLACE:
7022 case ACTION_HELP_WONDER:
7024 case ACTION_EXPEL_UNIT:
7025 case ACTION_JOIN_CITY:
7026 case ACTION_SPY_NUKE:
7031 case ACTION_HOME_CITY:
7032 case ACTION_HOMELESS:
7034 case ACTION_PARADROP:
7040 case ACTION_AIRLIFT:
7041 case ACTION_ATTACK:
7042 case ACTION_ATTACK2:
7045 case ACTION_WIPE_UNITS:
7053 case ACTION_HEAL_UNIT:
7054 case ACTION_HEAL_UNIT2:
7057 case ACTION_CULTIVATE:
7058 case ACTION_CULTIVATE2:
7059 case ACTION_PLANT:
7060 case ACTION_PLANT2:
7061 case ACTION_PILLAGE:
7062 case ACTION_PILLAGE2:
7063 case ACTION_CLEAN:
7064 case ACTION_CLEAN2:
7065 case ACTION_FORTIFY:
7066 case ACTION_FORTIFY2:
7067 case ACTION_ROAD:
7068 case ACTION_ROAD2:
7069 case ACTION_CONVERT:
7070 case ACTION_BASE:
7071 case ACTION_BASE2:
7072 case ACTION_MINE:
7073 case ACTION_MINE2:
7074 case ACTION_IRRIGATE:
7075 case ACTION_IRRIGATE2:
7092 case ACTION_BOMBARD:
7093 case ACTION_BOMBARD2:
7094 case ACTION_BOMBARD3:
7095 case ACTION_BOMBARD4:
7098 case ACTION_SPY_ATTACK:
7103 case ACTION_HUT_ENTER:
7104 case ACTION_HUT_ENTER2:
7105 case ACTION_HUT_ENTER3:
7106 case ACTION_HUT_ENTER4:
7111 case ACTION_UNIT_MOVE:
7112 case ACTION_UNIT_MOVE2:
7113 case ACTION_UNIT_MOVE3:
7114 case ACTION_TELEPORT:
7115 case ACTION_TELEPORT2:
7116 case ACTION_TELEPORT3:
7122 case ACTION_SPY_ESCAPE:
7124 case ACTION_ESCAPE:
7125 case ACTION_CIVIL_WAR:
7126 /* Actor consuming always is not ruleset changeable */
7127 return NULL;
7128 case ACTION_FOUND_CITY:
7129 return "found_city_consuming_always";
7130 case ACTION_NUKE:
7131 return "explode_nuclear_consuming_always";
7132 case ACTION_NUKE_CITY:
7133 return "nuke_city_consuming_always";
7134 case ACTION_NUKE_UNITS:
7135 return "nuke_units_consuming_always";
7137 return "spread_plague_actor_consuming_always";
7139 return "user_action_1_actor_consuming_always";
7141 return "user_action_2_actor_consuming_always";
7143 return "user_action_3_actor_consuming_always";
7145 return "user_action_4_actor_consuming_always";
7146 case ACTION_COUNT:
7147 break;
7148
7150 }
7151
7152 fc_assert(act >= 0 && act < ACTION_COUNT);
7153
7154 return NULL;
7155}
7156
7157/**********************************************************************/
7164const char *action_blocked_by_ruleset_var_name(const struct action *act)
7165{
7166 fc_assert_ret_val(act != NULL, NULL);
7167
7168 switch ((enum gen_action)action_number(act)) {
7169 case ACTION_MARKETPLACE:
7170 return "enter_marketplace_blocked_by";
7171 case ACTION_BOMBARD:
7172 return "bombard_blocked_by";
7173 case ACTION_BOMBARD2:
7174 return "bombard_2_blocked_by";
7175 case ACTION_BOMBARD3:
7176 return "bombard_3_blocked_by";
7177 case ACTION_BOMBARD4:
7178 return "bombard_4_blocked_by";
7180 return "bombard_lethal_blocked_by";
7182 return "bombard_lethal_2_blocked_by";
7183 case ACTION_NUKE:
7184 return "explode_nuclear_blocked_by";
7185 case ACTION_NUKE_CITY:
7186 return "nuke_city_blocked_by";
7187 case ACTION_NUKE_UNITS:
7188 return "nuke_units_blocked_by";
7189 case ACTION_ATTACK:
7190 return "attack_blocked_by";
7191 case ACTION_ATTACK2:
7192 return "attack_2_blocked_by";
7194 return "suicide_attack_blocked_by";
7196 return "suicide_attack_2_blocked_by";
7197 case ACTION_WIPE_UNITS:
7198 return "wipe_units_blocked_by";
7200 return "collect_ransom_blocked_by";
7202 return "conquer_city_shrink_blocked_by";
7204 return "conquer_city_shrink_2_blocked_by";
7206 return "conquer_city_shrink_3_blocked_by";
7208 return "conquer_city_shrink_4_blocked_by";
7209 case ACTION_UNIT_MOVE:
7210 return "move_blocked_by";
7211 case ACTION_UNIT_MOVE2:
7212 return "move_2_blocked_by";
7213 case ACTION_UNIT_MOVE3:
7214 return "move_3_blocked_by";
7215 case ACTION_TELEPORT:
7216 return "teleport_blocked_by";
7217 case ACTION_TELEPORT2:
7218 return "teleport_2_blocked_by";
7219 case ACTION_TELEPORT3:
7220 return "teleport_3_blocked_by";
7222 return "teleport_conquer_blocked_by";
7224 return "teleport_frighten_blocked_by";
7226 return "teleport_frighten_conquer_blocked_by";
7228 return "teleport_enter_blocked_by";
7230 return "teleport_enter_conquer_blocked_by";
7231 case ACTION_SPY_ESCAPE:
7232 case ACTION_SPY_POISON:
7256 case ACTION_STEAL_MAPS:
7258 case ACTION_TRADE_ROUTE:
7259 case ACTION_HELP_WONDER:
7261 case ACTION_EXPEL_UNIT:
7262 case ACTION_FOUND_CITY:
7263 case ACTION_JOIN_CITY:
7264 case ACTION_SPY_NUKE:
7269 case ACTION_HOME_CITY:
7270 case ACTION_HOMELESS:
7272 case ACTION_PARADROP:
7278 case ACTION_AIRLIFT:
7281 case ACTION_HEAL_UNIT:
7282 case ACTION_HEAL_UNIT2:
7285 case ACTION_CULTIVATE:
7286 case ACTION_CULTIVATE2:
7287 case ACTION_PLANT:
7288 case ACTION_PLANT2:
7289 case ACTION_PILLAGE:
7290 case ACTION_PILLAGE2:
7291 case ACTION_CLEAN:
7292 case ACTION_CLEAN2:
7293 case ACTION_FORTIFY:
7294 case ACTION_FORTIFY2:
7295 case ACTION_ROAD:
7296 case ACTION_ROAD2:
7297 case ACTION_CONVERT:
7298 case ACTION_BASE:
7299 case ACTION_BASE2:
7300 case ACTION_MINE:
7301 case ACTION_MINE2:
7302 case ACTION_IRRIGATE:
7303 case ACTION_IRRIGATE2:
7321 case ACTION_SPY_ATTACK:
7326 case ACTION_HUT_ENTER:
7327 case ACTION_HUT_ENTER2:
7328 case ACTION_HUT_ENTER3:
7329 case ACTION_HUT_ENTER4:
7335 case ACTION_CIVIL_WAR:
7336 case ACTION_ESCAPE:
7341 /* blocked_by is not ruleset changeable */
7342 return NULL;
7343 case ACTION_COUNT:
7345 break;
7346
7348 }
7349
7350 return NULL;
7351}
7352
7353/**********************************************************************/
7357const char *
7359{
7360 fc_assert_ret_val(act != NULL, NULL);
7361
7367 /* No support in the action performer function */
7368 return NULL;
7369 }
7370
7371 switch ((enum gen_action)action_number(act)) {
7373 return "bribe_unit_post_success_forced_actions";
7375 return "bribe_stack_post_success_forced_actions";
7376 case ACTION_ATTACK:
7377 return "attack_post_success_forced_actions";
7378 case ACTION_ATTACK2:
7379 return "attack_2_post_success_forced_actions";
7380 case ACTION_WIPE_UNITS:
7381 return "wipe_units_post_success_forced_actions";
7383 return "collect_ransom_post_success_forced_actions";
7384 case ACTION_MARKETPLACE:
7385 case ACTION_BOMBARD:
7386 case ACTION_BOMBARD2:
7387 case ACTION_BOMBARD3:
7388 case ACTION_BOMBARD4:
7391 case ACTION_NUKE:
7392 case ACTION_NUKE_CITY:
7393 case ACTION_NUKE_UNITS:
7400 case ACTION_SPY_POISON:
7422 case ACTION_STEAL_MAPS:
7424 case ACTION_TRADE_ROUTE:
7425 case ACTION_HELP_WONDER:
7427 case ACTION_EXPEL_UNIT:
7428 case ACTION_FOUND_CITY:
7429 case ACTION_JOIN_CITY:
7430 case ACTION_SPY_NUKE:
7435 case ACTION_HOME_CITY:
7436 case ACTION_HOMELESS:
7438 case ACTION_PARADROP:
7444 case ACTION_AIRLIFT:
7447 case ACTION_HEAL_UNIT:
7448 case ACTION_HEAL_UNIT2:
7451 case ACTION_CULTIVATE:
7452 case ACTION_CULTIVATE2:
7453 case ACTION_PLANT:
7454 case ACTION_PLANT2:
7455 case ACTION_PILLAGE:
7456 case ACTION_PILLAGE2:
7457 case ACTION_CLEAN:
7458 case ACTION_CLEAN2:
7459 case ACTION_FORTIFY:
7460 case ACTION_FORTIFY2:
7461 case ACTION_ROAD:
7462 case ACTION_ROAD2:
7463 case ACTION_CONVERT:
7464 case ACTION_BASE:
7465 case ACTION_BASE2:
7466 case ACTION_MINE:
7467 case ACTION_MINE2:
7468 case ACTION_IRRIGATE:
7469 case ACTION_IRRIGATE2:
7487 case ACTION_SPY_ATTACK:
7492 case ACTION_HUT_ENTER:
7493 case ACTION_HUT_ENTER2:
7494 case ACTION_HUT_ENTER3:
7495 case ACTION_HUT_ENTER4:
7500 case ACTION_UNIT_MOVE:
7501 case ACTION_UNIT_MOVE2:
7502 case ACTION_UNIT_MOVE3:
7503 case ACTION_TELEPORT:
7504 case ACTION_TELEPORT2:
7505 case ACTION_TELEPORT3:
7511 case ACTION_SPY_ESCAPE:
7513 case ACTION_ESCAPE:
7514 case ACTION_CIVIL_WAR:
7519 /* Not ruleset changeable */
7520 return NULL;
7521 case ACTION_COUNT:
7523 break;
7524
7526 }
7527
7528 return NULL;
7529}
7530
7531/**********************************************************************/
7539
7540/**********************************************************************/
7543const char *gen_action_name_update_cb(const char *old_name)
7544{
7545 if (is_ruleset_compat_mode()) {
7546 if (!fc_strcasecmp("Conquer City", old_name)) {
7547 return "Conquer City Shrink";
7548 }
7549 if (!fc_strcasecmp("Conquer City 2", old_name)) {
7550 return "Conquer City Shrink 2";
7551 }
7552 if (!fc_strcasecmp("Conquer City 3", old_name)) {
7553 return "Conquer City Shrink 3";
7554 }
7555 if (!fc_strcasecmp("Conquer City 4", old_name)) {
7556 return "Conquer City Shrink 4";
7557 }
7558 }
7559
7560 return old_name;
7561}
7562
7564{
7565 N_("individual cities"), /* ATK_CITY */
7566 N_("individual units"), /* ATK_UNIT */
7567 N_("unit stacks"), /* ATK_STACK */
7568 N_("tiles"), /* ATK_TILE */
7569 N_("tile extras"), /* ATK_EXTRAS */
7570 N_("itself") /* ATK_SELF */
7571};
7572
7573/**********************************************************************/
7578{
7579 fc_assert(kind >= 0 && kind < ATK_COUNT);
7580
7581 return _(atk_helpnames[kind]);
7582}
7583
7584/************************************************************************/
7588{
7589 fc_assert(result < ACTRES_LAST);
7590
7591 return actlist_by_result[result];
7592}
7593
7594/************************************************************************/
7598{
7599 fc_assert(activity < ACTIVITY_LAST);
7600
7601 return actlist_by_activity[activity];
7602}
bool is_action_possible_on_city(action_id act_id, const struct player *actor_player, const struct city *target_city)
Definition actions.c:5468
static struct action * actions[MAX_NUM_ACTIONS]
Definition actions.c:56
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1312
bool action_distance_inside_max(const struct action *action, const int distance)
Definition actions.c:1173
struct act_prob action_speculate_unit_on_extras(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4956
static enum fc_tristate is_action_possible(const struct civ_map *nmap, const action_id wanted_action, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, const bool omniscient, const struct city *homecity)
Definition actions.c:2791
const char * action_prob_explain(const struct act_prob prob)
Definition actions.c:1423
bool action_mp_full_makes_legal(const struct unit *actor, const action_id act_id)
Definition actions.c:5546
static struct act_prob action_prob_battle_then_dice_roll(const struct player *act_player, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct player *tgt_player, const struct action *paction)
Definition actions.c:3774
static bool is_action_enabled_unit_on_self_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile)
Definition actions.c:3406
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1098
bool action_prob_certain(const struct act_prob probability)
Definition actions.c:5078
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5707
req_vec_num_in_item action_enabler_vector_number(const void *enabler, const struct requirement_vector *vec)
Definition actions.c:2027
bool action_has_complex_target(const struct action *paction)
Definition actions.c:1132
static bool action_actor_utype_hard_reqs_ok_full(const struct action *paction, const struct unit_type *actor_unittype, bool ignore_third_party)
Definition actions.c:2376
struct req_vec_problem * action_enabler_suggest_repair(const struct action_enabler *enabler)
Definition actions.c:1897
static bool is_action_enabled_unit_on_tile_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3251
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5068
#define ACTPROB_VAL_NOT_IMPL
Definition actions.c:54
struct action_auto_perf auto_perfs[MAX_NUM_ACTION_AUTO_PERFORMERS]
Definition actions.c:58
bool action_actor_utype_hard_reqs_ok(const struct action *paction, const struct unit_type *actor_unittype)
Definition actions.c:2584
struct act_prob action_prob_new_not_impl(void)
Definition actions.c:5047
struct req_vec_problem * action_enabler_suggest_improvement(const struct action_enabler *enabler)
Definition actions.c:1963
static enum fc_tristate action_enabled_local(const action_id wanted_action, const struct req_context *actor, const struct req_context *target)
Definition actions.c:3501
struct act_prob action_speculate_unit_on_stack(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target)
Definition actions.c:4889
void actions_rs_pre_san_gen(void)
Definition actions.c:889
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:6454
struct act_prob action_speculate_unit_on_self(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat)
Definition actions.c:4990
static bool is_effect_val_known(enum effect_type effect_type, const struct player *pov_player, const struct req_context *context, const struct req_context *other_context)
Definition actions.c:3548
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7164
static bool is_action_enabled(const struct civ_map *nmap, const action_id wanted_action, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, const struct city *actor_home)
Definition actions.c:2964
#define ACTPROB_VAL_MAX
Definition actions.c:48
static struct act_prob action_prob(const struct civ_map *nmap, const action_id wanted_action, const struct req_context *actor, const struct city *actor_home, const struct req_context *target, const struct extra_type *target_extra)
Definition actions.c:3822
struct req_vec_problem * action_enabler_suggest_repair_oblig(const struct action_enabler *enabler)
Definition actions.c:1683
void action_array_add_all_by_result(action_id *act_array, int *position, enum action_result result)
Definition actions.c:5772
const char * action_name_translation(const struct action *paction)
Definition actions.c:1230
int action_dice_roll_odds(const struct player *act_player, const struct unit *act_unit, const struct city *tgt_city, const struct player *tgt_player, const struct action *paction)
Definition actions.c:5368
void action_array_end(action_id *act_array, int size)
Definition actions.c:5755
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4589
static struct act_prob action_prob_pre_action_dice_roll(const struct player *act_player, const struct unit *act_unit, const struct city *tgt_city, const struct player *tgt_player, const struct action *paction)
Definition actions.c:3726
const char * atk_helpnames[ATK_COUNT]
Definition actions.c:7563
static enum fc_tristate action_hard_reqs_actor(const struct civ_map *nmap, const struct action *paction, const struct req_context *actor, const bool omniscient, const struct city *homecity)
Definition actions.c:2604
static void hard_code_actions(void)
Definition actions.c:106
static bool is_action_enabled_unit_on_city_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct city *target_city)
Definition actions.c:3003
bool action_is_in_use(struct action *paction)
Definition actions.c:5661
static struct req_vec_problem * enabler_tile_tgt_local_diplrel_implies_claimed(const struct action_enabler *enabler)
Definition actions.c:1752
bool action_ever_possible(action_id action)
Definition actions.c:7535
const char * action_enabler_vector_by_number_name(req_vec_num_in_item vec)
Definition actions.c:2074
bool are_action_probabilitys_equal(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5119
static struct act_prob action_prob_self_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id)
Definition actions.c:4689
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7358
struct action * action_by_rule_name(const char *name)
Definition actions.c:1079
static bool action_has_possible_actor_hard_reqs(struct action *paction)
Definition actions.c:5631
static struct action * action_new(action_id id, enum action_actor_kind aak, enum action_result result, const int min_distance, const int max_distance, bool actor_consuming_always)
Definition actions.c:965
const char * action_rule_name(const struct action *action)
Definition actions.c:1216
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1239
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1119
static const struct tile * blocked_find_target_tile(const struct action *act, const struct unit *actor_unit, const struct tile *target_tile_arg, const struct city *target_city, const struct unit *target_unit)
Definition actions.c:2142
static bool action_prob_not_relevant(const struct act_prob probability)
Definition actions.c:5089
static struct act_prob ap_diplomat_battle(const struct unit *pattacker, const struct unit *pvictim, const struct tile *tgt_tile, const struct action *paction) fc__attribute((nonnull(3)))
Definition actions.c:3680
void actions_free(void)
Definition actions.c:899
static bool is_action_enabled_unit_on_extras_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3328
void action_enabler_free(struct action_enabler *enabler)
Definition actions.c:1495
bool is_action_enabled_unit_on_stack(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile)
Definition actions.c:3233
static enum fc_tristate tech_can_be_stolen(const struct player *actor_player, const struct player *target_player)
Definition actions.c:3567
static struct action_list * actlist_by_result[ACTRES_LAST]
Definition actions.c:99
struct action_list * action_list_by_activity(enum unit_activity activity)
Definition actions.c:7597
int action_number(const struct action *action)
Definition actions.c:1208
struct act_prob action_prob_new_unknown(void)
Definition actions.c:5057
bool action_would_be_blocked_by(const struct action *blocked, const struct action *blocker)
Definition actions.c:1196
#define ACTPROB_VAL_NA
Definition actions.c:52
static struct action * player_action_new(action_id id, enum action_result result)
Definition actions.c:1056
static struct req_vec_problem * enabler_first_clarification(const struct action_enabler *enabler)
Definition actions.c:1945
static bool action_prob_not_impl(const struct act_prob probability)
Definition actions.c:5100
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3309
struct act_prob action_prob_and(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5206
static bool actions_initialized
Definition actions.c:59
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:6991
bool action_immune_government(struct government *gov, action_id act)
Definition actions.c:5424
static bool is_target_possible(const action_id wanted_action, const struct player *actor_player, const struct req_context *target)
Definition actions.c:5447
static struct act_prob ap_dipl_battle_win(const struct unit *pattacker, const struct unit *pdefender)
Definition actions.c:3603
static struct act_prob action_prob_vs_stack_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4331
struct act_prob action_prob_vs_extras(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4672
struct act_prob action_prob_new_certain(void)
Definition actions.c:5027
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:6632
static struct act_prob action_prob_vs_city_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct city *target_city)
Definition actions.c:4144
bool action_is_internal(struct action *paction)
Definition actions.c:5687
int action_dice_roll_initial_odds(const struct action *paction)
Definition actions.c:5344
struct act_prob action_prob_self(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4742
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5276
static const struct unit_type * tgt_city_local_utype(const struct city *target_city)
Definition actions.c:2117
static struct requirement * req_vec_first_local_diplrel(const struct requirement_vector *vec)
Definition actions.c:1733
static struct act_prob action_prob_vs_tile_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4523
bool is_action_enabled_unit_on_city(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
Definition actions.c:3068
struct action_list * action_list_by_result(enum action_result result)
Definition actions.c:7587
bool action_univs_not_blocking(const struct action *paction, struct universal *actor_uni, struct universal *target_uni)
Definition actions.c:5731
struct act_prob action_speculate_unit_on_city(const struct civ_map *nmap, const action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, const bool omniscient_cheat, const struct city *target)
Definition actions.c:4821
bool actions_are_ready(void)
Definition actions.c:941
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Definition actions.c:3145
struct act_prob action_speculate_unit_on_tile(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4922
struct act_prob action_prob_vs_city(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Definition actions.c:4231
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:6819
static struct act_prob action_prob_vs_unit_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct unit *target_unit)
Definition actions.c:4247
bool action_maybe_possible_actor_unit(const struct civ_map *nmap, const action_id act_id, const struct unit *actor_unit)
Definition actions.c:5491
struct action * action_is_blocked_by(const struct civ_map *nmap, const struct action *act, const struct unit *actor_unit, const struct tile *target_tile_arg, const struct city *target_city_arg, const struct unit *target_unit)
Definition actions.c:2261
static bool is_enabler_active(const struct action_enabler *enabler, const struct req_context *actor, const struct req_context *target)
Definition actions.c:2947
static struct action_enabler_list * action_enablers_by_action[MAX_NUM_ACTIONS]
Definition actions.c:61
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:1526
const char * action_ui_name_default(int act)
Definition actions.c:6090
#define ACTPROB_VAL_1_PCT
Definition actions.c:50
bool action_enabler_utype_possible_actor(const struct action_enabler *ae, const struct unit_type *act_utype)
Definition actions.c:5569
static struct act_prob act_prob_unseen_target(const struct civ_map *nmap, action_id act_id, const struct unit *actor_unit)
Definition actions.c:3708
struct action_enabler * action_enabler_new(void)
Definition actions.c:1475
bool action_requires_details(const struct action *paction)
Definition actions.c:1145
struct act_prob action_prob_new_not_relevant(void)
Definition actions.c:5037
const char * action_target_kind_help(enum action_target_kind kind)
Definition actions.c:7577
static struct req_vec_problem * enabler_first_self_contradiction(const struct action_enabler *enabler)
Definition actions.c:1825
int action_get_role(const struct action *paction)
Definition actions.c:1463
struct act_prob action_speculate_unit_on_unit(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct unit *target)
Definition actions.c:4856
static struct action * unit_action_new(action_id id, enum action_result result, bool rare_pop_up, bool unitwaittime_controlled, enum moves_actor_kind moves_actor, const int min_distance, const int max_distance, bool actor_consuming_always)
Definition actions.c:1030
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:5723
struct act_prob action_prob_new_impossible(void)
Definition actions.c:5017
bool action_enabler_possible_actor(const struct action_enabler *ae)
Definition actions.c:5596
static const struct city * blocked_find_target_city(const struct action *act, const struct unit *actor_unit, const struct tile *target_tile, const struct city *target_city_arg, const struct unit *target_unit)
Definition actions.c:2202
struct action ** _actions
Definition actions.c:57
bool action_id_exists(const action_id act_id)
Definition actions.c:1068
bool action_enabler_remove(struct action_enabler *enabler)
Definition actions.c:1543
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1108
struct act_prob action_prob_unit_vs_tgt(const struct civ_map *nmap, const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Definition actions.c:4764
static bool action_prob_is_signal(const struct act_prob probability)
Definition actions.c:5111
struct action_enabler * action_enabler_copy(const struct action_enabler *original)
Definition actions.c:1511
static const char * action_prob_to_text(const struct act_prob prob)
Definition actions.c:1271
int action_prob_cmp_pessimist(const struct act_prob ap1, const struct act_prob ap2)
Definition actions.c:5128
struct act_prob action_prob_vs_stack(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4506
bool action_id_is_internal(action_id act)
Definition actions.c:5699
bool is_action_enabled_unit_on_self(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit)
Definition actions.c:3458
bool action_id_is_rare_pop_up(action_id act_id)
Definition actions.c:1160
void actions_init(void)
Definition actions.c:840
static struct req_vec_problem * ae_suggest_repair_if_no_oblig(const struct action_enabler *enabler, const struct obligatory_req_vector *oblig)
Definition actions.c:1579
struct act_prob action_prob_vs_unit(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Definition actions.c:4314
bool is_action_enabled_player(const struct civ_map *nmap, const action_id wanted_action, const struct player *actor_plr)
Definition actions.c:3471
static const struct impr_type * tgt_city_local_building(const struct city *target_city)
Definition actions.c:2094
static struct astring ui_name_str
Definition actions.c:63
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3386
static bool is_action_enabled_unit_on_unit_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct unit *target_unit)
Definition actions.c:3086
static bool is_action_enabled_unit_on_stack_full(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct tile *target_tile)
Definition actions.c:3163
double action_prob_to_0_to_1_pessimist(const struct act_prob ap)
Definition actions.c:5179
const char * gen_action_name_update_cb(const char *old_name)
Definition actions.c:7543
static struct action_list * actlist_by_activity[ACTIVITY_LAST]
Definition actions.c:100
struct action_enabler_list * action_enablers_for_action(action_id action)
Definition actions.c:1559
struct requirement_vector * action_enabler_vector_by_number(const void *enabler, req_vec_num_in_item number)
Definition actions.c:2050
bool action_distance_accepted(const struct action *action, const int distance)
Definition actions.c:1184
static struct act_prob action_prob_vs_extras_full(const struct civ_map *nmap, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4606
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:5792
const char * action_get_ui_name_mnemonic(action_id act_id, const char *mnemonic)
Definition actions.c:1258
#define ACTPROB_VAL_MIN
Definition actions.c:46
#define action_noninternal_iterate_end
Definition actions.h:240
#define ACTION_DISTANCE_MAX
Definition actions.h:107
#define enabler_get_action(_enabler_)
Definition actions.h:186
#define ASSERT_UNUSED_ACTION_CASES
Definition actions.h:38
#define ACTPROB_CERTAIN
Definition actions.h:692
#define enabler_get_action_id(_enabler_)
Definition actions.h:187
#define ACTPROB_NA
Definition actions.h:693
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_enabler_list_re_iterate_end
Definition actions.h:200
#define ACTION_DISTANCE_LAST_NON_SIGNAL
Definition actions.h:103
#define action_enabler_list_re_iterate(action_enabler_list, aenabler)
Definition actions.h:196
#define action_has_result(_act_, _res_)
Definition actions.h:184
#define action_enabler_list_iterate_end
Definition actions.h:194
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:105
#define action_iterate_end
Definition actions.h:218
#define MAX_NUM_ACTIONS
Definition actions.h:62
#define action_iterate_all(_act_)
Definition actions.h:204
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_iterate_all_end
Definition actions.h:209
#define ACTPROB_NOT_KNOWN
Definition actions.h:695
#define action_enabler_list_iterate(action_enabler_list, aenabler)
Definition actions.h:192
#define action_id_distance_accepted(act_id, distance)
Definition actions.h:449
#define ACTPROB_IMPOSSIBLE
Definition actions.h:691
#define ACTPROB_NOT_IMPLEMENTED
Definition actions.h:694
#define action_iterate(_act_)
Definition actions.h:214
#define ACTION_ANY
Definition actions.h:56
#define action_noninternal_iterate(_act_)
Definition actions.h:235
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define action_id_has_result_safe(act_id, result)
Definition actions.h:430
#define ACTION_ODDS_PCT_DICE_ROLL_NA
Definition actions.h:698
#define ACTION_NONE
Definition actions.h:59
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:672
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:258
enum fc_tristate actres_possible(const struct civ_map *nmap, enum action_result result, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, enum fc_tristate def, bool omniscient, const struct city *homecity)
Definition actres.c:835
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:301
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:364
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:272
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:770
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
@ DRT_DIPLCHANCE
Definition actres.h:107
@ DRT_CERTAIN
Definition actres.h:107
@ DRT_NONE
Definition actres.h:107
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
void astr_clear(struct astring *astr)
Definition astring.c:201
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:271
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
bool territory_claiming_base(const struct base_type *pbase)
Definition base.c:162
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
static bool is_non_attack_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:755
#define city_tile(_pcity_)
Definition city.h:561
#define city_owner(_pcity_)
Definition city.h:560
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender, const struct action *paction)
Definition combat.c:480
enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit, const struct action *paction, const struct tile *ptile)
Definition combat.c:257
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile, const struct action *paction)
Definition combat.c:841
struct unit * get_diplomatic_defender(const struct unit *act_unit, const struct unit *pvictim, const struct tile *tgt_tile, const struct action *paction)
Definition combat.c:947
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:312
@ ATT_OK
Definition combat.h:35
char * enablers
Definition comments.c:57
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
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 * target_tile
Definition dialogs_g.h:57
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
int int id
Definition editgui_g.h:28
struct @22::@23 reqs
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct req_context *other_context, enum effect_type effect_type)
Definition effects.c:744
struct effect_list * get_effects(enum effect_type effect_type)
Definition effects.c:143
#define effect_list_iterate_end
Definition effects.h:81
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:79
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:275
bool is_native_extra_to_uclass(const struct extra_type *pextra, const struct unit_class *pclass)
Definition extras.c:857
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define extra_type_list_iterate_end
Definition extras.h:167
const struct functions * fc_funcs
int Tech_type_id
Definition fc_types.h:236
@ RPT_CERTAIN
Definition fc_types.h:533
@ RPT_POSSIBLE
Definition fc_types.h:532
int action_id
Definition fc_types.h:248
#define ACTRES_NONE
Definition fc_types.h:186
#define MAX_NUM_ACTION_AUTO_PERFORMERS
Definition fc_types.h:54
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
struct civ_game game
Definition game.c:61
static bool is_ruleset_compat_mode(void)
Definition game.h:370
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert_ret(condition)
Definition log.h:192
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action_msg(condition, action, message,...)
Definition log.h:202
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_error(message,...)
Definition log.h:104
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:238
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:209
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:675
#define MAP_DISTANCE_MAX
Definition map.h:674
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
bool can_see_techs_of_target(const struct player *pow_player, const struct player *target_player)
enum fc_tristate mke_eval_reqs(const struct player *pov_player, const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:350
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:362
int unit_move_rate(const struct unit *punit)
Definition movement.c:89
bool unit_could_load_at(const struct unit *punit, const struct tile *ptile)
Definition movement.c:944
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:901
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:213
void oblig_hard_reqs_init(void)
Definition oblig_reqs.c:809
void oblig_hard_reqs_free(void)
Definition oblig_reqs.c:829
void hard_code_oblig_hard_reqs_ruleset(void)
Definition oblig_reqs.c:772
void hard_code_oblig_hard_reqs(void)
Definition oblig_reqs.c:252
struct obligatory_req_vector * oblig_hard_reqs_get(enum action_result res)
Definition oblig_reqs.c:854
struct obligatory_req_vector * oblig_hard_reqs_get_sub(enum action_sub_result res)
Definition oblig_reqs.c:865
#define obligatory_req_vector_iterate_end
Definition oblig_reqs.h:48
#define obligatory_req_vector_iterate(obreq_vec, pobreq)
Definition oblig_reqs.h:46
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 pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1388
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1164
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1409
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:993
bool player_can_trust_tile_has_no_units(const struct player *pplayer, const struct tile *ptile)
Definition player.c:967
bool universal_never_there(const struct universal *source)
const struct req_context * req_context_empty(void)
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
bool universal_fulfills_requirements(bool check_necessary, const struct requirement_vector *reqs, const struct universal *source)
struct req_vec_problem * req_vec_suggest_repair(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
struct req_vec_problem * req_vec_problem_new(int num_suggested_solutions, const char *descr,...)
bool are_reqs_active(const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct requirement * req_vec_first_contradiction_in_vec(const struct requirement *req, const struct requirement_vector *vec)
bool does_req_contradicts_reqs(const struct requirement *req, const struct requirement_vector *vec)
bool req_vec_is_impossible_to_fulfill(const struct requirement_vector *reqs)
struct req_vec_problem * req_vec_suggest_improvement(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
#define requirement_fulfilled_by_unit_type(_ut_, _rqs_)
signed char req_vec_num_in_item
req_vec_num_in_item a requirement vectors number in an item.
#define requirement_vector_iterate_end
#define requirement_fulfilled_by_government(_gov_, _rqs_)
#define requirement_vector_iterate(req_vec, preq)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
server_setting_id server_setting_by_name(const char *name)
int server_setting_value_int_get(server_setting_id id)
enum fc_tristate fc_tristate_and(enum fc_tristate one, enum fc_tristate two)
Definition shared.c:127
fc_tristate
Definition shared.h:46
@ TRI_YES
Definition shared.h:46
@ TRI_NO
Definition shared.h:46
@ TRI_MAYBE
Definition shared.h:46
#define CLIP(lower, current, upper)
Definition shared.h:57
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
int max
Definition fc_types.h:950
int min
Definition fc_types.h:949
enum action_auto_perf_cause cause
Definition actions.h:327
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:335
action_id action
Definition actions.h:171
struct requirement_vector actor_reqs
Definition actions.h:172
struct requirement_vector target_reqs
Definition actions.h:173
bool unitwaittime_controlled
Definition actions.h:160
action_id id
Definition actions.h:111
bool actor_consuming_always
Definition actions.h:144
bool rare_pop_up
Definition actions.h:157
int max_distance
Definition actions.h:127
bool quiet
Definition actions.h:134
enum action_sub_target_kind sub_target_kind
Definition actions.h:119
enum moves_actor_kind moves_actor
Definition actions.h:164
struct action::@12::@13 is_unit
enum action_result result
Definition actions.h:114
char ui_name[MAX_LEN_NAME]
Definition actions.h:130
bv_action_sub_results sub_results
Definition actions.h:115
enum action_actor_kind actor_kind
Definition actions.h:117
enum act_tgt_compl target_complexity
Definition actions.h:122
bv_actions blocked_by
Definition actions.h:138
bool configured
Definition actions.h:112
union action::@12 actor
enum action_target_kind target_kind
Definition actions.h:118
int min_distance
Definition actions.h:127
Definition city.h:317
int id
Definition city.h:323
struct tile * tile
Definition city.h:319
struct packet_game_info info
Definition game.h:89
int(* player_tile_city_id_get)(const struct tile *ptile, const struct player *pplayer)
bool tech_steal_allow_holes
enum airlifting_style airlifting_style
bool airlift_from_always_enabled
bv_actions diplchance_initial_odds
const struct tile * tile
const struct player * player
const struct unit * unit
const struct city * city
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
struct veteran_system * veteran
Definition unittype.h:549
Definition unit.h:140
int moves_left
Definition unit.h:152
struct tile * tile
Definition unit.h:142
bool paradropped
Definition unit.h:177
const struct unit_type * utype
Definition unit.h:141
enum universals_n kind
Definition fc_types.h:608
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
#define fc__attribute(x)
Definition support.h:99
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:119
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate(_p)
Definition tech.h:271
#define advance_iterate_end
Definition tech.h:272
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
Definition tile.c:407
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_owner(_tile)
Definition tile.h:97
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2544
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:401
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2528
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:794
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2098
#define unit_tile(_pu)
Definition unit.h:407
#define unit_owner(_pu)
Definition unit.h:406
#define unit_home(_pu_)
Definition unit.h:404
#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_may_act_move_frags(const struct unit_type *punit_type, const action_id act_id, const int move_fragments)
Definition unittype.c:1062
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2601
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:194
bool utype_can_do_act_if_tgt_citytile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
Definition unittype.c:1000
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:375
#define utype_class(_t_)
Definition unittype.h:754
#define L_LAST
Definition unittype.h:444
#define unit_type_iterate(_p)
Definition unittype.h:860
#define unit_type_iterate_end
Definition unittype.h:867
#define U_NOT_OBSOLETED
Definition unittype.h:533