Freeciv-3.4
Loading...
Searching...
No Matches
rulesave.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 "registry.h"
21#include "string_vector.h"
22
23/* common */
24#include "accessarea.h"
25#include "achievements.h"
26#include "counters.h"
27#include "game.h"
28#include "government.h"
29#include "map.h"
30#include "movement.h"
31#include "multipliers.h"
32#include "nation.h"
33#include "rgbcolor.h"
34#include "sex.h"
35#include "specialist.h"
36#include "style.h"
37#include "tiledef.h"
38#include "unittype.h"
39#include "version.h"
40
41/* server */
42#include "ruleload.h"
43#include "settings.h"
44
45/* tools/ruleutil */
46#include "comments.h"
47
48#include "rulesave.h"
49
50/* Ruleset format version */
51/*
52 * 1 - Freeciv-2.6
53 * 10 - Freeciv-3.0
54 * 20 - Freeciv-3.1
55 * 30 - Freeciv-3.2
56 * 40 - Freeciv-3.3
57 */
58#define FORMAT_VERSION RSFORMAT_CURRENT
59
60/**********************************************************************/
63static struct section_file *create_ruleset_file(const char *rsname,
64 const char *rstype)
65{
66 struct section_file *sfile = secfile_new(TRUE);
67 char buf[500];
68
70
71 if (rsname != nullptr && rsname[0] != '\0') {
72 fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);
73 } else {
74 fc_snprintf(buf, sizeof(buf), "Template %s data for Freeciv", rstype);
75 }
76
77 secfile_insert_str(sfile, buf, "datafile.description");
78 secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
79 secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
80 secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");
81
82 return sfile;
83}
84
85/**********************************************************************/
88static bool save_default_int(struct section_file *sfile, int value,
89 int default_value, const char *path,
90 const char *entry)
91{
92 if (value != default_value) {
93 if (entry != nullptr) {
94 secfile_insert_int(sfile, value,
95 "%s.%s", path, entry);
96 } else {
97 secfile_insert_int(sfile, value,
98 "%s", path);
99 }
100 }
101
102 return TRUE;
103}
104
105/**********************************************************************/
108static bool save_default_bool(struct section_file *sfile, bool value,
109 bool default_value, const char *path,
110 const char *entry)
111{
112 if ((value && !default_value)
113 || (!value && default_value)) {
114 if (entry != nullptr) {
115 secfile_insert_bool(sfile, value,
116 "%s.%s", path, entry);
117 } else {
118 secfile_insert_bool(sfile, value,
119 "%s", path);
120 }
121 }
122
123 return TRUE;
124}
125
126/**********************************************************************/
129static bool save_name_translation(struct section_file *sfile,
130 struct name_translation *name,
131 const char *path)
132{
133 struct entry *mod_entry;
134
137 "%s.name", path);
141 secfile_insert_str(sfile,
143 "%s.rule_name", path);
144 }
145
146 return TRUE;
147}
148
149/**********************************************************************/
152static bool save_reqs_vector(struct section_file *sfile,
153 const struct requirement_vector *reqs,
154 const char *path, const char *entry)
155{
156 int i;
157 bool includes_negated = FALSE;
159 bool includes_quiet = FALSE;
160
162 if (!preq->present) {
164 }
165 if (preq->survives) {
167 }
168 if (preq->quiet) {
170 }
172
173 i = 0;
175 secfile_insert_str(sfile,
176 universals_n_name(preq->source.kind),
177 "%s.%s%d.type", path, entry, i);
178 secfile_insert_str(sfile,
179 universal_rule_name(&(preq->source)),
180 "%s.%s%d.name", path, entry, i);
181 secfile_insert_str(sfile,
182 req_range_name(preq->range),
183 "%s.%s%d.range", path, entry, i);
184
185 if (includes_surviving) {
187 preq->survives,
188 "%s.%s%d.survives", path, entry, i);
189 }
190
191 if (includes_negated) {
193 preq->present,
194 "%s.%s%d.present", path, entry, i);
195 }
196
197 if (includes_quiet) {
199 preq->quiet,
200 "%s.%s%d.quiet", path, entry, i);
201 }
202
203 i++;
205
206 return TRUE;
207}
208
209/**********************************************************************/
212static bool save_tech_list(struct section_file *sfile, int *input,
213 const char *path, const char *entry)
214{
215 const char *tech_names[MAX_NUM_TECH_LIST];
216 int set_count;
217 int i;
218
219 set_count = 0;
220 for (i = 0; input[i] != A_LAST && i < MAX_NUM_TECH_LIST; i++) {
222 }
223
224 if (set_count > 0) {
226 "%s.%s", path, entry);
227 }
228
229 return TRUE;
230}
231
232/**********************************************************************/
235static bool save_tech_ref(struct section_file *sfile,
236 const struct advance *padv,
237 const char *path, const char *entry)
238{
239 if (padv == A_NEVER) {
240 secfile_insert_str(sfile, "Never", "%s.%s", path, entry);
241 } else {
243 "%s.%s", path, entry);
244 }
245
246 return TRUE;
247}
248
249/**********************************************************************/
252static bool save_terrain_ref(struct section_file *sfile,
253 const struct terrain *save,
254 const struct terrain *pthis,
255 const char *path, const char *entry)
256{
257 if (save == nullptr) {
258 secfile_insert_str(sfile, "none", "%s.%s", path, entry);
259 } else if (save == pthis) {
260 secfile_insert_str(sfile, "yes", "%s.%s", path, entry);
261 } else {
263 "%s.%s", path, entry);
264 }
265
266 return TRUE;
267}
268
269/**********************************************************************/
272static bool save_gov_ref(struct section_file *sfile,
273 const struct government *gov,
274 const char *path, const char *entry)
275{
276 secfile_insert_str(sfile, government_rule_name(gov), "%s.%s", path, entry);
277
278 return TRUE;
279}
280
281/**********************************************************************/
285static bool save_building_list(struct section_file *sfile, int *input,
286 const char *path, const char *entry)
287{
289 int set_count;
290 int i;
291
292 set_count = 0;
293 for (i = 0; input[i] != B_LAST && i < MAX_NUM_BUILDING_LIST; i++) {
295 }
296
297 if (set_count > 0) {
299 "%s.%s", path, entry);
300 }
301
302 return TRUE;
303}
304
305/**********************************************************************/
309static bool save_unit_list(struct section_file *sfile, struct unit_type **input,
310 const char *path, const char *entry)
311{
312 const char *unit_names[MAX_NUM_UNIT_LIST];
313 int set_count;
314 int i;
315
316 set_count = 0;
317 for (i = 0; input[i] != nullptr && i < MAX_NUM_UNIT_LIST; i++) {
319 }
320
321 if (set_count > 0) {
323 "%s.%s", path, entry);
324 }
325
326 return TRUE;
327}
328
329/**********************************************************************/
332static bool save_uclass_vec(struct section_file *sfile,
333 bv_unit_classes *bits,
334 const char *path, const char *entry,
335 bool unreachable_only)
336{
337 const char *class_names[UCL_LAST];
338 int classes = 0;
339
341 if (BV_ISSET(*(bits), uclass_index(pcargo))
343 || !unreachable_only)) {
345 }
347
348 if (classes > 0) {
350 "%s.%s", path, entry);
351 }
352
353 return TRUE;
354}
355
356/**********************************************************************/
359static bool save_strvec(struct section_file *sfile,
360 struct strvec *to_save,
361 const char *path, const char *entry)
362{
363 if (to_save != nullptr) {
365 const char *sections[sect_count];
366 int i;
367
368 for (i = 0; i < sect_count; i++) {
369 sections[i] = strvec_get(to_save, i);
370 }
371
372 secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
373 }
374
375 return TRUE;
376}
377
378/**********************************************************************/
381static bool save_ruleset_file(struct section_file *sfile, const char *filename)
382{
383 return secfile_save(sfile, filename, 0, FZ_PLAIN);
384}
385
386/**********************************************************************/
389static bool save_buildings_ruleset(const char *filename, const char *name)
390{
391 struct section_file *sfile = create_ruleset_file(name, "building");
392 int sect_idx;
393 int i;
394 bool uflags_building = FALSE;
395
396 if (sfile == nullptr) {
397 return FALSE;
398 }
399
400 for (i = 0; i < MAX_NUM_USER_BUILDING_FLAGS; i++) {
402 const char *helptxt = impr_flag_helptxt(i + IF_USER_FLAG_1);
403
404 if (flagname != nullptr) {
405 if (!uflags_building) {
408 }
409
410 secfile_insert_str(sfile, flagname, "control.building_flags%d.name", i);
411
412 /* Save the user flag help text even when it is undefined. That makes
413 * the formatting code happy. The resulting "" is ignored when the
414 * ruleset is loaded. */
415 secfile_insert_str(sfile, helptxt,
416 "control.building_flags%d.helptxt", i);
417 }
418 }
419
420 comment_buildings(sfile);
421
422 sect_idx = 0;
424 if (!pb->ruledit_disabled) {
425 char path[512];
426 const char *flag_names[IF_COUNT];
427 int set_count;
428 int flagi;
429
430 fc_snprintf(path, sizeof(path), "building_%d", sect_idx++);
431
432 save_name_translation(sfile, &(pb->name), path);
433
435 "%s.genus", path);
436
437 if (strcmp(pb->graphic_str, "-")) {
438 secfile_insert_str(sfile, pb->graphic_str, "%s.graphic", path);
439 }
440 if (strcmp(pb->graphic_alt, "-")) {
441 secfile_insert_str(sfile, pb->graphic_alt, "%s.graphic_alt", path);
442 }
443 if (strcmp(pb->graphic_alt2, "-")) {
444 secfile_insert_str(sfile, pb->graphic_alt2, "%s.graphic_alt2", path);
445 }
446 if (strcmp(pb->soundtag, "-")) {
447 secfile_insert_str(sfile, pb->soundtag, "%s.sound", path);
448 }
449 if (strcmp(pb->soundtag_alt, "-")) {
450 secfile_insert_str(sfile, pb->soundtag_alt, "%s.sound_alt", path);
451 }
452 if (strcmp(pb->soundtag_alt2, "-")) {
453 secfile_insert_str(sfile, pb->soundtag_alt2, "%s.sound_alt2", path);
454 }
455
456 save_reqs_vector(sfile, &(pb->reqs), path, "reqs");
457 save_reqs_vector(sfile, &(pb->obsolete_by), path, "obsolete_by");
458
459 secfile_insert_int(sfile, pb->build_cost, "%s.build_cost", path);
460 secfile_insert_int(sfile, pb->upkeep, "%s.upkeep", path);
461 secfile_insert_int(sfile, pb->sabotage, "%s.sabotage", path);
462
463 set_count = 0;
464 for (flagi = 0; flagi < IF_COUNT; flagi++) {
467 }
468 }
469
470 if (set_count > 0) {
472 "%s.flags", path);
473 }
474
475 save_strvec(sfile, pb->helptext, path, "helptext");
476 }
478
479 return save_ruleset_file(sfile, filename);
480}
481
482/**********************************************************************/
485static bool save_styles_ruleset(const char *filename, const char *name)
486{
487 struct section_file *sfile = create_ruleset_file(name, "styles");
488 int sect_idx;
489 int i;
490
491 if (sfile == nullptr) {
492 return FALSE;
493 }
494
495 comment_styles(sfile);
496
497 sect_idx = 0;
499 char path[512];
500
501 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
502
503 save_name_translation(sfile, &(pstyle->name), path);
505
506 comment_citystyles(sfile);
507
508 sect_idx = 0;
509 for (i = 0; i < game.control.num_city_styles; i++) {
510 char path[512];
511
512 fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++);
513
514 save_name_translation(sfile, &(city_styles[i].name), path);
515
516 secfile_insert_str(sfile, city_styles[i].graphic, "%s.graphic", path);
517 secfile_insert_str(sfile, city_styles[i].graphic_alt, "%s.graphic_alt", path);
518 if (strcmp(city_styles[i].citizens_graphic, "-")) {
519 secfile_insert_str(sfile, city_styles[i].citizens_graphic,
520 "%s.citizens_graphic", path);
521 }
522
523 save_reqs_vector(sfile, &(city_styles[i].reqs), path, "reqs");
524 }
525
526 comment_musicstyles(sfile);
527
528 sect_idx = 0;
530 char path[512];
531
532 fc_snprintf(path, sizeof(path), "musicstyle_%d", sect_idx++);
533
534 secfile_insert_str(sfile, pmus->music_peaceful, "%s.music_peaceful", path);
535 secfile_insert_str(sfile, pmus->music_combat, "%s.music_combat", path);
536
537 save_reqs_vector(sfile, &(pmus->reqs), path, "reqs");
539
540 return save_ruleset_file(sfile, filename);
541}
542
543/**********************************************************************/
550 const int aap,
551 const char *uflags_path,
552 bool (*unexpected_req)(
553 const struct requirement *preq))
554{
556 size_t i;
557 size_t ret;
558
559 const struct action_auto_perf *auto_perf =
561
562 i = 0;
564 fc_assert(req->range == REQ_RANGE_LOCAL);
565
566 if (req->source.kind == VUT_UTFLAG) {
567 fc_assert(!req->present);
568
569 protecor_flag[i++] = req->source.value.unitflag;
570 } else if (unexpected_req(req)) {
571 struct astring astr;
572
573 log_error("Can't handle action auto performer requirement %s",
574 req_to_fstring(req, &astr));
575 astr_free(&astr);
576
577 return FALSE;
578 }
580
583 "%s", uflags_path);
584
585 if (ret != i) {
586 log_error("%s: didn't save all unit type flags.", uflags_path);
587
588 return FALSE;
589 }
590
591 return TRUE;
592}
593
594/**********************************************************************/
600static bool save_action_auto_actions(struct section_file *sfile,
601 const int aap,
602 const char *actions_path)
603{
605 size_t i, j;
606 size_t ret;
607
608 const struct action_auto_perf *auto_perf
610
611 for (i = 0, j = 0;
612 i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
613 i++) {
614 struct action *paction = action_by_number(auto_perf->alternatives[i]);
615
617 /* Don't mention non enabled actions. */
618 continue;
619 }
620
621 /* This action is included in the output. */
622 unit_acts[j] = auto_perf->alternatives[i];
623 j++;
624 }
625
628 "%s", actions_path);
629
630 if (ret != j) {
631 log_error("%s: didn't save all actions.", actions_path);
632
633 return FALSE;
634 }
635
636 return TRUE;
637}
638
639/**********************************************************************/
643static bool unexpected_non_otype(const struct requirement *req)
644{
645 return !(req->source.kind == VUT_OTYPE && req->present);
646}
647
648/**********************************************************************/
653static bool save_muuk_action_auto(struct section_file *sfile,
654 const int aap,
655 const char *item)
656{
657 char uflags_path[100];
658 char action_path[100];
659
661 "missing_unit_upkeep.%s_protected", item);
663 "missing_unit_upkeep.%s_unit_act", item);
664
668}
669
670/**********************************************************************/
673static bool save_cities_ruleset(const char *filename, const char *name)
674{
675 struct section_file *sfile = create_ruleset_file(name, "cities");
676 int sect_idx;
677
678 if (sfile == nullptr) {
679 return FALSE;
680 }
681
682 comment_specialists(sfile);
683
684 sect_idx = 0;
687 char path[512];
688
689 fc_snprintf(path, sizeof(path),
691 ? "super_specialist_%d" : "specialist_%d", sect_idx++);
692
693 save_name_translation(sfile, &(s->name), path);
694
697 "%s.short_name", path);
698 }
699
700 save_reqs_vector(sfile, &(s->reqs), path, "reqs");
701
702 secfile_insert_str(sfile, s->graphic_str, "%s.graphic", path);
703 if (strcmp(s->graphic_alt, "-")) {
704 secfile_insert_str(sfile, s->graphic_alt, "%s.graphic_alt", path);
705 }
706
707 save_strvec(sfile, s->helptext, path, "helptext");
708
710
713 "parameters.celebrate_size_limit");
714 }
717 "parameters.add_to_size_limit");
718 }
721 "parameters.angry_citizens");
722 }
725 "parameters.changable_tax");
726 }
727 if (game.info.forced_science != 0) {
729 "parameters.forced_science");
730 }
731 if (game.info.forced_luxury != 100) {
733 "parameters.forced_luxury");
734 }
735 if (game.info.forced_gold != 0) {
737 "parameters.forced_gold");
738 }
741 "parameters.vision_reveal_tiles");
742 }
743 if (game.info.pop_report_zeroes != 1) {
745 "parameters.pop_report_zeroes");
746 }
747
750 "citizen.nationality", nullptr);
753 "citizen.ubuilder_nationality", nullptr);
756 "citizen.convert_speed", nullptr);
757 if (game.info.conquest_convert_pct != 0) {
759 "citizen.conquest_convert_pct");
760 }
761
764 "citizen.partisans_pct");
765 }
766
768 "food");
771 "missing_unit_upkeep.food_wipe");
772 }
773
775 "gold");
778 "missing_unit_upkeep.gold_wipe");
779 }
780
782 "shield");
785 "missing_unit_upkeep.shield_wipe");
786 }
787
788 return save_ruleset_file(sfile, filename);
789}
790
791/**************************************************************************
792 Effect saving callback data structure.
793**************************************************************************/
794typedef struct {
795 int idx;
798
799/**********************************************************************/
802static bool effect_save(struct effect *peffect, void *data)
803{
805 char path[512];
806
807 if (peffect->rulesave.do_not_save) {
808 /* Is supposed to be skipped. */
809 return TRUE;
810 }
811
812 fc_snprintf(path, sizeof(path), "effect_%d", cbdata->idx++);
813
816 "%s.type", path);
817 secfile_insert_int(cbdata->sfile, peffect->value, "%s.value", path);
818
819 save_reqs_vector(cbdata->sfile, &peffect->reqs, path, "reqs");
820
821 if (peffect->rulesave.comment != nullptr) {
822 secfile_insert_str(cbdata->sfile, peffect->rulesave.comment,
823 "%s.comment", path);
824 }
825
826 return TRUE;
827}
828
829/**********************************************************************/
832static bool save_effects_ruleset(const char *filename, const char *name)
833{
834 struct section_file *sfile = create_ruleset_file(name, "effect");
835 effect_cb_data data;
836 int i;
837 int sidx;
838
839 if (sfile == nullptr) {
840 return FALSE;
841 }
842
843 data.idx = 0;
844 data.sfile = sfile;
845
846 comment_ueffs(sfile);
847
848 sidx = 0;
849 for (i = EFT_USER_EFFECT_1 ; i <= EFT_USER_EFFECT_LAST; i++) {
850 enum effect_type val = user_effect_ai_valued_as(i);
851
852 if (val != i) {
853 char path[512];
854
855 fc_snprintf(path, sizeof(path), "ueff_%d", sidx++);
856
858 "%s.type", path);
860 "%s.ai_valued_as", path);
861 }
862 }
863
864 comment_effects(sfile);
865
866 if (!iterate_effect_cache(effect_save, &data)) {
867 return FALSE;
868 }
869
870 return save_ruleset_file(sfile, filename);
871}
872
873/**********************************************************************/
876static bool save_action_max_range(struct section_file *sfile,
877 action_id act)
878{
879 struct action *paction = action_by_number(act);
880
881 if (paction->max_distance == ACTION_DISTANCE_UNLIMITED) {
883 "actions.%s",
884 action_max_range_ruleset_var_name(act)) != nullptr;
885 } else {
888 "actions",
890 }
891}
892
893/**********************************************************************/
896static bool save_action_range(struct section_file *sfile, action_id act)
897{
898 struct action *paction = action_by_number(act);
899
900 if (action_min_range_ruleset_var_name(act) != nullptr) {
901 /* Min range can be loaded from the ruleset. */
902 save_default_int(sfile,
903 paction->min_distance,
905 "actions",
907 }
908
909 if (action_max_range_ruleset_var_name(act) != nullptr) {
910 /* Max range can be loaded from the ruleset. */
911 if (!save_action_max_range(sfile, act)) {
912 return FALSE;
913 }
914 }
915
916 return TRUE;
917}
918
919/**********************************************************************/
922static bool save_action_kind(struct section_file *sfile, action_id act)
923{
924 if (action_target_kind_ruleset_var_name(act) != nullptr) {
925 struct action *paction = action_by_number(act);
926
927 /* Target kind can be loaded from the ruleset. */
929 /* Don't save the default for actions that aren't enabled. */
930 return TRUE;
931 }
932
936 "actions.%s",
938 }
939
940 return TRUE;
941}
942
943/**********************************************************************/
947 action_id act)
948{
950 struct action *paction = action_by_number(act);
951
952 /* Actor consumption can be loaded from the ruleset. */
954 /* Don't save value for actions that aren't enabled. */
955 return TRUE;
956 }
957
958 save_default_bool(sfile,
961 "actions",
963 }
964
965 return TRUE;
966}
967
968/**********************************************************************/
971static bool save_action_blocked_by(struct section_file *sfile,
972 struct action *paction)
973{
975 char comment[1024];
976 int i = 0;
977
979 /* Action blocked by shouldn't be written to the ruleset for this
980 * action. */
981 return TRUE;
982 }
983
985 /* Don't save value for actions that aren't enabled. */
986 return TRUE;
987 }
988
989 fc_snprintf(comment, sizeof(comment),
990 "Forbid \"%s\" if any one of the listed actions are legal.",
992
995
997 /* Don't save value for actions that aren't enabled. */
998 continue;
999 }
1000
1001 if (BV_ISSET(paction->blocked_by, blocker_id)) {
1003 i++;
1004 }
1006
1008 sfile, &action_vec, i, gen_action, comment, "actions.%s",
1010 != i) {
1011 log_error("Didn't save all %s blocking actions.",
1013
1014 return FALSE;
1015 }
1016
1017 return TRUE;
1018}
1019
1020/**********************************************************************/
1025 int performer_slot,
1026 struct action *paction)
1027{
1028 char action_list_path[100];
1029
1031 /* Not relevant. */
1032 return TRUE;
1033 }
1034
1035 if (!action_is_in_use(paction)) {
1036 /* Don't save value for actions that aren't enabled. */
1037 return TRUE;
1038 }
1039
1041 "actions.%s",
1044 return FALSE;
1045 }
1046
1047 return TRUE;
1048}
1049
1050/**********************************************************************/
1053static bool save_bv_actions(struct section_file *sfile,
1054 bv_actions content,
1055 const char *path)
1056{
1058 int i = 0;
1059
1060 action_iterate(act_id) {
1061 struct action *paction = action_by_number(act_id);
1062
1063 if (!action_is_in_use(paction)) {
1064 /* Don't save value for actions that aren't enabled. */
1065 continue;
1066 }
1067
1068 if (BV_ISSET(content, act_id)) {
1069 action_vec[i] = act_id;
1070 i++;
1071 }
1073
1075 "%s", path) != i) {
1076 log_error("Didn't save all of %s.", path);
1077
1078 return FALSE;
1079 }
1080
1081 return TRUE;
1082}
1083/**********************************************************************/
1086static bool save_actions_ruleset(const char *filename, const char *name)
1087{
1088 struct section_file *sfile = create_ruleset_file(name, "actions");
1090 int i = 0;
1091 int sect_idx = 0;
1092
1093 /* TODO: move action logic from save_game_ruleset to here */
1094 if (sfile == nullptr) {
1095 return FALSE;
1096 }
1097 {
1098 /* Action auto performers aren't ready to be exposed in the ruleset
1099 * yet. The behavior when two action auto performers for the same
1100 * cause can fire isn't set in stone yet. How is one of them chosen?
1101 * What if all the actions of the chosen action auto performer turned
1102 * out to be illegal but one of the other action auto performers that
1103 * fired has legal actions? These issues can decide what other action
1104 * rules action auto performers can represent in the future. Deciding
1105 * should therefore wait until a rule needs action auto performers to
1106 * work a certain way. */
1107 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
1108 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
1109 * requirement vector to the ruleset. */
1110 const struct action_auto_perf *auto_perf =
1112
1113 comment_auto_attack(sfile);
1114
1115 save_reqs_vector(sfile, &auto_perf->reqs,
1116 "auto_attack", "if_attacker");
1117
1119 "auto_attack.attack_actions");
1120 }
1121
1124 "actions.diplchance_initial_odds")) {
1125 return FALSE;
1126 }
1127
1131 log_error("Didn't save all post success forced actions.");
1132 return FALSE;
1133 }
1134
1138 log_error("Didn't save all post success forced actions.");
1139 return FALSE;
1140 }
1141
1144 log_error("Didn't save all post success forced actions.");
1145 return FALSE;
1146 }
1147
1150 log_error("Didn't save all post success forced actions.");
1151 return FALSE;
1152 }
1153
1155 "actions.escape_city")) {
1156 log_error("Didn't save all escape city forced actions.");
1157 return FALSE;
1158 }
1159
1161 "actions.unit_stack_death")) {
1162 log_error("Didn't save all escape unit stack death forced actions.");
1163 return FALSE;
1164 }
1165
1168 "actions.poison_empties_food_stock", nullptr);
1169
1172 "actions.steal_maps_reveals_all_cities", nullptr);
1173
1174 action_iterate(act_id) {
1175 struct action *act = action_by_number(act_id);
1176
1177 save_action_kind(sfile, act_id);
1178 save_action_range(sfile, act_id);
1180 save_action_blocked_by(sfile, act);
1182
1184
1185 i = 0;
1186 action_iterate(act) {
1187 if (action_by_number(act)->quiet) {
1188 action_vec[i] = act;
1189 i++;
1190 }
1192
1194 "actions.quiet_actions") != i) {
1195 log_error("Didn't save all quiet actions.");
1196
1197 return FALSE;
1198 }
1199
1200 comment_actions(sfile);
1201 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
1202 struct action *paction = action_by_number(i);
1203
1204 if (!action_is_in_use(paction)) {
1205 /* Don't mention non enabled actions. */
1206 continue;
1207 }
1208
1209 if (paction->configured) {
1210 char path[512];
1211 const char *ui_name;
1212
1213 fc_snprintf(path, sizeof(path), "action_%d", i);
1214
1216 "%s.action", path);
1217
1218 if (!action_id_is_internal(i)) {
1219 ui_name = paction->ui_name;
1220
1221 if (ui_name == nullptr) {
1222 fc_assert(ui_name != nullptr);
1223
1224 return FALSE;
1225 }
1226
1229 "%s.ui_name", path);
1230 }
1231 }
1232 }
1233 }
1234
1235 comment_enablers(sfile);
1236 sect_idx = 0;
1238 char path[512];
1239
1240 if (pae->rulesave.ruledit_disabled) {
1241 continue;
1242 }
1243
1244 fc_snprintf(path, sizeof(path), "enabler_%d", sect_idx++);
1245
1247 "%s.action", path);
1248
1249 save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs");
1250 save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs");
1251
1252 if (pae->rulesave.comment != nullptr) {
1253 secfile_insert_str(sfile, pae->rulesave.comment, "%s.comment", path);
1254 }
1256
1257 return save_ruleset_file(sfile, filename);
1258}
1259
1260/**********************************************************************/
1263static bool save_game_ruleset(const char *filename, const char *name)
1264{
1265 struct section_file *sfile = create_ruleset_file(name, "game");
1266 int sect_idx;
1267 int col_idx;
1268 int set_count;
1269 enum gameloss_style gs;
1270 const char *style_names[32]; /* FIXME: Should determine max length automatically.
1271 * currently it's 3 (bits 0,1, and 2) so there's plenty of
1272 * safety margin here. */
1273 const char *tnames[game.server.ruledit.named_teams];
1274 enum trade_route_type trt;
1275 int i;
1276 bool locks;
1277
1278 if (sfile == nullptr) {
1279 return FALSE;
1280 }
1281
1282 if (game.server.ruledit.description_file != nullptr) {
1284 "ruledit.description_file");
1285 }
1286
1290 "ruledit.std_tileset_compat");
1291 }
1292
1293 if (game.control.preferred_tileset[0] != '\0') {
1295 "tileset.preferred");
1296 }
1297 if (game.control.preferred_soundset[0] != '\0') {
1299 "soundset.preferred");
1300 }
1301 if (game.control.preferred_musicset[0] != '\0') {
1303 "musicset.preferred");
1304 }
1305
1306 secfile_insert_str(sfile, game.control.name, "about.name");
1307 secfile_insert_str(sfile, game.control.version, "about.version");
1308
1309 if (game.control.alt_dir[0] != '\0') {
1310 secfile_insert_str(sfile, game.control.alt_dir, "about.alt_dir");
1311 }
1312
1313 if (game.ruleset_summary != nullptr) {
1314 struct entry *mod_entry;
1315
1317 "about.summary");
1319 }
1320
1321 if (game.ruleset_description != nullptr) {
1322 if (game.server.ruledit.description_file == nullptr) {
1324 "about.description");
1325 } else {
1327 "about.description");
1328 }
1329 }
1330
1331 if (game.ruleset_capabilities != nullptr) {
1333 "about.capabilities");
1334 } else {
1335 secfile_insert_str(sfile, "", "about.capabilities");
1336 }
1337
1339 "options", "global_init_techs");
1341 "options", "global_init_buildings");
1342
1344 FALSE,
1345 "options.popup_tech_help", nullptr);
1348 "civstyle.base_pollution", nullptr);
1349
1350 set_count = 0;
1352 if (game.info.gameloss_style & gs) {
1354 }
1355 }
1356
1357 if (set_count > 0) {
1359
1361 "civstyle.gameloss_style");
1362 }
1363
1366 "civstyle.happy_cost", nullptr);
1369 "civstyle.food_cost", nullptr);
1370 save_default_bool(sfile,
1373 FALSE,
1374 "civstyle.paradrop_to_transport", nullptr);
1377 "civstyle.base_bribe_cost", nullptr);
1380 }
1383 "civstyle.ransom_gold", nullptr);
1386 "civstyle.pillage_select", nullptr);
1389 "civstyle.tech_steal_allow_holes", nullptr);
1392 "civstyle.tech_trade_allow_holes", nullptr);
1395 "civstyle.tech_trade_loss_allow_holes", nullptr);
1398 "civstyle.tech_parasite_allow_holes", nullptr);
1401 "civstyle.tech_loss_allow_holes", nullptr);
1404 "civstyle.upgrade_veteran_loss", nullptr);
1407 "civstyle.autoupgrade_veteran_loss", nullptr);
1408
1410
1413 "civstyle.granary_food_ini");
1414
1417 "civstyle.granary_food_inc", nullptr);
1418
1420 char buffer[256];
1421
1422 fc_snprintf(buffer, sizeof(buffer),
1423 "civstyle.min_city_center_%s",
1425
1428 buffer, nullptr);
1430
1433 "civstyle.init_vis_radius_sq", nullptr);
1436 "civstyle.init_city_radius_sq", nullptr);
1437
1439
1442 secfile_insert_str(sfile,
1444 "civstyle.gold_upkeep_style");
1445 }
1447 1, "civstyle.output_granularity", nullptr);
1448
1451 }
1453 FALSE, "civstyle.airlift_from_always_enabled", nullptr);
1455 TRUE, "civstyle.airlift_to_always_enabled", nullptr);
1456
1460 secfile_insert_str(sfile,
1462 "wonder_visibility.small_wonders");
1463 }
1464
1467 "illness.illness_on", nullptr);
1470 "illness.illness_base_factor", nullptr);
1473 "illness.illness_min_size", nullptr);
1476 "illness.illness_trade_infection", nullptr);
1479 "illness.illness_pollution_factor", nullptr);
1480 comment_incite_cost(sfile);
1483 "incite_cost.base_incite_cost", nullptr);
1486 "incite_cost.improvement_factor", nullptr);
1489 "incite_cost.unit_factor", nullptr);
1492 "incite_cost.total_factor", nullptr);
1493
1496 }
1499 "combat_rules.tired_attack", nullptr);
1502 }
1505 "combat_rules.only_killing_makes_veteran", nullptr);
1508 }
1511 "combat_rules.only_real_fight_makes_veteran", nullptr);
1514 }
1517 "combat_rules.combat_odds_scaled_veterancy", nullptr);
1520 }
1523 "combat_rules.damage_reduces_bombard_rate", nullptr);
1526 }
1528 "combat_rules.low_firepower_badwallattacker", nullptr);
1531 }
1533 "combat_rules.low_firepower_pearl_harbor", nullptr);
1536 }
1538 "combat_rules.low_firepower_combat_bonus", nullptr);
1541 }
1543 "combat_rules.low_firepower_nonnat_bombard", nullptr);
1546 }
1549 "combat_rules.nuke_pop_loss_pct", nullptr);
1553 }
1556 "combat_rules.nuke_defender_survival_chance_pct", nullptr);
1559 "borders.radius_sq_city", nullptr);
1562 "borders.size_effect", nullptr);
1566 }
1569 "borders.radius_sq_city_permanent", nullptr);
1570
1573 "research.tech_cost_style");
1576 }
1579 "research.base_tech_cost", nullptr);
1582 }
1585 "research.min_tech_cost", nullptr);
1588 "research.tech_leakage");
1591 "research.tech_upkeep_style");
1594 "research.tech_upkeep_divider", nullptr);
1597 "research.free_tech_method");
1598
1601 "culture.victory_min_points", nullptr);
1604 "culture.victory_lead_pct", nullptr);
1607 }
1610 "culture.migration_pml", nullptr);
1613 }
1616 "culture.history_interest_pml", nullptr);
1619 }
1622 "world_peace.victory_turns", nullptr);
1623
1626 "calendar.skip_year_0", nullptr);
1629 "calendar.start_year", nullptr);
1630 if (game.calendar.calendar_fragments != 0) {
1632 }
1634 0, "calendar.fragments", nullptr);
1635
1636 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
1637 if (game.calendar.calendar_fragment_name[i][0] != '\0') {
1639 "calendar.fragment_name%d", i);
1640 }
1641 }
1642
1645 "calendar.positive_label");
1646 }
1649 "calendar.negative_label");
1650 }
1651
1652 if (game.plr_bg_color != nullptr) {
1653 rgbcolor_save(sfile, game.plr_bg_color, "playercolors.background");
1654 }
1655
1656 col_idx = 0;
1658 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1660
1661
1662 if (game.server.ruledit.named_teams > 0) {
1663 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1665 }
1666
1669 "teams.names");
1670 }
1671
1672 comment_disasters(sfile);
1673
1674 sect_idx = 0;
1676 char path[512];
1678 const char *effect_names[DE_COUNT];
1679
1680 fc_snprintf(path, sizeof(path), "disaster_%d", sect_idx++);
1681
1682 save_name_translation(sfile, &(pd->name), path);
1683 save_reqs_vector(sfile, &(pd->reqs), path, "reqs");
1684 if (pd->frequency != GAME_DEFAULT_DISASTER_FREQ) {
1685 secfile_insert_int(sfile, pd->frequency,
1686 "%s.frequency", path);
1687 }
1688
1689 set_count = 0;
1693 if (BV_ISSET(pd->effects, de)) {
1695 }
1696 }
1697
1698 if (set_count > 0) {
1700 "%s.effects", path);
1701 }
1703
1704 comment_achievements(sfile);
1705
1706 sect_idx = 0;
1708 char path[512];
1709
1710 fc_snprintf(path, sizeof(path), "achievement_%d", sect_idx++);
1711
1712 save_name_translation(sfile, &(pach->name), path);
1713
1715 "%s.type", path);
1716
1717 save_default_bool(sfile, pach->unique,
1719 path, "unique");
1720 save_default_int(sfile, pach->value,
1722 path, "value");
1723 save_default_int(sfile, pach->culture,
1724 0, path, "culture");
1725
1726 secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
1727 if (pach->cons_msg != nullptr) {
1728 secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
1729 }
1730
1732
1734
1735 set_count = 0;
1736 for (trt = 0; trt < TRT_LAST; trt++) {
1739
1740 if (set->trade_pct != 100 || strcmp(cancelling, "Active")) {
1741 char path[256];
1742
1743 fc_snprintf(path, sizeof(path),
1744 "trade.settings%d", set_count++);
1745
1747 "%s.type", path);
1748 secfile_insert_int(sfile, set->trade_pct,
1749 "%s.pct", path);
1751 "%s.cancelling", path);
1753 "%s.bonus", path);
1754 }
1755 }
1756
1758 0, "trade.min_trade_route_val", nullptr);
1759
1761 FALSE, "trade.reveal_trade_partner", nullptr);
1762
1765 "trade.goods_selection");
1766 }
1767
1768 /* Goods */
1769 comment_goods(sfile);
1770
1771 sect_idx = 0;
1773 char path[512];
1774 const char *flag_names[GF_COUNT];
1775 int flagi;
1776
1777 fc_snprintf(path, sizeof(path), "goods_%d", sect_idx++);
1778
1779 save_name_translation(sfile, &(pgood->name), path);
1780
1781 save_reqs_vector(sfile, &(pgood->reqs), path, "reqs");
1782
1783 save_default_int(sfile, pgood->from_pct, 100, path, "from_pct");
1784 save_default_int(sfile, pgood->to_pct, 100, path, "to_pct");
1785 save_default_int(sfile, pgood->onetime_pct, 100, path, "onetime_pct");
1786 save_default_int(sfile, pgood->select_priority, 1, path, "select_priority");
1787 save_default_int(sfile, pgood->replace_priority, 1, path, "replace_priority");
1788
1789 set_count = 0;
1790 for (flagi = 0; flagi < GF_COUNT; flagi++) {
1791 if (goods_has_flag(pgood, flagi)) {
1793 }
1794 }
1795
1796 if (set_count > 0) {
1798 "%s.flags", path);
1799 }
1800
1801 save_strvec(sfile, pgood->helptext, path, "helptext");
1803
1804 {
1805 const struct unit_type *access_unit = access_info_access_unit();
1806
1807 if (access_unit != nullptr) {
1808 secfile_insert_str(sfile, utype_rule_name(access_unit),
1809 "aarea.access_unit");
1810 }
1811 }
1812
1813 /* Clauses */
1814 comment_clauses(sfile);
1815
1816 sect_idx = 0;
1817 for (i = 0; i < CLAUSE_COUNT; i++) {
1818 struct clause_info *info = clause_info_get(i);
1819
1820 if (info->enabled) {
1821 char path[512];
1822
1823 fc_snprintf(path, sizeof(path), "clause_%d", sect_idx++);
1824
1826 "%s.type", path);
1827 save_reqs_vector(sfile, &(info->giver_reqs), path, "giver_reqs");
1828 save_reqs_vector(sfile, &(info->receiver_reqs), path, "receiver_reqs");
1829 save_reqs_vector(sfile, &(info->either_reqs), path, "either_reqs");
1830 }
1831 }
1832
1833 /* Counters */
1834 comment_counters(sfile);
1835
1836 sect_idx = 0;
1838 char path[512];
1839
1840 fc_snprintf(path, sizeof(path), "counter_%d", sect_idx++);
1841
1842 save_name_translation(sfile, &(pcounter->name), path);
1843
1844 save_default_int(sfile, pcounter->def, 0, path, "def");
1845 save_default_int(sfile, pcounter->checkpoint, 0, path, "checkpoint");
1846
1847 secfile_insert_str(sfile, counter_behavior_name(pcounter->type), "%s.type", path);
1848
1849 if (pcounter->helptext != nullptr
1850 && strvec_size(pcounter->helptext) > 0) {
1851 save_strvec(sfile, pcounter->helptext, "%s.helptext", path);
1852 }
1854
1855 locks = FALSE;
1858 locks = TRUE;
1859 break;
1860 }
1862
1863 set_count = 0;
1865 struct sf_cb_data info = { pset, FALSE };
1866
1869 "settings.set%d.name", set_count);
1870 switch (setting_type(pset)) {
1871 case SST_BOOL:
1873 "settings.set%d.value", set_count);
1874 break;
1875 case SST_INT:
1877 "settings.set%d.value", set_count);
1878 break;
1879 case SST_STRING:
1881 "settings.set%d.value", set_count);
1882 break;
1883 case SST_ENUM:
1886 "settings.set%d.value", set_count);
1887 break;
1888 case SST_BITWISE:
1891 "settings.set%d.value", set_count);
1892 break;
1893 case SST_COUNT:
1895 secfile_insert_str(sfile, "Unknown setting type",
1896 "settings.set%d.value", set_count);
1897 break;
1898 }
1899
1900 if (locks) {
1902 "settings.set%d.lock", set_count);
1903 }
1904
1905 set_count++;
1906 }
1908
1909 return save_ruleset_file(sfile, filename);
1910}
1911
1912/**********************************************************************/
1915static bool save_governments_ruleset(const char *filename, const char *name)
1916{
1917 struct section_file *sfile = create_ruleset_file(name, "government");
1918 int sect_idx;
1919 bool uflags_government = FALSE;
1920 int i;
1921
1922 if (sfile == nullptr) {
1923 return FALSE;
1924 }
1925
1926 for (i = 0; i < MAX_NUM_USER_GOVERNMENT_FLAGS; i++) {
1928 const char *helptxt = gov_flag_helptxt(i + GOVF_USER_FLAG_1);
1929
1930 if (flagname != nullptr) {
1931 if (!uflags_government) {
1934 }
1935
1936 secfile_insert_str(sfile, flagname, "control.government_flags%d.name", i);
1937
1938 /* Save the user flag help text even when it is undefined. That makes
1939 * the formatting code happy. The resulting "" is ignored when the
1940 * ruleset is loaded. */
1941 secfile_insert_str(sfile, helptxt,
1942 "control.government_flags%d.helptxt", i);
1943 }
1944 }
1945
1946 save_gov_ref(sfile, game.government_during_revolution, "governments",
1947 "during_revolution");
1948
1949 comment_govs(sfile);
1950
1951 sect_idx = 0;
1953 char path[512];
1954 struct ruler_title *prtitle;
1955 const char *flag_names[TF_COUNT];
1956 int set_count;
1957 int flagi;
1958
1959 fc_snprintf(path, sizeof(path), "government_%d", sect_idx++);
1960
1961 save_name_translation(sfile, &(pg->name), path);
1962
1963 secfile_insert_str(sfile, pg->graphic_str, "%s.graphic", path);
1964 secfile_insert_str(sfile, pg->graphic_alt, "%s.graphic_alt", path);
1965 secfile_insert_str(sfile, pg->sound_str, "%s.sound", path);
1966 secfile_insert_str(sfile, pg->sound_alt, "%s.sound_alt", path);
1967
1968 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1969
1970 if (pg->ai.better != nullptr) {
1971 save_gov_ref(sfile, pg->ai.better, path,
1972 "ai_better");
1973 }
1974
1975 ruler_title_hash_lookup(pg->ruler_titles, nullptr,
1976 &prtitle);
1977 if (prtitle != nullptr) {
1978 const char *title;
1979
1981 if (title != nullptr) {
1983 "%s.ruler_male_title", path);
1984 }
1985
1987 if (title != nullptr) {
1989 "%s.ruler_female_title", path);
1990 }
1991 }
1992
1993 set_count = 0;
1995 if (BV_ISSET(pg->flags, flagi)) {
1997 }
1998 }
1999
2000 if (set_count > 0) {
2002 "%s.flags", path);
2003 }
2004
2005 save_strvec(sfile, pg->helptext, path, "helptext");
2006
2008
2009 comment_policies(sfile);
2010
2011 sect_idx = 0;
2012 multipliers_iterate(pmul) {
2013 if (!pmul->ruledit_disabled) {
2014 char path[512];
2015
2016 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
2017
2018 save_name_translation(sfile, &(pmul->name), path);
2019
2020 secfile_insert_int(sfile, pmul->start, "%s.start", path);
2021 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
2022 secfile_insert_int(sfile, pmul->step, "%s.step", path);
2023 secfile_insert_int(sfile, pmul->def, "%s.default", path);
2024
2025 save_default_int(sfile, pmul->offset, 0, path, "offset");
2026 save_default_int(sfile, pmul->factor, 100, path, "factor");
2027 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
2028
2029 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
2030
2031 save_strvec(sfile, pmul->helptext, path, "helptext");
2032 }
2034
2035 return save_ruleset_file(sfile, filename);
2036}
2037
2038/**********************************************************************/
2041static bool save_traits(struct trait_limits *traits,
2042 struct trait_limits *default_traits,
2043 struct section_file *sfile,
2044 const char *secname, const char *field_prefix)
2045{
2046 enum trait tr;
2047
2048 /* FIXME: Use specenum trait names without duplicating them here.
2049 * Just needs to take care of case.
2050 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
2051 const char *trait_names[] = {
2052 "expansionist",
2053 "trader",
2054 "aggressive",
2055 "builder",
2056 nullptr
2057 };
2058
2059 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != nullptr;
2060 tr = trait_next(tr)) {
2061 int default_default;
2062
2063 default_default = (traits[tr].min + traits[tr].max) / 2;
2064
2065 if ((default_traits == nullptr && traits[tr].min != TRAIT_DEFAULT_VALUE)
2066 || (default_traits != nullptr && traits[tr].min != default_traits[tr].min)) {
2067 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
2068 trait_names[tr]);
2069 }
2070 if ((default_traits == nullptr && traits[tr].max != TRAIT_DEFAULT_VALUE)
2071 || (default_traits != nullptr && traits[tr].max != default_traits[tr].max)) {
2072 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
2073 trait_names[tr]);
2074 }
2075 if (default_default != traits[tr].fixed) {
2076 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
2077 trait_names[tr]);
2078 }
2079 }
2080
2081 return TRUE;
2082}
2083
2084/**********************************************************************/
2087static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
2088 int sect_idx)
2089{
2090 char path[512];
2091 int max_items = nation_city_list_size(pnat->server.default_cities);
2092 char *city_str[max_items];
2095 const char *list_items[max_items];
2096 int set_count;
2097 int subsect_idx;
2098
2099 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
2100
2101 if (pnat->translation_domain == nullptr) {
2102 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
2103 } else {
2104 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
2105 }
2106
2107 save_name_translation(sfile, &(pnat->adjective), path);
2108 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
2109
2110 set_count = 0;
2112 if (nation_is_in_set(pnat, pset)) {
2114 }
2119 }
2121
2122 if (set_count > 0) {
2123 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
2124 }
2125
2126 set_count = 0;
2127 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
2130 if (set_count > 0) {
2131 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
2132 }
2133
2134 subsect_idx = 0;
2136 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
2137 path, subsect_idx);
2138 secfile_insert_str(sfile,
2141 "%s.leaders%d.sex", path, subsect_idx++);
2143
2144 if (pnat->server.rgb != nullptr) {
2145 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
2146 }
2147
2148 save_traits(pnat->server.traits, game.server.default_traits,
2149 sfile, path, "trait_");
2150
2151 if (!pnat->is_playable) {
2152 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
2153 }
2154
2155 if (pnat->barb_type != NOT_A_BARBARIAN) {
2156 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
2157 "%s.barbarian_type", path);
2158 }
2159
2160 if (strcmp(pnat->flag_graphic_str, "-")) {
2161 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
2162 }
2163 if (strcmp(pnat->flag_graphic_alt, "-")) {
2164 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
2165 }
2166
2167 subsect_idx = 0;
2169 struct ruler_title *prtitle;
2170
2171 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
2173 "%s.ruler_titles%d.government", path, subsect_idx);
2175 "%s.ruler_titles%d.male_title", path, subsect_idx);
2177 "%s.ruler_titles%d.female_title", path, subsect_idx++);
2178 }
2180
2181 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
2182
2183 set_count = 0;
2184 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
2187 if (set_count > 0) {
2188 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
2189 }
2190
2191 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
2192 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
2193 save_unit_list(sfile, pnat->init_units, path, "init_units");
2194
2195 if (pnat->init_government) {
2196 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
2197 "%s.init_government", path);
2198 }
2199
2200 set_count = 0;
2201 nation_city_list_iterate(pnat->server.default_cities, pncity) {
2202 bool list_started = FALSE;
2203
2205 + strlen(")")
2206 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
2207
2210 case NCP_DISLIKE:
2211 strcat(city_str[set_count], " (!river");
2213 break;
2214 case NCP_LIKE:
2215 strcat(city_str[set_count], " (river");
2217 break;
2218 case NCP_NONE:
2219 break;
2220 }
2221
2223 const char *pref = nullptr;
2224
2226 case NCP_DISLIKE:
2227 pref = "!";
2228 break;
2229 case NCP_LIKE:
2230 pref = "";
2231 break;
2232 case NCP_NONE:
2233 pref = nullptr;
2234 break;
2235 }
2236
2237 if (pref != nullptr) {
2238 if (list_started) {
2239 strcat(city_str[set_count], ", ");
2240 } else {
2241 strcat(city_str[set_count], " (");
2243 }
2246 }
2247
2249
2250 if (list_started) {
2251 strcat(city_str[set_count], ")");
2252 }
2253
2255 set_count++;
2257 if (set_count > 0) {
2258 int i;
2259
2260 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
2261
2262 for (i = 0; i < set_count; i++) {
2263 FC_FREE(city_str[i]);
2264 }
2265 }
2266
2267 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
2268
2269 return TRUE;
2270}
2271
2272/**********************************************************************/
2275static bool save_nations_ruleset(const char *filename, const char *name,
2276 struct rule_data *data)
2277{
2278 struct section_file *sfile = create_ruleset_file(name, "nation");
2279
2280 if (sfile == nullptr) {
2281 return FALSE;
2282 }
2283
2284 if (data->nationlist != nullptr || game.server.ruledit.embedded_nations != nullptr) {
2286 if (data->nationlist != nullptr) {
2287 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2288 }
2289 if (game.server.ruledit.embedded_nations != nullptr) {
2290 int i;
2291 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2292
2293 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2294 * resrictions */
2295 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2297 }
2298
2301 "ruledit.embedded_nations");
2302 free(tmp);
2303 }
2304 }
2305
2306 save_traits(game.server.default_traits, nullptr, sfile,
2307 "default_traits", "");
2308
2309 if (data->nationlist == nullptr) {
2310 if (game.server.ruledit.allowed_govs != nullptr) {
2313 "compatibility.allowed_govs");
2314 }
2315 if (game.server.ruledit.allowed_terrains != nullptr) {
2318 "compatibility.allowed_terrains");
2319 }
2320 if (game.server.ruledit.allowed_styles != nullptr) {
2323 "compatibility.allowed_styles");
2324 }
2325 }
2326
2327 if (game.default_government != nullptr) {
2329 "compatibility.default_government");
2330 }
2331
2332 if (data->nationlist != nullptr) {
2333 secfile_insert_include(sfile, data->nationlist);
2334
2335 if (game.server.ruledit.embedded_nations != nullptr) {
2336 int sect_idx;
2337
2338 comment_nations(sfile);
2339
2341 sect_idx++) {
2342 struct nation_type *pnat
2344
2345 if (pnat == nullptr) {
2346 log_error("Embedded nation \"%s\" not found!",
2348 } else {
2349 save_nation(sfile, pnat, sect_idx);
2350 }
2351 }
2352 }
2353 } else {
2354 int sect_idx = 0;
2355
2356 comment_nationsets(sfile);
2357
2359 char path[512];
2360
2361 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2362
2363 /* We don't use save_name_translation() for this as name and rule_name must
2364 * always be saved separately */
2365 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2366 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2367 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2369
2370 comment_nationgroups(sfile);
2371
2372 sect_idx = 0;
2374 char path[512];
2375
2376 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2377
2378 save_name_translation(sfile, &(pgroup->name), path);
2379
2380 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2381 if (pgroup->hidden) {
2382 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2383 }
2385
2386 comment_nations(sfile);
2387
2388 sect_idx = 0;
2390 save_nation(sfile, pnat, sect_idx++);
2392 }
2393
2394 return save_ruleset_file(sfile, filename);
2395}
2396
2397/**********************************************************************/
2400static bool save_techs_ruleset(const char *filename, const char *name)
2401{
2402 struct section_file *sfile = create_ruleset_file(name, "tech");
2403 int i;
2404 int sect_idx;
2406 bool uflags_tech = FALSE;
2407
2408 if (sfile == nullptr) {
2409 return FALSE;
2410 }
2411
2412 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2413 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2414 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2415
2416 if (flagname != nullptr) {
2417 if (!uflags_tech) {
2418 comment_uflags_tech(sfile);
2419 uflags_tech = TRUE;
2420 }
2421
2422 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2423
2424 /* Save the user flag help text even when it is undefined. That makes
2425 * the formatting code happy. The resulting "" is ignored when the
2426 * ruleset is loaded. */
2427 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2428 }
2429 }
2430
2431 comment_tech_classes(sfile);
2432
2433 sect_idx = 0;
2435 char path[512];
2436
2437 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2438
2439 save_name_translation(sfile, &(ptclass->name), path);
2441
2442 comment_techs(sfile);
2443
2444 sect_idx = 0;
2446 if (pa->require[AR_ONE] != A_NEVER) {
2447 char path[512];
2448 const char *flag_names[TF_COUNT];
2449 int set_count;
2450 int flagi;
2451
2452 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2453
2454 save_name_translation(sfile, &(pa->name), path);
2455
2456 if (game.control.num_tech_classes > 0) {
2457 if (pa->tclass != nullptr) {
2459 "%s.class", path);
2460 }
2461 }
2462
2463 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2464 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2465 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2466 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2467 }
2468
2469 save_reqs_vector(sfile, &(pa->research_reqs), path,
2470 "research_reqs");
2471
2472 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2473 if (strcmp("-", pa->graphic_alt)) {
2474 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2475 }
2476 if (pa->bonus_message != nullptr) {
2477 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2478 }
2479
2480 set_count = 0;
2481 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2484 }
2485 }
2486
2487 if (set_count > 0) {
2489 "%s.flags", path);
2490 }
2491 if (pa->cost >= 0) {
2492 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2493 }
2494
2495 save_strvec(sfile, pa->helptext, path, "helptext");
2496 }
2497
2499
2500 return save_ruleset_file(sfile, filename);
2501}
2502
2503/**********************************************************************/
2506static bool save_terrain_ruleset(const char *filename, const char *name)
2507{
2508 struct section_file *sfile = create_ruleset_file(name, "terrain");
2509 int sect_idx;
2510 int i;
2511 bool uflags_terr = FALSE;
2512 bool uflags_extra = FALSE;
2513
2514 if (sfile == nullptr) {
2515 return FALSE;
2516 }
2517
2518 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2520 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2521
2522 if (flagname != nullptr) {
2523 if (!uflags_terr) {
2525 uflags_terr = TRUE;
2526 }
2527
2528 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2529
2530 /* Save the user flag help text even when it is undefined. That makes
2531 * the formatting code happy. The resulting "" is ignored when the
2532 * ruleset is loaded. */
2533 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2534 }
2535 }
2536
2537 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2539 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2540
2541 if (flagname != nullptr) {
2542 if (!uflags_extra) {
2543 /* TODO: Uncomment this, once there's a way to stop
2544 * the comment getting written inside preceding
2545 * terrain flags table. */
2546 /* comment_uflags_extra(sfile); */
2548 }
2549
2550 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2551
2552 /* Save the user flag help text even when it is undefined. That makes
2553 * the formatting code happy. The resulting "" is ignored when the
2554 * ruleset is loaded. */
2555 secfile_insert_str(sfile, helptxt,
2556 "control.extra_flags%d.helptxt", i);
2557 }
2558 }
2559
2560 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2561 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2562 "parameters.ocean_reclaim_requirement");
2563 }
2564 if (terrain_control.land_channel_requirement_pct <= 100) {
2565 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2566 "parameters.land_channel_requirement");
2567 }
2568 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2569 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2570 "parameters.thaw_requirement");
2571 }
2572 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2573 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2574 "parameters.freeze_requirement");
2575 }
2576 if (terrain_control.lake_max_size != 0) {
2577 secfile_insert_int(sfile, terrain_control.lake_max_size,
2578 "parameters.lake_max_size");
2579 }
2580 if (terrain_control.min_start_native_area != 0) {
2581 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2582 "parameters.min_start_native_area");
2583 }
2584 if (terrain_control.move_fragments != 3) {
2585 secfile_insert_int(sfile, terrain_control.move_fragments,
2586 "parameters.move_fragments");
2587 }
2588 if (terrain_control.igter_cost != 1) {
2589 secfile_insert_int(sfile, terrain_control.igter_cost,
2590 "parameters.igter_cost");
2591 }
2592 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2593 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2594 "parameters.pythagorean_diagonal");
2595 }
2598 "parameters.ocean_resources");
2599 }
2600
2601 comment_terrains(sfile);
2602
2603 sect_idx = 0;
2605 char path[512];
2606 char identifier[2];
2607 int r;
2608 const char *flag_names[TER_USER_LAST];
2609 const char *puc_names[UCL_LAST];
2610 int flagi;
2611 int set_count;
2612
2613 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2614
2615 save_name_translation(sfile, &(pterr->name), path);
2616
2617 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2618 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2619 secfile_insert_str(sfile, pterr->graphic_alt2, "%s.graphic_alt2", path);
2620 identifier[0] = pterr->identifier;
2621 identifier[1] = '\0';
2622 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2623
2625 "%s.class", path);
2626
2627 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2628 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2629
2631 if (pterr->output[o] != 0) {
2632 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2634 }
2636
2637 /* Check resource count */
2638 for (r = 0; pterr->resources[r] != nullptr; r++) {
2639 /* Just increasing r as long as there is resources */
2640 }
2641
2642 {
2643 const char *resource_names[r];
2644 bool save_frequencies = FALSE;
2645
2646 r = 0;
2651 }
2653
2655 "%s.resources", path);
2656
2657 if (save_frequencies) {
2658 secfile_insert_int_vec(sfile, pterr->resource_freq, r,
2659 "%s.resource_freq", path);
2660 }
2661 }
2662
2664 if (pterr->road_output_incr_pct[o] != 0) {
2665 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2666 "%s.road_%s_incr_pct", path,
2668 }
2670
2671 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2672 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2673
2674 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2675 "cultivate_result");
2676 secfile_insert_int(sfile, pterr->cultivate_time,
2677 "%s.cultivate_time", path);
2678
2679 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2680 "plant_result");
2681 secfile_insert_int(sfile, pterr->plant_time,
2682 "%s.plant_time", path);
2683
2684 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2685 "%s.irrigation_food_incr", path);
2686 secfile_insert_int(sfile, pterr->irrigation_time,
2687 "%s.irrigation_time", path);
2688
2689 secfile_insert_int(sfile, pterr->mining_shield_incr,
2690 "%s.mining_shield_incr", path);
2691 secfile_insert_int(sfile, pterr->mining_time,
2692 "%s.mining_time", path);
2693
2694 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2695 "transform_result");
2696 secfile_insert_int(sfile, pterr->transform_time,
2697 "%s.transform_time", path);
2698
2699 if (pterr->animal != nullptr) {
2701 "%s.animal", path);
2702 } else {
2703 secfile_insert_str(sfile, "None",
2704 "%s.animal", path);
2705 }
2706
2707 secfile_insert_int(sfile, pterr->placing_time,
2708 "%s.placing_time", path);
2709 secfile_insert_int(sfile, pterr->pillage_time,
2710 "%s.pillage_time", path);
2711
2712 i = 0;
2713 extra_type_iterate(pextra) {
2714 int rmtime = pterr->extra_removal_times[extra_index(pextra)];
2715
2716 if (rmtime != 0) {
2717 secfile_insert_str(sfile, extra_rule_name(pextra),
2718 "%s.extra_settings%d.extra",
2719 path, i);
2721 "%s.extra_settings%d.removal_time",
2722 path, i++);
2723 }
2725
2726 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2727 "warmer_wetter_result");
2728 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2729 "warmer_drier_result");
2730 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2731 "cooler_wetter_result");
2732 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2733 "cooler_drier_result");
2734
2735 set_count = 0;
2736 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2739 }
2740 }
2741
2742 if (set_count > 0) {
2744 "%s.flags", path);
2745 }
2746
2747 {
2749
2753 if (pterr->property[mtp] != 0) {
2754 secfile_insert_int(sfile, pterr->property[mtp],
2755 "%s.property_%s", path,
2757 }
2758 }
2759 }
2760
2761 set_count = 0;
2763 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2765 }
2767
2768 if (set_count > 0) {
2770 "%s.native_to", path);
2771 }
2772
2773 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2774
2775 save_strvec(sfile, pterr->helptext, path, "helptext");
2776
2778
2779 comment_resources(sfile);
2780
2781 sect_idx = 0;
2783 if (!pres->ruledit_disabled) {
2784 char path[512];
2785 char identifier[2];
2786
2787 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2788
2790 "%s.extra", path);
2791
2793 if (pres->data.resource->output[o] != 0) {
2794 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2795 path, get_output_identifier(o));
2796 }
2798
2799 if (pres->data.resource->id_old_save != '\0') {
2800 identifier[0] = pres->data.resource->id_old_save;
2801 identifier[1] = '\0';
2802 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2803 }
2804 }
2806
2807 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2808 "extraui.ui_name_base_fortress");
2809 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2810 "extraui.ui_name_base_airbase");
2811
2812 comment_extras(sfile);
2813
2814 sect_idx = 0;
2816 char path[512];
2817 const char *flag_names[EF_COUNT];
2818 const char *cause_names[EC_COUNT];
2819 const char *puc_names[UCL_LAST];
2820 const char *extra_names[MAX_EXTRA_TYPES];
2821 int flagi;
2822 int causei;
2823 int set_count;
2824 bool worker_cause;
2825
2826 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2827
2828 save_name_translation(sfile, &(pextra->name), path);
2829
2830 secfile_insert_str(sfile, extra_category_name(pextra->category),
2831 "%s.category", path);
2832
2833 set_count = 0;
2834 for (causei = 0; causei < EC_COUNT; causei++) {
2835 if (is_extra_caused_by(pextra, causei)) {
2837 }
2838 }
2839
2840 if (set_count > 0) {
2842 "%s.causes", path);
2843 }
2844
2845 set_count = 0;
2846 for (causei = 0; causei < ERM_COUNT; causei++) {
2847 if (is_extra_removed_by(pextra, causei)) {
2849 }
2850 }
2851
2852 if (set_count > 0) {
2854 "%s.rmcauses", path);
2855 }
2856
2857 if (strcmp(pextra->graphic_str, "-")) {
2858 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2859 }
2860 if (strcmp(pextra->graphic_alt, "-")) {
2861 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2862 }
2863 if (strcmp(pextra->activity_gfx, "-")) {
2864 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2865 }
2866 if (strcmp(pextra->act_gfx_alt, "-")) {
2867 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2868 }
2869 if (strcmp(pextra->act_gfx_alt2, "-")) {
2870 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2871 }
2872 if (strcmp(pextra->rmact_gfx, "-")) {
2873 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2874 }
2875 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2876 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2877 }
2878
2879 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2880 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2881 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2882 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2883
2885 if ((!pextra->buildable && worker_cause)
2886 || (pextra->buildable && !worker_cause)) {
2887 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2888 }
2889 if (!pextra->generated) {
2890 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2891 }
2892 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2893 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2894 if (pextra->build_time_factor != 1) {
2895 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2896 }
2897 if (pextra->removal_time_factor != 1) {
2898 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2899 }
2900 if (pextra->infracost != 0) {
2901 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2902 }
2903 if (pextra->defense_bonus != 0) {
2904 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2905 }
2906 if (pextra->eus != EUS_NORMAL) {
2908 "%s.unit_seen", path);
2909 }
2911 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2912 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2913 }
2915 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2916 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2917 path);
2918 }
2919
2920 set_count = 0;
2922 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2924 }
2926
2927 if (set_count > 0) {
2929 "%s.native_to", path);
2930 }
2931
2932 if (pextra->no_aggr_near_city >= 0) {
2933 secfile_insert_int(sfile, pextra->no_aggr_near_city,
2934 "%s.no_aggr_near_city", path);
2935 }
2936
2937 set_count = 0;
2938 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2939 if (extra_has_flag(pextra, flagi)) {
2941 }
2942 }
2943
2944 if (set_count > 0) {
2946 "%s.flags", path);
2947 }
2948
2949 set_count = 0;
2951 if (!can_extras_coexist(pextra, confl)) {
2953 }
2955
2956 if (set_count > 0) {
2958 "%s.conflicts", path);
2959 }
2960
2961 set_count = 0;
2962 extra_type_iterate(top) {
2963 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2965 }
2967
2968 if (set_count > 0) {
2970 "%s.hidden_by", path);
2971 }
2972
2973 set_count = 0;
2974 extra_type_iterate(top) {
2975 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2977 }
2979
2980 if (set_count > 0) {
2982 "%s.bridged_over", path);
2983 }
2984
2985 save_strvec(sfile, pextra->helptext, path, "helptext");
2986
2988
2989 comment_bases(sfile);
2990
2991 sect_idx = 0;
2993 if (!pextra->ruledit_disabled) {
2994 char path[512];
2995 struct base_type *pbase = extra_base_get(pextra);
2996
2997 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2998
2999 secfile_insert_str(sfile, extra_rule_name(pextra),
3000 "%s.extra", path);
3001
3003 "%s.gui_type", path);
3004
3005 if (pbase->border_sq >= 0) {
3006 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
3007 }
3008 if (pbase->vision_main_sq >= 0) {
3009 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
3010 }
3011 if (pbase->vision_invis_sq >= 0) {
3012 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
3013 }
3014 if (pbase->vision_subs_sq >= 0) {
3015 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
3016 }
3017 }
3019
3020 comment_roads(sfile);
3021
3022 sect_idx = 0;
3024 if (!pextra->ruledit_disabled) {
3025 struct road_type *proad = extra_road_get(pextra);
3026 char path[512];
3027 const char *flag_names[RF_COUNT];
3028 int flagi;
3029 int set_count;
3030
3031 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
3032
3033 secfile_insert_str(sfile, extra_rule_name(pextra),
3034 "%s.extra", path);
3035
3036 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
3037
3038 if (proad->move_mode != RMM_FAST_ALWAYS) {
3039 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
3040 "%s.move_mode", path);
3041 }
3042
3044 if (proad->tile_incr_const[o] != 0) {
3045 secfile_insert_int(sfile, proad->tile_incr_const[o],
3046 "%s.%s_incr_const", path, get_output_identifier(o));
3047 }
3048 if (proad->tile_incr[o] != 0) {
3049 secfile_insert_int(sfile, proad->tile_incr[o],
3050 "%s.%s_incr", path, get_output_identifier(o));
3051 }
3052 if (proad->tile_bonus[o] != 0) {
3053 secfile_insert_int(sfile, proad->tile_bonus[o],
3054 "%s.%s_bonus", path, get_output_identifier(o));
3055 }
3057
3058 switch (proad->compat) {
3059 case ROCO_ROAD:
3060 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
3061 break;
3062 case ROCO_RAILROAD:
3063 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
3064 break;
3065 case ROCO_RIVER:
3066 secfile_insert_str(sfile, "River", "%s.compat_special", path);
3067 break;
3068 case ROCO_NONE:
3069 secfile_insert_str(sfile, "None", "%s.compat_special", path);
3070 break;
3071 }
3072
3074 "%s.gui_type", path);
3075
3076 set_count = 0;
3077 for (flagi = 0; flagi < RF_COUNT; flagi++) {
3078 if (road_has_flag(proad, flagi)) {
3080 }
3081 }
3082
3083 if (set_count > 0) {
3085 "%s.flags", path);
3086 }
3087 }
3089
3090 // comment_tiledefs(sfile);
3091
3092 sect_idx = 0;
3094 char path[512];
3095 const char *extra_names[MAX_EXTRA_TYPES];
3096 int set_count;
3097
3098 fc_snprintf(path, sizeof(path), "tiledef_%d", sect_idx++);
3099
3100 save_name_translation(sfile, &(td->name), path);
3101
3102 set_count = 0;
3103 extra_type_list_iterate(td->extras, pextra) {
3106
3107 if (set_count > 0) {
3109 "%s.extras", path);
3110 }
3112
3113 return save_ruleset_file(sfile, filename);
3114}
3115
3116/**********************************************************************/
3119static bool save_veteran_system(struct section_file *sfile, const char *path,
3120 struct veteran_system *vsystem)
3121{
3122 const char *vlist_name[vsystem->levels];
3123 int vlist_power[vsystem->levels];
3124 int vlist_raise[vsystem->levels];
3125 int vlist_wraise[vsystem->levels];
3126 int vlist_move[vsystem->levels];
3127 int i;
3128
3129 for (i = 0; i < vsystem->levels; i++) {
3130 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
3131 vlist_power[i] = vsystem->definitions[i].power_fact;
3132 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
3133 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
3134 vlist_move[i] = vsystem->definitions[i].move_bonus;
3135 }
3136
3138 "%s.veteran_names", path);
3140 "%s.veteran_power_fact", path);
3142 "%s.veteran_base_raise_chance", path);
3144 "%s.veteran_work_raise_chance", path);
3146 "%s.veteran_move_bonus", path);
3147
3148 return TRUE;
3149}
3150
3151/**********************************************************************/
3154static bool save_combat_bonuses(struct section_file *sfile,
3155 struct unit_type *put,
3156 char *path)
3157{
3158 int i;
3159 bool has_quiet = FALSE;
3160
3162 if (pbonus->quiet) {
3163 has_quiet = TRUE;
3164 }
3166
3167 i = 0;
3168
3171 "%s.bonuses%d.flag", path, i);
3173 "%s.bonuses%d.type", path, i);
3174 secfile_insert_int(sfile, pbonus->value,
3175 "%s.bonuses%d.value", path, i);
3176
3177 if (has_quiet) {
3178 secfile_insert_bool(sfile, pbonus->quiet,
3179 "%s.bonuses%d.quiet", path, i);
3180 }
3181
3182 i++;
3184
3185 return TRUE;
3186}
3187
3188/**********************************************************************/
3191static bool save_units_ruleset(const char *filename, const char *name)
3192{
3193 struct section_file *sfile = create_ruleset_file(name, "unit");
3194 int i;
3195 int sect_idx;
3196 bool uflags_utype = FALSE;
3197 bool uflags_uclass = FALSE;
3198
3199 if (sfile == nullptr) {
3200 return FALSE;
3201 }
3202
3203 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
3205 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
3206
3207 if (flagname != nullptr) {
3208 if (!uflags_utype) {
3209 comment_uflags_utype(sfile);
3211 }
3212
3213 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
3214
3215 /* Save the user flag help text even when it is undefined. That makes
3216 * the formatting code happy. The resulting "" is ignored when the
3217 * ruleset is loaded. */
3218 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
3219 }
3220 }
3221
3222 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
3224 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
3225
3226 if (flagname != nullptr) {
3227 if (!uflags_uclass) {
3228 /* TODO: Uncomment this, once there's a way to stop
3229 * the comment getting written inside preceding
3230 * utype flags table. */
3231 /* comment_uflags_uclass(sfile); */
3233 }
3234
3235 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
3236
3237 /* Save the user flag help text even when it is undefined. That makes
3238 * the formatting code happy. The resulting "" is ignored when the
3239 * ruleset is loaded. */
3240 secfile_insert_str(sfile, helptxt,
3241 "control.class_flags%d.helptxt", i);
3242 }
3243 }
3244
3245 save_veteran_system(sfile, "veteran_system", game.veteran);
3246
3247 comment_uclasses(sfile);
3248
3249 sect_idx = 0;
3251 char path[512];
3252 const char *flag_names[UCF_COUNT];
3253 int flagi;
3254 int set_count;
3255
3256 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
3257
3258 save_name_translation(sfile, &(puc->name), path);
3259
3260 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
3261 "%s.min_speed", path);
3262 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
3263 if (puc->non_native_def_pct != 100) {
3264 secfile_insert_int(sfile, puc->non_native_def_pct,
3265 "%s.non_native_def_pct", path);
3266 }
3267
3268 set_count = 0;
3269 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
3270 if (uclass_has_flag(puc, flagi)) {
3272 }
3273 }
3274
3275 if (set_count > 0) {
3277 "%s.flags", path);
3278 }
3279
3280 save_strvec(sfile, puc->helptext, path, "helptext");
3281
3283
3284 comment_utypes(sfile);
3285
3286 sect_idx = 0;
3288 if (!put->ruledit_disabled) {
3289 char path[512];
3290 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
3291 int flagi;
3292 int set_count;
3293
3294 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
3295
3296 save_name_translation(sfile, &(put->name), path);
3297
3298 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
3299 "%s.class", path);
3300
3301 save_reqs_vector(sfile, &(put->build_reqs), path, "reqs");
3302
3303 if (put->obsoleted_by != nullptr) {
3304 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
3305 "%s.obsolete_by", path);
3306 }
3307
3308 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
3309 if (strcmp("-", put->graphic_alt)) {
3310 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
3311 }
3312 if (strcmp("-", put->graphic_alt2)) {
3313 secfile_insert_str(sfile, put->graphic_alt2, "%s.graphic_alt2", path);
3314 }
3315 if (strcmp("-", put->sound_move)) {
3316 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
3317 }
3318 if (strcmp("-", put->sound_move_alt)) {
3319 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
3320 }
3321 if (strcmp("-", put->sound_fight)) {
3322 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
3323 }
3324 if (strcmp("-", put->sound_fight_alt)) {
3325 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
3326 }
3327
3328 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
3329 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
3330 if (DEFAULT_SPECIALIST < 0 || DEFAULT_SPECIALIST != specialist_index(put->spec_type)) {
3331 secfile_insert_str(sfile, specialist_rule_name(put->spec_type),
3332 "%s.specialist", path);
3333 }
3334 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
3335 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
3336 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
3337 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3338 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3339
3340 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3341 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3342 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3343
3344 if (put->vlayer != V_MAIN) {
3346 "%s.vision_layer", path);
3347 }
3348
3349 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3350 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3351 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3352 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3353
3355 if (put->upkeep[o] != 0) {
3356 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3357 path, get_output_identifier(o));
3358 }
3360
3361 if (put->converted_to != nullptr) {
3362 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3363 "%s.convert_to", path);
3364 }
3365 if (put->convert_time != 1) {
3366 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3367 }
3368
3369 save_combat_bonuses(sfile, put, path);
3370 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3371
3372 if (put->veteran != nullptr) {
3373 save_veteran_system(sfile, path, put->veteran);
3374 }
3375
3376 if (put->paratroopers_range != 0) {
3377 secfile_insert_int(sfile, put->paratroopers_range,
3378 "%s.paratroopers_range", path);
3379 }
3380 if (put->bombard_rate != 0) {
3381 secfile_insert_int(sfile, put->bombard_rate,
3382 "%s.bombard_rate", path);
3383 }
3384 if (put->city_slots != 0) {
3385 secfile_insert_int(sfile, put->city_slots,
3386 "%s.city_slots", path);
3387 }
3388 if (put->city_size != 1) {
3389 secfile_insert_int(sfile, put->city_size,
3390 "%s.city_size", path);
3391 }
3392
3393 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3394 "%s.tp_defense", path);
3395
3396 set_count = 0;
3397 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3398 if (utype_has_flag(put, flagi)) {
3400 }
3401 }
3402
3403 if (set_count > 0) {
3405 "%s.flags", path);
3406 }
3407
3408 set_count = 0;
3409 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3410 if (utype_has_role(put, flagi)) {
3412 }
3413 }
3414
3415 if (set_count > 0) {
3417 "%s.roles", path);
3418 }
3419
3420 save_strvec(sfile, put->helptext, path, "helptext");
3421 }
3423
3424 return save_ruleset_file(sfile, filename);
3425}
3426
3427/**********************************************************************/
3430static bool save_script_lua(const char *filename, const char *name,
3431 const char *buffer)
3432{
3433 if (buffer != nullptr) {
3434 FILE *ffile = fc_fopen(filename, "w");
3435 int full_len = strlen(buffer);
3436 int len;
3437
3438 if (ffile != nullptr) {
3439 len = fwrite(buffer, 1, full_len, ffile);
3440
3441 if (len != full_len) {
3442 return FALSE;
3443 }
3444
3445 fclose(ffile);
3446 } else {
3447 return FALSE;
3448 }
3449 }
3450
3451 return TRUE;
3452}
3453
3454/**********************************************************************/
3457static bool save_luadata(const char *filename)
3458{
3459 if (game.server.luadata != nullptr) {
3460 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3461 }
3462
3463 return TRUE;
3464}
3465
3466/**********************************************************************/
3469bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3470{
3471 if (make_dir(path, DIRMODE_DEFAULT)) {
3472 bool success = TRUE;
3473 char filename[500];
3474
3475 if (success) {
3476 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3477 success = save_buildings_ruleset(filename, name);
3478 }
3479
3480 if (success) {
3481 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3482 success = save_styles_ruleset(filename, name);
3483 }
3484
3485 if (success) {
3486 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3487 success = save_cities_ruleset(filename, name);
3488 }
3489
3490 if (success) {
3491 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3492 success = save_effects_ruleset(filename, name);
3493 }
3494
3495 if (success) {
3496 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3497 success = save_game_ruleset(filename, name);
3498 }
3499
3500 if (success) {
3501 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3503 }
3504
3505 if (success) {
3506 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3507 success = save_nations_ruleset(filename, name, data);
3508 }
3509
3510 if (success) {
3511 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3512 success = save_techs_ruleset(filename, name);
3513 }
3514
3515 if (success) {
3516 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3517 success = save_terrain_ruleset(filename, name);
3518 }
3519
3520 if (success) {
3521 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3522 success = save_units_ruleset(filename, name);
3523 }
3524
3525 if (success) {
3526 fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path);
3527 success = save_actions_ruleset(filename, name);
3528 }
3529
3530 if (success) {
3531 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3533 }
3534
3535 if (success) {
3536 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3538 }
3539
3540 if (success) {
3541 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3542 success = save_luadata(filename);
3543 }
3544
3545 return success;
3546 } else {
3547 log_error(_("Failed to create directory %s"), path);
3548 return FALSE;
3549 }
3550
3551 return TRUE;
3552}
const struct unit_type * access_info_access_unit(void)
Definition accessarea.c:72
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:6396
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7114
void action_array_end(action_id *act_array, int size)
Definition actions.c:5993
bool action_is_in_use(struct action *paction)
Definition actions.c:5899
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7310
const char * action_rule_name(const struct action *action)
Definition actions.c:1237
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:6939
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:6576
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:6765
const char * action_ui_name_default(int act)
Definition actions.c:6028
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:5961
bool action_id_is_internal(action_id act)
Definition actions.c:5937
#define action_enablers_iterate_end
Definition actions.h:283
#define enabler_get_action(_enabler_)
Definition actions.h:186
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:375
#define ACTION_AUTO_POST_BRIBE_UNIT
Definition actions.h:376
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:373
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define NUM_ACTIONS
Definition actions.h:63
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:382
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:381
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:105
#define ACTION_AUTO_POST_WIPE_UNITS
Definition actions.h:383
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:374
#define action_iterate_end
Definition actions.h:218
#define MAX_NUM_ACTIONS
Definition actions.h:62
#define ACTION_AUTO_POST_BRIBE_STACK
Definition actions.h:377
#define action_enablers_iterate(_enabler_)
Definition actions.h:277
#define action_iterate(_act_)
Definition actions.h:214
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:372
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:378
#define ACTION_NONE
Definition actions.h:59
int actres_min_range_default(enum action_result result)
Definition actres.c:377
int actres_max_range_default(enum action_result result)
Definition actres.c:467
void astr_free(struct astring *astr)
Definition astring.c:148
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
const char * get_output_identifier(Output_type_id output)
Definition city.c:619
static const struct city struct citystyle * city_styles
Definition city.c:84
#define output_type_iterate(output)
Definition city.h:846
#define output_type_iterate_end
Definition city.h:852
char * uflags_government
Definition comments.c:54
void comment_borders_radius_permanent(struct section_file *sfile)
Definition comments.c:814
char * uflags_building
Definition comments.c:53
void comment_uflags_utype(struct section_file *sfile)
Definition comments.c:472
void comment_world_peace_turns(struct section_file *sfile)
Definition comments.c:895
void comment_combat_rules_nuke_defender_survival(struct section_file *sfile)
Definition comments.c:778
void comment_roads(struct section_file *sfile)
Definition comments.c:408
void comment_civstyle_granary(struct section_file *sfile)
Definition comments.c:617
void comment_research_tech_leakage(struct section_file *sfile)
Definition comments.c:850
void comment_uclasses(struct section_file *sfile)
Definition comments.c:360
void comment_calendar_fragments(struct section_file *sfile)
Definition comments.c:904
void comment_actions_quiet_actions(struct section_file *sfile)
Definition comments.c:805
void comment_uflags_terrain(struct section_file *sfile)
Definition comments.c:488
void comment_combat_rules_low_fp_pearl_harbor(struct section_file *sfile)
Definition comments.c:739
void comment_citystyles(struct section_file *sfile)
Definition comments.c:424
void comment_std_tileset_compat(struct section_file *sfile)
Definition comments.c:914
void comment_govs(struct section_file *sfile)
Definition comments.c:344
void comment_research_base_tech_cost(struct section_file *sfile)
Definition comments.c:832
void comment_research_tech_cost_style(struct section_file *sfile)
Definition comments.c:823
void comment_combat_rules_only_killing_veteran(struct section_file *sfile)
Definition comments.c:689
void comment_bases(struct section_file *sfile)
Definition comments.c:400
void comment_terrains(struct section_file *sfile)
Definition comments.c:376
void comment_uflags_tech(struct section_file *sfile)
Definition comments.c:504
void comment_file_header(struct section_file *sfile)
Definition comments.c:312
void comment_effects(struct section_file *sfile)
Definition comments.c:440
void comment_actions_dc_initial_odds(struct section_file *sfile)
Definition comments.c:796
void comment_combat_rules_scaled_veterancy(struct section_file *sfile)
Definition comments.c:709
void comment_research_upkeep_style(struct section_file *sfile)
Definition comments.c:859
void comment_disasters(struct section_file *sfile)
Definition comments.c:456
void comment_clauses(struct section_file *sfile)
Definition comments.c:592
void comment_goods(struct section_file *sfile)
Definition comments.c:536
char * uflags_tech
Definition comments.c:52
void comment_civstyle_gameloss_style(struct section_file *sfile)
Definition comments.c:635
char * uflags_extra
Definition comments.c:51
void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
Definition comments.c:644
void comment_extras(struct section_file *sfile)
Definition comments.c:392
void comment_uflags_government(struct section_file *sfile)
Definition comments.c:520
void comment_combat_rules_low_fp_nonnat_bombard(struct section_file *sfile)
Definition comments.c:759
void comment_ueffs(struct section_file *sfile)
Definition comments.c:448
void comment_techs(struct section_file *sfile)
Definition comments.c:336
void comment_nations(struct section_file *sfile)
Definition comments.c:568
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:528
void comment_combat_rules_low_fp_combat_bonus(struct section_file *sfile)
Definition comments.c:749
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:609
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:576
void comment_specialists(struct section_file *sfile)
Definition comments.c:560
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:432
void comment_civstyle_airlift_always(struct section_file *sfile)
Definition comments.c:653
void comment_resources(struct section_file *sfile)
Definition comments.c:384
void comment_civstyle_ransom_gold(struct section_file *sfile)
Definition comments.c:626
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:328
void comment_culture_migration_pml(struct section_file *sfile)
Definition comments.c:886
void comment_combat_rules_only_real_fight_veteran(struct section_file *sfile)
Definition comments.c:699
char * uflags_uclass
Definition comments.c:49
void comment_research_free_tech_method(struct section_file *sfile)
Definition comments.c:868
void comment_combat_rules_nuke_pop_loss(struct section_file *sfile)
Definition comments.c:769
void comment_utypes(struct section_file *sfile)
Definition comments.c:368
char * uflags_utype
Definition comments.c:48
void comment_research_min_tech_cost(struct section_file *sfile)
Definition comments.c:841
void comment_culture_history_interest(struct section_file *sfile)
Definition comments.c:877
void comment_policies(struct section_file *sfile)
Definition comments.c:352
void comment_combat_rules_low_fp_badwallattacker(struct section_file *sfile)
Definition comments.c:729
void comment_achievements(struct section_file *sfile)
Definition comments.c:464
void comment_combat_rules_damage_reduces_bombard_rate(struct section_file *sfile)
Definition comments.c:719
void comment_actions(struct section_file *sfile)
Definition comments.c:544
void comment_counters(struct section_file *sfile)
Definition comments.c:600
void comment_styles(struct section_file *sfile)
Definition comments.c:416
void comment_combat_rules_tired_attack(struct section_file *sfile)
Definition comments.c:680
void comment_uflags_building(struct section_file *sfile)
Definition comments.c:512
void comment_buildings(struct section_file *sfile)
Definition comments.c:320
void comment_enablers(struct section_file *sfile)
Definition comments.c:552
void comment_nationsets(struct section_file *sfile)
Definition comments.c:584
void comment_wonder_visibility_small_wonders(struct section_file *sfile)
Definition comments.c:662
void comment_incite_cost(struct section_file *sfile)
Definition comments.c:671
void comment_auto_attack(struct section_file *sfile)
Definition comments.c:788
char * incite_cost
Definition comments.c:76
#define counters_re_iterate_end
Definition counters.h:75
#define counters_re_iterate(pcount)
Definition counters.h:67
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:292
#define disaster_type_iterate(_p)
Definition disaster.h:82
#define disaster_type_iterate_end
Definition disaster.h:88
struct @22::@23 reqs
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1321
enum effect_type user_effect_ai_valued_as(enum effect_type real)
Definition effects.c:1357
#define EFT_USER_EFFECT_LAST
Definition effects.h:33
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:988
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1046
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:875
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:976
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:1017
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:203
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_type_re_active_iterate_end
Definition extras.h:329
#define extra_type_list_iterate_end
Definition extras.h:167
#define extra_base_get(_e_)
Definition extras.h:190
#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 MAX_NUM_USER_EXTRA_FLAGS
Definition extras.h:83
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
#define MAX_NUM_USER_BUILDING_FLAGS
Definition fc_types.h:492
@ ROCO_RAILROAD
Definition fc_types.h:946
@ ROCO_NONE
Definition fc_types.h:946
@ ROCO_RIVER
Definition fc_types.h:946
@ ROCO_ROAD
Definition fc_types.h:946
#define MAX_NUM_NATION_SETS
Definition fc_types.h:58
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int action_id
Definition fc_types.h:249
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:63
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:59
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define MAX_LEN_NAME
Definition fc_types.h:67
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
#define UCL_LAST
Definition fc_types.h:275
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:874
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:866
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:863
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:849
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:822
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:780
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:776
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:814
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:898
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:870
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:884
#define RS_DEFAULT_HAPPY_COST
Definition game.h:854
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:888
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:828
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:778
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:507
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:889
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:880
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:796
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:841
#define GAME_DEFAULT_START_YEAR
Definition game.h:748
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:802
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:878
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:774
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:845
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:806
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:862
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:890
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:788
#define RS_DEFAULT_FOOD_COST
Definition game.h:858
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:818
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:810
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:398
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:832
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:792
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:784
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:798
const char * gov_flag_id_name_cb(enum gov_flag_id flag)
Definition government.c:644
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:385
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:376
const char * gov_flag_helptxt(enum gov_flag_id id)
Definition government.c:656
const char * government_rule_name(const struct government *pgovern)
Definition government.c:135
#define governments_iterate(NAME_pgov)
Definition government.h:127
#define governments_re_active_iterate(_p)
Definition government.h:132
#define governments_re_active_iterate_end
Definition government.h:136
#define governments_iterate_end
Definition government.h:130
#define MAX_NUM_USER_GOVERNMENT_FLAGS
Definition government.h:29
const char * title
Definition repodlgs.c:1314
struct impr_type * improvement_by_number(const Impr_type_id id)
const char * impr_flag_id_name_cb(enum impr_flag_id flag)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
const char * impr_flag_helptxt(enum impr_flag_id id)
#define improvement_re_active_iterate_end
#define improvement_re_active_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
@ FZ_PLAIN
Definition ioz.h:38
#define fc_assert(condition)
Definition log.h:177
#define log_error(message,...)
Definition log.h:104
struct terrain_misc terrain_control
Definition map.c:68
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
#define SINGLE_MOVE
Definition movement.h:26
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
#define multipliers_iterate_end
Definition multipliers.h:67
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * untranslated_name(const struct name_translation *ptrans)
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c:424
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:296
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:435
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1117
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:824
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1138
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:867
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:857
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:448
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:121
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:286
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:835
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_list_iterate(nationlist, pnation)
Definition nation.h:84
#define nation_sets_iterate_end
Definition nation.h:307
#define nation_sets_iterate(NAME_pset)
Definition nation.h:303
#define nations_iterate_end
Definition nation.h:338
@ NCP_NONE
Definition nation.h:41
@ NCP_DISLIKE
Definition nation.h:40
@ NCP_LIKE
Definition nation.h:42
#define nation_city_list_iterate(citylist, pncity)
Definition nation.h:48
#define nation_list_iterate_end
Definition nation.h:86
#define nation_city_list_iterate_end
Definition nation.h:50
#define nations_iterate(NAME_pnation)
Definition nation.h:335
#define nation_leader_list_iterate_end
Definition nation.h:59
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:313
#define nation_groups_iterate_end
Definition nation.h:317
int len
Definition packhand.c:128
struct section_file * secfile_new(bool allow_duplicates)
bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
bool secfile_save(const struct section_file *secfile, const char *filename, int compression_level, enum fz_method compression_method)
struct section * secfile_insert_include(struct section_file *secfile, const char *filename)
struct entry * secfile_insert_filereference(struct section_file *secfile, const char *filename, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_enum_vec(secfile, enumerators, dim, specenum_type, path,...)
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
#define secfile_insert_int_vec(secfile, values, dim, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_insert_enum_vec_comment(secfile, enumerators, dim, specenum_type, comment, path,...)
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
const char * universal_rule_name(const struct universal *psource)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
Definition rgbcolor.c:121
#define rgbcolor_list_iterate_end
Definition rgbcolor.h:45
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)
Definition rgbcolor.h:43
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:416
char * get_parser_buffer(void)
Definition ruleload.c:572
char * get_script_buffer(void)
Definition ruleload.c:564
#define RS_DEFAULT_CONVERT_SPEED
Definition ruleload.h:122
#define RS_DEFAULT_UBUILD_NAT
Definition ruleload.h:121
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleload.h:108
#define RS_DEFAULT_WORLD_PEACE_TURNS
Definition ruleload.h:98
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleload.h:83
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleload.h:102
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleload.h:84
#define GAME_DEFAULT_ACH_VALUE
Definition ruleload.h:77
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleload.h:82
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleload.h:93
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleload.h:95
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleload.h:110
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleload.h:105
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleload.h:85
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleload.h:96
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleload.h:100
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleload.h:86
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleload.h:81
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleload.h:76
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleload.h:107
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleload.h:78
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleload.h:79
#define RS_DEFAULT_BASE_TECH_COST
Definition ruleload.h:112
#define RULESET_CAPABILITIES
Definition ruleload.h:24
#define RS_DEFAULT_NATIONALITY
Definition ruleload.h:120
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleload.h:73
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleload.h:80
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleload.h:88
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleload.h:72
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleload.h:106
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleload.h:103
#define RS_DEFAULT_MIN_TECH_COST
Definition ruleload.h:116
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleload.h:74
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleload.h:94
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleload.h:75
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:152
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:212
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:129
static bool save_terrain_ref(struct section_file *sfile, const struct terrain *save, const struct terrain *pthis, const char *path, const char *entry)
Definition rulesave.c:252
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:309
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:2275
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:922
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:946
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:876
static bool save_traits(struct trait_limits *traits, struct trait_limits *default_traits, struct section_file *sfile, const char *secname, const char *field_prefix)
Definition rulesave.c:2041
#define FORMAT_VERSION
Definition rulesave.c:58
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3469
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:673
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2400
static bool save_uclass_vec(struct section_file *sfile, bv_unit_classes *bits, const char *path, const char *entry, bool unreachable_only)
Definition rulesave.c:332
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:1024
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:381
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:3119
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1053
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:108
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:802
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1263
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:389
static bool save_action_auto_uflag_block(struct section_file *sfile, const int aap, const char *uflags_path, bool(*unexpected_req)(const struct requirement *preq))
Definition rulesave.c:549
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:643
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:285
static bool save_luadata(const char *filename)
Definition rulesave.c:3457
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1915
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:971
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:359
static bool save_actions_ruleset(const char *filename, const char *name)
Definition rulesave.c:1086
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:3191
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2506
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:653
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:896
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:272
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:485
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:63
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:3154
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:832
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:88
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:2087
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3430
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:600
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:235
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4693
int setting_int_get(struct setting *pset)
Definition settings.c:3830
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3404
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3912
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5657
const char * setting_name(const struct setting *pset)
Definition settings.c:3375
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4301
char * setting_str_get(struct setting *pset)
Definition settings.c:3901
bool setting_bool_get(struct setting *pset)
Definition settings.c:3718
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4108
int read_enum_value(const struct setting *pset)
Definition settings.c:4038
#define settings_iterate(_level, _pset)
Definition settings.h:188
#define settings_iterate_end
Definition settings.h:194
const char * sex_rule_name(sex_t kind)
Definition sex.c:43
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
bool make_dir(const char *pathname, int mode)
Definition shared.c:1779
#define DIRMODE_DEFAULT
Definition shared.h:258
#define MAX(x, y)
Definition shared.h:54
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:110
bool is_super_specialist_id(Specialist_type_id sp)
Definition specialist.c:184
Specialist_type_id specialist_index(const struct specialist *sp)
Definition specialist.c:90
const char * specialist_rule_name(const struct specialist *sp)
Definition specialist.c:157
#define specialist_type_iterate_end
Definition specialist.h:85
#define specialist_type_iterate(sp)
Definition specialist.h:79
#define DEFAULT_SPECIALIST
Definition specialist.h:43
const char * strvec_get(const struct strvec *psv, size_t svindex)
size_t strvec_size(const struct strvec *psv)
bool actor_consuming_always
Definition actions.h:144
int max_distance
Definition actions.h:127
bool quiet
Definition actions.h:134
char ui_name[MAX_LEN_NAME]
Definition actions.h:130
enum action_target_kind target_kind
Definition actions.h:118
int named_teams
Definition game.h:301
size_t as_count
Definition game.h:300
struct civ_game::@32::@36::@42 ruledit
struct rgbcolor_list * plr_colors
Definition game.h:252
const char ** allowed_govs
Definition game.h:292
int upgrade_veteran_loss
Definition game.h:206
struct rgbcolor * plr_bg_color
Definition game.h:103
int incite_total_factor
Definition game.h:157
int init_vis_radius_sq
Definition game.h:159
bool vision_reveal_tiles
Definition game.h:207
char * description_file
Definition game.h:288
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int base_incite_cost
Definition game.h:141
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
int autoupgrade_veteran_loss
Definition game.h:139
int start_year
Definition game.h:198
int incite_improvement_factor
Definition game.h:156
struct section_file * luadata
Definition game.h:254
char ** embedded_nations
Definition game.h:290
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:111
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:281
const char ** allowed_terrains
Definition game.h:295
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:294
const char ** allowed_styles
Definition game.h:298
bool std_tileset_compat
Definition game.h:302
struct civ_game::@31 rgame
size_t embedded_nations_count
Definition game.h:291
int incite_unit_factor
Definition game.h:158
char * ruleset_capabilities
Definition game.h:86
int ransom_gold
Definition game.h:182
struct civ_game::@32::@36 server
size_t at_count
Definition game.h:297
struct veteran_system * veteran
Definition game.h:101
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
struct civ_map::@44::@46 server
bool ocean_resources
Definition map_types.h:119
struct requirement_vector receiver_reqs
Definition diptreaty.h:61
struct requirement_vector giver_reqs
Definition diptreaty.h:60
enum clause_type type
Definition diptreaty.h:58
struct requirement_vector either_reqs
Definition diptreaty.h:62
bool enabled
Definition diptreaty.h:59
struct section_file * sfile
Definition rulesave.c:796
Definition climisc.h:82
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
char negative_year_label[MAX_LEN_NAME]
char positive_year_label[MAX_LEN_NAME]
bool tech_steal_allow_holes
enum gameloss_style gameloss_style
int granary_food_ini[MAX_GRANARY_INIS]
enum goods_selection_method goods_selection
enum gold_upkeep_style gold_upkeep_style
int low_firepower_pearl_harbor
bool damage_reduces_bombard_rate
int nuke_defender_survival_chance_pct
enum tech_upkeep_style tech_upkeep_style
bool tech_trade_loss_allow_holes
enum free_tech_method free_tech_method
bool steal_maps_reveals_all_cities
bool only_real_fight_makes_veteran
enum tech_leakage_style tech_leakage
int min_city_center_output[O_LAST]
bool airlift_from_always_enabled
bool only_killing_makes_veteran
bool poison_empties_food_stock
bv_actions diplchance_initial_odds
bool tech_trade_allow_holes
int low_firepower_nonnat_bombard
bool tech_parasite_allow_holes
int low_firepower_combat_bonus
int border_city_permanent_radius_sq
int low_firepower_badwallattacker
bool airlift_to_always_enabled
enum wonder_visib_type small_wonder_visibility
enum tech_cost_style tech_cost_style
bool combat_odds_scaled_veterancy
bool unit_builders_nationality
char alt_dir[MAX_LEN_NAME]
char version[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_soundset[MAX_LEN_NAME]
struct universal source
char * nationlist
Definition rulesave.h:22
struct requirement_vector reqs
Definition specialist.h:38
char graphic_alt[MAX_LEN_NAME]
Definition specialist.h:36
struct strvec * helptext
Definition specialist.h:40
char graphic_str[MAX_LEN_NAME]
Definition specialist.h:35
struct name_translation name
Definition specialist.h:31
struct name_translation abbreviation
Definition specialist.h:32
enum trade_route_bonus_type bonus_type
Definition traderoutes.h:78
enum trade_route_illegal_cancelling cancelling
Definition traderoutes.h:77
enum universals_n kind
Definition fc_types.h:593
struct civ_map map
const char * style_rule_name(const struct nation_style *pstyle)
Definition style.c:108
#define music_styles_iterate(_p)
Definition style.h:72
#define music_styles_iterate_end
Definition style.h:79
#define styles_re_active_iterate_end
Definition style.h:60
#define styles_re_active_iterate(_p)
Definition style.h:56
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:505
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * tech_flag_id_name_cb(enum tech_flag_id flag)
Definition tech.c:433
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:352
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Definition tech.c:216
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:309
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:445
#define advance_re_active_iterate(_p)
Definition tech.h:279
#define A_NEVER
Definition tech.h:51
#define tech_class_iterate_end
Definition tech.h:201
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:105
@ AR_TWO
Definition tech.h:109
@ AR_ROOT
Definition tech.h:110
@ AR_ONE
Definition tech.h:108
#define advance_re_active_iterate_end
Definition tech.h:283
#define A_NONE
Definition tech.h:43
#define tech_class_iterate(_p)
Definition tech.h:195
#define A_LAST
Definition tech.h:45
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:821
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:250
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:833
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define terrain_type_iterate_end
Definition terrain.h:272
#define MAX_NUM_TERRAINS
Definition terrain.h:69
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:32
#define terrain_resources_iterate_end
Definition terrain.h:294
#define terrain_resources_iterate(pterrain, _res, _freq)
Definition terrain.h:285
#define RESOURCE_FREQUENCY_DEFAULT
Definition terrain.h:101
#define tiledef_iterate_end
Definition tiledef.h:54
#define tiledef_iterate(_p)
Definition tiledef.h:48
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
const char * trade_route_type_name(enum trade_route_type type)
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
const char * trade_route_cancelling_type_name(enum trade_route_illegal_cancelling type)
#define goods_type_re_active_iterate_end
#define goods_type_re_active_iterate(_p)
trade_route_type
Definition traderoutes.h:37
@ TRT_LAST
Definition traderoutes.h:48
#define TRAIT_DEFAULT_VALUE
Definition traits.h:32
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Definition unittype.c:1880
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:224
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
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Definition unittype.c:1868
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Definition unittype.c:1931
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1943
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 combat_bonus_list_iterate_end
Definition unittype.h:487
#define L_FIRST
Definition unittype.h:354
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:485
#define unit_class_iterate(_p)
Definition unittype.h:916
#define unit_class_re_active_iterate_end
Definition unittype.h:932
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:336
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define UTYF_LAST_USER_FLAG
Definition unittype.h:335
#define L_LAST
Definition unittype.h:444
#define unit_class_re_active_iterate(_p)
Definition unittype.h:928
#define uclass_index(_c_)
Definition unittype.h:749
#define unit_class_iterate_end
Definition unittype.h:923
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:128
#define unit_type_re_active_iterate_end
Definition unittype.h:879
const char * freeciv_datafile_version(void)
Definition version.c:186