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#include <stdarg.h>
20
21/* utility */
22#include "astring.h"
23
24/* common */
25#include "actions.h"
26#include "city.h"
27#include "combat.h"
28#include "fc_interface.h"
29#include "game.h"
30#include "map.h"
31#include "metaknowledge.h"
32#include "movement.h"
33#include "oblig_reqs.h"
34#include "research.h"
35#include "server_settings.h"
36#include "unit.h"
37
38
39/* Values used to interpret action probabilities.
40 *
41 * Action probabilities are sent over the network. A change in a value here
42 * will therefore change the network protocol.
43 *
44 * A change in a value here should also update the action probability
45 * format documentation in fc_types.h */
46/* The lowest possible probability value (0%) */
47#define ACTPROB_VAL_MIN 0
48/* The highest possible probability value (100%) */
49#define ACTPROB_VAL_MAX 200
50/* A probability increase of 1% corresponds to this increase. */
51#define ACTPROB_VAL_1_PCT (ACTPROB_VAL_MAX / 100)
52/* Action probability doesn't apply when min is this. */
53#define ACTPROB_VAL_NA 253
54/* Action probability unsupported when min is this. */
55#define ACTPROB_VAL_NOT_IMPL 254
56
61
63
65
66static struct action *
69 bool rare_pop_up,
72 const int min_distance,
73 const int max_distance,
75
76static bool is_enabler_active(const struct action_enabler *enabler,
77 const struct req_context *actor,
78 const struct req_context *target);
79
80static inline bool
82static inline bool
84static inline bool
86
88 const struct unit *pvictim,
89 const struct tile *tgt_tile,
90 const struct action *paction)
92
93/* Make sure that an action distance can target the whole map. */
96
99
100
101/**********************************************************************/
104static void hard_code_actions(void)
105{
108 FALSE, TRUE,
109 MAK_ESCAPE, 0, 1, TRUE);
112 FALSE, TRUE,
113 MAK_ESCAPE, 0, 1, FALSE);
116 FALSE, TRUE,
117 MAK_ESCAPE, 0, 1, TRUE);
120 FALSE, TRUE,
121 MAK_ESCAPE, 0, 1, FALSE);
124 FALSE, TRUE,
125 /* Tries a forced move if the target unit is alone at
126 * its tile and not in a city. Takes all movement if
127 * the forced move fails. */
129 0, 1, FALSE);
132 FALSE, TRUE,
133 MAK_ESCAPE, 0, 1, TRUE);
136 FALSE, TRUE,
137 MAK_ESCAPE, 0, 1, FALSE);
141 FALSE, TRUE,
142 MAK_ESCAPE, 0, 1, TRUE);
146 FALSE, TRUE,
147 MAK_ESCAPE, 0, 1, TRUE);
151 FALSE, TRUE,
152 MAK_ESCAPE, 0, 1, FALSE);
156 FALSE, TRUE,
157 MAK_ESCAPE, 0, 1, FALSE);
160 FALSE, TRUE,
161 MAK_ESCAPE, 0, 1, TRUE);
164 FALSE, TRUE,
165 MAK_ESCAPE, 0, 1, FALSE);
169 FALSE, TRUE,
170 MAK_STAYS, 0, 1, FALSE);
174 FALSE, TRUE,
175 MAK_STAYS, 0, 1, TRUE);
179 FALSE, TRUE,
180 MAK_ESCAPE, 0, 1, TRUE);
184 FALSE, TRUE,
185 MAK_ESCAPE, 0, 1, FALSE);
189 FALSE, TRUE,
190 MAK_ESCAPE, 0, 1, TRUE);
194 FALSE, TRUE,
195 MAK_ESCAPE, 0, 1, FALSE);
199 FALSE, TRUE,
200 MAK_STAYS, 0, 1, FALSE);
204 FALSE, TRUE,
205 MAK_STAYS, 0, 1, TRUE);
209 FALSE, TRUE,
210 MAK_ESCAPE, 0, 1, TRUE);
214 FALSE, TRUE,
215 MAK_ESCAPE, 0, 1, FALSE);
219 FALSE, TRUE,
220 MAK_ESCAPE, 0, 1, FALSE);
224 FALSE, TRUE,
225 MAK_ESCAPE, 0, 1, FALSE);
228 FALSE, TRUE,
229 MAK_STAYS, 0, 1, TRUE);
232 FALSE, TRUE,
233 MAK_STAYS, 0, 1, TRUE);
236 FALSE, TRUE,
237 MAK_STAYS, 0, 1, TRUE);
241 /* A single domestic unit at the target tile will make
242 * the action illegal. It must therefore be performed
243 * from another tile. */
244 1, 1,
245 FALSE);
249 /* Illegal to perform to a target on another tile.
250 * Reason: The Freeciv code assumes that the city
251 * founding unit is located at the tile were the new
252 * city is founded. */
253 0, 0,
254 TRUE);
257 TRUE, TRUE,
258 MAK_STAYS, 0, 1, TRUE);
261 FALSE, TRUE,
262 MAK_ESCAPE, 0, 1, TRUE);
265 FALSE, TRUE,
266 MAK_ESCAPE, 0, 1, FALSE);
270 /* A single domestic unit at the target tile will make
271 * the action illegal. It must therefore be performed
272 * from another tile. */
273 1,
274 /* Overwritten by the ruleset's bombard_max_range */
275 1,
276 FALSE);
279 FALSE, TRUE,
280 MAK_STAYS,
281 /* A single domestic unit at the target tile will make
282 * the action illegal. It must therefore be performed
283 * from another tile. */
284 1,
285 /* Overwritten by the ruleset's bombard_2_max_range */
286 1,
287 FALSE);
291 /* A single domestic unit at the target tile will make
292 * the action illegal. It must therefore be performed
293 * from another tile. */
294 1,
295 /* Overwritten by the ruleset's bombard_3_max_range */
296 1,
297 FALSE);
301 /* A single domestic unit at the target tile will make
302 * the action illegal. It must therefore be performed
303 * from another tile. */
304 1,
305 /* Overwritten by the ruleset's bombard_4_max_range */
306 1,
307 FALSE);
311 /* A single domestic unit at the target tile will make
312 * the action illegal. It must therefore be performed
313 * from another tile. */
314 1,
315 /* Overwritten by the ruleset's bombard_lethal_max_range */
316 1,
317 FALSE);
321 /* A single domestic unit at the target tile will make
322 * the action illegal. It must therefore be performed
323 * from another tile. */
324 1,
325 /* Overwritten by the ruleset's bombard_lethal_2_max_range */
326 1,
327 FALSE);
330 FALSE, TRUE,
331 MAK_ESCAPE, 0, 1, TRUE);
334 FALSE, TRUE,
335 MAK_ESCAPE, 0, 1, FALSE);
338 TRUE, TRUE,
339 MAK_STAYS, 0,
340 /* Overwritten by the ruleset's
341 * explode_nuclear_max_range */
342 0,
343 TRUE);
346 TRUE, TRUE,
347 MAK_STAYS, 1, 1, TRUE);
350 TRUE, TRUE,
351 MAK_STAYS, 1, 1, TRUE);
354 TRUE, TRUE,
355 MAK_STAYS, 0, 1, FALSE);
358 FALSE, TRUE,
359 MAK_STAYS, 0, 1, FALSE);
363 /* Illegal to perform to a target on another tile to
364 * keep the rules exactly as they were for now. */
365 0, 1,
366 TRUE);
369 /* Can't be ACTRES_NONE because
370 * action_success_actor_consume() sets unit lost
371 * reason based on action result. */
373 TRUE, TRUE,
374 MAK_STAYS, 0, 0, TRUE);
377 TRUE, FALSE,
378 /* Illegal to perform to a target on another tile to
379 * keep the rules exactly as they were for now. */
380 MAK_STAYS, 0, 0, FALSE);
383 TRUE, FALSE,
384 MAK_STAYS, 0, 0, FALSE);
388 /* Illegal to perform to a target on another tile to
389 * keep the rules exactly as they were for now. */
390 0, 0,
391 FALSE);
394 TRUE, TRUE,
396 1,
397 /* Still limited by each unit type's
398 * paratroopers_range field. */
400 FALSE);
403 TRUE, TRUE,
405 1,
406 /* Still limited by each unit type's
407 * paratroopers_range field. */
409 FALSE);
412 TRUE, TRUE,
414 1,
415 /* Still limited by each unit type's
416 * paratroopers_range field. */
418 FALSE);
422 TRUE, TRUE,
424 1,
425 /* Still limited by each unit type's
426 * paratroopers_range field. */
428 FALSE);
431 TRUE, TRUE,
433 1,
434 /* Still limited by each unit type's
435 * paratroopers_range field. */
437 FALSE);
441 TRUE, TRUE,
443 1,
444 /* Still limited by each unit type's
445 * paratroopers_range field. */
447 FALSE);
450 TRUE, TRUE,
452 1,
453 /* Overwritten by the ruleset's airlift_max_range. */
455 FALSE);
458 FALSE, TRUE,
459 /* Tries a forced move if the target unit's tile has
460 * no non-allied units and the occupychance dice roll
461 * tells it to move. */
463 1, 1, FALSE);
466 FALSE, TRUE,
467 /* Tries a forced move if the target unit's tile has
468 * no non-allied units and the occupychance dice roll
469 * tells it to move. */
471 1, 1, FALSE);
474 FALSE, TRUE,
475 MAK_FORCED, 1, 1, TRUE);
478 FALSE, TRUE,
479 MAK_FORCED, 1, 1, TRUE);
482 FALSE, TRUE,
484 1, 1, FALSE);
487 FALSE, FALSE,
488 MAK_STAYS, 1, 1, FALSE);
491 FALSE, FALSE,
492 MAK_STAYS, 1, 1, FALSE);
495 FALSE, TRUE,
496 MAK_REGULAR, 1, 1, FALSE);
499 FALSE, TRUE,
500 MAK_REGULAR, 1, 1, FALSE);
503 FALSE, TRUE,
504 MAK_REGULAR, 1, 1, FALSE);
507 FALSE, TRUE,
508 MAK_REGULAR, 1, 1, FALSE);
511 FALSE, TRUE,
512 MAK_REGULAR, 1, 1, FALSE);
515 FALSE, TRUE,
516 MAK_REGULAR, 1, 1, FALSE);
519 FALSE, TRUE,
520 MAK_REGULAR, 1, 1, FALSE);
523 FALSE, TRUE,
524 MAK_REGULAR, 1, 1, FALSE);
527 FALSE, TRUE,
528 MAK_STAYS, 0, 1, FALSE);
531 FALSE, TRUE,
532 MAK_STAYS, 0, 1, FALSE);
535 TRUE, FALSE,
536 MAK_STAYS, 0, 0, FALSE);
539 TRUE, FALSE,
540 MAK_STAYS, 0, 0, FALSE);
543 TRUE, FALSE,
544 MAK_STAYS, 0, 0, FALSE);
547 TRUE, FALSE,
548 MAK_STAYS, 0, 0, FALSE);
551 TRUE, FALSE,
552 MAK_STAYS, 0, 0, FALSE);
555 TRUE, FALSE,
556 MAK_STAYS, 0, 0, FALSE);
559 TRUE, FALSE,
560 MAK_STAYS, 0, 0, FALSE);
563 TRUE, FALSE,
564 MAK_STAYS, 0, 0, FALSE);
567 TRUE, FALSE,
568 MAK_STAYS, 0, 0, FALSE);
571 TRUE, FALSE,
572 MAK_STAYS, 0, 0, FALSE);
575 TRUE, FALSE,
576 MAK_STAYS, 0, 0, FALSE);
579 TRUE, FALSE,
580 MAK_STAYS, 0, 0, FALSE);
583 TRUE, FALSE,
584 MAK_STAYS, 0, 0, FALSE);
587 TRUE, FALSE,
588 MAK_STAYS, 0, 0, FALSE);
591 TRUE, FALSE,
592 MAK_STAYS, 0, 0, FALSE);
595 TRUE, FALSE,
596 MAK_STAYS, 0, 0, FALSE);
599 TRUE, FALSE,
600 MAK_STAYS, 0, 0, FALSE);
603 TRUE, FALSE,
604 MAK_STAYS, 0, 0, FALSE);
607 TRUE, FALSE,
608 MAK_STAYS, 0, 0, FALSE);
611 TRUE, FALSE,
612 MAK_STAYS, 0, 0, FALSE);
615 TRUE, FALSE,
616 MAK_STAYS, 0, 0, FALSE);
619 TRUE, FALSE,
620 MAK_STAYS, 0, 0, FALSE);
623 TRUE, FALSE,
624 MAK_STAYS, 0, 0, FALSE);
627 TRUE, FALSE,
628 MAK_STAYS, 0, 0, FALSE);
631 TRUE, FALSE,
632 MAK_STAYS, 0, 0, FALSE);
635 TRUE, FALSE,
636 MAK_STAYS, 0, 0, FALSE);
639 TRUE, FALSE,
640 MAK_STAYS, 0, 0, FALSE);
643 TRUE, FALSE,
644 MAK_STAYS, 0, 0, FALSE);
647 TRUE, FALSE,
648 MAK_STAYS, 0, 0, FALSE);
652 FALSE, TRUE,
653 MAK_REGULAR, 1, 1, FALSE);
657 FALSE, TRUE,
658 MAK_REGULAR, 1, 1, FALSE);
662 FALSE, TRUE,
663 MAK_REGULAR, 1, 1, FALSE);
667 FALSE, TRUE,
668 MAK_REGULAR, 1, 1, FALSE);
671 TRUE, TRUE,
672 MAK_REGULAR, 1, 1, FALSE);
675 TRUE, TRUE,
676 MAK_REGULAR, 1, 1, FALSE);
679 TRUE, TRUE,
680 MAK_REGULAR, 1, 1, FALSE);
683 TRUE, TRUE,
684 MAK_REGULAR, 1, 1, FALSE);
687 FALSE, TRUE,
688 MAK_STAYS, 1, 1, FALSE);
691 FALSE, TRUE,
692 MAK_REGULAR, 1, 1, FALSE);
695 FALSE, TRUE,
696 MAK_REGULAR, 1, 1, FALSE);
699 FALSE, TRUE,
700 MAK_REGULAR, 1, 1, FALSE);
703 FALSE, TRUE,
704 MAK_REGULAR, 1, 1, FALSE);
707 FALSE, TRUE,
708 MAK_REGULAR, 1, 1, FALSE);
711 FALSE, TRUE,
712 MAK_REGULAR, 1, 1, FALSE);
715 FALSE, TRUE,
716 MAK_REGULAR, 1, 1, FALSE);
719 FALSE, TRUE,
720 MAK_REGULAR, 1, 1, FALSE);
723 TRUE, TRUE,
724 MAK_REGULAR, 1, 1, FALSE);
727 TRUE, TRUE,
728 MAK_REGULAR, 1, 1, FALSE);
731 TRUE, TRUE,
732 MAK_REGULAR, 1, 1, FALSE);
735 TRUE, TRUE,
736 MAK_TELEPORT, 1, 1, FALSE);
739 TRUE, TRUE,
740 MAK_TELEPORT, 1, 1, FALSE);
743 TRUE, TRUE,
744 MAK_TELEPORT, 1, 1, FALSE);
747 TRUE, TRUE,
748 MAK_TELEPORT, 1,
753 TRUE, TRUE,
754 MAK_TELEPORT, 1,
759 TRUE, TRUE,
760 MAK_TELEPORT, 1,
765 TRUE, TRUE,
766 MAK_TELEPORT, 1,
771 TRUE, TRUE,
772 MAK_TELEPORT, 1,
776 TRUE, FALSE,
777 MAK_STAYS, 0, 0, FALSE);
780 TRUE, FALSE,
781 MAK_STAYS, 0, 0, FALSE);
784 FALSE, TRUE,
786 /* Overwritten by the ruleset */
787 0, 1, FALSE);
790 FALSE, TRUE,
792 /* Overwritten by the ruleset */
793 0, 1, FALSE);
796 FALSE, TRUE,
798 /* Overwritten by the ruleset */
799 0, 1, FALSE);
802 FALSE, TRUE,
804 /* Overwritten by the ruleset */
805 0, 1, FALSE);
808 FALSE, TRUE,
809 /* Tries a forced move if the target unit's tile has
810 * no non-allied units and the occupychance dice roll
811 * tells it to move. */
813 1, 1, FALSE);
814
815 /* The structure even for these need to be created, for
816 * the action_id_rule_name() to work on iterations. */
817
818 /*
819 actions[ACTION_UNUSED_1]
820 = unit_action_new(ACTION_UNUSED_1, ACTRES_NONE,
821 FALSE, FALSE,
822 MAK_UNREPRESENTABLE,
823 0, 0, FALSE);
824 */
825}
826
827/**********************************************************************/
830void actions_init(void)
831{
832 int i, j;
833
834 for (i = 0; i < ACTRES_LAST; i++) {
836 }
837 for (i = 0; i < ACTIVITY_LAST; i++) {
839 }
840
841 /* Hard code the actions */
843
844 /* Initialize the action enabler list */
845 action_iterate_all(act) {
848
849 /* Initialize action obligatory hard requirements. */
851
852 /* Obligatory hard requirements are sorted by requirement in the source
853 * code. This makes it easy to read, modify and explain it. */
855
856 /* Initialize the action auto performers. */
857 for (i = 0; i < MAX_NUM_ACTION_AUTO_PERFORMERS; i++) {
858 /* Nothing here. Nothing after this point. */
860
861 /* The criteria to pick *this* auto performer for its cause. */
863
864 for (j = 0; j < MAX_NUM_ACTIONS; j++) {
865 /* Nothing here. Nothing after this point. */
867 }
868 }
869
870 /* The actions them self are now initialized. */
872}
873
874/**********************************************************************/
880{
881 /* Some obligatory hard requirements needs access to the rest of the
882 * ruleset. */
884}
885
886/**********************************************************************/
889void actions_free(void)
890{
891 int i;
892
893 /* Don't consider the actions to be initialized any longer. */
895
896 action_iterate_all(act) {
900
902
903 FC_FREE(actions[act]);
905
906 /* Free the obligatory hard action requirements. */
908
909 /* Free the action auto performers. */
910 for (i = 0; i < MAX_NUM_ACTION_AUTO_PERFORMERS; i++) {
912 }
913
915
916 for (i = 0; i < ACTRES_LAST; i++) {
919 }
920 for (i = 0; i < ACTIVITY_LAST; i++) {
923 }
924}
925
926/**********************************************************************/
932{
933 if (!actions_initialized) {
934 /* The actions them self aren't initialized yet. */
935 return FALSE;
936 }
937
939 if (actions[act]->ui_name[0] == '\0') {
940 /* A noninternal action without a UI name exists means that
941 * the ruleset haven't loaded yet. The ruleset loading will assign
942 * a default name to any actions not named by the ruleset.
943 * The client will get this name from the server. */
944 return FALSE;
945 }
947
948 /* The actions should be ready for use. */
949 return TRUE;
950}
951
952/**********************************************************************/
955static struct action *action_new(action_id id,
957 const int min_distance,
958 const int max_distance,
960{
961 struct action *action;
962
963 action = fc_malloc(sizeof(*action));
964
965 action->id = id;
966
968
969 if (result != ACTRES_LAST) {
971
973
974 if (act != ACTIVITY_LAST) {
976 }
977 }
978
979 /* Not set here */
981
986
987 /* ASTK_NONE implies ACT_TGT_COMPL_SIMPLE and
988 * !ASTK_NONE implies !ACT_TGT_COMPL_SIMPLE */
993 "%s contradicts itself regarding sub targets.",
995
996 /* The distance between the actor and itself is always 0. */
998 || (min_distance == 0 && max_distance == 0));
999
1002
1004
1005 /* Loaded from the ruleset. Until generalized actions are ready it has to
1006 * be defined separately from other action data. */
1007 action->ui_name[0] = '\0';
1008 action->quiet = FALSE;
1010
1011 return action;
1012}
1013
1014/**********************************************************************/
1017static struct action *
1019 enum action_result result,
1020 bool rare_pop_up,
1023 const int min_distance,
1024 const int max_distance,
1026{
1027 struct action *act = action_new(id, result,
1030
1032
1034
1036
1037 return act;
1038}
1039
1040/**********************************************************************/
1043bool action_id_exists(const action_id act_id)
1044{
1045 /* Actions are still hard coded. */
1046 return gen_action_is_valid(act_id) && actions[act_id];
1047}
1048
1049/**********************************************************************/
1054struct action *action_by_rule_name(const char *name)
1055{
1056 /* Actions are still hard coded in the gen_action enum. */
1058
1059 if (!action_id_exists(act_id)) {
1060 /* Nothing to return. */
1061
1062 log_verbose("Asked for non existing action named %s", name);
1063
1064 return NULL;
1065 }
1066
1067 return action_by_number(act_id);
1068}
1069
1070/**********************************************************************/
1074{
1075 fc_assert_ret_val_msg(paction, AAK_COUNT, "Action doesn't exist.");
1076
1077 return paction->actor_kind;
1078}
1079
1080/**********************************************************************/
1084 const struct action *paction)
1085{
1086 fc_assert_ret_val_msg(paction, ATK_COUNT, "Action doesn't exist.");
1087
1088 return paction->target_kind;
1089}
1090
1091/**********************************************************************/
1095 const struct action *paction)
1096{
1097 fc_assert_ret_val_msg(paction, ASTK_COUNT, "Action doesn't exist.");
1098
1099 return paction->sub_target_kind;
1100}
1101
1102/**********************************************************************/
1108{
1110
1111 return paction->target_complexity >= ACT_TGT_COMPL_FLEXIBLE;
1112}
1113
1114/**********************************************************************/
1121{
1123
1124 return paction->target_complexity >= ACT_TGT_COMPL_MANDATORY;
1125}
1126
1127/**********************************************************************/
1136{
1138 FALSE, "Action %d don't exist.", act_id);
1140
1141 return actions[act_id]->actor.is_unit.rare_pop_up;
1142}
1143
1144/**********************************************************************/
1149 const int distance)
1150{
1153}
1154
1155/**********************************************************************/
1160 const int distance)
1161{
1163
1164 return (distance >= action->min_distance
1165 && action_distance_inside_max(action, distance));
1166}
1167
1168/**********************************************************************/
1171bool action_would_be_blocked_by(const struct action *blocked,
1172 const struct action *blocker)
1173{
1174 fc_assert_ret_val(blocked, FALSE);
1175 fc_assert_ret_val(blocker, FALSE);
1176
1177 return BV_ISSET(blocked->blocked_by, action_number(blocker));
1178}
1179
1180/**********************************************************************/
1183int action_number(const struct action *action)
1184{
1185 return action->id;
1186}
1187
1188/**********************************************************************/
1191const char *action_rule_name(const struct action *action)
1192{
1193 /* Rule name is still hard coded. */
1194 return action_id_rule_name(action->id);
1195}
1196
1197/**********************************************************************/
1205const char *action_name_translation(const struct action *paction)
1206{
1207 /* Use action_id_name_translation() to format the UI name. */
1209}
1210
1211/**********************************************************************/
1215{
1216 fc_assert_msg(actions[act_id], "Action %d don't exist.", act_id);
1217
1218 return gen_action_name(act_id);
1219}
1220
1221/**********************************************************************/
1226{
1227 return action_prepare_ui_name(act_id, "", ACTPROB_NA, NULL);
1228}
1229
1230/**********************************************************************/
1234 const char *mnemonic)
1235{
1237}
1238
1239/**********************************************************************/
1246static const char *action_prob_to_text(const struct act_prob prob)
1247{
1248 static struct astring chance = ASTRING_INIT;
1249
1250 /* How to interpret action probabilities like prob is documented in
1251 * fc_types.h */
1252 if (action_prob_is_signal(prob)) {
1254 || action_prob_not_relevant(prob));
1255
1256 /* Unknown because of missing server support or should not exits. */
1257 return NULL;
1258 }
1259
1260 if (prob.min == prob.max) {
1261 /* Only one probability in range. */
1262
1263 /* TRANS: the probability that an action will succeed. Given in
1264 * percentage. Resolution is 0.5%. */
1265 astr_set(&chance, _("%.1f%%"), (double)prob.max / ACTPROB_VAL_1_PCT);
1266 } else {
1267 /* TRANS: the interval (end points included) where the probability of
1268 * the action's success is. Given in percentage. Resolution is 0.5%. */
1269 astr_set(&chance, _("[%.1f%%, %.1f%%]"),
1270 (double)prob.min / ACTPROB_VAL_1_PCT,
1271 (double)prob.max / ACTPROB_VAL_1_PCT);
1272 }
1273
1274 return astr_str(&chance);
1275}
1276
1277/**********************************************************************/
1287const char *action_prepare_ui_name(action_id act_id, const char *mnemonic,
1288 const struct act_prob prob,
1289 const char *custom)
1290{
1291 struct astring chance = ASTRING_INIT;
1292
1293 /* Text representation of the probability. */
1294 const char *probtxt;
1295
1296 if (!actions_are_ready()) {
1297 /* Could be a client who haven't gotten the ruleset yet */
1298
1299 /* so there shouldn't be any action probability to show */
1301
1302 /* but the action should be valid */
1304 "Invalid action",
1305 "Invalid action %d", act_id);
1306
1307 /* and no custom text will be inserted */
1308 fc_assert(custom == NULL || custom[0] == '\0');
1309
1310 /* Make the best of what is known */
1311 astr_set(&ui_name_str, _("%s%s (name may be wrong)"),
1312 mnemonic, action_id_rule_name(act_id));
1313
1314 /* Return the guess. */
1315 return astr_str(&ui_name_str);
1316 }
1317
1319
1320 /* Format the info part of the action's UI name. */
1321 if (probtxt != NULL && custom != NULL) {
1322 /* TRANS: action UI name's info part with custom info and probability.
1323 * Hint: you can move the paren handling from this sting to the action
1324 * names if you need to add extra information (like a mnemonic letter
1325 * that doesn't appear in the action UI name) to it. In that case you
1326 * must do so for all strings with this comment and for every action
1327 * name. To avoid a `()` when no UI name info part is added you have
1328 * to add the extra information to every action name or remove the
1329 * surrounding parens. */
1330 astr_set(&chance, _(" (%s; %s)"), custom, probtxt);
1331 } else if (probtxt != NULL) {
1332 /* TRANS: action UI name's info part with probability.
1333 * Hint: you can move the paren handling from this sting to the action
1334 * names if you need to add extra information (like a mnemonic letter
1335 * that doesn't appear in the action UI name) to it. In that case you
1336 * must do so for all strings with this comment and for every action
1337 * name. To avoid a `()` when no UI name info part is added you have
1338 * to add the extra information to every action name or remove the
1339 * surrounding parens. */
1340 astr_set(&chance, _(" (%s)"), probtxt);
1341 } else if (custom != NULL) {
1342 /* TRANS: action UI name's info part with custom info.
1343 * Hint: you can move the paren handling from this sting to the action
1344 * names if you need to add extra information (like a mnemonic letter
1345 * that doesn't appear in the action UI name) to it. In that case you
1346 * must do so for all strings with this comment and for every action
1347 * name. To avoid a `()` when no UI name info part is added you have
1348 * to add the extra information to every action name or remove the
1349 * surrounding parens. */
1350 astr_set(&chance, _(" (%s)"), custom);
1351 } else {
1352 /* No info part to display. */
1354 }
1355
1356 fc_assert_msg(actions[act_id], "Action %d don't exist.", act_id);
1357
1358 /* Escape any instances of the mnemonic in the action's UI format string.
1359 * (Assumes any mnemonic can be escaped by doubling, and that they are
1360 * unlikely to appear in a format specifier. True for clients seen so
1361 * far: Gtk's _ and Qt's &) */
1362 {
1363 struct astring fmtstr = ASTRING_INIT;
1364 const char *ui_name = _(actions[act_id]->ui_name);
1365
1366 if (mnemonic[0] != '\0') {
1367 const char *hit;
1368
1369 fc_assert(!strchr(mnemonic, '%'));
1370 while ((hit = strstr(ui_name, mnemonic))) {
1371 astr_add(&fmtstr, "%.*s%s%s", (int)(hit - ui_name), ui_name,
1373 ui_name = hit + strlen(mnemonic);
1374 }
1375 }
1376 astr_add(&fmtstr, "%s", ui_name);
1377
1378 /* Use the modified format string */
1380 astr_str(&chance));
1381
1382 astr_free(&fmtstr);
1383 }
1384
1385 astr_free(&chance);
1386
1387 return astr_str(&ui_name_str);
1388}
1389
1390/**********************************************************************/
1398const char *action_prob_explain(const struct act_prob prob)
1399{
1400 static struct astring tool_tip = ASTRING_INIT;
1401
1402 if (action_prob_is_signal(prob)) {
1404
1405 /* Missing server support. No in game action will change this. */
1407 } else if (prob.min == prob.max) {
1408 /* TRANS: action probability of success. Given in percentage.
1409 * Resolution is 0.5%. */
1410 astr_set(&tool_tip, _("The probability of success is %.1f%%."),
1411 (double)prob.max / ACTPROB_VAL_1_PCT);
1412 } else {
1414 /* TRANS: action probability interval (min to max). Given in
1415 * percentage. Resolution is 0.5%. The string at the end is
1416 * shown when the interval is wide enough to not be caused by
1417 * rounding. It explains that the interval is imprecise because
1418 * the player doesn't have enough information. */
1419 _("The probability of success is %.1f%%, %.1f%% or somewhere"
1420 " in between.%s"),
1421 (double)prob.min / ACTPROB_VAL_1_PCT,
1422 (double)prob.max / ACTPROB_VAL_1_PCT,
1423 prob.max - prob.min > 1 ?
1424 /* TRANS: explanation used in the action probability tooltip
1425 * above. Preserve leading space. */
1426 _(" (This is the most precise interval I can calculate "
1427 "given the information our nation has access to.)") :
1428 "");
1429 }
1430
1431 return astr_str(&tool_tip);
1432}
1433
1434/**********************************************************************/
1439{
1441 "Action %s isn't performed by a unit",
1443
1444 return paction->id + L_LAST;
1445}
1446
1447/**********************************************************************/
1451{
1452 struct action_enabler *enabler;
1453
1454 enabler = fc_malloc(sizeof(*enabler));
1455 enabler->ruledit_disabled = FALSE;
1456 requirement_vector_init(&enabler->actor_reqs);
1457 requirement_vector_init(&enabler->target_reqs);
1458
1459 /* Make sure that action doesn't end up as a random value that happens to
1460 * be a valid action id. */
1461 enabler->action = ACTION_NONE;
1462
1463 return enabler;
1464}
1465
1466/**********************************************************************/
1470{
1471 requirement_vector_free(&enabler->actor_reqs);
1472 requirement_vector_free(&enabler->target_reqs);
1473
1474 free(enabler);
1475}
1476
1477/**********************************************************************/
1480struct action_enabler *
1482{
1484
1485 enabler->action = original->action;
1486
1487 requirement_vector_copy(&enabler->actor_reqs, &original->actor_reqs);
1488 requirement_vector_copy(&enabler->target_reqs, &original->target_reqs);
1489
1490 return enabler;
1491}
1492
1493/**********************************************************************/
1497{
1498 /* Sanity check: a non existing action enabler can't be added. */
1500 /* Sanity check: a non existing action doesn't have enablers. */
1502
1505 enabler);
1506}
1507
1508/**********************************************************************/
1514{
1515 /* Sanity check: a non existing action enabler can't be removed. */
1517 /* Sanity check: a non existing action doesn't have enablers. */
1519
1522 enabler);
1523}
1524
1525/**********************************************************************/
1528struct action_enabler_list *
1530{
1531 /* Sanity check: a non existing action doesn't have enablers. */
1533
1535}
1536
1537/**********************************************************************/
1548static struct req_vec_problem *
1550 const struct obligatory_req_vector *oblig)
1551{
1552 struct action *paction;
1553
1554 /* Sanity check: a non existing action enabler is missing but it doesn't
1555 * miss any obligatory hard requirements. */
1557
1558 /* Sanity check: a non existing action doesn't have any obligatory hard
1559 * requirements. */
1562
1563 /* No obligatory hard requirements. */
1565
1567 struct req_vec_problem *out;
1568 int i;
1569 bool fulfilled = FALSE;
1570
1571 /* Check each alternative. */
1572 for (i = 0; i < obreq->contras->alternatives; i++) {
1573 const struct requirement_vector *ae_vec;
1574
1575 /* Select action enabler requirement vector. */
1576 ae_vec = (obreq->contras->alternative[i].is_target
1577 ? &enabler->target_reqs
1578 : &enabler->actor_reqs);
1579
1580 if (does_req_contradicts_reqs(&obreq->contras->alternative[i].req,
1581 ae_vec)
1582 /* Consider the hard requirement fulfilled since a universal that
1583 * never is there always will be absent in this ruleset. */
1584 || (obreq->contras->alternative[i].req.present
1586 &obreq->contras->alternative[i].req.source))) {
1587 /* It is enough that one alternative accepts the enabler. */
1588 fulfilled = TRUE;
1589 break;
1590 }
1591
1592 /* Fall back to the next alternative */
1593 }
1594
1595 if (fulfilled) {
1596 /* This obligatory hard requirement isn't a problem. */
1597 continue;
1598 }
1599
1600 /* Missing hard obligatory requirement detected */
1601
1602 out = req_vec_problem_new(obreq->contras->alternatives,
1603 obreq->error_msg,
1605
1606 for (i = 0; i < obreq->contras->alternatives; i++) {
1607 const struct requirement_vector *ae_vec;
1608
1609 /* Select action enabler requirement vector. */
1610 ae_vec = (obreq->contras->alternative[i].is_target
1611 ? &enabler->target_reqs
1612 : &enabler->actor_reqs);
1613
1614 /* The suggested fix is to append a requirement that makes the enabler
1615 * contradict the missing hard obligatory requirement detector. */
1616 out->suggested_solutions[i].operation = RVCO_APPEND;
1617 out->suggested_solutions[i].vector_number
1619
1620 /* Change the requirement from what should conflict to what is
1621 * wanted. */
1622 out->suggested_solutions[i].req.present
1623 = !obreq->contras->alternative[i].req.present;
1624 out->suggested_solutions[i].req.source
1625 = obreq->contras->alternative[i].req.source;
1626 out->suggested_solutions[i].req.range
1627 = obreq->contras->alternative[i].req.range;
1628 out->suggested_solutions[i].req.survives
1629 = obreq->contras->alternative[i].req.survives;
1630 out->suggested_solutions[i].req.quiet
1631 = obreq->contras->alternative[i].req.quiet;
1632 }
1633
1634 /* Return the first problem found. The next problem will be detected
1635 * during the next call. */
1636 return out;
1638
1639 /* No obligatory req problems found. */
1640 return NULL;
1641}
1642
1643/**********************************************************************/
1652struct req_vec_problem *
1654{
1655 struct action *paction;
1657 struct req_vec_problem *out;
1658
1659 /* Sanity check: a non existing action enabler is missing but it doesn't
1660 * miss any obligatory hard requirements. */
1662
1663 /* Sanity check: a non existing action doesn't have any obligatory hard
1664 * requirements. */
1667
1668 if (paction->result != ACTRES_NONE) {
1669 /* A hard coded action result may mean obligatory requirements. */
1671 if (out != NULL) {
1672 return out;
1673 }
1674 }
1675
1679 if (!BV_ISSET(paction->sub_results, sub_res)) {
1680 /* Not relevant */
1681 continue;
1682 }
1683
1684 /* The action has this sub result. Check its hard requirements. */
1687 if (out != NULL) {
1688 return out;
1689 }
1690 }
1691
1692 /* No obligatory req problems found. */
1693 return NULL;
1694}
1695
1696/**********************************************************************/
1702static struct requirement *
1704{
1706 if (preq->source.kind == VUT_DIPLREL
1707 && preq->range == REQ_RANGE_LOCAL) {
1708 return preq;
1709 }
1711
1712 return NULL;
1713}
1714
1715/**********************************************************************/
1723static struct requirement *
1725 const struct requirement_vector *vec)
1726{
1727 /* If the requirement is contradicted by any requirement in the vector it
1728 * contradicts the entire requirement vector. */
1731 return preq;
1732 }
1734
1735 /* Not a singe requirement in the requirement vector is contradicted be
1736 * the specified requirement. */
1737 return NULL;
1738}
1739
1740/**********************************************************************/
1746static struct req_vec_problem *
1748 const struct action_enabler *enabler)
1749{
1750 struct req_vec_problem *out;
1751 struct requirement *local_diplrel;
1752 struct requirement *claimed_req;
1756 struct astring astr;
1757
1759 /* Not tile targeted */
1760 return NULL;
1761 }
1762
1764 if (local_diplrel == NULL) {
1765 /* No local diplrel */
1766 return NULL;
1767 }
1768
1769 /* Tile is unclaimed as a requirement. */
1771 tile_is_unclaimed.survives = FALSE;
1772 tile_is_unclaimed.source.kind = VUT_CITYTILE;
1773 tile_is_unclaimed.present = FALSE;
1774 tile_is_unclaimed.source.value.citytile = CITYT_CLAIMED;
1775
1777 &enabler->target_reqs);
1778
1779 if (claimed_req) {
1780 /* Already clear */
1781 return NULL;
1782 }
1783
1784 /* Tile is claimed as a requirement. */
1786 tile_is_claimed.survives = FALSE;
1787 tile_is_claimed.source.kind = VUT_CITYTILE;
1788 tile_is_claimed.present = TRUE;
1789 tile_is_claimed.source.value.citytile = CITYT_CLAIMED;
1790
1792 1,
1793 /* TRANS: ruledit shows this when an enabler for a tile targeted
1794 * action requires that the actor has a diplomatic relationship to
1795 * the target but doesn't require that the target tile is claimed.
1796 * (DiplRel requirements to an unclaimed tile are never fulfilled
1797 * so this is implicit.) */
1798 N_("Requirement {%s} of action \"%s\" implies a claimed "
1799 "tile. No diplomatic relation to Nature."),
1801
1802 astr_free(&astr);
1803
1804 /* The solution is to add the requirement that the tile is claimed */
1805 out->suggested_solutions[0].req = tile_is_claimed;
1806 out->suggested_solutions[0].vector_number
1808 out->suggested_solutions[0].operation = RVCO_APPEND;
1809
1810 return out;
1811}
1812
1813/**********************************************************************/
1819static struct req_vec_problem *
1821{
1822 struct req_vec_problem *out;
1823 struct requirement *local_diplrel;
1824 struct requirement *unclaimed_req;
1827 struct astring astr1;
1828 struct astring astr2;
1829
1831 /* Not tile targeted */
1832 return NULL;
1833 }
1834
1836 if (local_diplrel == NULL) {
1837 /* No local diplrel */
1838 return NULL;
1839 }
1840
1841 /* Tile is claimed as a requirement. */
1843 tile_is_claimed.survives = FALSE;
1844 tile_is_claimed.source.kind = VUT_CITYTILE;
1845 tile_is_claimed.present = TRUE;
1846 tile_is_claimed.source.value.citytile = CITYT_CLAIMED;
1847
1849 &enabler->target_reqs);
1850
1851 if (unclaimed_req == NULL) {
1852 /* No unclaimed req */
1853 return NULL;
1854 }
1855
1857 2,
1858 /* TRANS: ruledit shows this when an enabler for a tile targeted
1859 * action requires that the target tile is unclaimed and that the
1860 * actor has a diplomatic relationship to the target. (DiplRel
1861 * requirements to an unclaimed tile are never fulfilled.) */
1862 N_("In enabler for \"%s\": No diplomatic relation to Nature."
1863 " Requirements {%s} and {%s} contradict each other."),
1867
1868 astr_free(&astr1);
1869 astr_free(&astr2);
1870
1871 /* The first suggestion is to remove the diplrel */
1872 out->suggested_solutions[0].req = *local_diplrel;
1873 out->suggested_solutions[0].vector_number
1875 out->suggested_solutions[0].operation = RVCO_REMOVE;
1876
1877 /* The 2nd is to remove the requirement that the tile is unclaimed */
1878 out->suggested_solutions[1].req = *unclaimed_req;
1879 out->suggested_solutions[1].vector_number
1881 out->suggested_solutions[1].operation = RVCO_REMOVE;
1882
1883 return out;
1884}
1885
1886/**********************************************************************/
1891struct req_vec_problem *
1893{
1894 struct req_vec_problem *out;
1895
1897 if (out != NULL) {
1898 return out;
1899 }
1900
1901 /* Look for errors in the requirement vectors. */
1902 out = req_vec_suggest_repair(&enabler->actor_reqs,
1904 enabler);
1905 if (out != NULL) {
1906 return out;
1907 }
1908
1909 out = req_vec_suggest_repair(&enabler->target_reqs,
1911 enabler);
1912 if (out != NULL) {
1913 return out;
1914 }
1915
1916 /* Enabler specific contradictions. */
1918 if (out != NULL) {
1919 return out;
1920 }
1921
1922 /* Needed in action not enabled explanation finding. */
1924 if (out != NULL) {
1925 return out;
1926 }
1927
1928 /* No problems found. */
1929 return NULL;
1930}
1931
1932/**********************************************************************/
1939static struct req_vec_problem *
1941{
1942 struct req_vec_problem *out;
1943
1944 out = NULL;
1945
1946 return out;
1947}
1948
1949/**********************************************************************/
1957struct req_vec_problem *
1959{
1960 struct action *paction;
1961 struct req_vec_problem *out;
1962
1964 if (out) {
1965 /* A bug, not just a potential improvement */
1966 return out;
1967 }
1968
1970
1971 /* Look for improvement suggestions to the requirement vectors. */
1974 enabler);
1975 if (out) {
1976 return out;
1977 }
1978 out = req_vec_suggest_improvement(&enabler->target_reqs,
1980 enabler);
1981 if (out) {
1982 return out;
1983 }
1984
1985 /* Detect unused action enablers. */
1987 bool has_user = FALSE;
1988
1992 &(enabler->actor_reqs))) {
1993 has_user = TRUE;
1994 break;
1995 }
1997
1998 if (!has_user) {
1999 /* TRANS: ruledit warns a user about an unused action enabler */
2000 out = req_vec_problem_new(0, N_("Action enabler for \"%s\" is never"
2001 " used by any unit."),
2003 }
2004 }
2005 if (out != NULL) {
2006 return out;
2007 }
2008
2010
2011 return out;
2012}
2013
2014/**********************************************************************/
2023 const struct requirement_vector *vec)
2024{
2025 struct action_enabler *ae = (struct action_enabler *)enabler;
2026
2027 if (vec == &ae->actor_reqs) {
2028 return 0;
2029 } else if (vec == &ae->target_reqs) {
2030 return 1;
2031 } else {
2032 return -1;
2033 }
2034}
2035
2036/********************************************************************/
2044struct requirement_vector *
2046 req_vec_num_in_item number)
2047{
2048 struct action_enabler *ae = (struct action_enabler *)enabler;
2049
2050 fc_assert_ret_val(number >= 0, NULL);
2051
2052 switch (number) {
2053 case 0:
2054 return &ae->actor_reqs;
2055 case 1:
2056 return &ae->target_reqs;
2057 default:
2058 return NULL;
2059 }
2060}
2061
2062/*********************************************************************/
2070{
2071 switch (vec) {
2072 case 0:
2073 /* TRANS: requirement vector in an action enabler (ruledit) */
2074 return _("actor_reqs");
2075 case 1:
2076 /* TRANS: requirement vector in an action enabler (ruledit) */
2077 return _("target_reqs");
2078 default:
2079 return NULL;
2080 }
2081}
2082
2083/**********************************************************************/
2088static const struct impr_type *
2090{
2091 /* Only used with city targets */
2093
2094 if (target_city->production.kind == VUT_IMPROVEMENT) {
2095 /* The local building is what the target city currently is building. */
2096 return target_city->production.value.building;
2097 } else {
2098 /* In the current semantic the local building is always the building
2099 * being built. */
2100 /* TODO: Consider making the local building the target building for
2101 * actions that allows specifying a building target. */
2102 return NULL;
2103 }
2104}
2105
2106/**********************************************************************/
2111static const struct unit_type *
2113{
2114 /* Only used with city targets */
2116
2117 if (target_city->production.kind == VUT_UTYPE) {
2118 /* The local unit type is what the target city currently is
2119 * building. */
2120 return target_city->production.value.utype;
2121 } else {
2122 /* In the current semantic the local utype is always the type of the
2123 * unit being built. */
2124 return NULL;
2125 }
2126}
2127
2128/**********************************************************************/
2136static const struct tile *
2138 const struct unit *actor_unit,
2139 const struct tile *target_tile_arg,
2140 const struct city *target_city,
2141 const struct unit *target_unit)
2142{
2143 if (target_tile_arg != NULL) {
2144 /* Trust the caller. */
2145 return target_tile_arg;
2146 }
2147
2148 /* Action should always be set */
2149 fc_assert_ret_val(act, NULL);
2150
2151 switch (action_get_target_kind(act)) {
2152 case ATK_CITY:
2154 return city_tile(target_city);
2155 case ATK_UNIT:
2156 if (target_unit == NULL) {
2158 return NULL;
2159 }
2160 return unit_tile(target_unit);
2161 case ATK_UNITS:
2163 if (target_unit) {
2164 return unit_tile(target_unit);
2165 }
2166
2168 case ATK_TILE:
2169 case ATK_EXTRAS:
2171 return target_tile_arg;
2172 case ATK_SELF:
2174 return unit_tile(actor_unit);
2175 case ATK_COUNT:
2176 /* Handled below. */
2177 break;
2178 }
2179
2180 fc_assert_msg(FALSE, "Bad action target kind %d for action %s",
2182 return NULL;
2183}
2184
2185/**********************************************************************/
2194static const struct city *
2196 const struct unit *actor_unit,
2197 const struct tile *target_tile,
2198 const struct city *target_city_arg,
2199 const struct unit *target_unit)
2200{
2201 if (target_city_arg != NULL) {
2202 /* Trust the caller. */
2203 return target_city_arg;
2204 }
2205
2206 /* action should always be set */
2207 fc_assert_ret_val(act, NULL);
2208
2209 switch (action_get_target_kind(act)) {
2210 case ATK_CITY:
2212 return target_city_arg;
2213 case ATK_UNIT:
2217 case ATK_UNITS:
2219 if (target_unit) {
2222 }
2223
2225 case ATK_TILE:
2226 case ATK_EXTRAS:
2228 return tile_city(target_tile);
2229 case ATK_SELF:
2233 case ATK_COUNT:
2234 /* Handled below. */
2235 break;
2236 }
2237
2238 fc_assert_msg(FALSE, "Bad action target kind %d for action %s",
2240 return NULL;
2241}
2242
2243/**********************************************************************/
2249struct action *action_is_blocked_by(const struct action *act,
2250 const struct unit *actor_unit,
2251 const struct tile *target_tile_arg,
2252 const struct city *target_city_arg,
2253 const struct unit *target_unit)
2254{
2255 const struct tile *target_tile
2258 const struct city *target_city
2261 const struct civ_map *nmap = &(wld.map);
2262
2264 struct action *blocker = action_by_number(blocker_id);
2265
2267 continue);
2268
2269 if (!action_would_be_blocked_by(act, blocker)) {
2270 /* It doesn't matter if it is legal. It won't block the action. */
2271 continue;
2272 }
2273
2274 switch (action_get_target_kind(blocker)) {
2275 case ATK_CITY:
2276 if (!target_city) {
2277 /* Can't be enabled. No target. */
2278 continue;
2279 }
2282 return blocker;
2283 }
2284 break;
2285 case ATK_UNIT:
2286 if (!target_unit) {
2287 /* Can't be enabled. No target. */
2288 continue;
2289 }
2292 return blocker;
2293 }
2294 break;
2295 case ATK_UNITS:
2296 if (!target_tile) {
2297 /* Can't be enabled. No target. */
2298 continue;
2299 }
2302 return blocker;
2303 }
2304 break;
2305 case ATK_TILE:
2306 if (!target_tile) {
2307 /* Can't be enabled. No target. */
2308 continue;
2309 }
2312 return blocker;
2313 }
2314 break;
2315 case ATK_EXTRAS:
2316 if (!target_tile) {
2317 /* Can't be enabled. No target. */
2318 continue;
2319 }
2322 return blocker;
2323 }
2324 break;
2325 case ATK_SELF:
2327 return blocker;
2328 }
2329 break;
2330 case ATK_COUNT:
2332 continue);
2333 break;
2334 }
2336
2337 /* Not blocked. */
2338 return NULL;
2339}
2340
2341/**********************************************************************/
2361static bool
2363 const struct unit_type *actor_unittype,
2364 bool ignore_third_party)
2365{
2366 switch (paction->result) {
2367 case ACTRES_JOIN_CITY:
2368 if (actor_unittype->pop_cost <= 0) {
2369 /* Reason: Must have population to add. */
2370 return FALSE;
2371 }
2372 break;
2373
2374 case ACTRES_BOMBARD:
2375 if (actor_unittype->bombard_rate <= 0) {
2376 /* Reason: Can't bombard if it never fires. */
2377 return FALSE;
2378 }
2379
2380 if (actor_unittype->attack_strength <= 0) {
2381 /* Reason: Can't bombard without attack strength. */
2382 return FALSE;
2383 }
2384
2385 break;
2386
2388 if (actor_unittype->obsoleted_by == U_NOT_OBSOLETED) {
2389 /* Reason: Nothing to upgrade to. */
2390 return FALSE;
2391 }
2392 break;
2393
2394 case ACTRES_ATTACK:
2395 case ACTRES_WIPE_UNITS:
2397 if (actor_unittype->attack_strength <= 0) {
2398 /* Reason: Can't attack without strength. */
2399 return FALSE;
2400 }
2401 break;
2402
2403 case ACTRES_CONVERT:
2404 if (!actor_unittype->converted_to) {
2405 /* Reason: must be able to convert to something. */
2406 return FALSE;
2407 }
2408 break;
2409
2411 if (actor_unittype->transport_capacity < 1) {
2412 /* Reason: can't transport anything to unload. */
2413 return FALSE;
2414 }
2415 break;
2416
2418 if (actor_unittype->transport_capacity < 1) {
2419 /* Reason: can't transport anything to load. */
2420 return FALSE;
2421 }
2422 break;
2423
2428 if (!ignore_third_party) {
2429 bool has_transporter = FALSE;
2430
2434 break;
2435 }
2437
2438 if (!has_transporter) {
2439 /* Reason: no other unit can transport this unit. */
2440 return FALSE;
2441 }
2442 }
2443 break;
2444
2446 if (!ignore_third_party) {
2447 bool has_target = FALSE;
2449
2450 /* Use cache when it has been initialized */
2451 if (pclass->cache.native_bases != NULL) {
2452 /* Extra being native one is a hard requirement */
2453 extra_type_list_iterate(pclass->cache.native_bases, pextra) {
2454 if (!territory_claiming_base(pextra->data.base)) {
2455 /* Hard requirement */
2456 continue;
2457 }
2458
2459 has_target = TRUE;
2460 break;
2462 } else {
2464
2466 if (!is_native_extra_to_uclass(pextra, pclass)) {
2467 /* Hard requirement */
2468 continue;
2469 }
2470
2471 has_target = TRUE;
2472 break;
2474 }
2475
2476 if (!has_target) {
2477 /* Reason: no extras can be conquered by this unit. */
2478 return FALSE;
2479 }
2480 }
2481 break;
2482
2483 case ACTRES_PARADROP:
2485 if (actor_unittype->paratroopers_range <= 0) {
2486 /* Reason: Can't paradrop 0 tiles. */
2487 return FALSE;
2488 }
2489 break;
2490
2491 case ACTRES_HUT_ENTER:
2495 case ACTRES_SPY_POISON:
2504 case ACTRES_SPY_ESCAPE:
2505 case ACTRES_TRADE_ROUTE:
2506 case ACTRES_MARKETPLACE:
2507 case ACTRES_HELP_WONDER:
2511 case ACTRES_FOUND_CITY:
2512 case ACTRES_STEAL_MAPS:
2513 case ACTRES_SPY_NUKE:
2514 case ACTRES_NUKE:
2515 case ACTRES_NUKE_UNITS:
2517 case ACTRES_EXPEL_UNIT:
2520 case ACTRES_HOME_CITY:
2521 case ACTRES_HOMELESS:
2522 case ACTRES_AIRLIFT:
2526 case ACTRES_HEAL_UNIT:
2527 case ACTRES_PILLAGE:
2528 case ACTRES_CLEAN:
2529 case ACTRES_FORTIFY:
2531 case ACTRES_CULTIVATE:
2532 case ACTRES_PLANT:
2533 case ACTRES_ROAD:
2534 case ACTRES_BASE:
2535 case ACTRES_MINE:
2536 case ACTRES_IRRIGATE:
2537 case ACTRES_SPY_ATTACK:
2538 case ACTRES_UNIT_MOVE:
2539 case ACTRES_TELEPORT:
2542 case ACTRES_NONE:
2543 /* No hard unit type requirements. */
2544 break;
2545
2547 }
2548
2549 return TRUE;
2550}
2551
2552/**********************************************************************/
2568bool
2575
2576/**********************************************************************/
2588static enum fc_tristate
2590 const struct action *paction,
2591 const struct req_context *actor,
2592 const bool omniscient,
2593 const struct city *homecity)
2594{
2595 enum action_result result = paction->result;
2596
2597 if (actor == NULL) {
2599 }
2600
2602 TRUE)) {
2603 /* Info leak: The actor player knows the type of their unit. */
2604 /* The actor unit type can't perform the action because of hard
2605 * unit type requirements. */
2606 return TRI_NO;
2607 }
2608
2609 switch (result) {
2610 case ACTRES_PARADROP:
2612 /* Reason: Keep the old rules. */
2613 /* Info leak: The player knows if their unit already has paradropped this
2614 * turn. */
2615 if (actor->unit->paradropped) {
2616 return TRI_NO;
2617 }
2618
2619 break;
2620
2621 case ACTRES_AIRLIFT:
2622 {
2623 /* Obligatory hard requirement. Checked here too since
2624 * action_hard_reqs_actor() may be called before any
2625 * action enablers are checked. */
2626 if (actor->city == NULL) {
2627 /* No city to airlift from. */
2628 return TRI_NO;
2629 }
2630
2631 if (actor->player != city_owner(actor->city)
2633 && pplayers_allied(actor->player,
2634 city_owner(actor->city)))) {
2635 /* Not allowed to airlift from this source. */
2636 return TRI_NO;
2637 }
2638
2639 if (!(omniscient || city_owner(actor->city) == actor->player)) {
2640 /* Can't check for airlifting capacity. */
2641 return TRI_MAYBE;
2642 }
2643
2644 if (0 >= actor->city->airlift
2647 /* The source cannot airlift for this turn (maybe already airlifted
2648 * or no airport).
2649 *
2650 * See also do_airline() in server/unittools.h. */
2651 return TRI_NO;
2652 }
2653 }
2654 break;
2655
2656 case ACTRES_CONVERT:
2657 /* Reason: Keep the old rules. */
2658 /* Info leak: The player knows their unit's cargo and location. */
2659 if (!unit_can_convert(nmap, actor->unit)) {
2660 return TRI_NO;
2661 }
2662 break;
2663
2666 if (unit_transported(actor->unit)) {
2667 if (!can_unit_unload(actor->unit, unit_transport_get(actor->unit))) {
2668 /* Can't leave current transport. */
2669 return TRI_NO;
2670 }
2671 }
2672 break;
2673
2675 if (!can_unit_unload(actor->unit, unit_transport_get(actor->unit))) {
2676 /* Keep the old rules about Unreachable and disembarks. */
2677 return TRI_NO;
2678 }
2679 break;
2680
2681 case ACTRES_HOMELESS:
2682 case ACTRES_UNIT_MOVE:
2683 case ACTRES_TELEPORT:
2687 case ACTRES_SPY_POISON:
2696 case ACTRES_SPY_ESCAPE:
2697 case ACTRES_TRADE_ROUTE:
2698 case ACTRES_MARKETPLACE:
2699 case ACTRES_HELP_WONDER:
2703 case ACTRES_FOUND_CITY:
2704 case ACTRES_JOIN_CITY:
2705 case ACTRES_STEAL_MAPS:
2706 case ACTRES_BOMBARD:
2707 case ACTRES_SPY_NUKE:
2708 case ACTRES_NUKE:
2709 case ACTRES_NUKE_UNITS:
2711 case ACTRES_EXPEL_UNIT:
2714 case ACTRES_HOME_CITY:
2716 case ACTRES_ATTACK:
2717 case ACTRES_WIPE_UNITS:
2723 case ACTRES_HEAL_UNIT:
2725 case ACTRES_CULTIVATE:
2726 case ACTRES_PLANT:
2727 case ACTRES_PILLAGE:
2728 case ACTRES_CLEAN:
2729 case ACTRES_FORTIFY:
2730 case ACTRES_ROAD:
2731 case ACTRES_BASE:
2732 case ACTRES_MINE:
2733 case ACTRES_IRRIGATE:
2737 case ACTRES_SPY_ATTACK:
2738 case ACTRES_HUT_ENTER:
2741 case ACTRES_NONE:
2742 /* No hard unit requirements. */
2743 break;
2744
2746 }
2747
2748 return TRI_YES;
2749}
2750
2751/**********************************************************************/
2774static enum fc_tristate
2777 const struct req_context *actor,
2778 const struct req_context *target,
2779 const struct extra_type *target_extra,
2780 const bool omniscient,
2781 const struct city *homecity)
2782{
2783 enum fc_tristate out;
2786
2787 if (actor == NULL) {
2789 }
2790 if (target == NULL) {
2791 target = req_context_empty();
2792 }
2793
2794 fc_assert_msg((tkind == ATK_CITY && target->city != NULL)
2795 || (tkind == ATK_TILE && target->tile != NULL)
2796 || (tkind == ATK_EXTRAS && target->tile != NULL)
2797 || (tkind == ATK_UNIT && target->unit != NULL)
2798 /* At this level each individual unit is tested. */
2799 || (tkind == ATK_UNITS && target->unit != NULL)
2800 || (tkind == ATK_SELF),
2801 "Missing target!");
2802
2803 /* Info leak: The player knows where their unit is. */
2804 if (tkind != ATK_SELF
2807 target->tile))) {
2808 /* The distance between the actor and the target isn't inside the
2809 * action's accepted range. */
2810 return TRI_NO;
2811 }
2812
2813 switch (tkind) {
2814 case ATK_UNIT:
2815 /* The Freeciv code for all actions that is controlled by action
2816 * enablers and targets a unit assumes that the acting
2817 * player can see the target unit.
2818 * Examples:
2819 * - action_prob_vs_unit()'s quick check that the distance between actor
2820 * and target is acceptable would leak distance to target unit if the
2821 * target unit can't be seen.
2822 */
2823 if (!can_player_see_unit(actor->player, target->unit)) {
2824 return TRI_NO;
2825 }
2826 break;
2827 case ATK_CITY:
2828 /* The Freeciv code assumes that the player is aware of the target
2829 * city's existence. (How can you order an airlift to a city when you
2830 * don't know its city ID?) */
2832 actor->player)
2833 != target->city->id) {
2834 return TRI_NO;
2835 }
2836 break;
2837 case ATK_UNITS:
2838 case ATK_TILE:
2839 case ATK_EXTRAS:
2840 case ATK_SELF:
2841 /* No special player knowledge checks. */
2842 break;
2843 case ATK_COUNT:
2845 break;
2846 }
2847
2849 target->tile, target->city, target->unit)) {
2850 /* Allows an action to block an other action. If a blocking action is
2851 * legal the actions it blocks becomes illegal. */
2852 return TRI_NO;
2853 }
2854
2855 /* Actor specific hard requirements. */
2857
2858 if (out == TRI_NO) {
2859 /* Illegal because of a hard actor requirement. */
2860 return TRI_NO;
2861 }
2862
2863 /* Quick checks for action itself */
2864 if (paction->result == ACTRES_ATTACK
2865 || paction->result == ACTRES_WIPE_UNITS
2866 || paction->result == ACTRES_COLLECT_RANSOM) {
2867 /* Reason: Keep the old rules. */
2868 if (!can_unit_attack_tile(actor->unit, paction, target->tile)) {
2869 return TRI_NO;
2870 }
2871 }
2872
2873 /* Hard requirements for results. */
2875 paction->result, actor,
2876 target, target_extra, out, omniscient,
2877 homecity);
2878
2879 if (out == TRI_NO) {
2880 /* Illegal because of a hard actor requirement. */
2881 return TRI_NO;
2882 }
2883
2884 if (paction->result == ACTRES_NUKE_UNITS) {
2886 target->tile)
2887 != ATT_OK) {
2888 /* Unreachable. */
2889 return TRI_NO;
2890 }
2891 } else if (paction->result == ACTRES_PARADROP
2892 || paction->result == ACTRES_PARADROP_CONQUER) {
2893 if (can_player_see_tile(actor->player, target->tile)) {
2894 /* Check for seen stuff that may kill the actor unit. */
2895
2896 /* Reason: Keep the old rules. Be merciful. */
2897 /* Info leak: The player sees the target tile. */
2898 if (!can_unit_exist_at_tile(nmap, actor->unit, target->tile)
2899 && (!BV_ISSET(paction->sub_results, ACT_SUB_RES_MAY_EMBARK)
2900 || !unit_could_load_at(actor->unit, target->tile))) {
2901 return TRI_NO;
2902 }
2903
2904 /* Reason: Keep the old rules. Be merciful. */
2905 /* Info leak: The player sees the target tile. */
2906 if (is_non_attack_city_tile(target->tile, actor->player)) {
2907 return TRI_NO;
2908 }
2909
2910 /* Reason: Be merciful. */
2911 /* Info leak: The player sees all units checked. Invisible units are
2912 * ignored. */
2913 unit_list_iterate(target->tile->units, pother) {
2914 if (can_player_see_unit(actor->player, pother)
2915 && !pplayers_allied(actor->player, unit_owner(pother))) {
2916 return TRI_NO;
2917 }
2919 }
2920 }
2921
2922 return out;
2923}
2924
2925/**********************************************************************/
2931static bool is_enabler_active(const struct action_enabler *enabler,
2932 const struct req_context *actor,
2933 const struct req_context *target)
2934{
2935 return are_reqs_active(actor, target, &enabler->actor_reqs, RPT_CERTAIN)
2936 && are_reqs_active(target, actor, &enabler->target_reqs, RPT_CERTAIN);
2937}
2938
2939/**********************************************************************/
2948static bool is_action_enabled(const struct civ_map *nmap,
2950 const struct req_context *actor,
2951 const struct req_context *target,
2952 const struct extra_type *target_extra,
2953 const struct city *actor_home)
2954{
2955 enum fc_tristate possible;
2956
2958 TRUE, actor_home);
2959
2960 if (possible != TRI_YES) {
2961 /* This context is omniscient. Should be yes or no. */
2963 "Is omniscient, should get yes or no.");
2964
2965 /* The action enablers are irrelevant since the action it self is
2966 * impossible. */
2967 return FALSE;
2968 }
2969
2971 enabler) {
2972 if (is_enabler_active(enabler, actor, target)) {
2973 return TRUE;
2974 }
2976
2977 return FALSE;
2978}
2979
2980/**********************************************************************/
2986static bool
2989 const struct unit *actor_unit,
2990 const struct city *actor_home,
2991 const struct tile *actor_tile,
2992 const struct city *target_city)
2993{
2994 const struct impr_type *target_building;
2995 const struct unit_type *target_utype;
2996
2997 if (actor_unit == NULL || target_city == NULL) {
2998 /* Can't do an action when actor or target are missing. */
2999 return FALSE;
3000 }
3001
3003 FALSE, "Action %s is performed by %s not %s",
3008
3011 FALSE, "Action %s is against %s not %s",
3016
3018
3020 /* No point in continuing. */
3021 return FALSE;
3022 }
3023
3026
3028 &(const struct req_context) {
3029 .player = unit_owner(actor_unit),
3030 .city = tile_city(actor_tile),
3031 .tile = actor_tile,
3032 .unit = actor_unit,
3033 .unittype = unit_type_get(actor_unit),
3034 },
3035 &(const struct req_context) {
3036 .player = city_owner(target_city),
3037 .city = target_city,
3038 .building = target_building,
3040 .unittype = target_utype,
3041 },
3042 NULL,
3043 actor_home);
3044}
3045
3046/**********************************************************************/
3062
3063/**********************************************************************/
3069static bool
3072 const struct unit *actor_unit,
3073 const struct city *actor_home,
3074 const struct tile *actor_tile,
3075 const struct unit *target_unit)
3076{
3077 if (actor_unit == NULL || target_unit == NULL) {
3078 /* Can't do an action when actor or target are missing. */
3079 return FALSE;
3080 }
3081
3083 FALSE, "Action %s is performed by %s not %s",
3088
3091 FALSE, "Action %s is against %s not %s",
3096
3098
3100 /* No point in continuing. */
3101 return FALSE;
3102 }
3103
3105 &(const struct req_context) {
3106 .player = unit_owner(actor_unit),
3107 .city = tile_city(actor_tile),
3108 .tile = actor_tile,
3109 .unit = actor_unit,
3110 .unittype = unit_type_get(actor_unit),
3111 },
3112 &(const struct req_context) {
3113 .player = unit_owner(target_unit),
3116 .unit = target_unit,
3117 .unittype = unit_type_get(target_unit),
3118 },
3119 NULL,
3120 actor_home);
3121}
3122
3123/**********************************************************************/
3139
3140/**********************************************************************/
3146static bool
3149 const struct unit *actor_unit,
3150 const struct city *actor_home,
3151 const struct tile *actor_tile,
3152 const struct tile *target_tile)
3153{
3154 const struct req_context *actor_ctxt;
3155
3156 if (actor_unit == NULL || target_tile == NULL
3157 || unit_list_size(target_tile->units) == 0) {
3158 /* Can't do an action when actor or target are missing. */
3159 return FALSE;
3160 }
3161
3163 FALSE, "Action %s is performed by %s not %s",
3168
3171 FALSE, "Action %s is against %s not %s",
3176
3178
3180 /* No point in continuing. */
3181 return FALSE;
3182 }
3183
3184 actor_ctxt = &(const struct req_context) {
3185 .player = unit_owner(actor_unit),
3186 .city = tile_city(actor_tile),
3187 .tile = actor_tile,
3188 .unit = actor_unit,
3189 .unittype = unit_type_get(actor_unit),
3190 };
3191
3194 &(const struct req_context) {
3195 .player = unit_owner(target_unit),
3198 .unit = target_unit,
3199 .unittype = unit_type_get(target_unit),
3200 },
3201 NULL, actor_home)) {
3202 /* One unit makes it impossible for all units. */
3203 return FALSE;
3204 }
3206
3207 /* Not impossible for any of the units at the tile. */
3208 return TRUE;
3209}
3210
3211/**********************************************************************/
3227
3228/**********************************************************************/
3234static bool
3237 const struct unit *actor_unit,
3238 const struct city *actor_home,
3239 const struct tile *actor_tile,
3240 const struct tile *target_tile,
3241 const struct extra_type *target_extra)
3242{
3243 if (actor_unit == NULL || target_tile == NULL) {
3244 /* Can't do an action when actor or target are missing. */
3245 return FALSE;
3246 }
3247
3249 FALSE, "Action %s is performed by %s not %s",
3254
3257 FALSE, "Action %s is against %s not %s",
3262
3264
3266 /* No point in continuing. */
3267 return FALSE;
3268 }
3269
3271 &(const struct req_context) {
3272 .player = unit_owner(actor_unit),
3273 .city = tile_city(actor_tile),
3274 .tile = actor_tile,
3275 .unit = actor_unit,
3276 .unittype = unit_type_get(actor_unit),
3277 },
3278 &(const struct req_context) {
3279 .player = tile_owner(target_tile),
3280 .city = tile_city(target_tile),
3281 .tile = target_tile,
3282 },
3284 actor_home);
3285}
3286
3287/**********************************************************************/
3295 const struct unit *actor_unit,
3296 const struct tile *target_tile,
3297 const struct extra_type *target_extra)
3298{
3303}
3304
3305/**********************************************************************/
3311static bool
3314 const struct unit *actor_unit,
3315 const struct city *actor_home,
3316 const struct tile *actor_tile,
3317 const struct tile *target_tile,
3318 const struct extra_type *target_extra)
3319{
3320 if (actor_unit == NULL || target_tile == NULL) {
3321 /* Can't do an action when actor or target are missing. */
3322 return FALSE;
3323 }
3324
3326 FALSE, "Action %s is performed by %s not %s",
3331
3334 FALSE, "Action %s is against %s not %s",
3339
3341
3343 /* No point in continuing. */
3344 return FALSE;
3345 }
3346
3348 &(const struct req_context) {
3349 .player = unit_owner(actor_unit),
3350 .city = tile_city(actor_tile),
3351 .tile = actor_tile,
3352 .unit = actor_unit,
3353 .unittype = unit_type_get(actor_unit),
3354 },
3355 &(const struct req_context) {
3356 .player = target_tile->extras_owner,
3357 .city = tile_city(target_tile),
3358 .tile = target_tile,
3359 },
3361 actor_home);
3362}
3363
3364/**********************************************************************/
3381
3382/**********************************************************************/
3389static bool
3392 const struct unit *actor_unit,
3393 const struct city *actor_home,
3394 const struct tile *actor_tile)
3395{
3396 if (actor_unit == NULL) {
3397 /* Can't do an action when the actor is missing. */
3398 return FALSE;
3399 }
3400
3402 FALSE, "Action %s is performed by %s not %s",
3407
3410 FALSE, "Action %s is against %s not %s",
3415
3417
3419 /* No point in continuing. */
3420 return FALSE;
3421 }
3422
3424 &(const struct req_context) {
3425 .player = unit_owner(actor_unit),
3426 .city = tile_city(actor_tile),
3427 .tile = actor_tile,
3428 .unit = actor_unit,
3429 .unittype = unit_type_get(actor_unit),
3430 },
3431 NULL, NULL,
3432 actor_home);
3433}
3434
3435/**********************************************************************/
3450
3451/**********************************************************************/
3469static enum fc_tristate
3471 const struct req_context *actor,
3472 const struct req_context *target)
3473{
3474 enum fc_tristate current;
3475 enum fc_tristate result;
3476
3477 if (actor == NULL || actor->player == NULL) {
3478 /* Need actor->player for point of view */
3479 return TRI_MAYBE;
3480 }
3481
3482 if (target == NULL) {
3483 target = req_context_empty();
3484 }
3485
3486 result = TRI_NO;
3488 enabler) {
3489 current = fc_tristate_and(mke_eval_reqs(actor->player,
3490 actor, target,
3491 &enabler->actor_reqs,
3492 RPT_CERTAIN),
3493 mke_eval_reqs(actor->player,
3494 target, actor,
3495 &enabler->target_reqs,
3496 RPT_CERTAIN));
3497 if (current == TRI_YES) {
3498 return TRI_YES;
3499 } else if (current == TRI_MAYBE) {
3500 result = TRI_MAYBE;
3501 }
3503
3504 return result;
3505}
3506
3507/**********************************************************************/
3517static bool is_effect_val_known(enum effect_type effect_type,
3518 const struct player *pov_player,
3519 const struct req_context *context,
3520 const struct req_context *other_context)
3521{
3522 effect_list_iterate(get_effects(effect_type), peffect) {
3524 &(peffect->reqs), RPT_CERTAIN)) {
3525 return FALSE;
3526 }
3528
3529 return TRUE;
3530}
3531
3532/**********************************************************************/
3535static enum fc_tristate
3563
3564/**********************************************************************/
3573 const struct unit *pdefender)
3574{
3575 /* Keep unconverted until the end to avoid scaling each step */
3576 int chance;
3577 struct act_prob out;
3578
3579 /* Superspy always win */
3581 /* A defending UTYF_SUPERSPY will defeat every possible attacker. */
3582 return ACTPROB_IMPOSSIBLE;
3583 }
3585 /* An attacking UTYF_SUPERSPY will defeat every possible defender
3586 * except another UTYF_SUPERSPY. */
3587 return ACTPROB_CERTAIN;
3588 }
3589
3590 /* Base chance is 50% */
3591 chance = 50;
3592
3593 /* Spy attack bonus */
3595 chance += 25;
3596 }
3597
3598 /* Spy defense bonus */
3600 chance -= 25;
3601 }
3602
3603 /* Veteran attack and defense bonus */
3604 {
3605 const struct veteran_level *vatt =
3607 const struct veteran_level *vdef =
3609
3610 chance += vatt->power_fact - vdef->power_fact;
3611 }
3612
3613 /* Defense bonus. */
3614 {
3615 const struct req_context defender_ctxt = {
3616 .player = tile_owner(pdefender->tile),
3617 .city = tile_city(pdefender->tile),
3618 .tile = pdefender->tile,
3619 };
3622 NULL)) {
3623 return ACTPROB_NOT_KNOWN;
3624 }
3625
3626 /* Reduce the chance of an attack by EFT_SPY_RESISTANT percent. */
3628 NULL,
3630 NULL,
3632 ) / 100;
3633 }
3634
3635 chance = CLIP(0, chance, 100);
3636
3637 /* Convert to action probability */
3640
3641 return out;
3642}
3643
3644/**********************************************************************/
3650 const struct unit *pvictim,
3651 const struct tile *tgt_tile,
3652 const struct action *paction)
3653{
3654 struct unit *pdefender;
3655
3657 tgt_tile)) {
3658 /* Don't leak information about unseen defenders. */
3659 return ACTPROB_NOT_KNOWN;
3660 }
3661
3663 paction);
3664
3665 if (pdefender) {
3666 /* There will be a diplomatic battle instead of an action. */
3668 };
3669
3670 /* No diplomatic battle will occur. */
3671 return ACTPROB_CERTAIN;
3672}
3673
3674/**********************************************************************/
3678 action_id act_id,
3679 const struct unit *actor_unit)
3680{
3682 /* Unknown because the target is unseen. */
3683 return ACTPROB_NOT_KNOWN;
3684 } else {
3685 /* The actor it self can't do this. */
3686 return ACTPROB_IMPOSSIBLE;
3687 }
3688}
3689
3690/**********************************************************************/
3694static struct act_prob
3696 const struct unit *act_unit,
3697 const struct city *tgt_city,
3698 const struct player *tgt_player,
3699 const struct action *paction)
3700{
3702 &(const struct req_context) {
3703 .player = act_player,
3704 .city = tgt_city,
3705 .unit = act_unit,
3706 .unittype = unit_type_get(act_unit),
3707 },
3708 &(const struct req_context) {
3709 .player = tgt_player,
3710 })
3712 &(const struct req_context) {
3713 .player = tgt_player,
3714 .city = tgt_city,
3715 .unit = act_unit,
3716 },
3717 &(const struct req_context) {
3718 .player = act_player,
3719 })) {
3722 struct act_prob result = { .min = unconverted * ACTPROB_VAL_1_PCT,
3723 .max = unconverted * ACTPROB_VAL_1_PCT };
3724
3725 return result;
3726 } else {
3727 /* Could be improved to return a more exact probability in some cases.
3728 * Example: The player has enough information to know that the
3729 * probability always will be above 25% and always under 75% because
3730 * the only effect with unknown requirements that may apply adds (or
3731 * subtracts) 50% while all the requirements of the other effects that
3732 * may apply are known. */
3733 return ACTPROB_NOT_KNOWN;
3734 }
3735}
3736
3737/**********************************************************************/
3742static struct act_prob
3744 const struct unit *act_unit,
3745 const struct city *tgt_city,
3746 const struct unit *tgt_unit,
3747 const struct tile *tgt_tile,
3748 const struct player *tgt_player,
3749 const struct action *paction)
3750{
3751 struct act_prob battle;
3752 struct act_prob dice_roll;
3753
3754 battle = ACTPROB_CERTAIN;
3755 switch (actres_get_battle_kind(paction->result)) {
3756 case ABK_NONE:
3757 /* No pre action battle. */
3758 break;
3759 case ABK_DIPLOMATIC:
3761 paction);
3762 break;
3763 case ABK_STANDARD:
3764 /* Not supported here yet. Implement when users appear. */
3766 break;
3767 case ABK_COUNT:
3769 break;
3770 }
3771
3774 paction);
3775
3776 return action_prob_and(&battle, &dice_roll);
3777}
3778
3779/**********************************************************************/
3790static struct act_prob
3793 const struct req_context *actor,
3794 const struct city *actor_home,
3795 const struct req_context *target,
3796 const struct extra_type *target_extra)
3797{
3798 int known;
3799 struct act_prob chance;
3801
3802 if (actor == NULL) {
3804 }
3805 if (target == NULL) {
3806 target = req_context_empty();
3807 }
3808
3809 known = is_action_possible(nmap, wanted_action, actor, target,
3811 FALSE, actor_home);
3812
3813 if (known == TRI_NO) {
3814 /* The action enablers are irrelevant since the action it self is
3815 * impossible. */
3816 return ACTPROB_IMPOSSIBLE;
3817 }
3818
3820
3821 known = fc_tristate_and(known,
3823 actor, target));
3824
3825 switch (paction->result) {
3826 case ACTRES_SPY_POISON:
3827 /* All uncertainty comes from potential diplomatic battles and the
3828 * (diplchance server setting and the) Action_Odds_Pct effect controlled
3829 * dice roll before the action. */
3831 target->city, target->unit,
3832 target->tile, target->player,
3833 paction);
3834 break;
3836 /* TODO */
3837 break;
3839 /* TODO */
3840 break;
3841 case ACTRES_STEAL_MAPS:
3842 /* TODO */
3843 break;
3845 /* All uncertainty comes from potential diplomatic battles. */
3846 chance = ap_diplomat_battle(actor->unit, target->unit, target->tile,
3847 paction);
3848 break;
3850 /* All uncertainty comes from potential diplomatic battles. */
3851 chance = ap_diplomat_battle(actor->unit, target->unit, target->tile,
3852 paction);
3853 break;
3854 case ACTRES_SPY_ATTACK:
3855 /* All uncertainty comes from potential diplomatic battles. */
3856 chance = ap_diplomat_battle(actor->unit, NULL, target->tile,
3857 paction);
3858 break;
3860 /* TODO */
3861 break;
3863 /* TODO */
3864 break;
3866 /* TODO */
3867 break;
3869 /* TODO */
3870 break;
3873 break;
3875 /* Do the victim have anything worth taking? */
3876 known = fc_tristate_and(known,
3877 tech_can_be_stolen(actor->player,
3878 target->player));
3879
3880 /* TODO: Calculate actual chance */
3881
3882 break;
3884 /* Do the victim have anything worth taking? */
3885 known = fc_tristate_and(known,
3886 tech_can_be_stolen(actor->player,
3887 target->player));
3888
3889 /* TODO: Calculate actual chance */
3890
3891 break;
3893 /* There is no risk that the city won't get investigated. */
3895 break;
3896 case ACTRES_SPY_ESCAPE:
3897 /* TODO */
3898 break;
3899 case ACTRES_TRADE_ROUTE:
3900 /* TODO */
3901 break;
3902 case ACTRES_MARKETPLACE:
3903 /* Possible when not blocked by is_action_possible() */
3905 break;
3906 case ACTRES_HELP_WONDER:
3907 /* Possible when not blocked by is_action_possible() */
3909 break;
3911 /* No battle is fought first. */
3913 break;
3914 case ACTRES_EXPEL_UNIT:
3915 /* No battle is fought first. */
3917 break;
3918 case ACTRES_BOMBARD:
3919 /* No battle is fought first. */
3921 break;
3922 case ACTRES_FOUND_CITY:
3923 /* Possible when not blocked by is_action_possible() */
3925 break;
3926 case ACTRES_JOIN_CITY:
3927 /* Possible when not blocked by is_action_possible() */
3929 break;
3930 case ACTRES_SPY_NUKE:
3931 /* All uncertainty comes from potential diplomatic battles and the
3932 * (diplchance server setting and the) Action_Odds_Pct effect controlled
3933 * dice roll before the action. */
3935 target->city, target->unit,
3936 target->tile,
3937 target->player,
3938 paction);
3939 break;
3940 case ACTRES_NUKE:
3941 /* TODO */
3942 break;
3943 case ACTRES_NUKE_UNITS:
3944 /* TODO */
3945 break;
3947 /* No battle is fought first. */
3949 break;
3951 /* No battle is fought first. */
3953 break;
3955 /* No battle is fought first. */
3957 break;
3958 case ACTRES_HOME_CITY:
3959 /* No battle is fought first. */
3961 break;
3962 case ACTRES_HOMELESS:
3963 /* No battle is fought first. */
3965 break;
3967 /* No battle is fought first. */
3969 break;
3970 case ACTRES_PARADROP:
3972 /* TODO */
3973 break;
3974 case ACTRES_AIRLIFT:
3975 /* Possible when not blocked by is_action_possible() */
3977 break;
3978 case ACTRES_ATTACK:
3980 {
3981 struct unit *defender_unit = get_defender(nmap, actor->unit,
3982 target->tile, paction);
3983
3984 if (can_player_see_unit(actor->player, defender_unit)) {
3985 double unconverted = unit_win_chance(nmap, actor->unit,
3987
3989 floor((double)ACTPROB_VAL_MAX * unconverted));
3991 ceil((double)ACTPROB_VAL_MAX * unconverted));
3992 } else if (known == TRI_YES) {
3993 known = TRI_MAYBE;
3994 }
3995 }
3996 break;
3997 case ACTRES_WIPE_UNITS:
3999 break;
4001 /* TODO: not implemented yet because:
4002 * - dice roll 100% * Action_Odds_Pct could be handled with
4003 * action_prob_pre_action_dice_roll().
4004 * - sub target building may be missing. May be missing without player
4005 * knowledge if it isn't visible. See is_improvement_visible() and
4006 * can_player_see_city_internals(). */
4007 break;
4009 /* All uncertainty comes from the (diplchance server setting and the)
4010 * Action_Odds_Pct effect controlled dice roll before the action. */
4012 target->city, target->player,
4013 paction);
4014 break;
4016 /* No battle is fought first. */
4018 break;
4020 /* No battle is fought first. */
4022 break;
4023 case ACTRES_HEAL_UNIT:
4024 /* No battle is fought first. */
4026 break;
4028 case ACTRES_CULTIVATE:
4029 case ACTRES_PLANT:
4030 case ACTRES_PILLAGE:
4031 case ACTRES_CLEAN:
4032 case ACTRES_FORTIFY:
4033 case ACTRES_ROAD:
4034 case ACTRES_CONVERT:
4035 case ACTRES_BASE:
4036 case ACTRES_MINE:
4037 case ACTRES_IRRIGATE:
4039 break;
4042 break;
4045 break;
4048 break;
4051 break;
4054 break;
4057 break;
4058 case ACTRES_HUT_ENTER:
4060 /* Entering the hut happens with a probability of 100%. What happens
4061 * next is probably up to dice rolls in Lua. */
4063 break;
4064 case ACTRES_UNIT_MOVE:
4065 case ACTRES_TELEPORT:
4068 break;
4069 /* Not UI action, so chance is meaningless */
4072 break;
4073 case ACTRES_NONE:
4074 /* Accommodate ruleset authors that wishes to roll the dice in Lua.
4075 * Would be ACTPROB_CERTAIN if not for that. */
4076 /* TODO: maybe allow the ruleset author to give a probability from
4077 * Lua? */
4079 break;
4080
4081 case ACTRES_UNUSED_1:
4083 break;
4084 }
4085
4086 /* Non signal action probabilities should be in range. */
4088 || chance.max <= ACTPROB_VAL_MAX),
4089 chance.max = ACTPROB_VAL_MAX);
4091 || chance.min >= ACTPROB_VAL_MIN),
4092 chance.min = ACTPROB_VAL_MIN);
4093
4094 switch (known) {
4095 case TRI_NO:
4096 return ACTPROB_IMPOSSIBLE;
4097 break;
4098 case TRI_MAYBE:
4099 return ACTPROB_NOT_KNOWN;
4100 break;
4101 case TRI_YES:
4102 return chance;
4103 break;
4104 };
4105
4106 fc_assert_msg(FALSE, "Should be yes, maybe or no");
4107
4109}
4110
4111/**********************************************************************/
4115static struct act_prob
4117 const struct unit *actor_unit,
4118 const struct city *actor_home,
4119 const struct tile *actor_tile,
4120 const action_id act_id,
4121 const struct city *target_city)
4122{
4123 const struct impr_type *target_building;
4124 const struct unit_type *target_utype;
4125 const struct action *act = action_by_number(act_id);
4126
4127 if (actor_unit == NULL || target_city == NULL) {
4128 /* Can't do an action when actor or target are missing. */
4129 return ACTPROB_IMPOSSIBLE;
4130 }
4131
4134 "Action %s is performed by %s not %s",
4135 action_id_rule_name(act_id),
4137 action_id_get_actor_kind(act_id)),
4139
4142 "Action %s is against %s not %s",
4143 action_id_rule_name(act_id),
4147
4149
4150 if (!unit_can_do_action(actor_unit, act_id)) {
4151 /* No point in continuing. */
4152 return ACTPROB_IMPOSSIBLE;
4153 }
4154
4155 /* Doesn't leak information about city position since an unknown city
4156 * can't be targeted and a city can't move. */
4157 if (!action_id_distance_accepted(act_id,
4160 /* No point in continuing. */
4161 return ACTPROB_IMPOSSIBLE;
4162 }
4163
4164 /* Doesn't leak information since it must be 100% certain from the
4165 * player's perspective that the blocking action is legal. */
4168 /* Don't offer to perform an action known to be blocked. */
4169 return ACTPROB_IMPOSSIBLE;
4170 }
4171
4173 /* The invisible city at this tile may, as far as the player knows, not
4174 * exist anymore. */
4175 return act_prob_unseen_target(nmap, act_id, actor_unit);
4176 }
4177
4180
4181 return action_prob(nmap, act_id,
4182 &(const struct req_context) {
4183 .player = unit_owner(actor_unit),
4184 .city = tile_city(actor_tile),
4185 .tile = actor_tile,
4186 .unit = actor_unit,
4187 .unittype = unit_type_get(actor_unit),
4188 },
4189 actor_home,
4190 &(const struct req_context) {
4191 .player = city_owner(target_city),
4192 .city = target_city,
4193 .building = target_building,
4195 .unittype = target_utype,
4196 }, NULL);
4197}
4198
4199/**********************************************************************/
4204 const struct unit *actor_unit,
4205 const action_id act_id,
4206 const struct city *target_city)
4207{
4211 act_id, target_city);
4212}
4213
4214/**********************************************************************/
4218static struct act_prob
4220 const struct unit *actor_unit,
4221 const struct city *actor_home,
4222 const struct tile *actor_tile,
4223 const action_id act_id,
4224 const struct unit *target_unit)
4225{
4226 if (actor_unit == NULL || target_unit == NULL) {
4227 /* Can't do an action when actor or target are missing. */
4228 return ACTPROB_IMPOSSIBLE;
4229 }
4230
4233 "Action %s is performed by %s not %s",
4234 action_id_rule_name(act_id),
4236 action_id_get_actor_kind(act_id)),
4238
4241 "Action %s is against %s not %s",
4242 action_id_rule_name(act_id),
4246
4248
4249 if (!unit_can_do_action(actor_unit, act_id)) {
4250 /* No point in continuing. */
4251 return ACTPROB_IMPOSSIBLE;
4252 }
4253
4254 /* Doesn't leak information about unit position since an unseen unit can't
4255 * be targeted. */
4256 if (!action_id_distance_accepted(act_id,
4259 /* No point in continuing. */
4260 return ACTPROB_IMPOSSIBLE;
4261 }
4262
4263 return action_prob(nmap, act_id,
4264 &(const struct req_context) {
4265 .player = unit_owner(actor_unit),
4266 .city = tile_city(actor_tile),
4267 .tile = actor_tile,
4268 .unit = actor_unit,
4269 .unittype = unit_type_get(actor_unit),
4270 },
4271 actor_home,
4272 &(const struct req_context) {
4273 .player = unit_owner(target_unit),
4276 .unit = target_unit,
4277 .unittype = unit_type_get(target_unit),
4278 },
4279 NULL);
4280}
4281
4282/**********************************************************************/
4287 const struct unit *actor_unit,
4288 const action_id act_id,
4289 const struct unit *target_unit)
4290{
4294 act_id,
4295 target_unit);
4296}
4297
4298/**********************************************************************/
4302static struct act_prob
4304 const struct unit *actor_unit,
4305 const struct city *actor_home,
4306 const struct tile *actor_tile,
4307 const action_id act_id,
4308 const struct tile *target_tile)
4309{
4310 struct act_prob prob_all;
4311 const struct req_context *actor_ctxt;
4312 const struct action *act = action_by_number(act_id);
4313
4314 if (actor_unit == NULL || target_tile == NULL) {
4315 /* Can't do an action when actor or target are missing. */
4316 return ACTPROB_IMPOSSIBLE;
4317 }
4318
4321 "Action %s is performed by %s not %s",
4322 action_id_rule_name(act_id),
4324 action_id_get_actor_kind(act_id)),
4326
4329 "Action %s is against %s not %s",
4330 action_id_rule_name(act_id),
4334
4336
4337 if (!unit_can_do_action(actor_unit, act_id)) {
4338 /* No point in continuing. */
4339 return ACTPROB_IMPOSSIBLE;
4340 }
4341
4342 /* Doesn't leak information about unit stack position since it is
4343 * specified as a tile and an unknown tile's position is known. */
4344 if (!action_id_distance_accepted(act_id,
4346 target_tile))) {
4347 /* No point in continuing. */
4348 return ACTPROB_IMPOSSIBLE;
4349 }
4350
4351 /* Doesn't leak information since the actor player can see the target
4352 * tile. */
4356 act_id,
4357 CITYT_CENTER, TRUE)) {
4358 /* Don't offer to perform actions that never can target a unit stack in
4359 * a city. */
4360 return ACTPROB_IMPOSSIBLE;
4361 }
4362
4363 /* Doesn't leak information since it must be 100% certain from the
4364 * player's perspective that the blocking action is legal. */
4368 target_unit)) {
4369 /* Don't offer to perform an action known to be blocked. */
4370 return ACTPROB_IMPOSSIBLE;
4371 }
4373
4374 /* Must be done here since an empty unseen tile will result in
4375 * ACTPROB_IMPOSSIBLE. */
4376 if (unit_list_size(target_tile->units) == 0) {
4377 /* Can't act against an empty tile. */
4378
4380 target_tile)) {
4381 /* Known empty tile. */
4382 return ACTPROB_IMPOSSIBLE;
4383 } else {
4384 /* The player doesn't know that the tile is empty. */
4385 return act_prob_unseen_target(nmap, act_id, actor_unit);
4386 }
4387 }
4388
4395 /* Hard coded rule: can't "Bombard", "Suicide Attack", or "Attack"
4396 * units in non enemy cities. */
4397 return ACTPROB_IMPOSSIBLE;
4398 }
4399
4406 /* Hard coded rule: can't "Nuke Units", "Wipe Units", "Suicide Attack",
4407 * or "Attack" units on non native tile without "AttackNonNative" and
4408 * not "Only_Native_Attack". */
4409 return ACTPROB_IMPOSSIBLE;
4410 }
4411
4412 /* Invisible units at this tile can make the action legal or illegal.
4413 * Invisible units can be stacked with visible units. The possible
4414 * existence of invisible units therefore makes the result uncertain. */
4418
4419 actor_ctxt = &(const struct req_context) {
4420 .player = unit_owner(actor_unit),
4421 .city = tile_city(actor_tile),
4422 .tile = actor_tile,
4423 .unit = actor_unit,
4424 .unittype = unit_type_get(actor_unit),
4425 };
4426
4428 struct act_prob prob_unit;
4429
4431 /* Only visible units are considered. The invisible units contributed
4432 * their uncertainty to prob_all above. */
4433 continue;
4434 }
4435
4437 &(const struct req_context) {
4438 .player = unit_owner(target_unit),
4441 .unit = target_unit,
4442 .unittype = unit_type_get(target_unit),
4443 },
4444 NULL);
4445
4447 /* One unit makes it impossible for all units. */
4448 return ACTPROB_IMPOSSIBLE;
4449 } else if (action_prob_not_impl(prob_unit)) {
4450 /* Not implemented dominates all except impossible. */
4452 } else {
4454 "Invalid probability [%d, %d]",
4455 prob_unit.min, prob_unit.max);
4456
4458 /* Special values dominate regular values. */
4459 continue;
4460 }
4461
4462 /* Probability against all target units considered until this moment
4463 * and the probability against this target unit. */
4464 prob_all.min = (prob_all.min * prob_unit.min) / ACTPROB_VAL_MAX;
4465 prob_all.max = (prob_all.max * prob_unit.max) / ACTPROB_VAL_MAX;
4466 break;
4467 }
4469
4470 /* Not impossible for any of the units at the tile. */
4471 return prob_all;
4472}
4473
4474/**********************************************************************/
4479 const action_id act_id,
4480 const struct tile *target_tile)
4481{
4482 const struct civ_map *nmap = &(wld.map);
4483
4487 act_id,
4488 target_tile);
4489}
4490
4491/**********************************************************************/
4495static struct act_prob
4497 const struct unit *actor_unit,
4498 const struct city *actor_home,
4499 const struct tile *actor_tile,
4500 const action_id act_id,
4501 const struct tile *target_tile,
4502 const struct extra_type *target_extra)
4503{
4504 if (actor_unit == NULL || target_tile == NULL) {
4505 /* Can't do an action when actor or target are missing. */
4506 return ACTPROB_IMPOSSIBLE;
4507 }
4508
4511 "Action %s is performed by %s not %s",
4512 action_id_rule_name(act_id),
4514 action_id_get_actor_kind(act_id)),
4516
4519 "Action %s is against %s not %s",
4520 action_id_rule_name(act_id),
4524
4526
4527 if (!unit_can_do_action(actor_unit, act_id)) {
4528 /* No point in continuing. */
4529 return ACTPROB_IMPOSSIBLE;
4530 }
4531
4532 /* Doesn't leak information about tile position since an unknown tile's
4533 * position is known. */
4534 if (!action_id_distance_accepted(act_id,
4536 target_tile))) {
4537 /* No point in continuing. */
4538 return ACTPROB_IMPOSSIBLE;
4539 }
4540
4541 return action_prob(nmap, act_id,
4542 &(const struct req_context) {
4543 .player = unit_owner(actor_unit),
4544 .city = tile_city(actor_tile),
4545 .tile = actor_tile,
4546 .unit = actor_unit,
4547 .unittype = unit_type_get(actor_unit),
4548 },
4549 actor_home,
4550 &(const struct req_context) {
4551 .player = tile_owner(target_tile),
4552 .city = tile_city(target_tile),
4553 .tile = target_tile,
4554 },
4555 target_extra);
4556}
4557
4558/**********************************************************************/
4563 const action_id act_id,
4564 const struct tile *target_tile,
4565 const struct extra_type *target_extra)
4566{
4567 const struct civ_map *nmap = &(wld.map);
4568
4572 act_id, target_tile, target_extra);
4573}
4574
4575/**********************************************************************/
4579static struct act_prob
4581 const struct unit *actor_unit,
4582 const struct city *actor_home,
4583 const struct tile *actor_tile,
4584 const action_id act_id,
4585 const struct tile *target_tile,
4586 const struct extra_type *target_extra)
4587{
4588 if (actor_unit == NULL || target_tile == NULL) {
4589 /* Can't do an action when actor or target are missing. */
4590 return ACTPROB_IMPOSSIBLE;
4591 }
4592
4595 "Action %s is performed by %s not %s",
4596 action_id_rule_name(act_id),
4598 action_id_get_actor_kind(act_id)),
4600
4603 "Action %s is against %s not %s",
4604 action_id_rule_name(act_id),
4608
4610
4611 if (!unit_can_do_action(actor_unit, act_id)) {
4612 /* No point in continuing. */
4613 return ACTPROB_IMPOSSIBLE;
4614 }
4615
4616 /* Doesn't leak information about tile position since an unknown tile's
4617 * position is known. */
4618 if (!action_id_distance_accepted(act_id,
4620 target_tile))) {
4621 /* No point in continuing. */
4622 return ACTPROB_IMPOSSIBLE;
4623 }
4624
4625 return action_prob(nmap, act_id,
4626 &(const struct req_context) {
4627 .player = unit_owner(actor_unit),
4628 .city = tile_city(actor_tile),
4629 .tile = actor_tile,
4630 .unit = actor_unit,
4631 .unittype = unit_type_get(actor_unit),
4632 },
4633 actor_home,
4634 &(const struct req_context) {
4635 .player = target_tile->extras_owner,
4636 .city = tile_city(target_tile),
4637 .tile = target_tile,
4638 },
4639 target_extra);
4640}
4641
4642/**********************************************************************/
4647 const action_id act_id,
4648 const struct tile *target_tile,
4649 const struct extra_type *target_extra)
4650{
4651 const struct civ_map *nmap = &(wld.map);
4652
4656 act_id, target_tile, target_extra);
4657}
4658
4659/**********************************************************************/
4663static struct act_prob
4665 const struct unit *actor_unit,
4666 const struct city *actor_home,
4667 const struct tile *actor_tile,
4668 const action_id act_id)
4669{
4670 if (actor_unit == NULL) {
4671 /* Can't do the action when the actor is missing. */
4672 return ACTPROB_IMPOSSIBLE;
4673 }
4674
4675 /* No point in checking distance to target. It is always 0. */
4676
4679 "Action %s is performed by %s not %s",
4680 action_id_rule_name(act_id),
4682 action_id_get_actor_kind(act_id)),
4684
4687 "Action %s is against %s not %s",
4688 action_id_rule_name(act_id),
4692
4694
4695 if (!unit_can_do_action(actor_unit, act_id)) {
4696 /* No point in continuing. */
4697 return ACTPROB_IMPOSSIBLE;
4698 }
4699
4700 return action_prob(nmap, act_id,
4701 &(const struct req_context) {
4702 .player = unit_owner(actor_unit),
4703 .city = tile_city(actor_tile),
4704 .tile = actor_tile,
4705 .unit = actor_unit,
4706 .unittype = unit_type_get(actor_unit),
4707 },
4708 actor_home,
4709 NULL,
4710 NULL);
4711}
4712
4713/**********************************************************************/
4718 const action_id act_id)
4719{
4720 const struct civ_map *nmap = &(wld.map);
4721
4725 act_id);
4726}
4727
4728/**********************************************************************/
4740 const struct unit *act_unit,
4741 const struct city *tgt_city,
4742 const struct unit *tgt_unit,
4743 const struct tile *tgt_tile,
4744 const struct extra_type *extra_tgt)
4745{
4746 /* Assume impossible until told otherwise. */
4747 struct act_prob prob = ACTPROB_IMPOSSIBLE;
4748 const struct civ_map *nmap = &(wld.map);
4749
4752
4754 case ATK_UNITS:
4755 if (tgt_tile) {
4757 }
4758 break;
4759 case ATK_TILE:
4760 if (tgt_tile) {
4762 }
4763 break;
4764 case ATK_EXTRAS:
4765 if (tgt_tile) {
4768 }
4769 break;
4770 case ATK_CITY:
4771 if (tgt_city) {
4773 }
4774 break;
4775 case ATK_UNIT:
4776 if (tgt_unit) {
4778 }
4779 break;
4780 case ATK_SELF:
4781 prob = action_prob_self(act_unit, paction->id);
4782 break;
4783 case ATK_COUNT:
4784 log_error("Invalid action target kind");
4785 break;
4786 }
4787
4788 return prob;
4789}
4790
4791/**********************************************************************/
4798 const struct city *actor_home,
4799 const struct tile *actor_tile,
4800 const bool omniscient_cheat,
4801 const struct city* target)
4802{
4803 /* FIXME: some unit state requirements still depend on the actor unit's
4804 * current position rather than on actor_tile. Maybe this function should
4805 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4806 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4807 const struct civ_map *nmap = &(wld.map);
4808
4809 if (omniscient_cheat) {
4812 target)) {
4813 return ACTPROB_CERTAIN;
4814 } else {
4815 return ACTPROB_IMPOSSIBLE;
4816 }
4817 } else {
4818 /* FIXME: this branch result depends _directly_ on actor's position.
4819 * I.e., like, not adjacent, no action. Other branch ignores radius. */
4821 act_id, target);
4822 }
4823}
4824
4825/**********************************************************************/
4830struct act_prob
4833 const struct city *actor_home,
4834 const struct tile *actor_tile,
4835 bool omniscient_cheat,
4836 const struct unit *target)
4837{
4838 /* FIXME: some unit state requirements still depend on the actor unit's
4839 * current position rather than on actor_tile. Maybe this function should
4840 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4841 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4842 const struct civ_map *nmap = &(wld.map);
4843
4844 if (omniscient_cheat) {
4847 target)) {
4848 return ACTPROB_CERTAIN;
4849 } else {
4850 return ACTPROB_IMPOSSIBLE;
4851 }
4852 } else {
4854 act_id, target);
4855 }
4856}
4857
4858/**********************************************************************/
4863struct act_prob
4866 const struct city *actor_home,
4867 const struct tile *actor_tile,
4868 bool omniscient_cheat,
4869 const struct tile *target)
4870{
4871 /* FIXME: some unit state requirements still depend on the actor unit's
4872 * current position rather than on actor_tile. Maybe this function should
4873 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4874 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4875 const struct civ_map *nmap = &(wld.map);
4876
4877 if (omniscient_cheat) {
4880 target)) {
4881 return ACTPROB_CERTAIN;
4882 } else {
4883 return ACTPROB_IMPOSSIBLE;
4884 }
4885 } else {
4887 act_id, target);
4888 }
4889}
4890
4891/**********************************************************************/
4896struct act_prob
4899 const struct city *actor_home,
4900 const struct tile *actor_tile,
4901 bool omniscient_cheat,
4902 const struct tile *target_tile,
4903 const struct extra_type *target_extra)
4904{
4905 /* FIXME: some unit state requirements still depend on the actor unit's
4906 * current position rather than on actor_tile. Maybe this function should
4907 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4908 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4909 const struct civ_map *nmap = &(wld.map);
4910
4911 if (omniscient_cheat) {
4915 return ACTPROB_CERTAIN;
4916 } else {
4917 return ACTPROB_IMPOSSIBLE;
4918 }
4919 } else {
4921 act_id, target_tile, target_extra);
4922 }
4923}
4924
4925/**********************************************************************/
4930struct act_prob
4933 const struct city *actor_home,
4934 const struct tile *actor_tile,
4935 bool omniscient_cheat,
4936 const struct tile *target_tile,
4937 const struct extra_type *target_extra)
4938{
4939 /* FIXME: some unit state requirements still depend on the actor unit's
4940 * current position rather than on actor_tile. Maybe this function should
4941 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4942 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4943 const struct civ_map *nmap = &(wld.map);
4944
4945 if (omniscient_cheat) {
4949 return ACTPROB_CERTAIN;
4950 } else {
4951 return ACTPROB_IMPOSSIBLE;
4952 }
4953 } else {
4955 act_id, target_tile, target_extra);
4956 }
4957}
4958
4959/**********************************************************************/
4964struct act_prob
4967 const struct city *actor_home,
4968 const struct tile *actor_tile,
4969 bool omniscient_cheat)
4970{
4971 /* FIXME: some unit state requirements still depend on the actor unit's
4972 * current position rather than on actor_tile. Maybe this function should
4973 * return ACTPROB_NOT_IMPLEMENTED when one of those is detected and no
4974 * other requirement makes the action ACTPROB_IMPOSSIBLE? */
4975 const struct civ_map *nmap = &(wld.map);
4976
4977 if (omniscient_cheat) {
4980 return ACTPROB_CERTAIN;
4981 } else {
4982 return ACTPROB_IMPOSSIBLE;
4983 }
4984 } else {
4986 act_id);
4987 }
4988}
4989
4990/**********************************************************************/
4994{
4996
4997 return out;
4998}
4999
5000/**********************************************************************/
5004{
5006
5007 return out;
5008}
5009
5010/**********************************************************************/
5014{
5016
5017 return out;
5018}
5019
5020/**********************************************************************/
5024{
5026
5027 return out;
5028}
5029
5030/**********************************************************************/
5034{
5036
5037 return out;
5038}
5039
5040/**********************************************************************/
5045{
5046 return (ACTPROB_VAL_MIN < probability.max
5048}
5049
5050/**********************************************************************/
5055{
5056 return (ACTPROB_VAL_MAX == probability.min
5057 && ACTPROB_VAL_MAX == probability.max);
5058}
5059
5060/**********************************************************************/
5064static inline bool
5070
5071/**********************************************************************/
5075static inline bool
5077{
5078 return probability.min == ACTPROB_VAL_NOT_IMPL
5079 && probability.max == ACTPROB_VAL_MIN;
5080}
5081
5082/**********************************************************************/
5086static inline bool
5088{
5089 return probability.max < probability.min;
5090}
5091
5092/**********************************************************************/
5096 const struct act_prob *ap2)
5097{
5098 return ap1->min == ap2->min && ap1->max == ap2->max;
5099}
5100
5101/**********************************************************************/
5105 const struct act_prob ap2)
5106{
5107 struct act_prob my_ap1;
5108 struct act_prob my_ap2;
5109
5110 /* The action probabilities are real. */
5113
5114 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5116 /* Assert that it is OK to convert the signal. */
5118
5120 } else {
5121 my_ap1 = ap1;
5122 }
5123
5125 /* Assert that it is OK to convert the signal. */
5127
5129 } else {
5130 my_ap2 = ap2;
5131 }
5132
5133 /* The action probabilities now have a comparison friendly form. */
5136
5137 /* Do the comparison. Start with min. Continue with max. */
5138 if (my_ap1.min < my_ap2.min) {
5139 return -1;
5140 } else if (my_ap1.min > my_ap2.min) {
5141 return 1;
5142 } else if (my_ap1.max < my_ap2.max) {
5143 return -1;
5144 } else if (my_ap1.max > my_ap2.max) {
5145 return 1;
5146 } else {
5147 return 0;
5148 }
5149}
5150
5151/**********************************************************************/
5156{
5157 struct act_prob my_ap;
5158
5159 /* The action probability is real. */
5161
5162 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5164 /* Assert that it is OK to convert the signal. */
5166
5168 } else {
5169 my_ap = ap;
5170 }
5171
5172 /* The action probability now has a math friendly form. */
5174
5175 return (double)my_ap.min / (double) ACTPROB_VAL_MAX;
5176}
5177
5178/**********************************************************************/
5183 const struct act_prob *ap2)
5184{
5185 struct act_prob my_ap1;
5186 struct act_prob my_ap2;
5187 struct act_prob out;
5188
5189 /* The action probabilities are real. */
5192
5195 /* Keep the information rather than converting the signal to
5196 * ACTPROB_NOT_KNOWN. */
5197
5198 /* Assert that it is OK to convert the signal. */
5200
5201 out.min = ap1->min;
5202 out.max = ap2->max;
5203
5204 return out;
5205 }
5206
5207 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5208 if (action_prob_is_signal(*ap1)) {
5209 /* Assert that it is OK to convert the signal. */
5211
5212 my_ap1.min = ACTPROB_VAL_MIN;
5213 my_ap1.max = ACTPROB_VAL_MAX;
5214 } else {
5215 my_ap1.min = ap1->min;
5216 my_ap1.max = ap1->max;
5217 }
5218
5219 if (action_prob_is_signal(*ap2)) {
5220 /* Assert that it is OK to convert the signal. */
5222
5223 my_ap2.min = ACTPROB_VAL_MIN;
5224 my_ap2.max = ACTPROB_VAL_MAX;
5225 } else {
5226 my_ap2.min = ap2->min;
5227 my_ap2.max = ap2->max;
5228 }
5229
5230 /* The action probabilities now have a math friendly form. */
5233
5234 /* Do the math. */
5235 out.min = (my_ap1.min * my_ap2.min) / ACTPROB_VAL_MAX;
5236 out.max = (my_ap1.max * my_ap2.max) / ACTPROB_VAL_MAX;
5237
5238 /* Cap at 100%. */
5239 out.min = MIN(out.min, ACTPROB_VAL_MAX);
5240 out.max = MIN(out.max, ACTPROB_VAL_MAX);
5241
5242 return out;
5243}
5244
5245/**********************************************************************/
5253 const struct act_prob *ap2)
5254{
5255 struct act_prob my_ap1;
5256 struct act_prob my_ap2;
5257 struct act_prob out;
5258
5259 /* The action probabilities are real. */
5262
5265 /* Keep the information rather than converting the signal to
5266 * ACTPROB_NOT_KNOWN. */
5267
5268 /* Assert that it is OK to convert the signal. */
5270
5271 out.min = ap1->min;
5272 out.max = ap2->max;
5273
5274 return out;
5275 }
5276
5277 /* Convert any signals to ACTPROB_NOT_KNOWN. */
5278 if (action_prob_is_signal(*ap1)) {
5279 /* Assert that it is OK to convert the signal. */
5281
5282 my_ap1.min = ACTPROB_VAL_MIN;
5283 my_ap1.max = ACTPROB_VAL_MAX;
5284 } else {
5285 my_ap1.min = ap1->min;
5286 my_ap1.max = ap1->max;
5287 }
5288
5289 if (action_prob_is_signal(*ap2)) {
5290 /* Assert that it is OK to convert the signal. */
5292
5293 my_ap2.min = ACTPROB_VAL_MIN;
5294 my_ap2.max = ACTPROB_VAL_MAX;
5295 } else {
5296 my_ap2.min = ap2->min;
5297 my_ap2.max = ap2->max;
5298 }
5299
5300 /* The action probabilities now have a math friendly form. */
5303
5304 /* Do the math. */
5305 out.min = my_ap1.min + (((ACTPROB_VAL_MAX - my_ap1.min) * my_ap2.min)
5306 / ACTPROB_VAL_MAX);
5307 out.max = my_ap1.max + (((ACTPROB_VAL_MAX - my_ap1.max) * my_ap2.max)
5308 / ACTPROB_VAL_MAX);
5309
5310 /* Cap at 100%. */
5311 out.min = MIN(out.min, ACTPROB_VAL_MAX);
5312 out.max = MIN(out.max, ACTPROB_VAL_MAX);
5313
5314 return out;
5315}
5316
5317/**********************************************************************/
5321{
5322 switch (actres_dice_type(paction->result)) {
5323 case DRT_DIPLCHANCE:
5325 /* Take the initial odds from the diplchance setting. */
5327 server_setting_by_name("diplchance"));
5328 }
5330 case DRT_CERTAIN:
5331 return 100;
5332 case DRT_NONE:
5333 break;
5334 }
5335
5336 /* The odds of the action not being stopped by its dice roll when the dice
5337 * isn't thrown is 100%. ACTION_ODDS_PCT_DICE_ROLL_NA is above 100% */
5339}
5340
5341/**********************************************************************/
5345 const struct unit *act_unit,
5346 const struct city *tgt_city,
5347 const struct player *tgt_player,
5348 const struct action *paction)
5349{
5351 const struct unit_type *actu_type = unit_type_get(act_unit);
5352
5353 fc_assert_action_msg(odds >= 0 && odds <= 100,
5354 odds = 100,
5355 "Bad initial odds for action number %d."
5356 " Does it roll the dice at all?",
5357 paction->id);
5358
5359 /* Let the Action_Odds_Pct effect modify the odds. The advantage of doing
5360 * it this way instead of rolling twice is that Action_Odds_Pct can
5361 * increase the odds. */
5362 odds = odds
5363 + ((odds
5365 &(const struct req_context) {
5366 .player = act_player,
5367 .city = tgt_city,
5368 .unit = act_unit,
5369 .unittype = actu_type,
5370 .action = paction,
5371 },
5372 &(const struct req_context) {
5373 .player = tgt_player,
5374 },
5376 / 100)
5377 - ((odds
5379 &(const struct req_context) {
5380 .player = tgt_player,
5381 .city = tgt_city,
5382 .unit = act_unit,
5383 .unittype = actu_type,
5384 .action = paction,
5385 },
5386 &(const struct req_context) {
5387 .player = act_player,
5388 },
5390 / 100);
5391
5392
5393 /* Odds are between 0% and 100%. */
5394 return CLIP(0, odds, 100);
5395}
5396
5397/**********************************************************************/
5401{
5402 struct action *paction = action_by_number(act);
5403
5404 /* Always immune since its not enabled. Doesn't count. */
5405 if (!action_is_in_use(paction)) {
5406 return FALSE;
5407 }
5408
5410 if (requirement_fulfilled_by_government(gov, &(enabler->target_reqs))) {
5411 return FALSE;
5412 }
5414
5415 return TRUE;
5416}
5417
5418/**********************************************************************/
5424 const struct player *actor_player,
5425 const struct req_context *target)
5426{
5428 enabler) {
5429 if (are_reqs_active(target,
5430 &(const struct req_context) {
5432 },
5433 &enabler->target_reqs, RPT_POSSIBLE)) {
5434 return TRUE;
5435 }
5437
5438 return FALSE;
5439}
5440
5441/**********************************************************************/
5445 const struct player *actor_player,
5446 const struct city* target_city)
5447{
5449 FALSE, "Action %s is against %s not cities",
5450 action_id_rule_name(act_id),
5452 action_id_get_target_kind(act_id)));
5453
5454 return is_target_possible(act_id, actor_player,
5455 &(const struct req_context) {
5456 .player = city_owner(target_city),
5457 .city = target_city,
5459 });
5460}
5461
5462/**********************************************************************/
5468 const action_id act_id,
5469 const struct unit *actor_unit)
5470{
5471 const struct player *actor_player = unit_owner(actor_unit);
5472 const struct req_context actor_ctxt = {
5474 .city = tile_city(unit_tile(actor_unit)),
5476 .unit = actor_unit,
5477 .unittype = unit_type_get(actor_unit),
5478 };
5479 const struct action *paction = action_by_number(act_id);
5480
5481 enum fc_tristate result;
5482
5484
5485 if (!utype_can_do_action(actor_unit->utype, act_id)) {
5486 /* The unit type can't perform the action. */
5487 return FALSE;
5488 }
5489
5492
5493 if (result == TRI_NO) {
5494 /* The hard requirements aren't fulfilled. */
5495 return FALSE;
5496 }
5497
5499 enabler) {
5500 const enum fc_tristate current
5502 &enabler->actor_reqs,
5503 /* Needed since no player to evaluate DiplRel
5504 * requirements against. */
5505 RPT_POSSIBLE);
5506
5507 if (current == TRI_YES
5508 || current == TRI_MAYBE) {
5509 /* The ruleset requirements may be fulfilled. */
5510 return TRUE;
5511 }
5513
5514 /* No action enabler allows this action. */
5515 return FALSE;
5516}
5517
5518/**********************************************************************/
5523 const action_id act_id)
5524{
5525 fc_assert(action_id_exists(act_id) || act_id == ACTION_ANY);
5526
5527 /* Check if full movement points may enable the specified action. */
5529 act_id,
5532 act_id,
5534}
5535
5536/**********************************************************************/
5561
5562/**********************************************************************/
5573{
5574 const struct action *paction = enabler_get_action(ae);
5575
5576 switch (action_get_actor_kind(paction)) {
5577 case AAK_UNIT:
5580 /* A possible actor unit type has been found. */
5581 return TRUE;
5582 }
5584
5585 /* No actor detected. */
5586 return FALSE;
5587 case AAK_COUNT:
5589 break;
5590 }
5591
5592 /* No actor detected. */
5593 return FALSE;
5594}
5595
5596/**********************************************************************/
5604{
5605 switch (action_get_actor_kind(paction)) {
5606 case AAK_UNIT:
5609 return TRUE;
5610 }
5612 break;
5613 case AAK_COUNT:
5615 break;
5616 }
5617
5618 /* No actor detected. */
5619 return FALSE;
5620}
5621
5622/**********************************************************************/
5630{
5632
5634 /* Hard requirements not fulfilled. */
5635 return FALSE;
5636 }
5637
5639
5641 /* If this iteration finds any entries, action is enabled. */
5642 return TRUE;
5644
5645 /* No non deleted action enabler. */
5646 return FALSE;
5647}
5648
5649/**********************************************************************/
5656{
5657 return paction != nullptr
5659}
5660
5661/**********************************************************************/
5671
5672/**********************************************************************/
5676{
5677 fc_assert_ret_val(num >= 0, NULL);
5679
5680 return &auto_perfs[num];
5681}
5682
5683/**********************************************************************/
5692{
5693 return action_auto_perf_slot_number(num);
5694}
5695
5696/**********************************************************************/
5700 struct universal *actor_uni,
5701 struct universal *target_uni)
5702{
5704 enab) {
5705 if ((actor_uni == NULL
5706 || universal_fulfills_requirements(FALSE, &(enab->actor_reqs),
5707 actor_uni))
5708 && (target_uni == NULL
5709 || universal_fulfills_requirements(FALSE, &(enab->target_reqs),
5710 target_uni))) {
5711 return TRUE;
5712 }
5714
5715 return FALSE;
5716}
5717
5718/**********************************************************************/
5724{
5726
5727 if (size < MAX_NUM_ACTIONS) {
5728 /* An action array is terminated by ACTION_NONE */
5730 }
5731}
5732
5733/**********************************************************************/
5741 int *position,
5742 enum action_result result)
5743{
5744 action_iterate(act) {
5745 struct action *paction = action_by_number(act);
5746 if (paction->result == result) {
5747 /* Assume one result for each action. */
5748 fc_assert_ret(*position < MAX_NUM_ACTIONS);
5749
5750 act_array[(*position)++] = paction->id;
5751 }
5753}
5754
5755/**********************************************************************/
5761{
5762 switch ((enum gen_action)act) {
5763 case ACTION_SPY_POISON:
5764 return "ui_name_poison_city";
5766 return "ui_name_poison_city_escape";
5768 return "ui_name_sabotage_unit";
5770 return "ui_name_sabotage_unit_escape";
5772 return "ui_name_bribe_unit";
5774 return "ui_name_sabotage_city";
5776 return "ui_name_sabotage_city_escape";
5778 return "ui_name_targeted_sabotage_city";
5780 return "ui_name_sabotage_city_production";
5782 return "ui_name_targeted_sabotage_city_escape";
5784 return "ui_name_sabotage_city_production_escape";
5786 return "ui_name_incite_city";
5788 return "ui_name_incite_city_escape";
5790 return "ui_name_establish_embassy";
5792 return "ui_name_establish_embassy_stay";
5794 return "ui_name_steal_tech";
5796 return "ui_name_steal_tech_escape";
5798 return "ui_name_targeted_steal_tech";
5800 return "ui_name_targeted_steal_tech_escape";
5802 return "ui_name_investigate_city";
5804 return "ui_name_investigate_city_spend_unit";
5806 return "ui_name_steal_gold";
5808 return "ui_name_steal_gold_escape";
5810 return "ui_name_spread_plague";
5811 case ACTION_STEAL_MAPS:
5812 return "ui_name_steal_maps";
5814 return "ui_name_steal_maps_escape";
5815 case ACTION_TRADE_ROUTE:
5816 return "ui_name_establish_trade_route";
5817 case ACTION_MARKETPLACE:
5818 return "ui_name_enter_marketplace";
5819 case ACTION_HELP_WONDER:
5820 return "ui_name_help_wonder";
5822 return "ui_name_capture_units";
5823 case ACTION_EXPEL_UNIT:
5824 return "ui_name_expel_unit";
5825 case ACTION_FOUND_CITY:
5826 return "ui_name_found_city";
5827 case ACTION_JOIN_CITY:
5828 return "ui_name_join_city";
5829 case ACTION_BOMBARD:
5830 return "ui_name_bombard";
5831 case ACTION_BOMBARD2:
5832 return "ui_name_bombard_2";
5833 case ACTION_BOMBARD3:
5834 return "ui_name_bombard_3";
5835 case ACTION_BOMBARD4:
5836 return "ui_name_bombard_4";
5838 return "ui_name_bombard_lethal";
5840 return "ui_name_bombard_lethal_2";
5841 case ACTION_SPY_NUKE:
5842 return "ui_name_suitcase_nuke";
5844 return "ui_name_suitcase_nuke_escape";
5845 case ACTION_NUKE:
5846 return "ui_name_explode_nuclear";
5847 case ACTION_NUKE_CITY:
5848 return "ui_name_nuke_city";
5849 case ACTION_NUKE_UNITS:
5850 return "ui_name_nuke_units";
5852 return "ui_name_destroy_city";
5854 return "ui_name_disband_unit_recover";
5856 return "ui_name_disband_unit";
5857 case ACTION_HOME_CITY:
5858 return "ui_name_home_city";
5859 case ACTION_HOMELESS:
5860 return "ui_name_homeless";
5862 return "ui_name_upgrade_unit";
5863 case ACTION_PARADROP:
5864 return "ui_name_paradrop_unit";
5866 return "ui_name_paradrop_unit_conquer";
5868 return "ui_name_paradrop_unit_frighten";
5870 return "ui_name_paradrop_unit_frighten_conquer";
5872 return "ui_name_paradrop_unit_enter";
5874 return "ui_name_paradrop_unit_enter_conquer";
5875 case ACTION_AIRLIFT:
5876 return "ui_name_airlift_unit";
5877 case ACTION_ATTACK:
5878 return "ui_name_attack";
5879 case ACTION_ATTACK2:
5880 return "ui_name_attack_2";
5882 return "ui_name_suicide_attack";
5884 return "ui_name_suicide_attack_2";
5885 case ACTION_WIPE_UNITS:
5886 return "ui_name_wipe_units";
5888 return "ui_name_collect_ransom";
5890 return "ui_name_surgical_strike_building";
5892 return "ui_name_surgical_strike_production";
5894 return "ui_name_conquer_city";
5896 return "ui_name_conquer_city_2";
5898 return "ui_name_conquer_city_3";
5900 return "ui_name_conquer_city_4";
5902 return "ui_name_conquer_extras";
5904 return "ui_name_conquer_extras_2";
5906 return "ui_name_conquer_extras_3";
5908 return "ui_name_conquer_extras_4";
5909 case ACTION_HEAL_UNIT:
5910 return "ui_name_heal_unit";
5911 case ACTION_HEAL_UNIT2:
5912 return "ui_name_heal_unit_2";
5914 return "ui_name_transform_terrain";
5916 return "ui_name_transform_terrain_2";
5917 case ACTION_CULTIVATE:
5918 return "ui_name_cultivate";
5919 case ACTION_CULTIVATE2:
5920 return "ui_name_cultivate_2";
5921 case ACTION_PLANT:
5922 return "ui_name_plant";
5923 case ACTION_PLANT2:
5924 return "ui_name_plant_2";
5925 case ACTION_PILLAGE:
5926 return "ui_name_pillage";
5927 case ACTION_PILLAGE2:
5928 return "ui_name_pillage_2";
5929 case ACTION_CLEAN:
5930 return "ui_name_clean";
5931 case ACTION_CLEAN2:
5932 return "ui_name_clean_2";
5933 case ACTION_FORTIFY:
5934 return "ui_name_fortify";
5935 case ACTION_FORTIFY2:
5936 return "ui_name_fortify_2";
5937 case ACTION_ROAD:
5938 return "ui_name_build_road";
5939 case ACTION_ROAD2:
5940 return "ui_name_build_road_2";
5941 case ACTION_CONVERT:
5942 return "ui_name_convert_unit";
5943 case ACTION_BASE:
5944 return "ui_name_build_base";
5945 case ACTION_BASE2:
5946 return "ui_name_build_base_2";
5947 case ACTION_MINE:
5948 return "ui_name_build_mine";
5949 case ACTION_MINE2:
5950 return "ui_name_build_mine_2";
5951 case ACTION_IRRIGATE:
5952 return "ui_name_irrigate";
5953 case ACTION_IRRIGATE2:
5954 return "ui_name_irrigate_2";
5956 return "ui_name_transport_deboard";
5958 return "ui_name_transport_board";
5960 return "ui_name_transport_board_2";
5962 return "ui_name_transport_board_3";
5964 return "ui_name_transport_embark";
5966 return "ui_name_transport_embark_2";
5968 return "ui_name_transport_embark_3";
5970 return "ui_name_transport_embark_4";
5972 return "ui_name_transport_unload";
5974 return "ui_name_transport_load";
5976 return "ui_name_transport_load_2";
5978 return "ui_name_transport_load_3";
5980 return "ui_name_transport_disembark";
5982 return "ui_name_transport_disembark_2";
5984 return "ui_name_transport_disembark_3";
5986 return "ui_name_transport_disembark_4";
5987 case ACTION_HUT_ENTER:
5988 return "ui_name_enter_hut";
5989 case ACTION_HUT_ENTER2:
5990 return "ui_name_enter_hut_2";
5991 case ACTION_HUT_ENTER3:
5992 return "ui_name_enter_hut_3";
5993 case ACTION_HUT_ENTER4:
5994 return "ui_name_enter_hut_4";
5996 return "ui_name_frighten_hut";
5998 return "ui_name_frighten_hut_2";
6000 return "ui_name_frighten_hut_3";
6002 return "ui_name_frighten_hut_4";
6003 case ACTION_SPY_ATTACK:
6004 return "ui_name_spy_attack";
6005 case ACTION_UNIT_MOVE:
6006 return "ui_name_unit_move";
6007 case ACTION_UNIT_MOVE2:
6008 return "ui_name_unit_move_2";
6009 case ACTION_UNIT_MOVE3:
6010 return "ui_name_unit_move_3";
6011 case ACTION_TELEPORT:
6012 return "ui_name_teleport";
6013 case ACTION_TELEPORT2:
6014 return "ui_name_teleport_2";
6015 case ACTION_TELEPORT3:
6016 return "ui_name_teleport_3";
6018 return "ui_name_teleport_conquer";
6020 return "ui_name_teleport_frighten";
6022 return "ui_name_teleport_frighten_conquer";
6024 return "ui_name_teleport_enter";
6026 return "ui_name_teleport_enter_conquer";
6027 case ACTION_SPY_ESCAPE:
6028 return "ui_name_escape";
6030 return "ui_name_user_action_1";
6032 return "ui_name_user_action_2";
6034 return "ui_name_user_action_3";
6036 return "ui_name_user_action_4";
6038 case ACTION_ESCAPE:
6039 fc_assert(!action_id_is_internal(act)); /* Fail always */
6040 break;
6041 case ACTION_COUNT:
6042 break;
6043
6045 }
6046
6047 fc_assert(act >= 0 && act < ACTION_COUNT);
6048
6049 return NULL;
6050}
6051
6052/**********************************************************************/
6055const char *action_ui_name_default(int act)
6056{
6057 switch ((enum gen_action)act) {
6058 case ACTION_SPY_POISON:
6059 /* TRANS: _Poison City (3% chance of success). */
6060 return N_("%sPoison City%s");
6062 /* TRANS: _Poison City and Escape (3% chance of success). */
6063 return N_("%sPoison City and Escape%s");
6065 /* TRANS: S_abotage Enemy Unit (3% chance of success). */
6066 return N_("S%sabotage Enemy Unit%s");
6068 /* TRANS: S_abotage Enemy Unit and Escape (3% chance of success). */
6069 return N_("S%sabotage Enemy Unit and Escape%s");
6071 /* TRANS: Bribe Enemy _Unit (3% chance of success). */
6072 return N_("Bribe Enemy %sUnit%s");
6074 /* TRANS: _Sabotage City (3% chance of success). */
6075 return N_("%sSabotage City%s");
6077 /* TRANS: _Sabotage City and Escape (3% chance of success). */
6078 return N_("%sSabotage City and Escape%s");
6080 /* TRANS: Industria_l Sabotage (3% chance of success). */
6081 return N_("Industria%sl Sabotage%s");
6083 /* TRANS: Industria_l Sabotage Production (3% chance of success). */
6084 return N_("Industria%sl Sabotage Production%s");
6086 /* TRANS: Industria_l Sabotage and Escape (3% chance of success). */
6087 return N_("Industria%sl Sabotage and Escape%s");
6089 /* TRANS: Industria_l Sabotage Production and Escape (3% chance of success). */
6090 return N_("Industria%sl Sabotage Production and Escape%s");
6092 /* TRANS: Incite a Re_volt (3% chance of success). */
6093 return N_("Incite a Re%svolt%s");
6095 /* TRANS: Incite a Re_volt and Escape (3% chance of success). */
6096 return N_("Incite a Re%svolt and Escape%s");
6098 /* TRANS: Establish _Embassy (100% chance of success). */
6099 return N_("Establish %sEmbassy%s");
6101 /* TRANS: Becom_e Ambassador (100% chance of success). */
6102 return N_("Becom%se Ambassador%s");
6104 /* TRANS: Steal _Technology (3% chance of success). */
6105 return N_("Steal %sTechnology%s");
6107 /* TRANS: Steal _Technology and Escape (3% chance of success). */
6108 return N_("Steal %sTechnology and Escape%s");
6110 /* TRANS: In_dustrial Espionage (3% chance of success). */
6111 return N_("In%sdustrial Espionage%s");
6113 /* TRANS: In_dustrial Espionage and Escape (3% chance of success). */
6114 return N_("In%sdustrial Espionage and Escape%s");
6116 /* TRANS: _Investigate City (100% chance of success). */
6117 return N_("%sInvestigate City%s");
6119 /* TRANS: _Investigate City (spends the unit) (100% chance of
6120 * success). */
6121 return N_("%sInvestigate City (spends the unit)%s");
6123 /* TRANS: Steal _Gold (100% chance of success). */
6124 return N_("Steal %sGold%s");
6126 /* TRANS: Steal _Gold and Escape (100% chance of success). */
6127 return N_("Steal %sGold and Escape%s");
6129 /* TRANS: Spread _Plague (100% chance of success). */
6130 return N_("Spread %sPlague%s");
6131 case ACTION_STEAL_MAPS:
6132 /* TRANS: Steal _Maps (100% chance of success). */
6133 return N_("Steal %sMaps%s");
6135 /* TRANS: Steal _Maps and Escape (100% chance of success). */
6136 return N_("Steal %sMaps and Escape%s");
6137 case ACTION_TRADE_ROUTE:
6138 /* TRANS: Establish Trade _Route (100% chance of success). */
6139 return N_("Establish Trade %sRoute%s");
6140 case ACTION_MARKETPLACE:
6141 /* TRANS: Enter _Marketplace (100% chance of success). */
6142 return N_("Enter %sMarketplace%s");
6143 case ACTION_HELP_WONDER:
6144 /* TRANS: Help _build Wonder (100% chance of success). */
6145 return N_("Help %sbuild Wonder%s");
6147 /* TRANS: _Capture Units (100% chance of success). */
6148 return N_("%sCapture Units%s");
6149 case ACTION_EXPEL_UNIT:
6150 /* TRANS: _Expel Unit (100% chance of success). */
6151 return N_("%sExpel Unit%s");
6152 case ACTION_FOUND_CITY:
6153 /* TRANS: _Found City (100% chance of success). */
6154 return N_("%sFound City%s");
6155 case ACTION_JOIN_CITY:
6156 /* TRANS: _Join City (100% chance of success). */
6157 return N_("%sJoin City%s");
6158 case ACTION_BOMBARD:
6159 /* TRANS: B_ombard (100% chance of success). */
6160 return N_("B%sombard%s");
6161 case ACTION_BOMBARD2:
6162 /* TRANS: B_ombard 2 (100% chance of success). */
6163 return N_("B%sombard 2%s");
6164 case ACTION_BOMBARD3:
6165 /* TRANS: B_ombard 3 (100% chance of success). */
6166 return N_("B%sombard 3%s");
6167 case ACTION_BOMBARD4:
6168 /* TRANS: B_ombard 4 (100% chance of success). */
6169 return N_("B%sombard 4%s");
6172 /* TRANS: Lethal B_ombard (100% chance of success). */
6173 return N_("Lethal B%sombard%s");
6174 case ACTION_SPY_NUKE:
6175 /* TRANS: Suitcase _Nuke (100% chance of success). */
6176 return N_("Suitcase %sNuke%s");
6178 /* TRANS: Suitcase _Nuke and Escape (100% chance of success). */
6179 return N_("Suitcase %sNuke and Escape%s");
6180 case ACTION_NUKE:
6181 /* TRANS: Explode _Nuclear (100% chance of success). */
6182 return N_("Explode %sNuclear%s");
6183 case ACTION_NUKE_CITY:
6184 /* TRANS: _Nuke City (100% chance of success). */
6185 return N_("%sNuke City%s");
6186 case ACTION_NUKE_UNITS:
6187 /* TRANS: _Nuke Units (100% chance of success). */
6188 return N_("%sNuke Units%s");
6190 /* TRANS: Destroy _City (100% chance of success). */
6191 return N_("Destroy %sCity%s");
6193 /* TRANS: Dis_band recovering production (100% chance of success). */
6194 return N_("Dis%sband recovering production%s");
6196 /* TRANS: Dis_band without recovering production (100% chance of success). */
6197 return N_("Dis%sband without recovering production%s");
6198 case ACTION_HOME_CITY:
6199 /* TRANS: Set _Home City (100% chance of success). */
6200 return N_("Set %sHome City%s");
6201 case ACTION_HOMELESS:
6202 /* TRANS: Make _Homeless (100% chance of success). */
6203 return N_("Make %sHomeless%s");
6205 /* TRANS: _Upgrade Unit (100% chance of success). */
6206 return N_("%sUpgrade Unit%s");
6207 case ACTION_PARADROP:
6208 /* TRANS: Drop _Paratrooper (100% chance of success). */
6209 return N_("Drop %sParatrooper%s");
6211 /* TRANS: Drop _Paratrooper (100% chance of success). */
6212 return N_("Drop %sParatrooper%s");
6214 /* TRANS: Drop _Paratrooper (100% chance of success). */
6215 return N_("Drop %sParatrooper%s");
6217 /* TRANS: Drop _Paratrooper (100% chance of success). */
6218 return N_("Drop %sParatrooper%s");
6220 /* TRANS: Drop _Paratrooper (100% chance of success). */
6221 return N_("Drop %sParatrooper%s");
6223 /* TRANS: Drop _Paratrooper (100% chance of success). */
6224 return N_("Drop %sParatrooper%s");
6225 case ACTION_AIRLIFT:
6226 /* TRANS: _Airlift to City (100% chance of success). */
6227 return N_("%sAirlift to City%s");
6228 case ACTION_ATTACK:
6229 case ACTION_ATTACK2:
6230 /* TRANS: _Attack (100% chance of success). */
6231 return N_("%sAttack%s");
6234 /* TRANS: _Suicide Attack (100% chance of success). */
6235 return N_("%sSuicide Attack%s");
6236 case ACTION_WIPE_UNITS:
6237 /* TRANS: _Wipe Units (100% chance of success). */
6238 return N_("%sWipe Units%s");
6240 /* TRANS: Collect _Ransom (100% chance of success). */
6241 return N_("Collect %sRansom%s");
6243 /* TRANS: Surgical Str_ike Building (100% chance of success). */
6244 return N_("Surgical Str%sike Building%s");
6246 /* TRANS: Surgical Str_ike Production (100% chance of success). */
6247 return N_("Surgical Str%sike Production%s");
6251 /* TRANS: _Conquer City (100% chance of success). */
6252 return N_("%sConquer City%s");
6254 /* TRANS: _Conquer City 2 (100% chance of success). */
6255 return N_("%sConquer City 2%s");
6259 /* TRANS: _Conquer Extras (100% chance of success). */
6260 return N_("%sConquer Extras%s");
6262 /* TRANS: _Conquer Extras 2 (100% chance of success). */
6263 return N_("%sConquer Extras 2%s");
6264 case ACTION_HEAL_UNIT:
6265 case ACTION_HEAL_UNIT2:
6266 /* TRANS: Heal _Unit (3% chance of success). */
6267 return N_("Heal %sUnit%s");
6270 /* TRANS: _Transform Terrain (3% chance of success). */
6271 return N_("%sTransform Terrain%s");
6272 case ACTION_CULTIVATE:
6273 case ACTION_CULTIVATE2:
6274 /* TRANS: Transform by _Cultivating (3% chance of success). */
6275 return N_("Transform by %sCultivating%s");
6276 case ACTION_PLANT:
6277 case ACTION_PLANT2:
6278 /* TRANS: Transform by _Planting (3% chance of success). */
6279 return N_("Transform by %sPlanting%s");
6280 case ACTION_PILLAGE:
6281 case ACTION_PILLAGE2:
6282 /* TRANS: Pilla_ge (100% chance of success). */
6283 return N_("Pilla%sge%s");
6284 case ACTION_CLEAN:
6285 case ACTION_CLEAN2:
6286 /* TRANS: Clean (100% chance of success). */
6287 return N_("%sClean%s");
6288 case ACTION_FORTIFY:
6289 case ACTION_FORTIFY2:
6290 /* TRANS: _Fortify (100% chance of success). */
6291 return N_("%sFortify%s");
6292 case ACTION_ROAD:
6293 case ACTION_ROAD2:
6294 /* TRANS: Build _Road (100% chance of success). */
6295 return N_("Build %sRoad%s");
6296 case ACTION_CONVERT:
6297 /* TRANS: _Convert Unit (100% chance of success). */
6298 return N_("%sConvert Unit%s");
6299 case ACTION_BASE:
6300 case ACTION_BASE2:
6301 /* TRANS: _Build Base (100% chance of success). */
6302 return N_("%sBuild Base%s");
6303 case ACTION_MINE:
6304 case ACTION_MINE2:
6305 /* TRANS: Build _Mine (100% chance of success). */
6306 return N_("Build %sMine%s");
6307 case ACTION_IRRIGATE:
6308 case ACTION_IRRIGATE2:
6309 /* TRANS: Build _Irrigation (100% chance of success). */
6310 return N_("Build %sIrrigation%s");
6312 /* TRANS: _Deboard (100% chance of success). */
6313 return N_("%sDeboard%s");
6317 /* TRANS: _Board (100% chance of success). */
6318 return N_("%sBoard%s");
6323 /* TRANS: _Embark (100% chance of success). */
6324 return N_("%sEmbark%s");
6326 /* TRANS: _Unload (100% chance of success). */
6327 return N_("%sUnload%s");
6331 /* TRANS: _Load (100% chance of success). */
6332 return N_("%sLoad%s");
6336 /* TRANS: _Disembark (100% chance of success). */
6337 return N_("%sDisembark%s");
6339 /* TRANS: _Disembark 2 (100% chance of success). */
6340 return N_("%sDisembark 2%s");
6341 case ACTION_SPY_ATTACK:
6342 /* TRANS: _Eliminate Diplomat (100% chance of success). */
6343 return N_("%sEliminate Diplomat%s");
6344 case ACTION_HUT_ENTER:
6345 case ACTION_HUT_ENTER2:
6346 case ACTION_HUT_ENTER3:
6347 case ACTION_HUT_ENTER4:
6348 /* TRANS: Enter _Hut (100% chance of success). */
6349 return N_("Enter %sHut%s");
6354 /* TRANS: Frighten _Hut (100% chance of success). */
6355 return N_("Frighten %sHut%s");
6356 case ACTION_UNIT_MOVE:
6357 case ACTION_UNIT_MOVE2:
6358 case ACTION_UNIT_MOVE3:
6359 /* TRANS: Regular _Move (100% chance of success). */
6360 return N_("Regular %sMove%s");
6361 case ACTION_TELEPORT:
6362 case ACTION_TELEPORT2:
6363 case ACTION_TELEPORT3:
6364 /* TRANS: _Teleport (100% chance of success). */
6365 return N_("%sTeleport%s");
6367 /* TRANS: _Teleport (100% chance of success). */
6368 return N_("%sTeleport%s");
6370 /* TRANS: _Teleport (100% chance of success). */
6371 return N_("%sTeleport%s");
6373 /* TRANS: _Teleport (100% chance of success). */
6374 return N_("%sTeleport%s");
6376 /* TRANS: _Teleport (100% chance of success). */
6377 return N_("%sTeleport%s");
6379 /* TRANS: _Teleport (100% chance of success). */
6380 return N_("%sTeleport%s");
6381 case ACTION_SPY_ESCAPE:
6382 /* TRANS: _Escape To Nearest City (100% chance of success). */
6383 return N_("%sEscape To Nearest City%s");
6385 /* TRANS: _User Action 1 (100% chance of success). */
6386 return N_("%sUser Action 1%s");
6388 /* TRANS: _User Action 2 (100% chance of success). */
6389 return N_("%sUser Action 2%s");
6391 /* TRANS: _User Action 3 (100% chance of success). */
6392 return N_("%sUser Action 3%s");
6394 /* TRANS: _User Action 4 (100% chance of success). */
6395 return N_("%sUser Action 4%s");
6397 return N_("%sGain Veterancy%s");
6398 case ACTION_ESCAPE:
6399 return N_("%sEscape%s");
6400 case ACTION_COUNT:
6401 fc_assert(act != ACTION_COUNT);
6402 break;
6403 }
6404
6405 return NULL;
6406}
6407
6408/**********************************************************************/
6415{
6416 switch ((enum gen_action)act) {
6417 case ACTION_SPY_POISON:
6441 case ACTION_STEAL_MAPS:
6443 case ACTION_TRADE_ROUTE:
6444 case ACTION_MARKETPLACE:
6445 case ACTION_HELP_WONDER:
6447 case ACTION_EXPEL_UNIT:
6448 case ACTION_FOUND_CITY:
6449 case ACTION_JOIN_CITY:
6450 case ACTION_SPY_NUKE:
6455 case ACTION_HOME_CITY:
6456 case ACTION_HOMELESS:
6458 case ACTION_PARADROP:
6464 case ACTION_AIRLIFT:
6465 case ACTION_ATTACK:
6466 case ACTION_ATTACK2:
6469 case ACTION_WIPE_UNITS:
6477 case ACTION_HEAL_UNIT:
6478 case ACTION_HEAL_UNIT2:
6481 case ACTION_CULTIVATE:
6482 case ACTION_CULTIVATE2:
6483 case ACTION_PLANT:
6484 case ACTION_PLANT2:
6485 case ACTION_PILLAGE:
6486 case ACTION_PILLAGE2:
6487 case ACTION_CLEAN:
6488 case ACTION_CLEAN2:
6489 case ACTION_FORTIFY:
6490 case ACTION_FORTIFY2:
6491 case ACTION_ROAD:
6492 case ACTION_ROAD2:
6493 case ACTION_CONVERT:
6494 case ACTION_BASE:
6495 case ACTION_BASE2:
6496 case ACTION_MINE:
6497 case ACTION_MINE2:
6498 case ACTION_IRRIGATE:
6499 case ACTION_IRRIGATE2:
6516 case ACTION_BOMBARD:
6517 case ACTION_BOMBARD2:
6518 case ACTION_BOMBARD3:
6519 case ACTION_BOMBARD4:
6522 case ACTION_SPY_ATTACK:
6527 case ACTION_HUT_ENTER:
6528 case ACTION_HUT_ENTER2:
6529 case ACTION_HUT_ENTER3:
6530 case ACTION_HUT_ENTER4:
6535 case ACTION_UNIT_MOVE:
6536 case ACTION_UNIT_MOVE2:
6537 case ACTION_UNIT_MOVE3:
6538 case ACTION_SPY_ESCAPE:
6540 case ACTION_ESCAPE:
6541 /* Min range is not ruleset changeable */
6542 return NULL;
6543 case ACTION_NUKE:
6544 return "explode_nuclear_min_range";
6545 case ACTION_NUKE_CITY:
6546 return "nuke_city_min_range";
6547 case ACTION_NUKE_UNITS:
6548 return "nuke_units_min_range";
6549 case ACTION_TELEPORT:
6550 return "teleport_min_range";
6551 case ACTION_TELEPORT2:
6552 return "teleport_2_min_range";
6553 case ACTION_TELEPORT3:
6554 return "teleport_3_min_range";
6556 return "teleport_conquer_min_range";
6558 return "teleport_frighten_min_range";
6560 return "teleport_frighten_conquer_min_range";
6562 return "teleport_enter_min_range";
6564 return "teleport_enter_conquer_min_range";
6566 return "user_action_1_min_range";
6568 return "user_action_2_min_range";
6570 return "user_action_3_min_range";
6572 return "user_action_4_min_range";
6573 case ACTION_COUNT:
6574 break;
6575
6577 }
6578
6579 fc_assert(act >= 0 && act < ACTION_COUNT);
6580
6581 return NULL;
6582}
6583
6584/**********************************************************************/
6591{
6592 switch ((enum gen_action)act) {
6593 case ACTION_SPY_POISON:
6617 case ACTION_STEAL_MAPS:
6619 case ACTION_TRADE_ROUTE:
6620 case ACTION_MARKETPLACE:
6622 case ACTION_EXPEL_UNIT:
6623 case ACTION_FOUND_CITY:
6624 case ACTION_JOIN_CITY:
6625 case ACTION_SPY_NUKE:
6629 case ACTION_HOME_CITY:
6630 case ACTION_HOMELESS:
6632 case ACTION_PARADROP:
6638 case ACTION_ATTACK:
6639 case ACTION_ATTACK2:
6642 case ACTION_WIPE_UNITS:
6650 case ACTION_HEAL_UNIT:
6651 case ACTION_HEAL_UNIT2:
6654 case ACTION_CULTIVATE:
6655 case ACTION_CULTIVATE2:
6656 case ACTION_PLANT:
6657 case ACTION_PLANT2:
6658 case ACTION_PILLAGE:
6659 case ACTION_PILLAGE2:
6660 case ACTION_CLEAN:
6661 case ACTION_CLEAN2:
6662 case ACTION_FORTIFY:
6663 case ACTION_FORTIFY2:
6664 case ACTION_ROAD:
6665 case ACTION_ROAD2:
6666 case ACTION_CONVERT:
6667 case ACTION_BASE:
6668 case ACTION_BASE2:
6669 case ACTION_MINE:
6670 case ACTION_MINE2:
6671 case ACTION_IRRIGATE:
6672 case ACTION_IRRIGATE2:
6689 case ACTION_SPY_ATTACK:
6694 case ACTION_HUT_ENTER:
6695 case ACTION_HUT_ENTER2:
6696 case ACTION_HUT_ENTER3:
6697 case ACTION_HUT_ENTER4:
6702 case ACTION_UNIT_MOVE:
6703 case ACTION_UNIT_MOVE2:
6704 case ACTION_UNIT_MOVE3:
6705 case ACTION_SPY_ESCAPE:
6707 case ACTION_ESCAPE:
6708 /* Max range is not ruleset changeable */
6709 return NULL;
6710 case ACTION_HELP_WONDER:
6711 return "help_wonder_max_range";
6713 return "disband_unit_recover_max_range";
6714 case ACTION_BOMBARD:
6715 return "bombard_max_range";
6716 case ACTION_BOMBARD2:
6717 return "bombard_2_max_range";
6718 case ACTION_BOMBARD3:
6719 return "bombard_3_max_range";
6720 case ACTION_BOMBARD4:
6721 return "bombard_4_max_range";
6723 return "bombard_lethal_max_range";
6725 return "bombard_lethal_2_max_range";
6726 case ACTION_NUKE:
6727 return "explode_nuclear_max_range";
6728 case ACTION_NUKE_CITY:
6729 return "nuke_city_max_range";
6730 case ACTION_NUKE_UNITS:
6731 return "nuke_units_max_range";
6732 case ACTION_AIRLIFT:
6733 return "airlift_max_range";
6734 case ACTION_TELEPORT:
6735 return "teleport_max_range";
6736 case ACTION_TELEPORT2:
6737 return "teleport_2_max_range";
6738 case ACTION_TELEPORT3:
6739 return "teleport_3_max_range";
6741 return "teleport_conquer_max_range";
6743 return "teleport_frighten_max_range";
6745 return "teleport_frighten_conquer_max_range";
6747 return "teleport_enter_max_range";
6749 return "teleport_enter_conquer_max_range";
6751 return "user_action_1_max_range";
6753 return "user_action_2_max_range";
6755 return "user_action_3_max_range";
6757 return "user_action_4_max_range";
6758 case ACTION_COUNT:
6759 break;
6760
6762 }
6763
6764 fc_assert(act >= 0 && act < ACTION_COUNT);
6765
6766 return NULL;
6767}
6768
6769/**********************************************************************/
6776{
6777 switch ((enum gen_action)act) {
6778 case ACTION_SPY_POISON:
6802 case ACTION_STEAL_MAPS:
6804 case ACTION_TRADE_ROUTE:
6805 case ACTION_MARKETPLACE:
6806 case ACTION_HELP_WONDER:
6808 case ACTION_EXPEL_UNIT:
6809 case ACTION_FOUND_CITY:
6810 case ACTION_JOIN_CITY:
6811 case ACTION_SPY_NUKE:
6813 case ACTION_NUKE_UNITS:
6817 case ACTION_HOME_CITY:
6818 case ACTION_HOMELESS:
6820 case ACTION_PARADROP:
6826 case ACTION_AIRLIFT:
6827 case ACTION_ATTACK:
6828 case ACTION_ATTACK2:
6831 case ACTION_WIPE_UNITS:
6839 case ACTION_HEAL_UNIT:
6840 case ACTION_HEAL_UNIT2:
6843 case ACTION_CULTIVATE:
6844 case ACTION_CULTIVATE2:
6845 case ACTION_PLANT:
6846 case ACTION_PLANT2:
6847 case ACTION_CLEAN:
6848 case ACTION_CLEAN2:
6849 case ACTION_FORTIFY:
6850 case ACTION_FORTIFY2:
6851 case ACTION_ROAD:
6852 case ACTION_ROAD2:
6853 case ACTION_CONVERT:
6854 case ACTION_BASE:
6855 case ACTION_BASE2:
6856 case ACTION_MINE:
6857 case ACTION_MINE2:
6858 case ACTION_IRRIGATE:
6859 case ACTION_IRRIGATE2:
6876 case ACTION_BOMBARD:
6877 case ACTION_BOMBARD2:
6878 case ACTION_BOMBARD3:
6879 case ACTION_BOMBARD4:
6882 case ACTION_SPY_ATTACK:
6887 case ACTION_HUT_ENTER:
6888 case ACTION_HUT_ENTER2:
6889 case ACTION_HUT_ENTER3:
6890 case ACTION_HUT_ENTER4:
6895 case ACTION_UNIT_MOVE:
6896 case ACTION_UNIT_MOVE2:
6897 case ACTION_UNIT_MOVE3:
6898 case ACTION_TELEPORT:
6899 case ACTION_TELEPORT2:
6900 case ACTION_TELEPORT3:
6906 case ACTION_SPY_ESCAPE:
6908 case ACTION_ESCAPE:
6909 /* Target kind is not ruleset changeable */
6910 return NULL;
6911 case ACTION_NUKE:
6912 return "explode_nuclear_target_kind";
6913 case ACTION_NUKE_CITY:
6914 return "nuke_city_target_kind";
6915 case ACTION_PILLAGE:
6916 return "pillage_target_kind";
6917 case ACTION_PILLAGE2:
6918 return "pillage_2_target_kind";
6920 return "user_action_1_target_kind";
6922 return "user_action_2_target_kind";
6924 return "user_action_3_target_kind";
6926 return "user_action_4_target_kind";
6927 case ACTION_COUNT:
6928 break;
6929
6931 }
6932
6933 fc_assert(act >= 0 && act < ACTION_COUNT);
6934
6935 return NULL;
6936}
6937
6938/**********************************************************************/
6946{
6947 switch ((enum gen_action)act) {
6948 case ACTION_SPY_POISON:
6971 case ACTION_STEAL_MAPS:
6973 case ACTION_TRADE_ROUTE:
6974 case ACTION_MARKETPLACE:
6975 case ACTION_HELP_WONDER:
6977 case ACTION_EXPEL_UNIT:
6978 case ACTION_JOIN_CITY:
6979 case ACTION_SPY_NUKE:
6984 case ACTION_HOME_CITY:
6985 case ACTION_HOMELESS:
6987 case ACTION_PARADROP:
6993 case ACTION_AIRLIFT:
6994 case ACTION_ATTACK:
6995 case ACTION_ATTACK2:
6998 case ACTION_WIPE_UNITS:
7006 case ACTION_HEAL_UNIT:
7007 case ACTION_HEAL_UNIT2:
7010 case ACTION_CULTIVATE:
7011 case ACTION_CULTIVATE2:
7012 case ACTION_PLANT:
7013 case ACTION_PLANT2:
7014 case ACTION_PILLAGE:
7015 case ACTION_PILLAGE2:
7016 case ACTION_CLEAN:
7017 case ACTION_CLEAN2:
7018 case ACTION_FORTIFY:
7019 case ACTION_FORTIFY2:
7020 case ACTION_ROAD:
7021 case ACTION_ROAD2:
7022 case ACTION_CONVERT:
7023 case ACTION_BASE:
7024 case ACTION_BASE2:
7025 case ACTION_MINE:
7026 case ACTION_MINE2:
7027 case ACTION_IRRIGATE:
7028 case ACTION_IRRIGATE2:
7045 case ACTION_BOMBARD:
7046 case ACTION_BOMBARD2:
7047 case ACTION_BOMBARD3:
7048 case ACTION_BOMBARD4:
7051 case ACTION_SPY_ATTACK:
7056 case ACTION_HUT_ENTER:
7057 case ACTION_HUT_ENTER2:
7058 case ACTION_HUT_ENTER3:
7059 case ACTION_HUT_ENTER4:
7064 case ACTION_UNIT_MOVE:
7065 case ACTION_UNIT_MOVE2:
7066 case ACTION_UNIT_MOVE3:
7067 case ACTION_TELEPORT:
7068 case ACTION_TELEPORT2:
7069 case ACTION_TELEPORT3:
7075 case ACTION_SPY_ESCAPE:
7077 case ACTION_ESCAPE:
7078 /* Actor consuming always is not ruleset changeable */
7079 return NULL;
7080 case ACTION_FOUND_CITY:
7081 return "found_city_consuming_always";
7082 case ACTION_NUKE:
7083 return "explode_nuclear_consuming_always";
7084 case ACTION_NUKE_CITY:
7085 return "nuke_city_consuming_always";
7086 case ACTION_NUKE_UNITS:
7087 return "nuke_units_consuming_always";
7089 return "spread_plague_actor_consuming_always";
7091 return "user_action_1_actor_consuming_always";
7093 return "user_action_2_actor_consuming_always";
7095 return "user_action_3_actor_consuming_always";
7097 return "user_action_4_actor_consuming_always";
7098 case ACTION_COUNT:
7099 break;
7100
7102 }
7103
7104 fc_assert(act >= 0 && act < ACTION_COUNT);
7105
7106 return NULL;
7107}
7108
7109/**********************************************************************/
7116const char *action_blocked_by_ruleset_var_name(const struct action *act)
7117{
7118 fc_assert_ret_val(act != NULL, NULL);
7119
7120 switch ((enum gen_action)action_number(act)) {
7121 case ACTION_MARKETPLACE:
7122 return "enter_marketplace_blocked_by";
7123 case ACTION_BOMBARD:
7124 return "bombard_blocked_by";
7125 case ACTION_BOMBARD2:
7126 return "bombard_2_blocked_by";
7127 case ACTION_BOMBARD3:
7128 return "bombard_3_blocked_by";
7129 case ACTION_BOMBARD4:
7130 return "bombard_4_blocked_by";
7132 return "bombard_lethal_blocked_by";
7134 return "bombard_lethal_2_blocked_by";
7135 case ACTION_NUKE:
7136 return "explode_nuclear_blocked_by";
7137 case ACTION_NUKE_CITY:
7138 return "nuke_city_blocked_by";
7139 case ACTION_NUKE_UNITS:
7140 return "nuke_units_blocked_by";
7141 case ACTION_ATTACK:
7142 return "attack_blocked_by";
7143 case ACTION_ATTACK2:
7144 return "attack_2_blocked_by";
7146 return "suicide_attack_blocked_by";
7148 return "suicide_attack_2_blocked_by";
7149 case ACTION_WIPE_UNITS:
7150 return "wipe_units_blocked_by";
7152 return "collect_ransom_blocked_by";
7154 return "conquer_city_blocked_by";
7156 return "conquer_city_2_blocked_by";
7158 return "conquer_city_3_blocked_by";
7160 return "conquer_city_4_blocked_by";
7161 case ACTION_UNIT_MOVE:
7162 return "move_blocked_by";
7163 case ACTION_UNIT_MOVE2:
7164 return "move_2_blocked_by";
7165 case ACTION_UNIT_MOVE3:
7166 return "move_3_blocked_by";
7167 case ACTION_TELEPORT:
7168 return "teleport_blocked_by";
7169 case ACTION_TELEPORT2:
7170 return "teleport_2_blocked_by";
7171 case ACTION_TELEPORT3:
7172 return "teleport_3_blocked_by";
7174 return "teleport_conquer_blocked_by";
7176 return "teleport_frighten_blocked_by";
7178 return "teleport_frighten_conquer_blocked_by";
7180 return "teleport_enter_blocked_by";
7182 return "teleport_enter_conquer_blocked_by";
7183 case ACTION_SPY_ESCAPE:
7184 case ACTION_SPY_POISON:
7207 case ACTION_STEAL_MAPS:
7209 case ACTION_TRADE_ROUTE:
7210 case ACTION_HELP_WONDER:
7212 case ACTION_EXPEL_UNIT:
7213 case ACTION_FOUND_CITY:
7214 case ACTION_JOIN_CITY:
7215 case ACTION_SPY_NUKE:
7220 case ACTION_HOME_CITY:
7221 case ACTION_HOMELESS:
7223 case ACTION_PARADROP:
7229 case ACTION_AIRLIFT:
7232 case ACTION_HEAL_UNIT:
7233 case ACTION_HEAL_UNIT2:
7236 case ACTION_CULTIVATE:
7237 case ACTION_CULTIVATE2:
7238 case ACTION_PLANT:
7239 case ACTION_PLANT2:
7240 case ACTION_PILLAGE:
7241 case ACTION_PILLAGE2:
7242 case ACTION_CLEAN:
7243 case ACTION_CLEAN2:
7244 case ACTION_FORTIFY:
7245 case ACTION_FORTIFY2:
7246 case ACTION_ROAD:
7247 case ACTION_ROAD2:
7248 case ACTION_CONVERT:
7249 case ACTION_BASE:
7250 case ACTION_BASE2:
7251 case ACTION_MINE:
7252 case ACTION_MINE2:
7253 case ACTION_IRRIGATE:
7254 case ACTION_IRRIGATE2:
7272 case ACTION_SPY_ATTACK:
7277 case ACTION_HUT_ENTER:
7278 case ACTION_HUT_ENTER2:
7279 case ACTION_HUT_ENTER3:
7280 case ACTION_HUT_ENTER4:
7286 case ACTION_ESCAPE:
7291 /* blocked_by is not ruleset changeable */
7292 return NULL;
7293 case ACTION_COUNT:
7295 break;
7296
7298 }
7299
7300 return NULL;
7301}
7302
7303/**********************************************************************/
7307const char *
7309{
7310 fc_assert_ret_val(act != NULL, NULL);
7311
7316 /* No support in the action performer function */
7317 return NULL;
7318 }
7319
7320 switch ((enum gen_action)action_number(act)) {
7322 return "bribe_unit_post_success_forced_actions";
7323 case ACTION_ATTACK:
7324 return "attack_post_success_forced_actions";
7325 case ACTION_ATTACK2:
7326 return "attack_2_post_success_forced_actions";
7327 case ACTION_WIPE_UNITS:
7328 return "wipe_units_post_success_forced_actions";
7330 return "collect_ransom_post_success_forced_actions";
7331 case ACTION_MARKETPLACE:
7332 case ACTION_BOMBARD:
7333 case ACTION_BOMBARD2:
7334 case ACTION_BOMBARD3:
7335 case ACTION_BOMBARD4:
7338 case ACTION_NUKE:
7339 case ACTION_NUKE_CITY:
7340 case ACTION_NUKE_UNITS:
7347 case ACTION_SPY_POISON:
7369 case ACTION_STEAL_MAPS:
7371 case ACTION_TRADE_ROUTE:
7372 case ACTION_HELP_WONDER:
7374 case ACTION_EXPEL_UNIT:
7375 case ACTION_FOUND_CITY:
7376 case ACTION_JOIN_CITY:
7377 case ACTION_SPY_NUKE:
7382 case ACTION_HOME_CITY:
7383 case ACTION_HOMELESS:
7385 case ACTION_PARADROP:
7391 case ACTION_AIRLIFT:
7394 case ACTION_HEAL_UNIT:
7395 case ACTION_HEAL_UNIT2:
7398 case ACTION_CULTIVATE:
7399 case ACTION_CULTIVATE2:
7400 case ACTION_PLANT:
7401 case ACTION_PLANT2:
7402 case ACTION_PILLAGE:
7403 case ACTION_PILLAGE2:
7404 case ACTION_CLEAN:
7405 case ACTION_CLEAN2:
7406 case ACTION_FORTIFY:
7407 case ACTION_FORTIFY2:
7408 case ACTION_ROAD:
7409 case ACTION_ROAD2:
7410 case ACTION_CONVERT:
7411 case ACTION_BASE:
7412 case ACTION_BASE2:
7413 case ACTION_MINE:
7414 case ACTION_MINE2:
7415 case ACTION_IRRIGATE:
7416 case ACTION_IRRIGATE2:
7434 case ACTION_SPY_ATTACK:
7439 case ACTION_HUT_ENTER:
7440 case ACTION_HUT_ENTER2:
7441 case ACTION_HUT_ENTER3:
7442 case ACTION_HUT_ENTER4:
7447 case ACTION_UNIT_MOVE:
7448 case ACTION_UNIT_MOVE2:
7449 case ACTION_UNIT_MOVE3:
7450 case ACTION_TELEPORT:
7451 case ACTION_TELEPORT2:
7452 case ACTION_TELEPORT3:
7458 case ACTION_SPY_ESCAPE:
7460 case ACTION_ESCAPE:
7465 /* Not ruleset changeable */
7466 return NULL;
7467 case ACTION_COUNT:
7469 break;
7470
7472 }
7473
7474 return NULL;
7475}
7476
7477/**********************************************************************/
7485
7486/**********************************************************************/
7489const char *gen_action_name_update_cb(const char *old_name)
7490{
7491 /* Uncomment and fill implementation, if compat mode
7492 * action name conversions needed. */
7493#if 0
7494 if (is_ruleset_compat_mode()) {
7495 }
7496#endif
7497
7498 return old_name;
7499}
7500
7502{
7503 N_("individual cities"), /* ATK_CITY */
7504 N_("individual units"), /* ATK_UNIT */
7505 N_("unit stacks"), /* ATK_UNITS */
7506 N_("tiles"), /* ATK_TILE */
7507 N_("tile extras"), /* ATK_EXTRAS */
7508 N_("itself") /* ATK_SELF */
7509};
7510
7511/**********************************************************************/
7516{
7517 fc_assert(kind >= 0 && kind < ATK_COUNT);
7518
7519 return _(atk_helpnames[kind]);
7520}
7521
7522/************************************************************************/
7526{
7527 fc_assert(result < ACTRES_LAST);
7528
7529 return actlist_by_result[result];
7530}
7531
7532/************************************************************************/
7536{
7537 fc_assert(activity < ACTIVITY_LAST);
7538
7539 return actlist_by_activity[activity];
7540}
bool is_action_possible_on_city(action_id act_id, const struct player *actor_player, const struct city *target_city)
Definition actions.c:5444
static struct action * actions[MAX_NUM_ACTIONS]
Definition actions.c:57
const char * action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const char *custom)
Definition actions.c:1287
bool action_distance_inside_max(const struct action *action, const int distance)
Definition actions.c:1148
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:2775
const char * action_prob_explain(const struct act_prob prob)
Definition actions.c:1398
bool action_mp_full_makes_legal(const struct unit *actor, const action_id act_id)
Definition actions.c:5522
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:3743
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:3390
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1073
bool action_prob_certain(const struct act_prob probability)
Definition actions.c:5054
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5675
req_vec_num_in_item action_enabler_vector_number(const void *enabler, const struct requirement_vector *vec)
Definition actions.c:2022
bool action_has_complex_target(const struct action *paction)
Definition actions.c:1107
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:2362
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4717
struct req_vec_problem * action_enabler_suggest_repair(const struct action_enabler *enabler)
Definition actions.c:1892
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:3235
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5044
#define ACTPROB_VAL_NOT_IMPL
Definition actions.c:55
struct action_auto_perf auto_perfs[MAX_NUM_ACTION_AUTO_PERFORMERS]
Definition actions.c:59
bool action_actor_utype_hard_reqs_ok(const struct action *paction, const struct unit_type *actor_unittype)
Definition actions.c:2569
struct act_prob action_prob_new_not_impl(void)
Definition actions.c:5023
struct req_vec_problem * action_enabler_suggest_improvement(const struct action_enabler *enabler)
Definition actions.c:1958
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:3470
void actions_rs_pre_san_gen(void)
Definition actions.c:879
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:6414
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:3517
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7116
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:2948
#define ACTPROB_VAL_MAX
Definition actions.c:49
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:3791
struct req_vec_problem * action_enabler_suggest_repair_oblig(const struct action_enabler *enabler)
Definition actions.c:1653
void action_array_add_all_by_result(action_id *act_array, int *position, enum action_result result)
Definition actions.c:5740
const char * action_name_translation(const struct action *paction)
Definition actions.c:1205
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:5344
void action_array_end(action_id *act_array, int size)
Definition actions.c:5723
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:3695
const char * atk_helpnames[ATK_COUNT]
Definition actions.c:7501
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:2589
static void hard_code_actions(void)
Definition actions.c:104
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:2987
bool action_is_in_use(struct action *paction)
Definition actions.c:5629
struct act_prob action_prob_unit_vs_tgt(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:4739
static struct req_vec_problem * enabler_tile_tgt_local_diplrel_implies_claimed(const struct action_enabler *enabler)
Definition actions.c:1747
bool action_ever_possible(action_id action)
Definition actions.c:7481
const char * action_enabler_vector_by_number_name(req_vec_num_in_item vec)
Definition actions.c:2069
bool are_action_probabilitys_equal(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5095
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:4664
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7308
struct action * action_by_rule_name(const char *name)
Definition actions.c:1054
static bool action_has_possible_actor_hard_reqs(struct action *paction)
Definition actions.c:5603
const char * action_rule_name(const struct action *action)
Definition actions.c:1191
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1214
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1094
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:2137
static bool action_prob_not_relevant(const struct act_prob probability)
Definition actions.c:5065
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:3649
void actions_free(void)
Definition actions.c:889
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:3312
void action_enabler_free(struct action_enabler *enabler)
Definition actions.c:1469
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4562
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:3217
static enum fc_tristate tech_can_be_stolen(const struct player *actor_player, const struct player *target_player)
Definition actions.c:3536
static struct action_list * actlist_by_result[ACTRES_LAST]
Definition actions.c:97
struct action_list * action_list_by_activity(enum unit_activity activity)
Definition actions.c:7535
int action_number(const struct action *action)
Definition actions.c:1183
struct act_prob action_prob_new_unknown(void)
Definition actions.c:5033
bool action_would_be_blocked_by(const struct action *blocked, const struct action *blocker)
Definition actions.c:1171
#define ACTPROB_VAL_NA
Definition actions.c:53
static struct req_vec_problem * enabler_first_clarification(const struct action_enabler *enabler)
Definition actions.c:1940
struct act_prob action_speculate_unit_on_self(action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat)
Definition actions.c:4965
static bool action_prob_not_impl(const struct act_prob probability)
Definition actions.c:5076
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:3293
struct act_prob action_prob_and(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5182
static bool actions_initialized
Definition actions.c:60
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:6945
bool action_immune_government(struct government *gov, action_id act)
Definition actions.c:5400
static bool is_target_possible(const action_id wanted_action, const struct player *actor_player, const struct req_context *target)
Definition actions.c:5423
static struct act_prob ap_dipl_battle_win(const struct unit *pattacker, const struct unit *pdefender)
Definition actions.c:3572
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:4303
struct action * action_is_blocked_by(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:2249
struct act_prob action_prob_new_certain(void)
Definition actions.c:5003
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:6590
struct act_prob action_speculate_unit_on_stack(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:4864
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:4116
bool action_is_internal(struct action *paction)
Definition actions.c:5655
int action_dice_roll_initial_odds(const struct action *paction)
Definition actions.c:5320
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5252
static const struct unit_type * tgt_city_local_utype(const struct city *target_city)
Definition actions.c:2112
static struct requirement * req_vec_first_local_diplrel(const struct requirement_vector *vec)
Definition actions.c:1703
struct act_prob action_prob_vs_stack(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4478
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:4496
struct act_prob action_speculate_unit_on_extras(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:4931
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:3052
struct action_list * action_list_by_result(enum action_result result)
Definition actions.c:7525
bool action_univs_not_blocking(const struct action *paction, struct universal *actor_uni, struct universal *target_uni)
Definition actions.c:5699
static struct requirement * req_vec_first_contradiction_in_vec(const struct requirement *req, const struct requirement_vector *vec)
Definition actions.c:1724
bool actions_are_ready(void)
Definition actions.c:931
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:3129
struct act_prob action_speculate_unit_on_city(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:4796
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:4203
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:6775
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:4219
bool action_maybe_possible_actor_unit(const struct civ_map *nmap, const action_id act_id, const struct unit *actor_unit)
Definition actions.c:5467
static bool is_enabler_active(const struct action_enabler *enabler, const struct req_context *actor, const struct req_context *target)
Definition actions.c:2931
static struct action_enabler_list * action_enablers_by_action[MAX_NUM_ACTIONS]
Definition actions.c:62
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:1496
const char * action_ui_name_default(int act)
Definition actions.c:6055
#define ACTPROB_VAL_1_PCT
Definition actions.c:51
bool action_enabler_utype_possible_actor(const struct action_enabler *ae, const struct unit_type *act_utype)
Definition actions.c:5545
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:3677
struct action_enabler * action_enabler_new(void)
Definition actions.c:1450
bool action_requires_details(const struct action *paction)
Definition actions.c:1120
struct act_prob action_prob_new_not_relevant(void)
Definition actions.c:5013
const char * action_target_kind_help(enum action_target_kind kind)
Definition actions.c:7515
static struct req_vec_problem * enabler_first_self_contradiction(const struct action_enabler *enabler)
Definition actions.c:1820
int action_get_role(const struct action *paction)
Definition actions.c:1438
struct act_prob action_prob_vs_extras(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4646
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:1018
struct act_prob action_speculate_unit_on_unit(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:4831
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:5691
struct act_prob action_prob_new_impossible(void)
Definition actions.c:4993
bool action_enabler_possible_actor(const struct action_enabler *ae)
Definition actions.c:5572
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:2195
struct action ** _actions
Definition actions.c:58
bool action_id_exists(const action_id act_id)
Definition actions.c:1043
bool action_enabler_remove(struct action_enabler *enabler)
Definition actions.c:1513
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1083
static bool action_prob_is_signal(const struct act_prob probability)
Definition actions.c:5087
struct action_enabler * action_enabler_copy(const struct action_enabler *original)
Definition actions.c:1481
static const char * action_prob_to_text(const struct act_prob prob)
Definition actions.c:1246
int action_prob_cmp_pessimist(const struct act_prob ap1, const struct act_prob ap2)
Definition actions.c:5104
bool action_id_is_internal(action_id act)
Definition actions.c:5667
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:3442
bool action_id_is_rare_pop_up(action_id act_id)
Definition actions.c:1135
void actions_init(void)
Definition actions.c:830
struct act_prob action_speculate_unit_on_tile(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:4897
static struct action * action_new(action_id id, enum action_result result, const int min_distance, const int max_distance, bool actor_consuming_always)
Definition actions.c:955
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:1549
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:4286
static const struct impr_type * tgt_city_local_building(const struct city *target_city)
Definition actions.c:2089
static struct astring ui_name_str
Definition actions.c:64
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:3370
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:3070
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:3147
double action_prob_to_0_to_1_pessimist(const struct act_prob ap)
Definition actions.c:5155
const char * gen_action_name_update_cb(const char *old_name)
Definition actions.c:7489
static struct action_list * actlist_by_activity[ACTIVITY_LAST]
Definition actions.c:98
struct action_enabler_list * action_enablers_for_action(action_id action)
Definition actions.c:1529
struct requirement_vector * action_enabler_vector_by_number(const void *enabler, req_vec_num_in_item number)
Definition actions.c:2045
bool action_distance_accepted(const struct action *action, const int distance)
Definition actions.c:1159
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:4580
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:5760
const char * action_get_ui_name_mnemonic(action_id act_id, const char *mnemonic)
Definition actions.c:1233
#define ACTPROB_VAL_MIN
Definition actions.c:47
#define action_noninternal_iterate_end
Definition actions.h:231
#define ACTION_DISTANCE_MAX
Definition actions.h:103
#define enabler_get_action(_enabler_)
Definition actions.h:177
#define ASSERT_UNUSED_ACTION_CASES
Definition actions.h:38
#define ACTPROB_CERTAIN
Definition actions.h:666
#define enabler_get_action_id(_enabler_)
Definition actions.h:178
#define ACTPROB_NA
Definition actions.h:667
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
#define action_enabler_list_re_iterate_end
Definition actions.h:191
#define ACTION_DISTANCE_LAST_NON_SIGNAL
Definition actions.h:99
#define action_enabler_list_re_iterate(action_enabler_list, aenabler)
Definition actions.h:187
#define action_has_result(_act_, _res_)
Definition actions.h:175
#define action_enabler_list_iterate_end
Definition actions.h:185
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:101
#define action_iterate_end
Definition actions.h:209
#define MAX_NUM_ACTIONS
Definition actions.h:58
#define action_iterate_all(_act_)
Definition actions.h:195
#define action_id_get_actor_kind(act_id)
Definition actions.h:403
#define action_iterate_all_end
Definition actions.h:200
#define ACTPROB_NOT_KNOWN
Definition actions.h:669
#define action_enabler_list_iterate(action_enabler_list, aenabler)
Definition actions.h:183
#define action_id_distance_accepted(act_id, distance)
Definition actions.h:439
#define ACTPROB_IMPOSSIBLE
Definition actions.h:665
#define ACTPROB_NOT_IMPLEMENTED
Definition actions.h:668
#define action_iterate(_act_)
Definition actions.h:205
#define ACTION_ANY
Definition actions.h:52
#define action_noninternal_iterate(_act_)
Definition actions.h:226
#define action_id_get_target_kind(act_id)
Definition actions.h:407
#define action_id_has_result_safe(act_id, result)
Definition actions.h:420
#define ACTION_ODDS_PCT_DICE_ROLL_NA
Definition actions.h:672
#define ACTION_NONE
Definition actions.h:55
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:669
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:258
enum fc_tristate actres_possible(const struct civ_map *nmap, enum action_result result, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, enum fc_tristate def, bool omniscient, const struct city *homecity)
Definition actres.c:831
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:766
#define ASSERT_UNUSED_ACTRES_CASES
Definition actres.h:37
@ DRT_DIPLCHANCE
Definition actres.h:110
@ DRT_CERTAIN
Definition actres.h:110
@ DRT_NONE
Definition actres.h:110
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:95
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
static bool is_non_attack_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:751
#define city_tile(_pcity_)
Definition city.h:564
#define city_owner(_pcity_)
Definition city.h:563
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:839
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:945
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:55
char * incite_cost
Definition comments.c:74
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile * 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 @21::@22 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:381
@ RPT_CERTAIN
Definition fc_types.h:678
@ RPT_POSSIBLE
Definition fc_types.h:677
int action_id
Definition fc_types.h:393
#define ACTRES_NONE
Definition fc_types.h:331
#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
struct world wld
Definition game.c:62
static bool is_ruleset_compat_mode(void)
Definition game.h:362
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action_msg(condition, action, message,...)
Definition log.h:201
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_error(message,...)
Definition log.h:103
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:636
#define MAP_DISTANCE_MAX
Definition map.h:632
#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:318
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:330
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:912
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:869
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:213
void oblig_hard_reqs_init(void)
Definition oblig_reqs.c:807
void oblig_hard_reqs_free(void)
Definition oblig_reqs.c:827
void hard_code_oblig_hard_reqs_ruleset(void)
Definition oblig_reqs.c:770
void hard_code_oblig_hard_reqs(void)
Definition oblig_reqs.c:250
struct obligatory_req_vector * oblig_hard_reqs_get(enum action_result res)
Definition oblig_reqs.c:852
struct obligatory_req_vector * oblig_hard_reqs_get_sub(enum action_sub_result res)
Definition oblig_reqs.c:863
#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)
bool are_requirements_contradictions(const struct requirement *req1, const struct requirement *req2)
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)
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
enum action_auto_perf_cause cause
Definition actions.h:318
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:326
action_id action
Definition actions.h:166
struct requirement_vector actor_reqs
Definition actions.h:167
struct requirement_vector target_reqs
Definition actions.h:168
bool unitwaittime_controlled
Definition actions.h:155
action_id id
Definition actions.h:107
bool actor_consuming_always
Definition actions.h:139
bool rare_pop_up
Definition actions.h:152
int max_distance
Definition actions.h:122
bool quiet
Definition actions.h:129
enum action_sub_target_kind sub_target_kind
Definition actions.h:114
enum moves_actor_kind moves_actor
Definition actions.h:159
struct action::@12::@13 is_unit
enum action_result result
Definition actions.h:109
char ui_name[MAX_LEN_NAME]
Definition actions.h:125
bv_action_sub_results sub_results
Definition actions.h:110
enum action_actor_kind actor_kind
Definition actions.h:112
enum act_tgt_compl target_complexity
Definition actions.h:117
bv_actions blocked_by
Definition actions.h:133
union action::@12 actor
enum action_target_kind target_kind
Definition actions.h:113
int min_distance
Definition actions.h:122
Definition city.h:320
int id
Definition city.h:326
struct tile * tile
Definition city.h:322
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:551
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:880
struct civ_map map
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:276
#define advance_iterate_end
Definition tech.h:277
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:2499
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:386
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2483
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2073
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
#define unit_home(_pu_)
Definition unit.h:394
#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:1058
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2583
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
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:996
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
#define utype_class(_t_)
Definition unittype.h:756
#define L_LAST
Definition unittype.h:446
#define unit_type_iterate(_p)
Definition unittype.h:859
#define unit_type_iterate_end
Definition unittype.h:866
#define U_NOT_OBSOLETED
Definition unittype.h:535