Freeciv-3.4
Loading...
Searching...
No Matches
rssanity.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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/* utility */
19#include "astring.h"
20#include "deprecations.h"
21
22/* common */
23#include "achievements.h"
24#include "actions.h"
25#include "effects.h"
26#include "game.h"
27#include "government.h"
28#include "map.h"
29#include "movement.h"
30#include "nation.h"
31#include "player.h"
32#include "specialist.h"
33#include "tech.h"
34
35/* server */
36#include "ruleload.h"
37#include "settings.h"
38
39#include "rssanity.h"
40
41/* These effects are always needed in the ruleset.
42 * First set are those that are mandatory even in compatibility mode. */
50
51/* These have been made mandatory in freeciv-3.4 */
52enum effect_type req_base_effects_3_4[] =
53 {
54 /* None yet */
56 };
57
58/**********************************************************************/
62{
65 ruleset_error(logger,
67 _("Too long ruleset summary. It can be only %d bytes long. "
68 "Put longer explanations to ruleset description."),
70 return FALSE;
71 }
72
73 return TRUE;
74}
75
76/**********************************************************************/
79static bool nation_has_initial_tech(struct nation_type *pnation,
80 struct advance *tech)
81{
82 int i;
83
84 /* See if it's given as global init tech */
85 for (i = 0; i < MAX_NUM_TECH_LIST
88 return TRUE;
89 }
90 }
91
92 /* See if it's given as national init tech */
93 for (i = 0;
94 i < MAX_NUM_TECH_LIST && pnation->init_techs[i] != A_LAST;
95 i++) {
96 if (pnation->init_techs[i] == advance_number(tech)) {
97 return TRUE;
98 }
99 }
100
101 return FALSE;
102}
103
104/**********************************************************************/
112
113/**********************************************************************/
118{
121 /* White list for SSET_INTERNAL and SSET_NETWORK settings. */
122 && !(pset == setting_by_name("phasemode")
123 || pset == setting_by_name("timeout")
124 || pset == setting_by_name("timeaddenemymove")
125 || pset == setting_by_name("unitwaittime")
126 || pset == setting_by_name("victories"))) {
127 /* The given server setting is a server operator related setting (like
128 * the compression type of savegames), not a game rule. */
129 return FALSE;
130 }
131
132 if (pset == setting_by_name("naturalcitynames")) {
133 /* This setting is about "look", not rules. */
134 return FALSE;
135 }
136
137 return TRUE;
138}
139
140/**********************************************************************/
145{
147 struct setting *pset;
148
149 /* TODO: use ssetv_setting_get() if setting value becomes multiplexed with
150 * the server setting id. */
151 id = (server_setting_id)ssetval;
153
155 /* Not supported yet. */
156 return FALSE;
157 }
158
160
163}
164
165/**********************************************************************/
172 struct requirement *preq,
173 const char *list_for)
174{
175 switch (preq->source.kind) {
176 case VUT_IMPROVEMENT:
177 case VUT_SITE:
178 /* This check corresponds to what is_req_active() will support.
179 * It can't be done in req_from_str(), as we may not have
180 * loaded all building information at that time. */
181 {
182 const struct impr_type *pimprove = preq->source.value.building;
183
184 if (preq->range == REQ_RANGE_WORLD && !is_great_wonder(pimprove)) {
185 ruleset_error(logger, LOG_ERROR,
186 _("%s: World-ranged requirement not supported for "
187 "%s (only great wonders supported)"), list_for,
189 return FALSE;
190 } else if (preq->range > REQ_RANGE_TRADE_ROUTE && !is_wonder(pimprove)) {
191 ruleset_error(logger, LOG_ERROR,
192 _("%s: %s-ranged requirement not supported for "
193 "%s (only wonders supported)"), list_for,
194 req_range_name(preq->range),
196 return FALSE;
197 }
198 }
199 break;
200 case VUT_MINCALFRAG:
201 /* Currently [calendar] is loaded after some requirements are
202 * parsed, so we can't do this in universal_value_from_str(). */
204 ruleset_error(logger, LOG_ERROR,
205 _("%s: MinCalFrag requirement used in ruleset without "
206 "calendar fragments"), list_for);
207 return FALSE;
208 } else if (preq->source.value.mincalfrag >= game.calendar.calendar_fragments) {
209 ruleset_error(logger, LOG_ERROR,
210 _("%s: MinCalFrag requirement %d out of range (max %d in "
211 "this ruleset)"), list_for, preq->source.value.mincalfrag,
213 return FALSE;
214 }
215 break;
217 /* There is currently no way to check a server setting's category and
218 * access level that works in both the client and the server. */
219 {
221 struct setting *pset;
222
223 id = ssetv_setting_get(preq->source.value.ssetval);
226
228 ruleset_error(logger, LOG_ERROR,
229 _("%s: ServerSetting requirement %s isn't visible enough "
230 "to appear in a requirement. Everyone should be able to "
231 "see the value of a server setting that appears in a "
232 "requirement."), list_for, server_setting_name_get(id));
233 return FALSE;
234 }
235
237 /* This is a server operator related setting (like the compression
238 * type of savegames), not a game rule. */
239 ruleset_error(logger, LOG_ERROR,
240 _("%s: ServerSetting requirement setting %s isn't about a "
241 "game rule."),
243 return FALSE;
244 }
245 }
246 break;
247 default:
248 /* No other universals have checks that can't be done at ruleset
249 * load time. See req_from_str(). */
250 break;
251 }
252 return TRUE;
253}
254
255/**********************************************************************/
259 int reqs_of_type[],
260 int local_reqs_of_type[],
261 int tile_reqs_of_type[],
262 struct requirement *preq, bool conjunctive,
263 int max_tiles, const char *list_for)
264{
265 int rc;
266
268
270 return FALSE;
271 }
272
273 if (!conjunctive) {
274 /* All the checks below are only meaningful for conjunctive lists. */
275 /* FIXME: we could add checks suitable for disjunctive lists. */
276 return TRUE;
277 }
278
279 /* Add to counter for positive requirements. */
280 if (preq->present) {
281 reqs_of_type[preq->source.kind]++;
282 }
283 rc = reqs_of_type[preq->source.kind];
284
285 if (preq->range == REQ_RANGE_LOCAL && preq->present) {
286 local_reqs_of_type[preq->source.kind]++;
287
288 switch (preq->source.kind) {
289 case VUT_EXTRA:
290 if (local_reqs_of_type[VUT_EXTRA] > 1) {
291 ruleset_error(logger, LOG_ERROR,
292 _("%s: Requirement list has multiple local-ranged extra "
293 "requirements (did you mean to make them tile-ranged?)"),
294 list_for);
295 return FALSE;
296 }
297 break;
298 default:
299 break;
300 }
301 }
302
303 if (preq->range == REQ_RANGE_TILE && preq->present) {
304 tile_reqs_of_type[preq->source.kind]++;
305
306 switch (preq->source.kind) {
307 case VUT_TERRAINCLASS:
309 ruleset_error(logger, LOG_ERROR,
310 _("%s: Requirement list has both tile terrain and terrainclass requirement"),
311 list_for);
312 return FALSE;
313 }
314 break;
315 case VUT_TERRAIN:
317 ruleset_error(logger, LOG_ERROR,
318 _("%s: Requirement list has both tile terrain and terrainclass requirement"),
319 list_for);
320 return FALSE;
321 }
322 break;
323 case VUT_MINLATITUDE:
324 case VUT_MAXLATITUDE:
325 if (tile_reqs_of_type[preq->range] > 1) {
326 ruleset_error(logger, LOG_ERROR,
327 _("%s: Requirement list has duplicate %s requirement at Tile range"),
329 return FALSE;
330 }
331 break;
332 default:
333 break;
334 }
335 }
336
337 if (rc > 1 && preq->present) {
338 /* Multiple requirements of the same type */
339 switch (preq->source.kind) {
340 case VUT_GOVERNMENT:
341 case VUT_ACTION:
342 case VUT_ACTIVITY:
343 case VUT_OTYPE:
344 case VUT_SPECIALIST:
345 case VUT_MINSIZE: /* Breaks nothing, but has no sense either */
346 case VUT_MINCITIES:
348 case VUT_MINMOVES: /* Breaks nothing, but has no sense either */
349 case VUT_MINVETERAN: /* Breaks nothing, but has no sense either */
350 case VUT_MINHP: /* Breaks nothing, but has no sense either */
351 case VUT_MINYEAR:
352 case VUT_MINCALFRAG:
353 case VUT_AI_LEVEL:
354 case VUT_TERRAINALTER: /* Local range only */
355 case VUT_STYLE:
356 case VUT_IMPR_GENUS:
357 case VUT_ORIGINAL_OWNER: /* City range -> only one original owner */
358 case VUT_FORM_AGE:
359 case VUT_MAX_DISTANCE_SQ: /* Breaks nothing, but has no sense either */
360 /* There can be only one requirement of these types (with current
361 * range limitations)
362 * Requirements might be identical, but we consider multiple
363 * declarations error anyway. */
364
365 ruleset_error(logger, LOG_ERROR,
366 _("%s: Requirement list has multiple %s requirements"),
368 return FALSE;
369 break;
370
371 case VUT_TERRAIN:
372 /* There can be only up to max_tiles requirements of these types */
373 if (max_tiles != -1 && rc > max_tiles) {
374 ruleset_error(logger, LOG_ERROR,
375 _("%s: Requirement list has more %s requirements than "
376 "can ever be fulfilled."), list_for,
378 return FALSE;
379 }
380 break;
381
382 case VUT_TERRAINCLASS:
383 if (rc > 2 || (max_tiles != -1 && rc > max_tiles)) {
384 ruleset_error(logger, LOG_ERROR,
385 _("%s: Requirement list has more %s requirements than "
386 "can ever be fulfilled."), list_for,
388 return FALSE;
389 }
390 break;
391
392 case VUT_AGE:
393 /* There can be age of the city, unit, and player */
394 if (rc > 3) {
395 ruleset_error(logger, LOG_ERROR,
396 _("%s: Requirement list has more %s requirements than "
397 "can ever be fulfilled."), list_for,
399 return FALSE;
400 }
401 break;
402
403 case VUT_MINTECHS:
404 case VUT_FUTURETECHS:
405 /* At ranges 'Player' and 'World' */
406 if (rc > 2) {
407 ruleset_error(logger, LOG_ERROR,
408 _("%s: Requirement list has more %s requirements than "
409 "can ever be fulfilled."), list_for,
411 return FALSE;
412 }
413 break;
414
415 case VUT_COUNTER:
416 /* Can have multiple, since many counters (also of the same range)
417 * can meet checkpoint */
419 /* Can have multiple, since there are many settings. */
420 case VUT_TOPO:
421 /* Can have multiple, since it's flag based (iso & hex) */
422 case VUT_WRAP:
423 /* Can have multiple, since it's flag based (wrapx & wrapy) */
424 case VUT_EXTRA:
425 case VUT_TILEDEF:
427 /* Note that there can be more than 1 extra / tile. */
430 /* Can require different numbers on e.g. local/adjacent tiles. */
431 case VUT_NATION:
432 /* Can require multiple nations at Team/Alliance/World range. */
433 case VUT_NATIONGROUP:
434 /* Nations can be in multiple groups. */
435 case VUT_NONE:
436 case VUT_ADVANCE:
437 case VUT_TECHFLAG:
438 case VUT_IMPROVEMENT:
439 case VUT_SITE:
440 case VUT_UNITSTATE:
441 case VUT_CITYTILE:
442 case VUT_GOOD:
443 case VUT_UTYPE:
444 case VUT_UCLASS:
445 case VUT_TILE_REL:
446 /* Can check different properties. */
447 case VUT_GOVFLAG:
448 case VUT_UTFLAG:
449 case VUT_UCFLAG:
450 case VUT_TERRFLAG:
451 case VUT_ROADFLAG:
452 case VUT_EXTRAFLAG:
453 case VUT_IMPR_FLAG:
454 case VUT_PLAYER_FLAG:
455 case VUT_PLAYER_STATE:
456 case VUT_NATIONALITY:
457 case VUT_MINCULTURE:
458 case VUT_ACHIEVEMENT:
459 case VUT_DIPLREL:
460 case VUT_DIPLREL_TILE:
464 /* Can have multiple requirements of these types */
465 case VUT_MINLATITUDE:
466 case VUT_MAXLATITUDE:
468 /* Can have multiple requirements at different ranges.
469 * TODO: Compare to number of legal ranges? */
470 break;
471 case VUT_CITYSTATUS:
472 /* Could check "CITYS_LAST * number of ranges" ? */
473 break;
474 case VUT_COUNT:
475 /* Should never be in requirement vector */
477 return FALSE;
478 break;
479 /* No default handling here, as we want compiler warning
480 * if new requirement type is added to enum and it's not handled
481 * here. */
482 }
483 }
484
485 return TRUE;
486}
487
488/**********************************************************************/
505 const struct requirement_vector *preqs,
506 bool conjunctive, int max_tiles,
507 const char *list_for)
508{
509 struct req_vec_problem *problem;
513
514 /* Initialize requirement counters */
515 memset(reqs_of_type, 0, sizeof(reqs_of_type));
517
522 return FALSE;
523 }
525
527 if (problem != NULL) {
528 ruleset_error(logger, LOG_ERROR, "%s: %s.", list_for, problem->description);
530 return FALSE;
531 }
532
533 return TRUE;
534}
535
536typedef struct {
537 struct {
538 bool effect_present[EFT_COUNT];
539 } base_effects;
541} els_data;
542
543/**********************************************************************/
546static bool effect_list_sanity_cb(struct effect *peffect, void *data)
547{
548 int one_tile = -1; /* TODO: Determine correct value from effect.
549 * -1 disables checking */
550 els_data *els = (els_data *)data;
551 struct astring astr;
552 int i;
553
554 for (i = 0; req_base_effects[i] != EFT_COUNT; i++) {
555 if (peffect->type == req_base_effects[i]) {
556 els->base_effects.effect_present[peffect->type] = TRUE;
557 break;
558 }
559 }
560 for (i = 0; req_base_effects_3_4[i] != EFT_COUNT; i++) {
561 if (peffect->type == req_base_effects_3_4[i]) {
562 els->base_effects.effect_present[peffect->type] = TRUE;
563 break;
564 }
565 }
566
568 /* Only unit targets can pay in move fragments. */
570 if (preq->source.kind == VUT_ACTION) {
571 if (action_get_target_kind(preq->source.value.action) != ATK_UNIT) {
572 /* TODO: support for ATK_STACK could be added. That would require
573 * manually calling action_success_target_pay_mp() in each
574 * supported unit stack targeted action performer (like
575 * action_consequence_success() does) or to have the unit stack
576 * targeted actions return a list of targets. */
577 ruleset_error(els->logger, LOG_ERROR,
578 _("The effect Action_Success_Target_Move_Cost has the"
579 " requirement {%s} but the action %s isn't"
580 " (single) unit targeted."),
582 universal_rule_name(&preq->source));
583 astr_free(&astr);
584 return FALSE;
585 }
586 }
588 } else if (peffect->type == EFT_ACTION_SUCCESS_MOVE_COST) {
589 /* Only unit actors can pay in move fragments. */
591 if (preq->source.kind == VUT_ACTION && preq->present) {
592 if (action_get_actor_kind(preq->source.value.action) != AAK_UNIT) {
593 ruleset_error(els->logger, LOG_ERROR,
594 _("The effect Action_Success_Actor_Move_Cost has the"
595 " requirement {%s} but the action %s isn't"
596 " performed by a unit."),
598 universal_rule_name(&preq->source));
599 astr_free(&astr);
600 return FALSE;
601 }
602 }
604 } else if (peffect->type == EFT_ACTION_ODDS_PCT
605 || peffect->type == EFT_ACTION_RESIST_PCT) {
606 /* Catch trying to set Action_Odds_Pct for non supported actions. */
608 if (preq->source.kind == VUT_ACTION && preq->present) {
609 if (action_dice_roll_initial_odds(preq->source.value.action)
611 ruleset_error(els->logger, LOG_ERROR,
612 _("The effect %s has the"
613 " requirement {%s} but the action %s doesn't"
614 " roll the dice to see if it fails."),
617 universal_rule_name(&preq->source));
618 astr_free(&astr);
619 return FALSE;
620 }
621 }
623 }
624
625 if (!sanity_check_req_vec(els->logger, &peffect->reqs, TRUE, one_tile,
626 effect_type_name(peffect->type))) {
627 ruleset_error(els->logger, LOG_ERROR,
628 _("Effects have conflicting or invalid requirements!"));
629
630 return FALSE;
631 }
632
633 return TRUE;
634}
635
636/**********************************************************************/
640{
641 if (num_role_units(L_BARBARIAN) > 0) {
643 ruleset_error(logger, LOG_ERROR, _("No role barbarian leader units"));
644 return FALSE;
645 }
647 ruleset_error(logger, LOG_ERROR, _("No role barbarian build units"));
648 return FALSE;
649 }
651 ruleset_error(logger, LOG_ERROR, _("No role barbarian ship units"));
652 return FALSE;
653 } else if (num_role_units(L_BARBARIAN_BOAT) > 0) {
654 bool sea_capable = FALSE;
656
658 if (is_ocean(pterr)
659 && BV_ISSET(pterr->native_to, uclass_index(utype_class(u)))) {
661 break;
662 }
664
665 if (!sea_capable) {
666 ruleset_error(logger, LOG_ERROR,
667 _("Barbarian boat (%s) needs to be able to move at sea."),
668 utype_rule_name(u));
669 return FALSE;
670 }
671 }
673 ruleset_error(logger, LOG_ERROR, _("No role sea raider barbarian units"));
674 return FALSE;
675 }
676
679 if (ptype->transport_capacity <= 1) {
680 ruleset_error(logger, LOG_ERROR,
681 _("Barbarian boat %s has no capacity for both "
682 "leader and at least one man."),
684 return FALSE;
685 }
686
692 ruleset_error(logger, LOG_ERROR,
693 _("Barbarian boat %s cannot transport "
694 "barbarian cargo %s."),
697 return FALSE;
698 }
699 }
701 }
703 }
704
705 return TRUE;
706}
707
708/**********************************************************************/
712{
713 /* Check some required flags and roles etc: */
714 if (num_role_units(UTYF_WORKERS) == 0) {
715 ruleset_error(logger, LOG_ERROR, _("No flag Worker units"));
716 return FALSE;
717 }
719 ruleset_error(logger, LOG_ERROR, _("No role Start Explorer units"));
720 return FALSE;
721 }
722 if (num_role_units(L_FERRYBOAT) == 0) {
723 ruleset_error(logger, LOG_ERROR, _("No role Ferryboat units"));
724 return FALSE;
725 }
726 if (num_role_units(L_FIRSTBUILD) == 0) {
727 ruleset_error(logger, LOG_ERROR, _("No role Firstbuild units"));
728 return FALSE;
729 }
730
731 if (num_role_units(L_FERRYBOAT) > 0) {
732 bool sea_capable = FALSE;
733 struct unit_type *u = get_role_unit(L_FERRYBOAT, 0);
734
736 if (is_ocean(pterr)
737 && BV_ISSET(pterr->native_to, uclass_index(utype_class(u)))) {
739 break;
740 }
742
743 if (!sea_capable) {
744 ruleset_error(logger, LOG_ERROR,
745 _("Ferryboat (%s) needs to be able to move at sea."),
746 utype_rule_name(u));
747 return FALSE;
748 }
749 }
750
751 if (num_role_units(L_PARTISAN) == 0
753 ruleset_error(logger, LOG_ERROR,
754 _("Inspire_Partisans effect present, "
755 "but no units with partisan role."));
756 return FALSE;
757 }
758
760 bool cargo = FALSE;
761
763 if (BV_ISSET(ptype->cargo, uclass_index(pclass))) {
764 cargo = TRUE;
765 break;
766 }
768
769 if (ptype->transport_capacity > 0) {
770 if (!cargo) {
771 ruleset_error(logger, LOG_ERROR,
772 _("%s has transport capacity %d, but no cargo types."),
773 utype_rule_name(ptype), ptype->transport_capacity);
774 return FALSE;
775 }
776 } else if (cargo) {
777 ruleset_error(logger, LOG_ERROR,
778 _("%s has cargo types, but no transport capacity."),
780 return FALSE;
781 }
783
784 return TRUE;
785}
786
787/**********************************************************************/
791{
792 /* Special Genus */
794 if (improvement_has_flag(pimprove, IF_GOLD)) {
795 if (pimprove->genus != IG_CONVERT) {
796 ruleset_error(logger, LOG_ERROR,
797 _("Gold producing improvement %s with genus other than \"Convert\""),
798 improvement_rule_name(pimprove));
799
800 return FALSE;
801 }
802 if (improvement_has_flag(pimprove, IF_INFRA)) {
803 ruleset_error(logger, LOG_ERROR,
804 _("The same improvement has both \"Gold\" and \"Infra\" flags"));
805 return FALSE;
806 }
807 } else if (improvement_has_flag(pimprove, IF_INFRA)) {
808 if (pimprove->genus != IG_CONVERT) {
809 ruleset_error(logger, LOG_ERROR,
810 _("Infrapoints producing improvement %s with genus other than \"Convert\""),
811 improvement_rule_name(pimprove));
812
813 return FALSE;
814 }
815 } else if (pimprove->genus == IG_CONVERT) {
816 ruleset_error(logger, LOG_ERROR,
817 _("Improvement %s with no conversion target with genus \"Convert\""),
818 improvement_rule_name(pimprove));
819 return FALSE;
820 }
821
823 && pimprove->genus != IG_IMPROVEMENT) {
824 ruleset_error(logger, LOG_ERROR,
825 _("Disasterproof improvement %s with genus other than \"Improvement\""),
826 improvement_rule_name(pimprove));
827
828 return FALSE;
829 }
830 if (pimprove->genus != IG_SPECIAL
836 RPT_POSSIBLE, FALSE))) {
837 ruleset_error(logger, LOG_ERROR,
838 _("Space part %s with genus other than \"Special\""),
839 improvement_rule_name(pimprove));
840 return FALSE;
841 }
842
843 if (!is_building_sellable(pimprove) && pimprove->upkeep != 0) {
844 ruleset_error(logger, LOG_ERROR,
845 _("%s is a nonsellable building with a nonzero upkeep value"),
846 improvement_rule_name(pimprove));
847 return FALSE;
848 }
850
851 return TRUE;
852}
853
854/**********************************************************************/
858{
859 enum effect_type boolean_effects[] =
860 {
884 };
885 int i;
886 bool ret = TRUE;
887
888 for (i = 0; boolean_effects[i] != EFT_COUNT; i++) {
891 ruleset_error(logger, LOG_ERROR,
892 _("Boolean effect %s can get disabled, but it can't get "
893 "enabled before that."),
895 ret = FALSE;
896 }
897 }
898
899 return ret;
900}
901
902/**********************************************************************/
910{
911 int num_utypes;
912 int i;
913 bool ok = TRUE; /* Store failures to variable instead of returning
914 * immediately so all errors get printed, not just first
915 * one. */
919 rs_conversion_logger logger = ((compat != NULL) ? compat->log_cb : NULL);
920
921 if (!sanity_check_metadata(logger)) {
922 ok = FALSE;
923 }
924
927 ruleset_error(logger, LOG_ERROR,
928 _("Cost based free tech method, but tech cost style "
929 "\"Civ I|II\" so all techs cost the same."));
930 ok = FALSE;
931 }
932
933 /* Advances. */
935 for (i = AR_ONE; i < AR_SIZE; i++) {
936 const struct advance *preq;
937
938 if (i == AR_ROOT) {
939 /* Self rootreq is a feature. */
940 continue;
941 }
942
944
945 if (A_NEVER == preq) {
946 continue;
947 } else if (preq == padvance) {
948 ruleset_error(logger, LOG_ERROR, _("Tech \"%s\" requires itself."),
950 ok = FALSE;
951 continue;
952 }
953
955 if (preqreq == padvance) {
956 ruleset_error(logger, LOG_ERROR,
957 _("Tech \"%s\" requires itself indirectly via \"%s\"."),
960 ok = FALSE;
961 }
963 }
964
965 requirement_vector_iterate(&(padvance->research_reqs), preq) {
966 if (preq->source.kind == VUT_ADVANCE) {
967 /* Don't allow this even if allowing changing reqs. Players will
968 * expect all tech reqs to appear in the client tech tree. That
969 * should be taken care of first. */
970 ruleset_error(logger, LOG_ERROR,
971 _("Tech \"%s\" requires a tech in its research_reqs."
972 " This isn't supported yet. Please keep using req1"
973 " and req2 like before."),
975 ok = FALSE;
977 /* If we get an obsolete improvement before the game,
978 * almost surely it is going to become not obsolete later.
979 * This check must catch it. */) {
980 struct astring astr;
981
982 /* Only support unchanging requirements until the reachability code
983 * can handle it and the tech tree can display changing
984 * requirements. */
985 ruleset_error(logger, LOG_ERROR,
986 _("Tech \"%s\" has the requirement %s in its"
987 " research_reqs. This requirement may change during"
988 " the game. Changing requirements aren't supported"
989 " yet."),
992 astr_free(&astr);
993 ok = FALSE;
994 }
996
997 if (padvance->bonus_message != NULL) {
998 if (!formats_match(padvance->bonus_message, "%s")) {
999 ruleset_error(logger, LOG_ERROR,
1000 _("Tech \"%s\" bonus message is not format with %%s "
1001 "for a bonus tech name."),
1003 ok = FALSE;
1004 }
1005 }
1007
1009 ruleset_error(logger, LOG_ERROR,
1010 _("The government form %s reserved for revolution handling "
1011 "has been set as default_government."),
1013 ok = FALSE;
1015 }
1016
1017 /* Check that all players can have their initial techs */
1018 nations_re_active_iterate(pnation) {
1019 int techi;
1020
1021 /* Check global initial techs */
1022 for (techi = 0; techi < MAX_NUM_TECH_LIST
1025 struct advance *a = valid_advance_by_number(tech);
1026
1027 if (a == NULL) {
1028 ruleset_error(logger, LOG_ERROR,
1029 _("Tech %s does not exist, but is initial "
1030 "tech for everyone."),
1032 ok = FALSE;
1033 } else if (advance_by_number(A_NONE) != a->require[AR_ROOT]
1034 && !nation_has_initial_tech(pnation, a->require[AR_ROOT])) {
1035 /* Nation has no root_req for tech */
1036 ruleset_error(logger, LOG_ERROR,
1037 _("Tech %s is initial for everyone, but %s has "
1038 "no root_req for it."),
1040 nation_rule_name(pnation));
1041 ok = FALSE;
1042 }
1043 }
1044
1045 /* Check national initial techs */
1046 for (techi = 0;
1047 techi < MAX_NUM_TECH_LIST && pnation->init_techs[techi] != A_LAST;
1048 techi++) {
1049 Tech_type_id tech = pnation->init_techs[techi];
1050 struct advance *a = valid_advance_by_number(tech);
1051
1052 if (a == NULL) {
1053 ruleset_error(logger, LOG_ERROR,
1054 _("Tech %s does not exist, but is initial tech for %s."),
1056 nation_rule_name(pnation));
1057 ok = FALSE;
1058 } else if (advance_by_number(A_NONE) != a->require[AR_ROOT]
1059 && !nation_has_initial_tech(pnation, a->require[AR_ROOT])) {
1060 /* Nation has no root_req for tech */
1061 ruleset_error(logger, LOG_ERROR,
1062 _("Tech %s is initial for %s, but they have "
1063 "no root_req for it."),
1065 nation_rule_name(pnation));
1066 ok = FALSE;
1067 }
1068 }
1069
1070 /* Check national initial buildings */
1072 && pnation->init_buildings[0] != B_LAST) {
1073 ruleset_error(logger, LOG_ERROR,
1074 _("Nation %s has init_buildings set but as barbarians will "
1075 "never get them."), nation_rule_name(pnation));
1076 }
1077
1078 if (!default_gov_failed && pnation->init_government == game.government_during_revolution) {
1079 ruleset_error(logger, LOG_ERROR,
1080 _("The government form %s reserved for revolution "
1081 "handling has been set as initial government for %s."),
1083 nation_rule_name(pnation));
1084 ok = FALSE;
1085 }
1087
1088 /* Check against unit upgrade loops */
1091 int chain_length = 0;
1092 const struct unit_type *upgraded = putype;
1093
1094 while (upgraded != NULL && !obsoleted_by_loop) {
1096 chain_length++;
1097 if (chain_length > num_utypes) {
1098 ruleset_error(logger, LOG_ERROR,
1099 _("There seems to be obsoleted_by loop in update "
1100 "chain that starts from %s"),
1102 ok = FALSE;
1104 }
1105 }
1107
1108 /* Some unit type properties depend on other unit type properties to work
1109 * properly. */
1111 /* "Spy" is a better "Diplomat". Until all the places that assume that
1112 * "Diplomat" is set if "Spy" is set is changed this limitation must be
1113 * kept. */
1116 ruleset_error(logger, LOG_ERROR,
1117 _("The unit type '%s' has the 'Spy' unit type flag but "
1118 "not the 'Diplomat' unit type flag."),
1120 ok = FALSE;
1121 }
1123
1124 /* Check that unit type fields are in range. */
1126 if (putype->paratroopers_range < 0
1127 || putype->paratroopers_range > UNIT_MAX_PARADROP_RANGE) {
1128 /* Paradrop range is limited by the network protocol. */
1129 ruleset_error(logger, LOG_ERROR,
1130 _("The paratroopers_range of the unit type '%s' is %d. "
1131 "That is out of range. Max range is %d."),
1133 putype->paratroopers_range, UNIT_MAX_PARADROP_RANGE);
1134 ok = FALSE;
1135 }
1136 /* never fires if game.scenario.prevent_new_cities is TRUE */
1137 if ((putype->city_size <= 0 || putype->city_size > MAX_CITY_SIZE)
1139 ruleset_error(logger, LOG_ERROR,
1140 _("Unit type '%s' would build size %d cities. "
1141 "City sizes must be from 1 to %d."),
1142 utype_rule_name(putype), putype->city_size,
1144 ok = FALSE;
1145 }
1147
1148 memset(&els, 0, sizeof(els));
1149 els.logger = logger;
1150
1151 /* Check requirement sets against conflicting requirements.
1152 * For effects check also other sanity in the same iteration */
1154 ok = FALSE;
1155 }
1156
1157 for (i = 0; req_base_effects[i] != EFT_COUNT; i++) {
1158 if (!els.base_effects.effect_present[req_base_effects[i]]) {
1159 ruleset_error(logger, LOG_ERROR,
1160 _("There is no base %s effect."),
1162 ok = FALSE;
1163 }
1164 }
1165 for (i = 0; req_base_effects_3_4[i] != EFT_COUNT; i++) {
1166 if (!els.base_effects.effect_present[req_base_effects_3_4[i]]) {
1168
1169 if (compat != nullptr && compat->compat_mode && compat->version < RSFORMAT_3_4) {
1170 log_deprecation("There is no base %s effect.", ename);
1171 if (compat->log_cb != nullptr) {
1172 char buf[512];
1173
1174 fc_snprintf(buf, sizeof(buf), _("Missing base %s effect. Please add one."), ename);
1175 compat->log_cb(buf);
1176 }
1177 } else {
1178 ruleset_error(logger, LOG_ERROR,
1179 _("There is no base %s effect."), ename);
1180 ok = FALSE;
1181 }
1182 }
1183 }
1184
1185 if (!sanity_check_boolean_effects(logger)) {
1186 ok = FALSE;
1187 }
1188
1189 /* Others use requirement vectors */
1190
1191 /* Disasters */
1193 if (!sanity_check_req_vec(logger, &pdis->reqs, TRUE, -1,
1195 ruleset_error(logger, LOG_ERROR,
1196 _("Disasters have conflicting or invalid requirements!"));
1197 ok = FALSE;
1198 }
1200
1201 /* Goods */
1203 if (!sanity_check_req_vec(logger, &pgood->reqs, TRUE, -1,
1205 ruleset_error(logger, LOG_ERROR,
1206 _("Goods have conflicting or invalid requirements!"));
1207 ok = FALSE;
1208 }
1210
1211 /* Buildings */
1213 if (!sanity_check_req_vec(logger, &pimprove->reqs, TRUE, -1,
1214 improvement_rule_name(pimprove))) {
1215 ruleset_error(logger, LOG_ERROR,
1216 _("Buildings have conflicting or invalid requirements!"));
1217 ok = FALSE;
1218 }
1219 if (!sanity_check_req_vec(logger, &pimprove->obsolete_by, FALSE, -1,
1220 improvement_rule_name(pimprove))) {
1221 ruleset_error(logger, LOG_ERROR,
1222 _("Buildings have conflicting or invalid obsolescence req!"));
1223 ok = FALSE;
1224 }
1226
1227 /* Governments */
1229 if (!sanity_check_req_vec(logger, &pgov->reqs, TRUE, -1,
1231 ruleset_error(logger, LOG_ERROR,
1232 _("Governments have conflicting or invalid requirements!"));
1233 ok = FALSE;
1234 }
1236
1237 /* Specialists */
1239 if (!sanity_check_req_vec(logger, &psp->reqs, TRUE, -1,
1240 specialist_rule_name(psp))) {
1241 ruleset_error(logger, LOG_ERROR,
1242 _("Specialists have conflicting or invalid requirements!"));
1243 ok = FALSE;
1244 }
1246
1247 /* Extras */
1249 if (!sanity_check_req_vec(logger, &pextra->reqs, TRUE, -1,
1250 extra_rule_name(pextra))) {
1251 ruleset_error(logger, LOG_ERROR,
1252 _("Extras have conflicting or invalid requirements!"));
1253 ok = FALSE;
1254 }
1255 if (!sanity_check_req_vec(logger, &pextra->rmreqs, TRUE, -1,
1256 extra_rule_name(pextra))) {
1257 ruleset_error(logger, LOG_ERROR,
1258 _("Extras have conflicting or invalid removal requirements!"));
1259 ok = FALSE;
1260 }
1261 if ((requirement_vector_size(&pextra->rmreqs) > 0)
1262 && !(pextra->rmcauses
1263 & (ERM_ENTER | ERM_CLEAN | ERM_PILLAGE))) {
1264 ruleset_error(logger, LOG_WARN,
1265 _("Requirements for extra removal defined but not "
1266 "a valid remove cause!"));
1267 }
1269
1270 /* Roads */
1272 struct road_type *proad = extra_road_get(pextra);
1273
1274 extra_type_list_iterate(proad->integrators, iextra) {
1276 int pnbr = road_number(proad);
1277
1278 if (pnbr != road_number(iroad)
1279 && !BV_ISSET(iroad->integrates, pnbr)) {
1280 /* We don't support non-symmetric integrator relationships yet. */
1281 ruleset_error(logger, LOG_ERROR,
1282 _("Road '%s' integrates with '%s' but not vice versa!"),
1283 extra_rule_name(pextra),
1285 ok = FALSE;
1286 }
1289
1290 /* City styles */
1291 for (i = 0; i < game.control.num_city_styles; i++) {
1292 if (!sanity_check_req_vec(logger, &city_styles[i].reqs, TRUE, -1,
1294 ruleset_error(logger, LOG_ERROR,
1295 _("City styles have conflicting or invalid requirements!"));
1296 ok = FALSE;
1297 }
1298 }
1299
1300 /* Actions */
1301 action_iterate(act) {
1302 struct action *paction = action_by_number(act);
1303
1304 if (!actres_legal_target_kind(paction->result, paction->target_kind)) {
1305 ruleset_error(logger, LOG_ERROR,
1306 _("Action \"%s\": unsupported target kind %s."),
1308 action_target_kind_name(paction->target_kind));
1309 ok = FALSE;
1310 }
1311
1312 if (paction->min_distance < 0) {
1313 ruleset_error(logger, LOG_ERROR,
1314 _("Action %s: negative min distance (%d)."),
1315 action_id_rule_name(act), paction->min_distance);
1316 ok = FALSE;
1317 }
1318
1319 if (paction->min_distance > ACTION_DISTANCE_LAST_NON_SIGNAL) {
1320 ruleset_error(logger, LOG_ERROR,
1321 _("Action %s: min distance (%d) larger than "
1322 "any distance on a map can be (%d)."),
1323 action_id_rule_name(act), paction->min_distance,
1325 ok = FALSE;
1326 }
1327
1328 if (paction->max_distance > ACTION_DISTANCE_MAX) {
1329 ruleset_error(logger, LOG_ERROR,
1330 _("Action %s: max distance is %d. "
1331 "A map can't be that big."),
1332 action_id_rule_name(act), paction->max_distance);
1333 ok = FALSE;
1334 }
1335
1336 if (!action_distance_inside_max(paction, paction->min_distance)) {
1337 ruleset_error(logger, LOG_ERROR,
1338 _("Action %s: min distance is %d but max distance is %d."),
1340 paction->min_distance, paction->max_distance);
1341 ok = FALSE;
1342 }
1343
1344 action_iterate(blocker) {
1345 if (BV_ISSET(paction->blocked_by, blocker)
1346 && action_id_get_target_kind(blocker) == ATK_UNIT
1348 /* Can't find an individual unit target to evaluate the blocking
1349 * action against. (A tile may have more than one individual
1350 * unit) */
1351 ruleset_error(logger, LOG_ERROR,
1352 _("The action %s can't block %s."),
1353 action_id_rule_name(blocker),
1354 action_id_rule_name(act));
1355 ok = FALSE;
1356 }
1358
1360 if (!sanity_check_req_vec(logger, &(enabler->actor_reqs), TRUE, -1,
1361 "Action Enabler Actor Reqs")
1362 || !sanity_check_req_vec(logger, &(enabler->target_reqs), TRUE, -1,
1363 "Action Enabler Target Reqs")) {
1364 ruleset_error(logger, LOG_ERROR,
1365 _("Action enabler for %s has conflicting or invalid "
1366 "requirements!"), action_id_rule_name(act));
1367 ok = FALSE;
1368 }
1369
1371 /* Special test for self targeted actions. */
1372
1373 if (requirement_vector_size(&(enabler->target_reqs)) > 0) {
1374 /* Shouldn't have target requirements since the action doesn't
1375 * have a target. */
1376 ruleset_error(logger, LOG_ERROR,
1377 _("An action enabler for %s has a target "
1378 "requirement vector. %s doesn't have a target."),
1380 action_id_rule_name(act));
1381 ok = FALSE;
1382 }
1383 }
1384
1385 requirement_vector_iterate(&(enabler->target_reqs), preq) {
1386 if (preq->source.kind == VUT_DIPLREL
1387 && preq->range == REQ_RANGE_LOCAL) {
1388 struct astring astr;
1389
1390 /* A Local DiplRel requirement can be expressed as a requirement
1391 * in actor_reqs. Demand that it is there. This avoids breaking
1392 * code that reasons about actions. */
1393 ruleset_error(logger, LOG_ERROR,
1394 _("Action enabler for %s has a local DiplRel "
1395 "requirement %s in target_reqs! Please read the "
1396 "section \"Requirement vector rules\" in "
1397 "doc/README.actions"),
1400 astr_free(&astr);
1401 ok = FALSE;
1402 } else if (preq->source.kind == VUT_MAX_DISTANCE_SQ
1403 && preq->range == REQ_RANGE_TILE) {
1404 struct astring astr;
1405
1406 /* A Tile-ranged MaxDistanceSq requirement can be expressed as a
1407 * requirement in actor_reqs. Demand that it is there. */
1408 ruleset_error(logger, LOG_ERROR,
1409 _("Action enabler for %s has a tile MaxDistanceSq "
1410 "requirement %s in target_reqs! Please read the "
1411 "section \"Requirement vector rules\" in "
1412 "doc/README.actions"),
1415 astr_free(&astr);
1416 ok = FALSE;
1417 }
1419
1420 if (compat == nullptr || !compat->compat_mode
1421 || compat->version >= RSFORMAT_3_4) {
1422 /* Support for letting some of the following hard requirements be
1423 * implicit were retired in Freeciv 3.0. Others were retired later.
1424 * Make sure that the opposite of each hard action requirement
1425 * blocks all its action enablers. */
1426
1427 struct req_vec_problem *problem
1429
1430 if (problem != nullptr) {
1431 ruleset_error(logger, LOG_ERROR, "%s", problem->description);
1433 ok = FALSE;
1434 }
1435
1437 if (problem != nullptr) {
1438 /* There is a potential for improving this enabler. */
1439 log_deprecation("%s", problem->description);
1441 }
1442 }
1444
1446 /* The action performer, action_dice_roll_initial_odds() and the
1447 * action probability calculation in action_prob() must probably all
1448 * be updated to add a new action here. */
1465 ruleset_error(logger, LOG_ERROR,
1466 _("diplchance_initial_odds: \"%s\" not supported."),
1468 ok = FALSE;
1469 }
1470
1471 if (BV_ISSET(paction->sub_results, ACT_SUB_RES_HUT_ENTER)
1472 && BV_ISSET(paction->sub_results, ACT_SUB_RES_HUT_FRIGHTEN)) {
1473 ruleset_error(logger, LOG_ERROR,
1474 _("%s both enters and frightens a hut at the same time."),
1476 ok = FALSE;
1477 }
1479
1480 /* Auto attack */
1481 {
1483
1485
1487 struct action *paction = action_by_number(act_id);
1488
1493 /* Only allow removing and changing the order of old auto
1494 * attack actions for now. Other actions need more testing and
1495 * fixing of issues caused by a worst case action probability of
1496 * 0%. */
1497 ruleset_error(logger, LOG_ERROR,
1498 _("auto_attack: %s not supported in"
1499 " attack_actions."),
1501 ok = FALSE;
1502 }
1504 }
1505
1506 /* There must be basic city style for each nation style to start with */
1509 ruleset_error(logger, LOG_ERROR,
1510 _("There's no basic city style for nation style %s"),
1512 ok = FALSE;
1513 }
1515
1516 /* Music styles */
1518 if (!sanity_check_req_vec(logger, &pmus->reqs, TRUE, -1, "Music Style")) {
1519 ruleset_error(logger, LOG_ERROR,
1520 _("Music Styles have conflicting or invalid requirements!"));
1521 ok = FALSE;
1522 }
1524
1527 if (!is_native_to_class(utype_class(panimal), pterr, nullptr)) {
1528 ruleset_error(logger, LOG_ERROR,
1529 _("%s has %s as animal to appear, but it's not native to the terrain."),
1531 ok = FALSE;
1532 break;
1533 }
1535
1537 (void) freq;
1539 ruleset_error(logger, LOG_ERROR,
1540 _("%s has %s as a resource, but it's not a resource extra."),
1542 ok = FALSE;
1543 }
1546
1547 /* Check that all unit classes can exist somewhere */
1550 bool can_exist = FALSE;
1551
1553 if (BV_ISSET(pterr->native_to, uclass_index(pclass))) {
1554 can_exist = TRUE;
1555 break;
1556 }
1558
1559 if (!can_exist) {
1561 if (BV_ISSET(pextra->native_to, uclass_index(pclass))
1562 && extra_has_flag(pextra, EF_NATIVE_TILE)) {
1563 can_exist = TRUE;
1564 break;
1565 }
1567 }
1568
1569 if (!can_exist) {
1570 ruleset_error(logger, LOG_ERROR,
1571 _("Unit class %s cannot exist anywhere."),
1573 ok = FALSE;
1574 }
1575 }
1577
1579 if (!pach->unique && pach->cons_msg == NULL) {
1580 ruleset_error(logger, LOG_ERROR,
1581 _("Achievement %s has no message for consecutive gainers though "
1582 "it's possible to be gained by multiple players"),
1584 ok = FALSE;
1585 }
1587
1589 int nati;
1590
1592 struct nation_type *pnat
1594
1595 if (pnat == NULL) {
1596 ruleset_error(logger, LOG_ERROR,
1597 _("There's nation %s listed in embedded nations, but there's "
1598 "no such nation."),
1600 ok = FALSE;
1601 }
1602 }
1603 }
1604
1605 if (ok) {
1606 ok = rs_common_units(logger);
1607 }
1608 if (ok) {
1609 ok = rs_barbarian_units(logger);
1610 }
1611 if (ok) {
1612 ok = rs_buildings(logger);
1613 }
1614
1615 return ok;
1616}
1617
1618/**********************************************************************/
1624{
1625 bool ok = TRUE;
1626
1629 if (pextra != pextra2) {
1630 int idx = extra_index(pextra2);
1631
1632 if (!BV_ISSET(pextra->conflicts, idx)) {
1633 log_debug("Autoconflicting resource %s with %s",
1635 BV_SET(pextra->conflicts, extra_index(pextra2));
1636 }
1637 }
1640
1641 /* Hard coded action blocking. */
1642 {
1643 const struct {
1644 const enum action_result blocked;
1645 const enum action_result blocker;
1646 } must_block[] = {
1647 /* Hard code that Help Wonder blocks Disband Unit Recover. This must be done
1648 * because caravan_shields makes it possible to avoid the
1649 * consequences of choosing to do Disband Unit Recover rather than having it
1650 * do Help Wonder.
1651 *
1652 * Explanation: Disband Unit Recover adds 50% of the shields used to produce
1653 * the unit to the production of the city where it is located. Help
1654 * Wonder adds 100%. If a unit that can do Help Wonder is disbanded with
1655 * production recovery in a city and the production later is changed
1656 * to something that can receive help from Help Wonder the remaining 50%
1657 * of the shields are added. This can be done because the city remembers
1658 * them in caravan_shields.
1659 *
1660 * If a unit that can do Help Wonder intentionally is disbanded with recovery
1661 * rather than making it do Help Wonder its shields will still be
1662 * remembered. The target city that got 50% of the shields can
1663 * therefore get 100% of them by changing its production. This trick
1664 * makes the ability to select Disband Unit Recover when Help Wonder is legal
1665 * pointless. */
1667
1668 /* Allowing regular disband when ACTION_HELP_WONDER or
1669 * ACTION_DISBAND_UNIT_RECOVER is legal while ACTION_HELP_WONDER always
1670 * blocks ACTION_DISBAND_UNIT_RECOVER doesn't work well with the force_*
1671 * semantics. Should move to the ruleset once it has blocked_by
1672 * semantics. */
1675
1676 /* Hard code that the ability to perform a regular attack blocks city
1677 * conquest. Is redundant as long as the requirement that the target
1678 * tile has no units remains hard coded. Kept "just in case" that
1679 * changes. */
1681
1682 /* Hard code that the ability to perform a regular attack blocks
1683 * extras conquest. Is redundant as long as the requirement that the
1684 * target tile has no non-allied units remains hard coded. Kept "just
1685 * in case" that changes. */
1687
1688 /* Hard code that the ability to enter or frighten a hut blocks
1689 * regular disembarking. */
1693 };
1694
1695 int i;
1696
1697 for (i = 0; i < ARRAY_SIZE(must_block); i++) {
1698 enum action_result blocked_result = must_block[i].blocked;
1699 enum action_result blocker_result = must_block[i].blocker;
1700
1703 if (!action_would_be_blocked_by(blocked, blocker)) {
1704 log_verbose("Autoblocking %s with %s",
1705 action_rule_name(blocked),
1706 action_rule_name(blocker));
1707 BV_SET(blocked->blocked_by, action_id(blocker));
1708 }
1711 }
1712 }
1713
1714 return ok;
1715}
1716
1717/**********************************************************************/
1721{
1722 bool ok = TRUE;
1723
1724 if (num_role_units(L_BARBARIAN) == 0) {
1725 struct setting *pset = setting_by_name("barbarians");
1726
1727 log_normal(_("Disabling 'barbarians' setting for lack of suitable "
1728 "unit types."));
1730 if (!setting_enum_set(pset, "DISABLED", NULL, NULL, 0)) {
1731 ok = FALSE;
1732 }
1734 }
1735
1736 return ok;
1737}
const char * achievement_rule_name(struct achievement *pach)
#define achievements_re_active_iterate(_p)
#define achievements_re_active_iterate_end
bool action_distance_inside_max(const struct action *action, const int distance)
Definition actions.c:1194
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1119
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5956
struct req_vec_problem * action_enabler_suggest_repair(const struct action_enabler *enabler)
Definition actions.c:1918
struct req_vec_problem * action_enabler_suggest_improvement(const struct action_enabler *enabler)
Definition actions.c:1984
const char * action_rule_name(const struct action *action)
Definition actions.c:1237
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1260
bool action_would_be_blocked_by(const struct action *blocked, const struct action *blocker)
Definition actions.c:1217
int action_dice_roll_initial_odds(const struct action *paction)
Definition actions.c:5593
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1129
struct action_enabler_list * action_enablers_for_action(action_id action)
Definition actions.c:1580
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:245
#define ACTION_DISTANCE_MAX
Definition actions.h:107
#define enabler_get_action(_enabler_)
Definition actions.h:186
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:375
#define action_auto_perf_actions_iterate_end
Definition actions.h:366
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_enabler_list_re_iterate_end
Definition actions.h:200
#define ACTION_DISTANCE_LAST_NON_SIGNAL
Definition actions.h:103
#define action_enabler_list_re_iterate(action_enabler_list, aenabler)
Definition actions.h:196
#define action_has_result(_act_, _res_)
Definition actions.h:184
#define action_by_result_iterate_end
Definition actions.h:249
#define action_auto_perf_actions_iterate(_autoperf_, _act_id_)
Definition actions.h:363
#define action_iterate_end
Definition actions.h:218
#define action_has_result_safe(paction, result)
Definition actions.h:428
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_ODDS_PCT_DICE_ROLL_NA
Definition actions.h:724
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:561
void astr_free(struct astring *astr)
Definition astring.c:148
#define BV_SET(bv, bit)
Definition bitvector.h:89
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
const char * city_style_rule_name(const int style)
Definition city.c:1806
static const struct city struct citystyle * city_styles
Definition city.c:84
#define MAX_CITY_SIZE
Definition city.h:104
char * incite_cost
Definition comments.c:77
#define MAX_LEN_CONTENT
Definition conn_types.h:32
#define log_deprecation(message,...)
const char * disaster_rule_name(struct disaster_type *pdis)
Definition disaster.c:105
#define disaster_type_re_active_iterate(_p)
Definition disaster.h:93
#define disaster_type_re_active_iterate_end
Definition disaster.h:96
int int id
Definition editgui_g.h:28
struct @22::@23 reqs
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1329
int get_potential_improvement_bonus(const struct impr_type *pimprove, const struct city *pcity, enum effect_type effect_type, const enum req_problem_type prob_type, bool consider_multipliers)
Definition effects.c:1210
int effect_cumulative_max(enum effect_type type, struct universal *unis, size_t n_unis)
Definition effects.c:388
int effect_cumulative_min(enum effect_type type, struct universal *for_uni)
Definition effects.c:424
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:875
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:203
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_type_re_active_iterate_end
Definition extras.h:329
#define extra_type_list_iterate_end
Definition extras.h:167
#define extra_road_get(_e_)
Definition extras.h:191
#define extra_type_re_active_iterate(_p)
Definition extras.h:325
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
int server_setting_id
Definition fc_types.h:765
int Tech_type_id
Definition fc_types.h:238
int ssetv
Definition fc_types.h:508
@ RPT_POSSIBLE
Definition fc_types.h:515
int action_id
Definition fc_types.h:250
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
const char * government_rule_name(const struct government *pgovern)
Definition government.c:135
#define governments_re_active_iterate(_p)
Definition government.h:132
#define governments_re_active_iterate_end
Definition government.h:136
bool is_building_sellable(const struct impr_type *pimprove)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_re_active_iterate_end
#define improvement_re_active_iterate(_p)
#define B_LAST
Definition improvement.h:42
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
@ LOG_ERROR
Definition log.h:31
@ LOG_WARN
Definition log.h:32
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:373
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:919
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:121
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:212
#define nations_re_active_iterate_end
Definition nation.h:370
#define nations_re_active_iterate(_pnat_)
Definition nation.h:367
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
req_vec_num_in_item req_vec_vector_number(const void *parent_item, const struct requirement_vector *vec)
struct req_vec_problem * req_vec_suggest_repair(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
const char * universal_rule_name(const struct universal *psource)
void req_vec_problem_free(struct req_vec_problem *issue)
const char * universal_type_rule_name(const struct universal *psource)
enum req_unchanging_status is_req_unchanging(const struct req_context *context, const struct requirement *req)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
@ REQUCH_HACK
Road_type_id road_number(const struct road_type *proad)
Definition road.c:32
bool sanity_check_ruleset_data(struct rscompat_info *compat)
Definition rssanity.c:909
static bool sanity_check_req_vec(rs_conversion_logger logger, const struct requirement_vector *preqs, bool conjunctive, int max_tiles, const char *list_for)
Definition rssanity.c:504
bool sanity_check_server_setting_value_in_req(ssetv ssetval)
Definition rssanity.c:144
enum effect_type req_base_effects[]
Definition rssanity.c:43
static bool sanity_check_req_set(rs_conversion_logger logger, int reqs_of_type[], int local_reqs_of_type[], int tile_reqs_of_type[], struct requirement *preq, bool conjunctive, int max_tiles, const char *list_for)
Definition rssanity.c:258
static bool sanity_check_boolean_effects(rs_conversion_logger logger)
Definition rssanity.c:857
static bool sanity_check_setting_is_seen(struct setting *pset)
Definition rssanity.c:108
static bool sanity_check_req_individual(rs_conversion_logger logger, struct requirement *preq, const char *list_for)
Definition rssanity.c:171
static bool rs_buildings(rs_conversion_logger logger)
Definition rssanity.c:790
enum effect_type req_base_effects_3_4[]
Definition rssanity.c:52
static bool sanity_check_metadata(rs_conversion_logger logger)
Definition rssanity.c:61
bool autolock_settings(void)
Definition rssanity.c:1720
static bool rs_common_units(rs_conversion_logger logger)
Definition rssanity.c:711
bool autoadjust_ruleset_data(void)
Definition rssanity.c:1623
static bool rs_barbarian_units(rs_conversion_logger logger)
Definition rssanity.c:639
static bool effect_list_sanity_cb(struct effect *peffect, void *data)
Definition rssanity.c:546
static bool sanity_check_setting_is_game_rule(struct setting *pset)
Definition rssanity.c:117
static bool nation_has_initial_tech(struct nation_type *pnation, struct advance *tech)
Definition rssanity.c:79
void(* rs_conversion_logger)(const char *msg)
Definition ruleload.h:41
#define ruleset_error(logger, level, format,...)
Definition ruleload.h:58
#define RSFORMAT_3_4
Definition ruleload.h:36
static struct compatibility compat[]
Definition savecompat.c:117
const char * server_setting_name_get(server_setting_id id)
enum sset_type server_setting_type_get(server_setting_id id)
server_setting_id ssetv_setting_get(ssetv enc)
bool server_setting_exists(server_setting_id id)
void setting_ruleset_lock_clear(struct setting *pset)
Definition settings.c:4721
struct setting * setting_by_name(const char *name)
Definition settings.c:3349
struct setting * setting_by_number(int id)
Definition settings.c:3341
enum sset_category setting_category(const struct setting *pset)
Definition settings.c:3420
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4065
void setting_ruleset_lock_set(struct setting *pset)
Definition settings.c:4701
bool setting_is_visible_at_level(const struct setting *pset, enum cmdlevel plevel)
Definition settings.c:3538
bool formats_match(const char *format1, const char *format2)
Definition shared.c:2446
#define ARRAY_SIZE(x)
Definition shared.h:85
const char * specialist_rule_name(const struct specialist *sp)
Definition specialist.c:157
#define specialist_type_re_active_iterate_end
Definition specialist.h:114
#define specialist_type_re_active_iterate(_p)
Definition specialist.h:109
struct advance * require[AR_SIZE]
Definition tech.h:129
struct civ_game::@32::@36::@42 ruledit
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
char ** embedded_nations
Definition game.h:290
struct civ_game::@31 rgame
size_t embedded_nations_count
Definition game.h:291
struct civ_game::@32::@36 server
struct packet_calendar_info calendar
Definition game.h:90
struct government * default_government
Definition game.h:93
struct government * government_during_revolution
Definition game.h:94
rs_conversion_logger logger
Definition rssanity.c:540
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:122
enum free_tech_method free_tech_method
bv_actions diplchance_initial_odds
enum tech_cost_style tech_cost_style
bv_unit_classes cargo
Definition unittype.h:565
const struct unit_type * obsoleted_by
Definition unittype.h:536
const char * style_rule_name(const struct nation_style *pstyle)
Definition style.c:104
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:204
#define music_styles_re_active_iterate_end
Definition style.h:91
#define music_styles_re_active_iterate(_p)
Definition style.h:88
#define styles_re_active_iterate_end
Definition style.h:62
#define styles_re_active_iterate(_p)
Definition style.h:58
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:110
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
Definition tech.c:139
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:181
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:314
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:100
#define advance_re_active_iterate(_p)
Definition tech.h:279
#define A_NEVER
Definition tech.h:51
#define advance_req_iterate(_goal, _padvance)
Definition tech.h:297
@ AR_ROOT
Definition tech.h:110
@ AR_ONE
Definition tech.h:108
@ AR_SIZE
Definition tech.h:111
#define advance_re_active_iterate_end
Definition tech.h:283
#define advance_req_iterate_end
Definition tech.h:301
#define A_NONE
Definition tech.h:43
#define A_LAST
Definition tech.h:45
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:249
#define terrain_re_active_iterate_end
Definition terrain.h:282
#define terrain_animals_iterate(pterrain, _animal)
Definition terrain.h:299
#define is_ocean(pterrain)
Definition terrain.h:195
#define terrain_re_active_iterate(_p)
Definition terrain.h:278
#define terrain_resources_iterate_end
Definition terrain.h:295
#define terrain_resources_iterate(pterrain, _res, _freq)
Definition terrain.h:286
#define terrain_animals_iterate_end
Definition terrain.h:307
const char * goods_rule_name(struct goods_type *pgood)
#define goods_type_re_active_iterate_end
#define goods_type_re_active_iterate(_p)
bool utype_is_cityfounder(const struct unit_type *utype)
Definition unittype.c:2997
struct unit_type * get_role_unit(int role, int role_index)
Definition unittype.c:2279
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:224
int num_role_units(int role)
Definition unittype.c:2229
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1604
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1667
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773
#define unit_type_re_active_iterate(_p)
Definition unittype.h:875
#define utype_class(_t_)
Definition unittype.h:756
#define unit_class_iterate(_p)
Definition unittype.h:916
#define unit_class_re_active_iterate_end
Definition unittype.h:932
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define unit_type_iterate(_p)
Definition unittype.h:863
#define unit_class_re_active_iterate(_p)
Definition unittype.h:928
#define UNIT_MAX_PARADROP_RANGE
Definition unittype.h:56
#define uclass_index(_c_)
Definition unittype.h:749
#define unit_class_iterate_end
Definition unittype.h:923
#define unit_type_iterate_end
Definition unittype.h:870
#define unit_type_re_active_iterate_end
Definition unittype.h:879