Freeciv-3.3
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 "achievements.h"
25#include "counters.h"
26#include "game.h"
27#include "government.h"
28#include "map.h"
29#include "movement.h"
30#include "multipliers.h"
31#include "nation.h"
32#include "rgbcolor.h"
33#include "sex.h"
34#include "specialist.h"
35#include "style.h"
36#include "unittype.h"
37#include "version.h"
38
39/* server */
40#include "ruleload.h"
41#include "settings.h"
42
43/* tools/ruleutil */
44#include "comments.h"
45
46#include "rulesave.h"
47
48/* Ruleset format version */
49/*
50 * 1 - Freeciv-2.6
51 * 10 - Freeciv-3.0
52 * 20 - Freeciv-3.1
53 * 30 - Freeciv-3.2
54 * 40 - Freeciv-3.3
55 */
56#define FORMAT_VERSION RSFORMAT_CURRENT
57
58/**********************************************************************/
61static struct section_file *create_ruleset_file(const char *rsname,
62 const char *rstype)
63{
64 struct section_file *sfile = secfile_new(TRUE);
65 char buf[500];
66
68
69 if (rsname != NULL && rsname[0] != '\0') {
70 fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);
71 } else {
72 fc_snprintf(buf, sizeof(buf), "Template %s data for Freeciv", rstype);
73 }
74
75 secfile_insert_str(sfile, buf, "datafile.description");
76 secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
77 secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
78 secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");
79
80 return sfile;
81}
82
83/**********************************************************************/
86static bool save_default_int(struct section_file *sfile, int value,
87 int default_value, const char *path,
88 const char *entry)
89{
90 if (value != default_value) {
91 if (entry != NULL) {
92 secfile_insert_int(sfile, value,
93 "%s.%s", path, entry);
94 } else {
95 secfile_insert_int(sfile, value,
96 "%s", path);
97 }
98 }
99
100 return TRUE;
101}
102
103/**********************************************************************/
106static bool save_default_bool(struct section_file *sfile, bool value,
107 bool default_value, const char *path,
108 const char *entry)
109{
110 if ((value && !default_value)
111 || (!value && default_value)) {
112 if (entry != NULL) {
113 secfile_insert_bool(sfile, value,
114 "%s.%s", path, entry);
115 } else {
116 secfile_insert_bool(sfile, value,
117 "%s", path);
118 }
119 }
120
121 return TRUE;
122}
123
124/**********************************************************************/
127static bool save_name_translation(struct section_file *sfile,
128 struct name_translation *name,
129 const char *path)
130{
131 struct entry *mod_entry;
132
135 "%s.name", path);
139 secfile_insert_str(sfile,
141 "%s.rule_name", path);
142 }
143
144 return TRUE;
145}
146
147/**********************************************************************/
150static bool save_reqs_vector(struct section_file *sfile,
151 const struct requirement_vector *reqs,
152 const char *path, const char *entry)
153{
154 int i;
155 bool includes_negated = FALSE;
157 bool includes_quiet = FALSE;
158
160 if (!preq->present) {
162 }
163 if (preq->survives) {
165 }
166 if (preq->quiet) {
168 }
170
171 i = 0;
173 secfile_insert_str(sfile,
174 universals_n_name(preq->source.kind),
175 "%s.%s%d.type", path, entry, i);
176 secfile_insert_str(sfile,
177 universal_rule_name(&(preq->source)),
178 "%s.%s%d.name", path, entry, i);
179 secfile_insert_str(sfile,
180 req_range_name(preq->range),
181 "%s.%s%d.range", path, entry, i);
182
183 if (includes_surviving) {
185 preq->survives,
186 "%s.%s%d.survives", path, entry, i);
187 }
188
189 if (includes_negated) {
191 preq->present,
192 "%s.%s%d.present", path, entry, i);
193 }
194
195 if (includes_quiet) {
197 preq->quiet,
198 "%s.%s%d.quiet", path, entry, i);
199 }
200
201 i++;
203
204 return TRUE;
205}
206
207/**********************************************************************/
210static bool save_tech_list(struct section_file *sfile, int *input,
211 const char *path, const char *entry)
212{
213 const char *tech_names[MAX_NUM_TECH_LIST];
214 int set_count;
215 int i;
216
217 set_count = 0;
218 for (i = 0; input[i] != A_LAST && i < MAX_NUM_TECH_LIST; i++) {
220 }
221
222 if (set_count > 0) {
224 "%s.%s", path, entry);
225 }
226
227 return TRUE;
228}
229
230/**********************************************************************/
233static bool save_tech_ref(struct section_file *sfile,
234 const struct advance *padv,
235 const char *path, const char *entry)
236{
237 if (padv == A_NEVER) {
238 secfile_insert_str(sfile, "Never", "%s.%s", path, entry);
239 } else {
241 "%s.%s", path, entry);
242 }
243
244 return TRUE;
245}
246
247/**********************************************************************/
250static bool save_terrain_ref(struct section_file *sfile,
251 const struct terrain *save,
252 const struct terrain *pthis,
253 const char *path, const char *entry)
254{
255 if (save == NULL) {
256 secfile_insert_str(sfile, "none", "%s.%s", path, entry);
257 } else if (save == pthis) {
258 secfile_insert_str(sfile, "yes", "%s.%s", path, entry);
259 } else {
261 "%s.%s", path, entry);
262 }
263
264 return TRUE;
265}
266
267/**********************************************************************/
270static bool save_gov_ref(struct section_file *sfile,
271 const struct government *gov,
272 const char *path, const char *entry)
273{
274 secfile_insert_str(sfile, government_rule_name(gov), "%s.%s", path, entry);
275
276 return TRUE;
277}
278
279/**********************************************************************/
283static bool save_building_list(struct section_file *sfile, int *input,
284 const char *path, const char *entry)
285{
287 int set_count;
288 int i;
289
290 set_count = 0;
291 for (i = 0; input[i] != B_LAST && i < MAX_NUM_BUILDING_LIST; i++) {
293 }
294
295 if (set_count > 0) {
297 "%s.%s", path, entry);
298 }
299
300 return TRUE;
301}
302
303/**********************************************************************/
307static bool save_unit_list(struct section_file *sfile, struct unit_type **input,
308 const char *path, const char *entry)
309{
310 const char *unit_names[MAX_NUM_UNIT_LIST];
311 int set_count;
312 int i;
313
314 set_count = 0;
315 for (i = 0; input[i] != NULL && i < MAX_NUM_UNIT_LIST; i++) {
317 }
318
319 if (set_count > 0) {
321 "%s.%s", path, entry);
322 }
323
324 return TRUE;
325}
326
327/**********************************************************************/
330static bool save_uclass_vec(struct section_file *sfile,
331 bv_unit_classes *bits,
332 const char *path, const char *entry,
333 bool unreachable_only)
334{
335 const char *class_names[UCL_LAST];
336 int classes = 0;
337
339 if (BV_ISSET(*(bits), uclass_index(pcargo))
341 || !unreachable_only)) {
343 }
345
346 if (classes > 0) {
348 "%s.%s", path, entry);
349 }
350
351 return TRUE;
352}
353
354/**********************************************************************/
357static bool save_strvec(struct section_file *sfile,
358 struct strvec *to_save,
359 const char *path, const char *entry)
360{
361 if (to_save != NULL) {
363 const char *sections[sect_count];
364 int i;
365
366 for (i = 0; i < sect_count; i++) {
367 sections[i] = strvec_get(to_save, i);
368 }
369
370 secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
371 }
372
373 return TRUE;
374}
375
376/**********************************************************************/
379static bool save_ruleset_file(struct section_file *sfile, const char *filename)
380{
381 return secfile_save(sfile, filename, 0, FZ_PLAIN);
382}
383
384/**********************************************************************/
387static bool save_buildings_ruleset(const char *filename, const char *name)
388{
389 struct section_file *sfile = create_ruleset_file(name, "building");
390 int sect_idx;
391 int i;
392 bool uflags_building = FALSE;
393
394 if (sfile == NULL) {
395 return FALSE;
396 }
397
398 for (i = 0; i < MAX_NUM_USER_BUILDING_FLAGS; i++) {
400 const char *helptxt = impr_flag_helptxt(i + IF_USER_FLAG_1);
401
402 if (flagname != NULL) {
403 if (!uflags_building) {
406 }
407
408 secfile_insert_str(sfile, flagname, "control.building_flags%d.name", i);
409
410 /* Save the user flag help text even when it is undefined. That makes
411 * the formatting code happy. The resulting "" is ignored when the
412 * ruleset is loaded. */
413 secfile_insert_str(sfile, helptxt,
414 "control.building_flags%d.helptxt", i);
415 }
416 }
417
418 comment_buildings(sfile);
419
420 sect_idx = 0;
422 if (!pb->ruledit_disabled) {
423 char path[512];
424 const char *flag_names[IF_COUNT];
425 int set_count;
426 int flagi;
427
428 fc_snprintf(path, sizeof(path), "building_%d", sect_idx++);
429
430 save_name_translation(sfile, &(pb->name), path);
431
433 "%s.genus", path);
434
435 if (strcmp(pb->graphic_str, "-")) {
436 secfile_insert_str(sfile, pb->graphic_str, "%s.graphic", path);
437 }
438 if (strcmp(pb->graphic_alt, "-")) {
439 secfile_insert_str(sfile, pb->graphic_alt, "%s.graphic_alt", path);
440 }
441 if (strcmp(pb->graphic_alt2, "-")) {
442 secfile_insert_str(sfile, pb->graphic_alt2, "%s.graphic_alt2", path);
443 }
444 if (strcmp(pb->soundtag, "-")) {
445 secfile_insert_str(sfile, pb->soundtag, "%s.sound", path);
446 }
447 if (strcmp(pb->soundtag_alt, "-")) {
448 secfile_insert_str(sfile, pb->soundtag_alt, "%s.sound_alt", path);
449 }
450 if (strcmp(pb->soundtag_alt2, "-")) {
451 secfile_insert_str(sfile, pb->soundtag_alt2, "%s.sound_alt2", path);
452 }
453
454 save_reqs_vector(sfile, &(pb->reqs), path, "reqs");
455 save_reqs_vector(sfile, &(pb->obsolete_by), path, "obsolete_by");
456
457 secfile_insert_int(sfile, pb->build_cost, "%s.build_cost", path);
458 secfile_insert_int(sfile, pb->upkeep, "%s.upkeep", path);
459 secfile_insert_int(sfile, pb->sabotage, "%s.sabotage", path);
460
461 set_count = 0;
462 for (flagi = 0; flagi < IF_COUNT; flagi++) {
465 }
466 }
467
468 if (set_count > 0) {
470 "%s.flags", path);
471 }
472
473 save_strvec(sfile, pb->helptext, path, "helptext");
474 }
476
477 return save_ruleset_file(sfile, filename);
478}
479
480/**********************************************************************/
483static bool save_styles_ruleset(const char *filename, const char *name)
484{
485 struct section_file *sfile = create_ruleset_file(name, "styles");
486 int sect_idx;
487 int i;
488
489 if (sfile == NULL) {
490 return FALSE;
491 }
492
493 comment_styles(sfile);
494
495 sect_idx = 0;
497 char path[512];
498
499 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
500
501 save_name_translation(sfile, &(pstyle->name), path);
503
504 comment_citystyles(sfile);
505
506 sect_idx = 0;
507 for (i = 0; i < game.control.num_city_styles; i++) {
508 char path[512];
509
510 fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++);
511
512 save_name_translation(sfile, &(city_styles[i].name), path);
513
514 secfile_insert_str(sfile, city_styles[i].graphic, "%s.graphic", path);
515 secfile_insert_str(sfile, city_styles[i].graphic_alt, "%s.graphic_alt", path);
516 if (strcmp(city_styles[i].citizens_graphic, "-")) {
517 secfile_insert_str(sfile, city_styles[i].citizens_graphic,
518 "%s.citizens_graphic", path);
519 }
520
521 save_reqs_vector(sfile, &(city_styles[i].reqs), path, "reqs");
522 }
523
524 comment_musicstyles(sfile);
525
526 sect_idx = 0;
528 char path[512];
529
530 fc_snprintf(path, sizeof(path), "musicstyle_%d", sect_idx++);
531
532 secfile_insert_str(sfile, pmus->music_peaceful, "%s.music_peaceful", path);
533 secfile_insert_str(sfile, pmus->music_combat, "%s.music_combat", path);
534
535 save_reqs_vector(sfile, &(pmus->reqs), path, "reqs");
537
538 return save_ruleset_file(sfile, filename);
539}
540
541/**********************************************************************/
548 const int aap,
549 const char *uflags_path,
550 bool (*unexpected_req)(
551 const struct requirement *preq))
552{
554 size_t i;
555 size_t ret;
556
557 const struct action_auto_perf *auto_perf =
559
560 i = 0;
562 fc_assert(req->range == REQ_RANGE_LOCAL);
563
564 if (req->source.kind == VUT_UTFLAG) {
565 fc_assert(!req->present);
566
567 protecor_flag[i++] = req->source.value.unitflag;
568 } else if (unexpected_req(req)) {
569 struct astring astr;
570
571 log_error("Can't handle action auto performer requirement %s",
572 req_to_fstring(req, &astr));
573 astr_free(&astr);
574
575 return FALSE;
576 }
578
581 "%s", uflags_path);
582
583 if (ret != i) {
584 log_error("%s: didn't save all unit type flags.", uflags_path);
585
586 return FALSE;
587 }
588
589 return TRUE;
590}
591
592/**********************************************************************/
598static bool save_action_auto_actions(struct section_file *sfile,
599 const int aap,
600 const char *actions_path)
601{
603 size_t i, j;
604 size_t ret;
605
606 const struct action_auto_perf *auto_perf =
608
609 for (i = 0, j = 0;
610 i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
611 i++) {
612 struct action *paction = action_by_number(auto_perf->alternatives[i]);
613
615 /* Don't mention non enabled actions. */
616 continue;
617 }
618
619 /* This action is included in the output. */
620 unit_acts[j] = auto_perf->alternatives[i];
621 j++;
622 }
623
626 "%s", actions_path);
627
628 if (ret != j) {
629 log_error("%s: didn't save all actions.", actions_path);
630
631 return FALSE;
632 }
633
634 return TRUE;
635}
636
637/**********************************************************************/
641static bool unexpected_non_otype(const struct requirement *req)
642{
643 return !(req->source.kind == VUT_OTYPE && req->present);
644}
645
646/**********************************************************************/
651static bool save_muuk_action_auto(struct section_file *sfile,
652 const int aap,
653 const char *item)
654{
655 char uflags_path[100];
656 char action_path[100];
657
659 "missing_unit_upkeep.%s_protected", item);
661 "missing_unit_upkeep.%s_unit_act", item);
662
666}
667
668/**********************************************************************/
671static bool save_cities_ruleset(const char *filename, const char *name)
672{
673 struct section_file *sfile = create_ruleset_file(name, "cities");
674 int sect_idx;
675
676 if (sfile == NULL) {
677 return FALSE;
678 }
679
680 comment_specialists(sfile);
681
682 sect_idx = 0;
685 char path[512];
686
687 fc_snprintf(path, sizeof(path), "specialist_%d", sect_idx++);
688
689 save_name_translation(sfile, &(s->name), path);
690
693 "%s.short_name", path);
694 }
695
696 save_reqs_vector(sfile, &(s->reqs), path, "reqs");
697
698 secfile_insert_str(sfile, s->graphic_str, "%s.graphic", path);
699 if (strcmp(s->graphic_alt, "-")) {
700 secfile_insert_str(sfile, s->graphic_alt, "%s.graphic_alt", path);
701 }
702
703 save_strvec(sfile, s->helptext, path, "helptext");
704
706
709 "parameters.celebrate_size_limit");
710 }
713 "parameters.add_to_size_limit");
714 }
717 "parameters.angry_citizens");
718 }
721 "parameters.changable_tax");
722 }
723 if (game.info.forced_science != 0) {
725 "parameters.forced_science");
726 }
727 if (game.info.forced_luxury != 100) {
729 "parameters.forced_luxury");
730 }
731 if (game.info.forced_gold != 0) {
733 "parameters.forced_gold");
734 }
737 "parameters.vision_reveal_tiles");
738 }
739 if (game.info.pop_report_zeroes != 1) {
741 "parameters.pop_report_zeroes");
742 }
743
746 "citizen.nationality", NULL);
749 "citizen.ubuilder_nationality", NULL);
752 "citizen.convert_speed", NULL);
753 if (game.info.conquest_convert_pct != 0) {
755 "citizen.conquest_convert_pct");
756 }
757
760 "citizen.partisans_pct");
761 }
762
764 "food");
767 "missing_unit_upkeep.food_wipe");
768 }
769
771 "gold");
774 "missing_unit_upkeep.gold_wipe");
775 }
776
778 "shield");
781 "missing_unit_upkeep.shield_wipe");
782 }
783
784 return save_ruleset_file(sfile, filename);
785}
786
787/**************************************************************************
788 Effect saving callback data structure.
789**************************************************************************/
790typedef struct {
791 int idx;
794
795/**********************************************************************/
798static bool effect_save(struct effect *peffect, void *data)
799{
801 char path[512];
802
803 if (peffect->rulesave.do_not_save) {
804 /* Is supposed to be skipped. */
805 return TRUE;
806 }
807
808 fc_snprintf(path, sizeof(path), "effect_%d", cbdata->idx++);
809
812 "%s.type", path);
813 secfile_insert_int(cbdata->sfile, peffect->value, "%s.value", path);
814
815 save_reqs_vector(cbdata->sfile, &peffect->reqs, path, "reqs");
816
817 if (peffect->rulesave.comment != NULL) {
818 secfile_insert_str(cbdata->sfile, peffect->rulesave.comment,
819 "%s.comment", path);
820 }
821
822 return TRUE;
823}
824
825/**********************************************************************/
828static bool save_effects_ruleset(const char *filename, const char *name)
829{
830 struct section_file *sfile = create_ruleset_file(name, "effect");
831 effect_cb_data data;
832 int i;
833 int sidx;
834
835 if (sfile == NULL) {
836 return FALSE;
837 }
838
839 data.idx = 0;
840 data.sfile = sfile;
841
842 comment_ueffs(sfile);
843
844 sidx = 0;
845 for (i = EFT_USER_EFFECT_1 ; i <= EFT_USER_EFFECT_LAST; i++) {
846 enum effect_type val = user_effect_ai_valued_as(i);
847
848 if (val != i) {
849 char path[512];
850
851 fc_snprintf(path, sizeof(path), "ueff_%d", sidx++);
852
854 "%s.type", path);
856 "%s.ai_valued_as", path);
857 }
858 }
859
860 comment_effects(sfile);
861
862 if (!iterate_effect_cache(effect_save, &data)) {
863 return FALSE;
864 }
865
866 return save_ruleset_file(sfile, filename);
867}
868
869/**********************************************************************/
872static bool save_action_ui_name(struct section_file *sfile,
873 int act, const char *entry_name)
874{
875 struct action *paction = action_by_number(act);
876 const char *ui_name;
877
879 return TRUE;
880 }
881
882 ui_name = paction->ui_name;
883
884 if (ui_name == NULL) {
886
887 return FALSE;
888 }
889
892 "actions.%s", entry_name);
893 }
894
895 return TRUE;
896}
897
898/**********************************************************************/
901static bool save_action_max_range(struct section_file *sfile,
902 action_id act)
903{
904 struct action *paction = action_by_number(act);
905
906 if (paction->max_distance == ACTION_DISTANCE_UNLIMITED) {
908 "actions.%s",
910 } else {
913 "actions",
915 }
916}
917
918/**********************************************************************/
921static bool save_action_range(struct section_file *sfile, action_id act)
922{
923 struct action *paction = action_by_number(act);
924
926 /* Min range can be loaded from the ruleset. */
927 save_default_int(sfile,
928 paction->min_distance,
930 "actions",
932 }
933
935 /* Max range can be loaded from the ruleset. */
936 if (!save_action_max_range(sfile, act)) {
937 return FALSE;
938 }
939 }
940
941 return TRUE;
942}
943
944/**********************************************************************/
947static bool save_action_kind(struct section_file *sfile, action_id act)
948{
950 struct action *paction = action_by_number(act);
951
952 /* Target kind can be loaded from the ruleset. */
954 /* Don't save the default for actions that aren't enabled. */
955 return TRUE;
956 }
957
961 "actions.%s",
963 }
964
965 return TRUE;
966}
967
968/**********************************************************************/
972 action_id act)
973{
975 struct action *paction = action_by_number(act);
976
977 /* Actor consumption can be loaded from the ruleset. */
979 /* Don't save value for actions that aren't enabled. */
980 return TRUE;
981 }
982
983 save_default_bool(sfile,
986 "actions",
988 }
989
990 return TRUE;
991}
992
993/**********************************************************************/
996static bool save_action_blocked_by(struct section_file *sfile,
997 struct action *paction)
998{
1000 char comment[1024];
1001 int i = 0;
1002
1004 /* Action blocked by shouldn't be written to the ruleset for this
1005 * action. */
1006 return TRUE;
1007 }
1008
1009 if (!action_is_in_use(paction)) {
1010 /* Don't save value for actions that aren't enabled. */
1011 return TRUE;
1012 }
1013
1014 fc_snprintf(comment, sizeof(comment),
1015 "Forbid \"%s\" if any one of the listed actions are legal.",
1017
1020
1021 if (!action_is_in_use(pblocker)) {
1022 /* Don't save value for actions that aren't enabled. */
1023 continue;
1024 }
1025
1026 if (BV_ISSET(paction->blocked_by, blocker_id)) {
1028 i++;
1029 }
1031
1033 sfile, &action_vec, i, gen_action, comment, "actions.%s",
1035 != i) {
1036 log_error("Didn't save all %s blocking actions.",
1038
1039 return FALSE;
1040 }
1041
1042 return TRUE;
1043}
1044
1045/**********************************************************************/
1050 int performer_slot,
1051 struct action *paction)
1052{
1053 char action_list_path[100];
1054
1056 /* Not relevant. */
1057 return TRUE;
1058 }
1059
1060 if (!action_is_in_use(paction)) {
1061 /* Don't save value for actions that aren't enabled. */
1062 return TRUE;
1063 }
1064
1066 "actions.%s",
1069 return FALSE;
1070 }
1071
1072 return TRUE;
1073}
1074
1075/**********************************************************************/
1078static bool save_bv_actions(struct section_file *sfile,
1079 bv_actions content,
1080 const char *path)
1081{
1083 int i = 0;
1084
1085 action_iterate(act_id) {
1086 struct action *paction = action_by_number(act_id);
1087
1088 if (!action_is_in_use(paction)) {
1089 /* Don't save value for actions that aren't enabled. */
1090 continue;
1091 }
1092
1093 if (BV_ISSET(content, act_id)) {
1094 action_vec[i] = act_id;
1095 i++;
1096 }
1098
1100 "%s", path) != i) {
1101 log_error("Didn't save all of %s.", path);
1102
1103 return FALSE;
1104 }
1105
1106 return TRUE;
1107}
1108/**********************************************************************/
1111static bool save_actions_ruleset(const char *filename, const char *name)
1112{
1113 struct section_file *sfile = create_ruleset_file(name, "actions");
1115 int i = 0;
1116 int sect_idx = 0;
1117
1118 /* TODO: move action logic from save_game_ruleset to here */
1119 if (sfile == NULL) {
1120 return FALSE;
1121 }
1122 {
1123 /* Action auto performers aren't ready to be exposed in the ruleset
1124 * yet. The behavior when two action auto performers for the same
1125 * cause can fire isn't set in stone yet. How is one of them chosen?
1126 * What if all the actions of the chosen action auto performer turned
1127 * out to be illegal but one of the other action auto performers that
1128 * fired has legal actions? These issues can decide what other action
1129 * rules action auto performers can represent in the future. Deciding
1130 * should therefore wait until a rule needs action auto performers to
1131 * work a certain way. */
1132 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
1133 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
1134 * requirement vector to the ruleset. */
1135 const struct action_auto_perf *auto_perf =
1137
1138 comment_auto_attack(sfile);
1139
1140 save_reqs_vector(sfile, &auto_perf->reqs,
1141 "auto_attack", "if_attacker");
1142
1144 "auto_attack.attack_actions");
1145 }
1146
1149 "actions.diplchance_initial_odds")) {
1150 return FALSE;
1151 }
1152
1156 log_error("Didn't save all post success forced actions.");
1157 return FALSE;
1158 }
1159
1162 log_error("Didn't save all post success forced actions.");
1163 return FALSE;
1164 }
1165
1168 log_error("Didn't save all post success forced actions.");
1169 return FALSE;
1170 }
1171
1173 "actions.escape_city")) {
1174 log_error("Didn't save all escape city forced actions.");
1175 return FALSE;
1176 }
1177
1179 "actions.unit_stack_death")) {
1180 log_error("Didn't save all escape unit stack death forced actions.");
1181 return FALSE;
1182 }
1183
1186 "actions.poison_empties_food_stock", NULL);
1187
1190 "actions.steal_maps_reveals_all_cities", NULL);
1191
1193
1194 action_iterate(act_id) {
1195 struct action *act = action_by_number(act_id);
1196
1197 if (!action_id_is_internal(act_id)) {
1198 save_action_ui_name(sfile,
1199 act_id, action_ui_name_ruleset_var_name(act_id));
1200 }
1201 save_action_kind(sfile, act_id);
1202 save_action_range(sfile, act_id);
1204 save_action_blocked_by(sfile, act);
1206
1208
1209 i = 0;
1210 action_iterate(act) {
1211 if (action_by_number(act)->quiet) {
1212 action_vec[i] = act;
1213 i++;
1214 }
1216
1218 "actions.quiet_actions") != i) {
1219 log_error("Didn't save all quiet actions.");
1220
1221 return FALSE;
1222 }
1223
1224 comment_enablers(sfile);
1225 sect_idx = 0;
1227 char path[512];
1228
1229 if (pae->ruledit_disabled) {
1230 continue;
1231 }
1232
1233 fc_snprintf(path, sizeof(path), "enabler_%d", sect_idx++);
1234
1236 "%s.action", path);
1237
1238 save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs");
1239 save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs");
1241
1242 return save_ruleset_file(sfile, filename);
1243}
1244
1245/**********************************************************************/
1248static bool save_game_ruleset(const char *filename, const char *name)
1249{
1250 struct section_file *sfile = create_ruleset_file(name, "game");
1251 int sect_idx;
1252 int col_idx;
1253 int set_count;
1254 enum gameloss_style gs;
1255 const char *style_names[32]; /* FIXME: Should determine max length automatically.
1256 * currently it's 3 (bits 0,1, and 2) so there's plenty of
1257 * safety margin here. */
1258 const char *tnames[game.server.ruledit.named_teams];
1259 enum trade_route_type trt;
1260 int i;
1261 bool locks;
1262
1263 if (sfile == NULL) {
1264 return FALSE;
1265 }
1266
1269 "ruledit.description_file");
1270 }
1271
1272 if (game.control.preferred_tileset[0] != '\0') {
1274 "tileset.preferred");
1275 }
1276 if (game.control.preferred_soundset[0] != '\0') {
1278 "soundset.preferred");
1279 }
1280 if (game.control.preferred_musicset[0] != '\0') {
1282 "musicset.preferred");
1283 }
1284
1285 secfile_insert_str(sfile, game.control.name, "about.name");
1286 secfile_insert_str(sfile, game.control.version, "about.version");
1287
1288 if (game.control.alt_dir[0] != '\0') {
1289 secfile_insert_str(sfile, game.control.alt_dir, "about.alt_dir");
1290 }
1291
1292 if (game.ruleset_summary != NULL) {
1293 struct entry *mod_entry;
1294
1296 "about.summary");
1298 }
1299
1300 if (game.ruleset_description != NULL) {
1303 "about.description");
1304 } else {
1306 "about.description");
1307 }
1308 }
1309
1312 "about.capabilities");
1313 } else {
1314 secfile_insert_str(sfile, "", "about.capabilities");
1315 }
1316
1318 "options", "global_init_techs");
1320 "options", "global_init_buildings");
1321
1323 FALSE,
1324 "options.popup_tech_help", NULL);
1327 "civstyle.base_pollution", NULL);
1328
1329 set_count = 0;
1331 if (game.info.gameloss_style & gs) {
1333 }
1334 }
1335
1336 if (set_count > 0) {
1338
1340 "civstyle.gameloss_style");
1341 }
1342
1345 "civstyle.happy_cost", NULL);
1348 "civstyle.food_cost", NULL);
1350 TRUE,
1351 "civstyle.civil_war_enabled", NULL);
1354 "civstyle.civil_war_bonus_celebrating", NULL);
1357 "civstyle.civil_war_bonus_unhappy", NULL);
1358 save_default_bool(sfile,
1361 FALSE,
1362 "civstyle.paradrop_to_transport", NULL);
1365 "civstyle.base_bribe_cost", NULL);
1368 }
1371 "civstyle.ransom_gold", NULL);
1374 "civstyle.pillage_select", NULL);
1377 "civstyle.tech_steal_allow_holes", NULL);
1380 "civstyle.tech_trade_allow_holes", NULL);
1383 "civstyle.tech_trade_loss_allow_holes", NULL);
1386 "civstyle.tech_parasite_allow_holes", NULL);
1389 "civstyle.tech_loss_allow_holes", NULL);
1392 "civstyle.upgrade_veteran_loss", NULL);
1395 "civstyle.autoupgrade_veteran_loss", NULL);
1396
1398
1401 "civstyle.granary_food_ini");
1402
1405 "civstyle.granary_food_inc", NULL);
1406
1408 char buffer[256];
1409
1410 fc_snprintf(buffer, sizeof(buffer),
1411 "civstyle.min_city_center_%s",
1413
1416 buffer, NULL);
1418
1421 "civstyle.init_vis_radius_sq", NULL);
1424 "civstyle.init_city_radius_sq", NULL);
1425
1427
1430 secfile_insert_str(sfile,
1432 "civstyle.gold_upkeep_style");
1433 }
1436 }
1438 "civstyle.homeless_gold_upkeep", NULL);
1440 1, "civstyle.output_granularity", NULL);
1441
1444 }
1446 FALSE, "civstyle.airlift_from_always_enabled", NULL);
1448 TRUE, "civstyle.airlift_to_always_enabled", NULL);
1449
1453 secfile_insert_str(sfile,
1455 "wonder_visibility.small_wonders");
1456 }
1457
1460 "illness.illness_on", NULL);
1463 "illness.illness_base_factor", NULL);
1466 "illness.illness_min_size", NULL);
1469 "illness.illness_trade_infection", NULL);
1472 "illness.illness_pollution_factor", NULL);
1473 comment_incite_cost(sfile);
1476 "incite_cost.base_incite_cost", NULL);
1479 "incite_cost.improvement_factor", NULL);
1482 "incite_cost.unit_factor", NULL);
1485 "incite_cost.total_factor", NULL);
1486
1489 }
1492 "combat_rules.tired_attack", NULL);
1495 }
1498 "combat_rules.only_killing_makes_veteran", NULL);
1501 }
1504 "combat_rules.only_real_fight_makes_veteran", NULL);
1507 }
1510 "combat_rules.combat_odds_scaled_veterancy", NULL);
1513 }
1516 "combat_rules.damage_reduces_bombard_rate", NULL);
1519 }
1521 "combat_rules.low_firepower_badwallattacker", NULL);
1524 }
1526 "combat_rules.low_firepower_pearl_harbour", NULL);
1529 }
1531 "combat_rules.low_firepower_combat_bonus", NULL);
1534 }
1536 "combat_rules.low_firepower_nonnat_bombard", NULL);
1539 }
1542 "combat_rules.nuke_pop_loss_pct", NULL);
1546 }
1549 "combat_rules.nuke_defender_survival_chance_pct", NULL);
1552 "borders.radius_sq_city", NULL);
1555 "borders.size_effect", NULL);
1559 }
1562 "borders.radius_sq_city_permanent", NULL);
1563
1566 "research.tech_cost_style");
1569 }
1572 "research.base_tech_cost", NULL);
1575 }
1578 "research.min_tech_cost", NULL);
1581 "research.tech_leakage");
1584 "research.tech_upkeep_style");
1587 "research.tech_upkeep_divider", NULL);
1590 "research.free_tech_method");
1591
1594 "culture.victory_min_points", NULL);
1597 "culture.victory_lead_pct", NULL);
1600 }
1603 "culture.migration_pml", NULL);
1606 }
1609 "culture.history_interest_pml", NULL);
1612 }
1615 "world_peace.victory_turns", NULL);
1616
1619 "calendar.skip_year_0", NULL);
1622 "calendar.start_year", NULL);
1623 if (game.calendar.calendar_fragments != 0) {
1625 }
1627 0, "calendar.fragments", NULL);
1628
1629 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
1630 if (game.calendar.calendar_fragment_name[i][0] != '\0') {
1632 "calendar.fragment_name%d", i);
1633 }
1634 }
1635
1638 "calendar.positive_label");
1639 }
1642 "calendar.negative_label");
1643 }
1644
1645 if (game.plr_bg_color != NULL) {
1646 rgbcolor_save(sfile, game.plr_bg_color, "playercolors.background");
1647 }
1648
1649 col_idx = 0;
1651 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1653
1654
1655 if (game.server.ruledit.named_teams > 0) {
1656 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1658 }
1659
1662 "teams.names");
1663 }
1664
1665 comment_disasters(sfile);
1666
1667 sect_idx = 0;
1669 char path[512];
1671 const char *effect_names[DE_COUNT];
1672
1673 fc_snprintf(path, sizeof(path), "disaster_%d", sect_idx++);
1674
1675 save_name_translation(sfile, &(pd->name), path);
1676 save_reqs_vector(sfile, &(pd->reqs), path, "reqs");
1677 if (pd->frequency != GAME_DEFAULT_DISASTER_FREQ) {
1678 secfile_insert_int(sfile, pd->frequency,
1679 "%s.frequency", path);
1680 }
1681
1682 set_count = 0;
1686 if (BV_ISSET(pd->effects, de)) {
1688 }
1689 }
1690
1691 if (set_count > 0) {
1693 "%s.effects", path);
1694 }
1696
1697 comment_achievements(sfile);
1698
1699 sect_idx = 0;
1701 char path[512];
1702
1703 fc_snprintf(path, sizeof(path), "achievement_%d", sect_idx++);
1704
1705 save_name_translation(sfile, &(pach->name), path);
1706
1708 "%s.type", path);
1709
1710 save_default_bool(sfile, pach->unique,
1712 path, "unique");
1713 save_default_int(sfile, pach->value,
1715 path, "value");
1716 save_default_int(sfile, pach->culture,
1717 0, path, "culture");
1718
1719 secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
1720 if (pach->cons_msg != NULL) {
1721 secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
1722 }
1723
1725
1727
1728 set_count = 0;
1729 for (trt = 0; trt < TRT_LAST; trt++) {
1732
1733 if (set->trade_pct != 100 || strcmp(cancelling, "Active")) {
1734 char path[256];
1735
1736 fc_snprintf(path, sizeof(path),
1737 "trade.settings%d", set_count++);
1738
1740 "%s.type", path);
1741 secfile_insert_int(sfile, set->trade_pct,
1742 "%s.pct", path);
1744 "%s.cancelling", path);
1746 "%s.bonus", path);
1747 }
1748 }
1749
1751 0, "trade.min_trade_route_val", NULL);
1752
1754 FALSE, "trade.reveal_trade_partner", NULL);
1755
1758 "trade.goods_selection");
1759 }
1760
1761 /* Goods */
1762 comment_goods(sfile);
1763
1764 sect_idx = 0;
1766 char path[512];
1767 const char *flag_names[GF_COUNT];
1768 int flagi;
1769
1770 fc_snprintf(path, sizeof(path), "goods_%d", sect_idx++);
1771
1772 save_name_translation(sfile, &(pgood->name), path);
1773
1774 save_reqs_vector(sfile, &(pgood->reqs), path, "reqs");
1775
1776 save_default_int(sfile, pgood->from_pct, 100, path, "from_pct");
1777 save_default_int(sfile, pgood->to_pct, 100, path, "to_pct");
1778 save_default_int(sfile, pgood->onetime_pct, 100, path, "onetime_pct");
1779 save_default_int(sfile, pgood->select_priority, 1, path, "select_priority");
1780 save_default_int(sfile, pgood->priority, 1, path, "priority");
1781
1782 set_count = 0;
1783 for (flagi = 0; flagi < GF_COUNT; flagi++) {
1784 if (goods_has_flag(pgood, flagi)) {
1786 }
1787 }
1788
1789 if (set_count > 0) {
1791 "%s.flags", path);
1792 }
1793
1794 save_strvec(sfile, pgood->helptext, path, "helptext");
1796
1797 /* Clauses */
1798 comment_clauses(sfile);
1799
1800 sect_idx = 0;
1801 for (i = 0; i < CLAUSE_COUNT; i++) {
1802 struct clause_info *info = clause_info_get(i);
1803
1804 if (info->enabled) {
1805 char path[512];
1806
1807 fc_snprintf(path, sizeof(path), "clause_%d", sect_idx++);
1808
1810 "%s.type", path);
1811 save_reqs_vector(sfile, &(info->giver_reqs), path, "giver_reqs");
1812 save_reqs_vector(sfile, &(info->receiver_reqs), path, "receiver_reqs");
1813 save_reqs_vector(sfile, &(info->either_reqs), path, "either_reqs");
1814 }
1815 }
1816
1817 /* Counters */
1818 comment_counters(sfile);
1819
1820 sect_idx = 0;
1822 char path[512];
1823
1824 fc_snprintf(path, sizeof(path), "counter_%d", sect_idx++);
1825
1826 save_name_translation(sfile, &(pcounter->name), path);
1827
1828 save_default_int(sfile, pcounter->def, 0, path, "def");
1829 save_default_int(sfile, pcounter->checkpoint, 0, path, "checkpoint");
1830
1831 secfile_insert_str(sfile, counter_behaviour_name(pcounter->type), "%s.type", path);
1832 if ((NULL != pcounter->helptext)
1833 && (0 < strvec_size(pcounter->helptext))) {
1834 save_strvec(sfile, pcounter->helptext, "%s.helptext", path);
1835 }
1836
1838
1839 locks = FALSE;
1842 locks = TRUE;
1843 break;
1844 }
1846
1847 set_count = 0;
1849 struct sf_cb_data info = { pset, FALSE };
1850
1853 "settings.set%d.name", set_count);
1854 switch (setting_type(pset)) {
1855 case SST_BOOL:
1857 "settings.set%d.value", set_count);
1858 break;
1859 case SST_INT:
1861 "settings.set%d.value", set_count);
1862 break;
1863 case SST_STRING:
1865 "settings.set%d.value", set_count);
1866 break;
1867 case SST_ENUM:
1870 "settings.set%d.value", set_count);
1871 break;
1872 case SST_BITWISE:
1875 "settings.set%d.value", set_count);
1876 break;
1877 case SST_COUNT:
1879 secfile_insert_str(sfile, "Unknown setting type",
1880 "settings.set%d.value", set_count);
1881 break;
1882 }
1883
1884 if (locks) {
1886 "settings.set%d.lock", set_count);
1887 }
1888
1889 set_count++;
1890 }
1892
1893 return save_ruleset_file(sfile, filename);
1894}
1895
1896/**********************************************************************/
1899static bool save_governments_ruleset(const char *filename, const char *name)
1900{
1901 struct section_file *sfile = create_ruleset_file(name, "government");
1902 int sect_idx;
1903
1904 if (sfile == NULL) {
1905 return FALSE;
1906 }
1907
1908 save_gov_ref(sfile, game.government_during_revolution, "governments",
1909 "during_revolution");
1910
1911 comment_govs(sfile);
1912
1913 sect_idx = 0;
1915 char path[512];
1916 struct ruler_title *prtitle;
1917
1918 fc_snprintf(path, sizeof(path), "government_%d", sect_idx++);
1919
1920 save_name_translation(sfile, &(pg->name), path);
1921
1922 secfile_insert_str(sfile, pg->graphic_str, "%s.graphic", path);
1923 secfile_insert_str(sfile, pg->graphic_alt, "%s.graphic_alt", path);
1924 secfile_insert_str(sfile, pg->sound_str, "%s.sound", path);
1925 secfile_insert_str(sfile, pg->sound_alt, "%s.sound_alt", path);
1926
1927 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1928
1929 if (pg->ai.better != NULL) {
1930 save_gov_ref(sfile, pg->ai.better, path,
1931 "ai_better");
1932 }
1933
1934 ruler_title_hash_lookup(pg->ruler_titles, NULL,
1935 &prtitle);
1936 if (prtitle != NULL) {
1937 const char *title;
1938
1940 if (title != NULL) {
1942 "%s.ruler_male_title", path);
1943 }
1944
1946 if (title != NULL) {
1948 "%s.ruler_female_title", path);
1949 }
1950 }
1951
1952 save_strvec(sfile, pg->helptext, path, "helptext");
1953
1955
1956 comment_policies(sfile);
1957
1958 sect_idx = 0;
1959 multipliers_iterate(pmul) {
1960 if (!pmul->ruledit_disabled) {
1961 char path[512];
1962
1963 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
1964
1965 save_name_translation(sfile, &(pmul->name), path);
1966
1967 secfile_insert_int(sfile, pmul->start, "%s.start", path);
1968 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
1969 secfile_insert_int(sfile, pmul->step, "%s.step", path);
1970 secfile_insert_int(sfile, pmul->def, "%s.default", path);
1971
1972 save_default_int(sfile, pmul->offset, 0, path, "offset");
1973 save_default_int(sfile, pmul->factor, 100, path, "factor");
1974 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
1975
1976 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
1977
1978 save_strvec(sfile, pmul->helptext, path, "helptext");
1979 }
1981
1982 return save_ruleset_file(sfile, filename);
1983}
1984
1985/**********************************************************************/
1988static bool save_traits(struct trait_limits *traits,
1989 struct trait_limits *default_traits,
1990 struct section_file *sfile,
1991 const char *secname, const char *field_prefix)
1992{
1993 enum trait tr;
1994
1995 /* FIXME: Use specenum trait names without duplicating them here.
1996 * Just needs to take care of case.
1997 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
1998 const char *trait_names[] = {
1999 "expansionist",
2000 "trader",
2001 "aggressive",
2002 "builder",
2003 NULL
2004 };
2005
2006 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != NULL;
2007 tr = trait_next(tr)) {
2008 int default_default;
2009
2010 default_default = (traits[tr].min + traits[tr].max) / 2;
2011
2012 if ((default_traits == NULL && traits[tr].min != TRAIT_DEFAULT_VALUE)
2013 || (default_traits != NULL && traits[tr].min != default_traits[tr].min)) {
2014 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
2015 trait_names[tr]);
2016 }
2017 if ((default_traits == NULL && traits[tr].max != TRAIT_DEFAULT_VALUE)
2018 || (default_traits != NULL && traits[tr].max != default_traits[tr].max)) {
2019 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
2020 trait_names[tr]);
2021 }
2022 if (default_default != traits[tr].fixed) {
2023 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
2024 trait_names[tr]);
2025 }
2026 }
2027
2028 return TRUE;
2029}
2030
2031/**********************************************************************/
2034static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
2035 int sect_idx)
2036{
2037 char path[512];
2038 int max_items = nation_city_list_size(pnat->server.default_cities);
2039 char *city_str[max_items];
2042 const char *list_items[max_items];
2043 int set_count;
2044 int subsect_idx;
2045
2046 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
2047
2048 if (pnat->translation_domain == NULL) {
2049 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
2050 } else {
2051 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
2052 }
2053
2054 save_name_translation(sfile, &(pnat->adjective), path);
2055 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
2056
2057 set_count = 0;
2059 if (nation_is_in_set(pnat, pset)) {
2061 }
2066 }
2068
2069 if (set_count > 0) {
2070 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
2071 }
2072
2073 set_count = 0;
2074 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
2077 if (set_count > 0) {
2078 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
2079 }
2080
2081 subsect_idx = 0;
2083 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
2084 path, subsect_idx);
2085 secfile_insert_str(sfile,
2088 "%s.leaders%d.sex", path, subsect_idx++);
2090
2091 if (pnat->server.rgb != NULL) {
2092 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
2093 }
2094
2095 save_traits(pnat->server.traits, game.server.default_traits,
2096 sfile, path, "trait_");
2097
2098 if (!pnat->is_playable) {
2099 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
2100 }
2101
2102 if (pnat->barb_type != NOT_A_BARBARIAN) {
2103 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
2104 "%s.barbarian_type", path);
2105 }
2106
2107 if (strcmp(pnat->flag_graphic_str, "-")) {
2108 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
2109 }
2110 if (strcmp(pnat->flag_graphic_alt, "-")) {
2111 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
2112 }
2113
2114 subsect_idx = 0;
2116 struct ruler_title *prtitle;
2117
2118 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
2120 "%s.ruler_titles%d.government", path, subsect_idx);
2122 "%s.ruler_titles%d.male_title", path, subsect_idx);
2124 "%s.ruler_titles%d.female_title", path, subsect_idx++);
2125 }
2127
2128 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
2129
2130 set_count = 0;
2131 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
2134 if (set_count > 0) {
2135 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
2136 }
2137
2138 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
2139 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
2140 save_unit_list(sfile, pnat->init_units, path, "init_units");
2141
2142 if (pnat->init_government) {
2143 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
2144 "%s.init_government", path);
2145 }
2146
2147 set_count = 0;
2148 nation_city_list_iterate(pnat->server.default_cities, pncity) {
2149 bool list_started = FALSE;
2150
2152 + strlen(")")
2153 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
2154
2157 case NCP_DISLIKE:
2158 strcat(city_str[set_count], " (!river");
2160 break;
2161 case NCP_LIKE:
2162 strcat(city_str[set_count], " (river");
2164 break;
2165 case NCP_NONE:
2166 break;
2167 }
2168
2170 const char *pref = NULL;
2171
2173 case NCP_DISLIKE:
2174 pref = "!";
2175 break;
2176 case NCP_LIKE:
2177 pref = "";
2178 break;
2179 case NCP_NONE:
2180 pref = NULL;
2181 break;
2182 }
2183
2184 if (pref != NULL) {
2185 if (list_started) {
2186 strcat(city_str[set_count], ", ");
2187 } else {
2188 strcat(city_str[set_count], " (");
2190 }
2193 }
2194
2196
2197 if (list_started) {
2198 strcat(city_str[set_count], ")");
2199 }
2200
2202 set_count++;
2204 if (set_count > 0) {
2205 int i;
2206
2207 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
2208
2209 for (i = 0; i < set_count; i++) {
2210 FC_FREE(city_str[i]);
2211 }
2212 }
2213
2214 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
2215
2216 return TRUE;
2217}
2218
2219/**********************************************************************/
2222static bool save_nations_ruleset(const char *filename, const char *name,
2223 struct rule_data *data)
2224{
2225 struct section_file *sfile = create_ruleset_file(name, "nation");
2226
2227 if (sfile == NULL) {
2228 return FALSE;
2229 }
2230
2231 if (data->nationlist != NULL || game.server.ruledit.embedded_nations != NULL) {
2233 if (data->nationlist != NULL) {
2234 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2235 }
2237 int i;
2238 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2239
2240 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2241 * resrictions */
2242 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2244 }
2245
2248 "ruledit.embedded_nations");
2249 free(tmp);
2250 }
2251 }
2252
2254 "default_traits", "");
2255
2256 if (data->nationlist == NULL) {
2260 "compatibility.allowed_govs");
2261 }
2265 "compatibility.allowed_terrains");
2266 }
2270 "compatibility.allowed_styles");
2271 }
2272 }
2273
2274 if (game.default_government != NULL) {
2276 "compatibility.default_government");
2277 }
2278
2279 if (data->nationlist != NULL) {
2280 secfile_insert_include(sfile, data->nationlist);
2281
2283 int sect_idx;
2284
2285 comment_nations(sfile);
2286
2288 sect_idx++) {
2289 struct nation_type *pnat
2291
2292 if (pnat == NULL) {
2293 log_error("Embedded nation \"%s\" not found!",
2295 } else {
2296 save_nation(sfile, pnat, sect_idx);
2297 }
2298 }
2299 }
2300 } else {
2301 int sect_idx = 0;
2302
2303 comment_nationsets(sfile);
2304
2306 char path[512];
2307
2308 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2309
2310 /* We don't use save_name_translation() for this as name and rule_name must
2311 * always be saved separately */
2312 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2313 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2314 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2316
2317 comment_nationgroups(sfile);
2318
2319 sect_idx = 0;
2321 char path[512];
2322
2323 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2324
2325 save_name_translation(sfile, &(pgroup->name), path);
2326
2327 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2328 if (pgroup->hidden) {
2329 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2330 }
2332
2333 comment_nations(sfile);
2334
2335 sect_idx = 0;
2337 save_nation(sfile, pnat, sect_idx++);
2339 }
2340
2341 return save_ruleset_file(sfile, filename);
2342}
2343
2344/**********************************************************************/
2347static bool save_techs_ruleset(const char *filename, const char *name)
2348{
2349 struct section_file *sfile = create_ruleset_file(name, "tech");
2350 int i;
2351 int sect_idx;
2353 bool uflags_tech = FALSE;
2354
2355 if (sfile == NULL) {
2356 return FALSE;
2357 }
2358
2359 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2360 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2361 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2362
2363 if (flagname != NULL) {
2364 if (!uflags_tech) {
2365 comment_uflags_tech(sfile);
2366 uflags_tech = TRUE;
2367 }
2368
2369 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2370
2371 /* Save the user flag help text even when it is undefined. That makes
2372 * the formatting code happy. The resulting "" is ignored when the
2373 * ruleset is loaded. */
2374 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2375 }
2376 }
2377
2378 comment_tech_classes(sfile);
2379
2380 sect_idx = 0;
2382 char path[512];
2383
2384 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2385
2386 save_name_translation(sfile, &(ptclass->name), path);
2388
2389 comment_techs(sfile);
2390
2391 sect_idx = 0;
2393 if (pa->require[AR_ONE] != A_NEVER) {
2394 char path[512];
2395 const char *flag_names[TF_COUNT];
2396 int set_count;
2397 int flagi;
2398
2399 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2400
2401 save_name_translation(sfile, &(pa->name), path);
2402
2403 if (game.control.num_tech_classes > 0) {
2404 if (pa->tclass != NULL) {
2406 "%s.class", path);
2407 }
2408 }
2409
2410 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2411 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2412 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2413 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2414 }
2415
2416 save_reqs_vector(sfile, &(pa->research_reqs), path,
2417 "research_reqs");
2418
2419 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2420 if (strcmp("-", pa->graphic_alt)) {
2421 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2422 }
2423 if (pa->bonus_message != NULL) {
2424 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2425 }
2426
2427 set_count = 0;
2428 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2431 }
2432 }
2433
2434 if (set_count > 0) {
2436 "%s.flags", path);
2437 }
2438 if (pa->cost >= 0) {
2439 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2440 }
2441
2442 save_strvec(sfile, pa->helptext, path, "helptext");
2443 }
2444
2446
2447 return save_ruleset_file(sfile, filename);
2448}
2449
2450/**********************************************************************/
2453static bool save_terrain_ruleset(const char *filename, const char *name)
2454{
2455 struct section_file *sfile = create_ruleset_file(name, "terrain");
2456 int sect_idx;
2457 int i;
2458 bool uflags_terr = FALSE;
2459 bool uflags_extra = FALSE;
2460
2461 if (sfile == NULL) {
2462 return FALSE;
2463 }
2464
2465 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2467 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2468
2469 if (flagname != NULL) {
2470 if (!uflags_terr) {
2472 uflags_terr = TRUE;
2473 }
2474
2475 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2476
2477 /* Save the user flag help text even when it is undefined. That makes
2478 * the formatting code happy. The resulting "" is ignored when the
2479 * ruleset is loaded. */
2480 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2481 }
2482 }
2483
2484 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2486 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2487
2488 if (flagname != NULL) {
2489 if (!uflags_extra) {
2490 /* TODO: Uncomment this, once there's a way to stop
2491 * the comment getting written inside preceding
2492 * terrain flags table. */
2493 /* comment_uflags_extra(sfile); */
2495 }
2496
2497 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2498
2499 /* Save the user flag help text even when it is undefined. That makes
2500 * the formatting code happy. The resulting "" is ignored when the
2501 * ruleset is loaded. */
2502 secfile_insert_str(sfile, helptxt,
2503 "control.extra_flags%d.helptxt", i);
2504 }
2505 }
2506
2507 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2508 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2509 "parameters.ocean_reclaim_requirement");
2510 }
2511 if (terrain_control.land_channel_requirement_pct <= 100) {
2512 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2513 "parameters.land_channel_requirement");
2514 }
2515 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2516 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2517 "parameters.thaw_requirement");
2518 }
2519 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2520 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2521 "parameters.freeze_requirement");
2522 }
2523 if (terrain_control.lake_max_size != 0) {
2524 secfile_insert_int(sfile, terrain_control.lake_max_size,
2525 "parameters.lake_max_size");
2526 }
2527 if (terrain_control.min_start_native_area != 0) {
2528 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2529 "parameters.min_start_native_area");
2530 }
2531 if (terrain_control.move_fragments != 3) {
2532 secfile_insert_int(sfile, terrain_control.move_fragments,
2533 "parameters.move_fragments");
2534 }
2535 if (terrain_control.igter_cost != 1) {
2536 secfile_insert_int(sfile, terrain_control.igter_cost,
2537 "parameters.igter_cost");
2538 }
2539 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2540 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2541 "parameters.pythagorean_diagonal");
2542 }
2545 "parameters.ocean_resources");
2546 }
2547
2548 comment_terrains(sfile);
2549
2550 sect_idx = 0;
2552 char path[512];
2553 char identifier[2];
2554 int r;
2555 const char *flag_names[TER_USER_LAST];
2556 const char *puc_names[UCL_LAST];
2557 int flagi;
2558 int set_count;
2559
2560 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2561
2562 save_name_translation(sfile, &(pterr->name), path);
2563
2564 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2565 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2566 secfile_insert_str(sfile, pterr->graphic_alt2, "%s.graphic_alt2", path);
2567 identifier[0] = pterr->identifier;
2568 identifier[1] = '\0';
2569 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2570
2572 "%s.class", path);
2573
2574 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2575 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2576
2578 if (pterr->output[o] != 0) {
2579 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2581 }
2583
2584 /* Check resource count */
2585 for (r = 0; pterr->resources[r] != NULL; r++) {
2586 /* Just increasing r as long as there is resources */
2587 }
2588
2589 {
2590 const char *resource_names[r];
2591 bool save_frequencies = FALSE;
2592
2593 r = 0;
2598 }
2600
2602 "%s.resources", path);
2603
2604 if (save_frequencies) {
2605 secfile_insert_int_vec(sfile, pterr->resource_freq, r,
2606 "%s.resource_freq", path);
2607 }
2608 }
2609
2611 if (pterr->road_output_incr_pct[o] != 0) {
2612 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2613 "%s.road_%s_incr_pct", path,
2615 }
2617
2618 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2619 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2620
2621 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2622 "cultivate_result");
2623 secfile_insert_int(sfile, pterr->cultivate_time,
2624 "%s.cultivate_time", path);
2625
2626 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2627 "plant_result");
2628 secfile_insert_int(sfile, pterr->plant_time,
2629 "%s.plant_time", path);
2630
2631 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2632 "%s.irrigation_food_incr", path);
2633 secfile_insert_int(sfile, pterr->irrigation_time,
2634 "%s.irrigation_time", path);
2635
2636 secfile_insert_int(sfile, pterr->mining_shield_incr,
2637 "%s.mining_shield_incr", path);
2638 secfile_insert_int(sfile, pterr->mining_time,
2639 "%s.mining_time", path);
2640
2641 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2642 "transform_result");
2643 secfile_insert_int(sfile, pterr->transform_time,
2644 "%s.transform_time", path);
2645
2646 if (pterr->animal != NULL) {
2648 "%s.animal", path);
2649 } else {
2650 secfile_insert_str(sfile, "None",
2651 "%s.animal", path);
2652 }
2653
2654 secfile_insert_int(sfile, pterr->placing_time,
2655 "%s.placing_time", path);
2656 secfile_insert_int(sfile, pterr->pillage_time,
2657 "%s.pillage_time", path);
2658
2659 i = 0;
2660 extra_type_iterate(pextra) {
2661 int rmtime = pterr->extra_removal_times[extra_index(pextra)];
2662
2663 if (rmtime != 0) {
2664 secfile_insert_str(sfile, extra_rule_name(pextra),
2665 "%s.extra_settings%d.extra",
2666 path, i);
2668 "%s.extra_settings%d.removal_time",
2669 path, i++);
2670 }
2672
2673 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2674 "warmer_wetter_result");
2675 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2676 "warmer_drier_result");
2677 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2678 "cooler_wetter_result");
2679 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2680 "cooler_drier_result");
2681
2682 set_count = 0;
2683 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2686 }
2687 }
2688
2689 if (set_count > 0) {
2691 "%s.flags", path);
2692 }
2693
2694 {
2696
2700 if (pterr->property[mtp] != 0) {
2701 secfile_insert_int(sfile, pterr->property[mtp],
2702 "%s.property_%s", path,
2704 }
2705 }
2706 }
2707
2708 set_count = 0;
2710 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2712 }
2714
2715 if (set_count > 0) {
2717 "%s.native_to", path);
2718 }
2719
2720 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2721
2722 save_strvec(sfile, pterr->helptext, path, "helptext");
2723
2725
2726 comment_resources(sfile);
2727
2728 sect_idx = 0;
2730 if (!pres->ruledit_disabled) {
2731 char path[512];
2732 char identifier[2];
2733
2734 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2735
2737 "%s.extra", path);
2738
2740 if (pres->data.resource->output[o] != 0) {
2741 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2742 path, get_output_identifier(o));
2743 }
2745
2746 if (pres->data.resource->id_old_save != '\0') {
2747 identifier[0] = pres->data.resource->id_old_save;
2748 identifier[1] = '\0';
2749 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2750 }
2751 }
2753
2754 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2755 "extraui.ui_name_base_fortress");
2756 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2757 "extraui.ui_name_base_airbase");
2758
2759 comment_extras(sfile);
2760
2761 sect_idx = 0;
2763 char path[512];
2764 const char *flag_names[EF_COUNT];
2765 const char *cause_names[EC_COUNT];
2766 const char *puc_names[UCL_LAST];
2767 const char *extra_names[MAX_EXTRA_TYPES];
2768 int flagi;
2769 int causei;
2770 int set_count;
2771 bool worker_cause;
2772
2773 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2774
2775 save_name_translation(sfile, &(pextra->name), path);
2776
2777 secfile_insert_str(sfile, extra_category_name(pextra->category),
2778 "%s.category", path);
2779
2780 set_count = 0;
2781 for (causei = 0; causei < EC_COUNT; causei++) {
2782 if (is_extra_caused_by(pextra, causei)) {
2784 }
2785 }
2786
2787 if (set_count > 0) {
2789 "%s.causes", path);
2790 }
2791
2792 set_count = 0;
2793 for (causei = 0; causei < ERM_COUNT; causei++) {
2794 if (is_extra_removed_by(pextra, causei)) {
2796 }
2797 }
2798
2799 if (set_count > 0) {
2801 "%s.rmcauses", path);
2802 }
2803
2804 if (strcmp(pextra->graphic_str, "-")) {
2805 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2806 }
2807 if (strcmp(pextra->graphic_alt, "-")) {
2808 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2809 }
2810 if (strcmp(pextra->activity_gfx, "-")) {
2811 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2812 }
2813 if (strcmp(pextra->act_gfx_alt, "-")) {
2814 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2815 }
2816 if (strcmp(pextra->act_gfx_alt2, "-")) {
2817 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2818 }
2819 if (strcmp(pextra->rmact_gfx, "-")) {
2820 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2821 }
2822 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2823 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2824 }
2825
2826 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2827 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2828 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2829 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2830
2832 if ((!pextra->buildable && worker_cause)
2833 || (pextra->buildable && !worker_cause)) {
2834 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2835 }
2836 if (!pextra->generated) {
2837 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2838 }
2839 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2840 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2841 if (pextra->build_time_factor != 1) {
2842 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2843 }
2844 if (pextra->removal_time_factor != 1) {
2845 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2846 }
2847 if (pextra->infracost != 0) {
2848 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2849 }
2850 if (pextra->defense_bonus != 0) {
2851 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2852 }
2853 if (pextra->eus != EUS_NORMAL) {
2855 "%s.unit_seen", path);
2856 }
2858 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2859 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2860 }
2862 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2863 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2864 path);
2865 }
2866
2867 set_count = 0;
2869 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2871 }
2873
2874 if (set_count > 0) {
2876 "%s.native_to", path);
2877 }
2878
2879 if (pextra->no_aggr_near_city >= 0) {
2880 secfile_insert_int(sfile, pextra->no_aggr_near_city,
2881 "%s.no_aggr_near_city", path);
2882 }
2883
2884 set_count = 0;
2885 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2886 if (extra_has_flag(pextra, flagi)) {
2888 }
2889 }
2890
2891 if (set_count > 0) {
2893 "%s.flags", path);
2894 }
2895
2896 set_count = 0;
2898 if (!can_extras_coexist(pextra, confl)) {
2900 }
2902
2903 if (set_count > 0) {
2905 "%s.conflicts", path);
2906 }
2907
2908 set_count = 0;
2909 extra_type_iterate(top) {
2910 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2912 }
2914
2915 if (set_count > 0) {
2917 "%s.hidden_by", path);
2918 }
2919
2920 set_count = 0;
2921 extra_type_iterate(top) {
2922 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2924 }
2926
2927 if (set_count > 0) {
2929 "%s.bridged_over", path);
2930 }
2931
2932 save_strvec(sfile, pextra->helptext, path, "helptext");
2933
2935
2936 comment_bases(sfile);
2937
2938 sect_idx = 0;
2940 if (!pextra->ruledit_disabled) {
2941 char path[512];
2942 struct base_type *pbase = extra_base_get(pextra);
2943
2944 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2945
2946 secfile_insert_str(sfile, extra_rule_name(pextra),
2947 "%s.extra", path);
2948
2950 "%s.gui_type", path);
2951
2952 if (pbase->border_sq >= 0) {
2953 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
2954 }
2955 if (pbase->vision_main_sq >= 0) {
2956 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
2957 }
2958 if (pbase->vision_invis_sq >= 0) {
2959 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
2960 }
2961 if (pbase->vision_subs_sq >= 0) {
2962 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
2963 }
2964 }
2966
2967 comment_roads(sfile);
2968
2969 sect_idx = 0;
2971 if (!pextra->ruledit_disabled) {
2972 struct road_type *proad = extra_road_get(pextra);
2973 char path[512];
2974 const char *flag_names[RF_COUNT];
2975 int flagi;
2976 int set_count;
2977
2978 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
2979
2980 secfile_insert_str(sfile, extra_rule_name(pextra),
2981 "%s.extra", path);
2982
2983 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
2984
2985 if (proad->move_mode != RMM_FAST_ALWAYS) {
2986 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
2987 "%s.move_mode", path);
2988 }
2989
2991 if (proad->tile_incr_const[o] != 0) {
2992 secfile_insert_int(sfile, proad->tile_incr_const[o],
2993 "%s.%s_incr_const", path, get_output_identifier(o));
2994 }
2995 if (proad->tile_incr[o] != 0) {
2996 secfile_insert_int(sfile, proad->tile_incr[o],
2997 "%s.%s_incr", path, get_output_identifier(o));
2998 }
2999 if (proad->tile_bonus[o] != 0) {
3000 secfile_insert_int(sfile, proad->tile_bonus[o],
3001 "%s.%s_bonus", path, get_output_identifier(o));
3002 }
3004
3005 switch (proad->compat) {
3006 case ROCO_ROAD:
3007 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
3008 break;
3009 case ROCO_RAILROAD:
3010 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
3011 break;
3012 case ROCO_RIVER:
3013 secfile_insert_str(sfile, "River", "%s.compat_special", path);
3014 break;
3015 case ROCO_NONE:
3016 secfile_insert_str(sfile, "None", "%s.compat_special", path);
3017 break;
3018 }
3019
3021 "%s.gui_type", path);
3022
3023 set_count = 0;
3024 for (flagi = 0; flagi < RF_COUNT; flagi++) {
3025 if (road_has_flag(proad, flagi)) {
3027 }
3028 }
3029
3030 if (set_count > 0) {
3032 "%s.flags", path);
3033 }
3034 }
3036
3037 return save_ruleset_file(sfile, filename);
3038}
3039
3040/**********************************************************************/
3043static bool save_veteran_system(struct section_file *sfile, const char *path,
3044 struct veteran_system *vsystem)
3045{
3046 const char *vlist_name[vsystem->levels];
3047 int vlist_power[vsystem->levels];
3048 int vlist_raise[vsystem->levels];
3049 int vlist_wraise[vsystem->levels];
3050 int vlist_move[vsystem->levels];
3051 int i;
3052
3053 for (i = 0; i < vsystem->levels; i++) {
3054 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
3055 vlist_power[i] = vsystem->definitions[i].power_fact;
3056 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
3057 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
3058 vlist_move[i] = vsystem->definitions[i].move_bonus;
3059 }
3060
3062 "%s.veteran_names", path);
3064 "%s.veteran_power_fact", path);
3066 "%s.veteran_base_raise_chance", path);
3068 "%s.veteran_work_raise_chance", path);
3070 "%s.veteran_move_bonus", path);
3071
3072 return TRUE;
3073}
3074
3075/**********************************************************************/
3078static bool save_combat_bonuses(struct section_file *sfile,
3079 struct unit_type *put,
3080 char *path)
3081{
3082 int i;
3083 bool has_quiet = FALSE;
3084
3086 if (pbonus->quiet) {
3087 has_quiet = TRUE;
3088 }
3090
3091 i = 0;
3092
3095 "%s.bonuses%d.flag", path, i);
3097 "%s.bonuses%d.type", path, i);
3098 secfile_insert_int(sfile, pbonus->value,
3099 "%s.bonuses%d.value", path, i);
3100
3101 if (has_quiet) {
3102 secfile_insert_bool(sfile, pbonus->quiet,
3103 "%s.bonuses%d.quiet", path, i);
3104 }
3105
3106 i++;
3108
3109 return TRUE;
3110}
3111
3112/**********************************************************************/
3115static bool save_units_ruleset(const char *filename, const char *name)
3116{
3117 struct section_file *sfile = create_ruleset_file(name, "unit");
3118 int i;
3119 int sect_idx;
3120 bool uflags_utype = FALSE;
3121 bool uflags_uclass = FALSE;
3122
3123 if (sfile == NULL) {
3124 return FALSE;
3125 }
3126
3127 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
3129 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
3130
3131 if (flagname != NULL) {
3132 if (!uflags_utype) {
3133 comment_uflags_utype(sfile);
3135 }
3136
3137 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
3138
3139 /* Save the user flag help text even when it is undefined. That makes
3140 * the formatting code happy. The resulting "" is ignored when the
3141 * ruleset is loaded. */
3142 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
3143 }
3144 }
3145
3146 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
3148 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
3149
3150 if (flagname != NULL) {
3151 if (!uflags_uclass) {
3152 /* TODO: Uncomment this, once there's a way to stop
3153 * the comment getting written inside preceding
3154 * utype flags table. */
3155 /* comment_uflags_uclass(sfile); */
3157 }
3158
3159 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
3160
3161 /* Save the user flag help text even when it is undefined. That makes
3162 * the formatting code happy. The resulting "" is ignored when the
3163 * ruleset is loaded. */
3164 secfile_insert_str(sfile, helptxt,
3165 "control.class_flags%d.helptxt", i);
3166 }
3167 }
3168
3169 save_veteran_system(sfile, "veteran_system", game.veteran);
3170
3171 comment_uclasses(sfile);
3172
3173 sect_idx = 0;
3175 char path[512];
3176 const char *flag_names[UCF_COUNT];
3177 int flagi;
3178 int set_count;
3179
3180 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
3181
3182 save_name_translation(sfile, &(puc->name), path);
3183
3184 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
3185 "%s.min_speed", path);
3186 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
3187 if (puc->non_native_def_pct != 100) {
3188 secfile_insert_int(sfile, puc->non_native_def_pct,
3189 "%s.non_native_def_pct", path);
3190 }
3191
3192 set_count = 0;
3193 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
3194 if (uclass_has_flag(puc, flagi)) {
3196 }
3197 }
3198
3199 if (set_count > 0) {
3201 "%s.flags", path);
3202 }
3203
3204 save_strvec(sfile, puc->helptext, path, "helptext");
3205
3207
3208 comment_utypes(sfile);
3209
3210 sect_idx = 0;
3212 if (!put->ruledit_disabled) {
3213 char path[512];
3214 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
3215 int flagi;
3216 int set_count;
3217
3218 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
3219
3220 save_name_translation(sfile, &(put->name), path);
3221
3222 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
3223 "%s.class", path);
3224
3225 save_reqs_vector(sfile, &(put->build_reqs), path, "reqs");
3226
3227 if (put->obsoleted_by != NULL) {
3228 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
3229 "%s.obsolete_by", path);
3230 }
3231
3232 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
3233 if (strcmp("-", put->graphic_alt)) {
3234 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
3235 }
3236 if (strcmp("-", put->graphic_alt2)) {
3237 secfile_insert_str(sfile, put->graphic_alt2, "%s.graphic_alt2", path);
3238 }
3239 if (strcmp("-", put->sound_move)) {
3240 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
3241 }
3242 if (strcmp("-", put->sound_move_alt)) {
3243 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
3244 }
3245 if (strcmp("-", put->sound_fight)) {
3246 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
3247 }
3248 if (strcmp("-", put->sound_fight_alt)) {
3249 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
3250 }
3251
3252 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
3253 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
3254 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
3255 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
3256 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
3257 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3258 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3259
3260 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3261 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3262 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3263
3264 if (put->vlayer != V_MAIN) {
3266 "%s.vision_layer", path);
3267 }
3268
3269 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3270 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3271 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3272 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3273
3275 if (put->upkeep[o] != 0) {
3276 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3277 path, get_output_identifier(o));
3278 }
3280
3281 if (put->converted_to != NULL) {
3282 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3283 "%s.convert_to", path);
3284 }
3285 if (put->convert_time != 1) {
3286 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3287 }
3288
3289 save_combat_bonuses(sfile, put, path);
3290 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3291
3292 if (put->veteran != NULL) {
3293 save_veteran_system(sfile, path, put->veteran);
3294 }
3295
3296 if (put->paratroopers_range != 0) {
3297 secfile_insert_int(sfile, put->paratroopers_range,
3298 "%s.paratroopers_range", path);
3299 }
3300 if (put->bombard_rate != 0) {
3301 secfile_insert_int(sfile, put->bombard_rate,
3302 "%s.bombard_rate", path);
3303 }
3304 if (put->city_slots != 0) {
3305 secfile_insert_int(sfile, put->city_slots,
3306 "%s.city_slots", path);
3307 }
3308 if (put->city_size != 1) {
3309 secfile_insert_int(sfile, put->city_size,
3310 "%s.city_size", path);
3311 }
3312
3313 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3314 "%s.tp_defense", path);
3315
3316 set_count = 0;
3317 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3318 if (utype_has_flag(put, flagi)) {
3320 }
3321 }
3322
3323 if (set_count > 0) {
3325 "%s.flags", path);
3326 }
3327
3328 set_count = 0;
3329 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3330 if (utype_has_role(put, flagi)) {
3332 }
3333 }
3334
3335 if (set_count > 0) {
3337 "%s.roles", path);
3338 }
3339
3340 save_strvec(sfile, put->helptext, path, "helptext");
3341 }
3343
3344 return save_ruleset_file(sfile, filename);
3345}
3346
3347/**********************************************************************/
3350static bool save_script_lua(const char *filename, const char *name,
3351 const char *buffer)
3352{
3353 if (buffer != NULL) {
3354 FILE *ffile = fc_fopen(filename, "w");
3355 int full_len = strlen(buffer);
3356 int len;
3357
3358 if (ffile != NULL) {
3359 len = fwrite(buffer, 1, full_len, ffile);
3360
3361 if (len != full_len) {
3362 return FALSE;
3363 }
3364
3365 fclose(ffile);
3366 } else {
3367 return FALSE;
3368 }
3369 }
3370
3371 return TRUE;
3372}
3373
3374/**********************************************************************/
3377static bool save_luadata(const char *filename)
3378{
3379 if (game.server.luadata != NULL) {
3380 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3381 }
3382
3383 return TRUE;
3384}
3385
3386/**********************************************************************/
3389bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3390{
3391 if (make_dir(path, DIRMODE_DEFAULT)) {
3392 bool success = TRUE;
3393 char filename[500];
3394
3395 if (success) {
3396 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3397 success = save_buildings_ruleset(filename, name);
3398 }
3399
3400 if (success) {
3401 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3402 success = save_styles_ruleset(filename, name);
3403 }
3404
3405 if (success) {
3406 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3407 success = save_cities_ruleset(filename, name);
3408 }
3409
3410 if (success) {
3411 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3412 success = save_effects_ruleset(filename, name);
3413 }
3414
3415 if (success) {
3416 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3417 success = save_game_ruleset(filename, name);
3418 }
3419
3420 if (success) {
3421 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3423 }
3424
3425 if (success) {
3426 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3427 success = save_nations_ruleset(filename, name, data);
3428 }
3429
3430 if (success) {
3431 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3432 success = save_techs_ruleset(filename, name);
3433 }
3434
3435 if (success) {
3436 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3437 success = save_terrain_ruleset(filename, name);
3438 }
3439
3440 if (success) {
3441 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3442 success = save_units_ruleset(filename, name);
3443 }
3444
3445 if (success) {
3446 fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path);
3447 success = save_actions_ruleset(filename, name);
3448 }
3449
3450 if (success) {
3451 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3453 }
3454
3455 if (success) {
3456 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3458 }
3459
3460 if (success) {
3461 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3462 success = save_luadata(filename);
3463 }
3464
3465 return success;
3466 } else {
3467 log_error(_("Failed to create directory %s"), path);
3468 return FALSE;
3469 }
3470
3471 return TRUE;
3472}
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:6414
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7116
void action_array_end(action_id *act_array, int size)
Definition actions.c:5723
bool action_is_in_use(struct action *paction)
Definition actions.c:5629
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7308
const char * action_rule_name(const struct action *action)
Definition actions.c:1191
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:6945
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:6590
bool action_is_internal(struct action *paction)
Definition actions.c:5655
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:6775
const char * action_ui_name_default(int act)
Definition actions.c:6055
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:5691
bool action_id_is_internal(action_id act)
Definition actions.c:5667
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:5760
#define action_enablers_iterate_end
Definition actions.h:274
#define enabler_get_action(_enabler_)
Definition actions.h:177
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:366
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:364
static struct action * action_by_number(action_id act_id)
Definition actions.h:390
#define NUM_ACTIONS
Definition actions.h:59
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:372
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:371
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:101
#define ACTION_AUTO_POST_WIPE_UNITS
Definition actions.h:373
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:365
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:367
#define action_iterate_end
Definition actions.h:209
#define MAX_NUM_ACTIONS
Definition actions.h:58
#define action_enablers_iterate(_enabler_)
Definition actions.h:268
#define action_iterate(_act_)
Definition actions.h:205
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:363
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:368
#define ACTION_NONE
Definition actions.h:55
int actres_min_range_default(enum action_result result)
Definition actres.c:376
int actres_max_range_default(enum action_result result)
Definition actres.c:465
void astr_free(struct astring *astr)
Definition astring.c:148
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
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:836
#define output_type_iterate_end
Definition city.h:842
void comment_borders_radius_permanent(struct section_file *sfile)
Definition comments.c:811
char * uflags_building
Definition comments.c:52
void comment_uflags_utype(struct section_file *sfile)
Definition comments.c:468
void comment_world_peace_turns(struct section_file *sfile)
Definition comments.c:892
void comment_combat_rules_nuke_defender_survival(struct section_file *sfile)
Definition comments.c:767
void comment_roads(struct section_file *sfile)
Definition comments.c:404
void comment_civstyle_granary(struct section_file *sfile)
Definition comments.c:597
void comment_research_tech_leakage(struct section_file *sfile)
Definition comments.c:847
void comment_actions_ui_names(struct section_file *sfile)
Definition comments.c:785
void comment_uclasses(struct section_file *sfile)
Definition comments.c:356
void comment_calendar_fragments(struct section_file *sfile)
Definition comments.c:901
void comment_actions_quiet_actions(struct section_file *sfile)
Definition comments.c:802
void comment_uflags_terrain(struct section_file *sfile)
Definition comments.c:484
void comment_citystyles(struct section_file *sfile)
Definition comments.c:420
void comment_govs(struct section_file *sfile)
Definition comments.c:340
void comment_combat_rules_low_fp_pearl_harbour(struct section_file *sfile)
Definition comments.c:728
void comment_research_base_tech_cost(struct section_file *sfile)
Definition comments.c:829
void comment_research_tech_cost_style(struct section_file *sfile)
Definition comments.c:820
void comment_combat_rules_only_killing_veteran(struct section_file *sfile)
Definition comments.c:678
void comment_bases(struct section_file *sfile)
Definition comments.c:396
void comment_terrains(struct section_file *sfile)
Definition comments.c:372
void comment_uflags_tech(struct section_file *sfile)
Definition comments.c:500
void comment_file_header(struct section_file *sfile)
Definition comments.c:308
void comment_effects(struct section_file *sfile)
Definition comments.c:436
void comment_actions_dc_initial_odds(struct section_file *sfile)
Definition comments.c:793
void comment_combat_rules_scaled_veterancy(struct section_file *sfile)
Definition comments.c:698
void comment_research_upkeep_style(struct section_file *sfile)
Definition comments.c:856
void comment_disasters(struct section_file *sfile)
Definition comments.c:452
void comment_clauses(struct section_file *sfile)
Definition comments.c:572
void comment_goods(struct section_file *sfile)
Definition comments.c:524
char * uflags_tech
Definition comments.c:51
void comment_civstyle_gameloss_style(struct section_file *sfile)
Definition comments.c:615
char * uflags_extra
Definition comments.c:50
void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
Definition comments.c:624
void comment_extras(struct section_file *sfile)
Definition comments.c:388
void comment_combat_rules_low_fp_nonnat_bombard(struct section_file *sfile)
Definition comments.c:748
void comment_ueffs(struct section_file *sfile)
Definition comments.c:444
void comment_techs(struct section_file *sfile)
Definition comments.c:332
void comment_nations(struct section_file *sfile)
Definition comments.c:548
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:516
void comment_combat_rules_low_fp_combat_bonus(struct section_file *sfile)
Definition comments.c:738
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:589
void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile)
Definition comments.c:633
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:556
void comment_specialists(struct section_file *sfile)
Definition comments.c:540
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:428
void comment_civstyle_airlift_always(struct section_file *sfile)
Definition comments.c:642
void comment_resources(struct section_file *sfile)
Definition comments.c:380
void comment_civstyle_ransom_gold(struct section_file *sfile)
Definition comments.c:606
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:324
void comment_culture_migration_pml(struct section_file *sfile)
Definition comments.c:883
void comment_combat_rules_only_real_fight_veteran(struct section_file *sfile)
Definition comments.c:688
char * uflags_uclass
Definition comments.c:48
void comment_research_free_tech_method(struct section_file *sfile)
Definition comments.c:865
void comment_combat_rules_nuke_pop_loss(struct section_file *sfile)
Definition comments.c:758
void comment_utypes(struct section_file *sfile)
Definition comments.c:364
char * uflags_utype
Definition comments.c:47
void comment_research_min_tech_cost(struct section_file *sfile)
Definition comments.c:838
void comment_culture_history_interest(struct section_file *sfile)
Definition comments.c:874
void comment_policies(struct section_file *sfile)
Definition comments.c:348
void comment_combat_rules_low_fp_badwallattacker(struct section_file *sfile)
Definition comments.c:718
void comment_achievements(struct section_file *sfile)
Definition comments.c:460
void comment_combat_rules_damage_reduces_bombard_rate(struct section_file *sfile)
Definition comments.c:708
void comment_counters(struct section_file *sfile)
Definition comments.c:580
void comment_styles(struct section_file *sfile)
Definition comments.c:412
void comment_combat_rules_tired_attack(struct section_file *sfile)
Definition comments.c:669
void comment_uflags_building(struct section_file *sfile)
Definition comments.c:508
void comment_buildings(struct section_file *sfile)
Definition comments.c:316
void comment_enablers(struct section_file *sfile)
Definition comments.c:532
void comment_nationsets(struct section_file *sfile)
Definition comments.c:564
void comment_wonder_visibility_small_wonders(struct section_file *sfile)
Definition comments.c:651
void comment_incite_cost(struct section_file *sfile)
Definition comments.c:660
void comment_auto_attack(struct section_file *sfile)
Definition comments.c:777
char * incite_cost
Definition comments.c:74
#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 @21::@22 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_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_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:655
@ ROCO_RAILROAD
Definition fc_types.h:1233
@ ROCO_NONE
Definition fc_types.h:1233
@ ROCO_RIVER
Definition fc_types.h:1233
@ ROCO_ROAD
Definition fc_types.h:1233
#define MAX_NUM_NATION_SETS
Definition fc_types.h:57
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int action_id
Definition fc_types.h:393
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:62
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
#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:66
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
#define UCL_LAST
Definition fc_types.h:419
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:61
struct world wld
Definition game.c:62
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:865
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:851
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:857
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:854
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:837
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:810
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:768
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:764
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:802
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:889
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:861
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:875
#define RS_DEFAULT_HAPPY_COST
Definition game.h:842
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:879
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:816
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:766
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:499
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:880
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:850
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:871
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:784
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:829
#define GAME_DEFAULT_START_YEAR
Definition game.h:740
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:790
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:869
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:762
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:833
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:794
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:853
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:881
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:776
#define RS_DEFAULT_FOOD_COST
Definition game.h:846
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:806
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:798
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:390
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:820
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:780
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:772
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:786
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:383
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:374
const char * government_rule_name(const struct government *pgovern)
Definition government.c:133
#define governments_iterate(NAME_pgov)
Definition government.h:122
#define governments_re_active_iterate(_p)
Definition government.h:127
#define governments_re_active_iterate_end
Definition government.h:131
#define governments_iterate_end
Definition government.h:125
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:37
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
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:412
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:290
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:422
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1079
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:797
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:837
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:434
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:281
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
#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:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
@ 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:333
#define nation_leader_list_iterate_end
Definition nation.h:59
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:311
#define nation_groups_iterate_end
Definition nation.h:315
int len
Definition packhand.c:127
struct section_file * secfile_new(bool allow_duplicates)
const char * entry_name(const struct entry *pentry)
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:563
char * get_script_buffer(void)
Definition ruleload.c:555
#define RS_DEFAULT_CONVERT_SPEED
Definition ruleload.h:123
#define RS_DEFAULT_UBUILD_NAT
Definition ruleload.h:122
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleload.h:109
#define RS_DEFAULT_WORLD_PEACE_TURNS
Definition ruleload.h:99
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleload.h:84
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleload.h:103
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleload.h:85
#define GAME_DEFAULT_ACH_VALUE
Definition ruleload.h:78
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleload.h:83
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleload.h:94
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleload.h:96
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleload.h:111
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleload.h:106
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleload.h:86
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleload.h:97
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleload.h:101
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleload.h:87
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleload.h:82
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleload.h:77
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleload.h:108
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleload.h:79
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleload.h:80
#define RS_DEFAULT_BASE_TECH_COST
Definition ruleload.h:113
#define RULESET_CAPABILITIES
Definition ruleload.h:24
#define RS_DEFAULT_NATIONALITY
Definition ruleload.h:121
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleload.h:74
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleload.h:81
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleload.h:89
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleload.h:73
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleload.h:107
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleload.h:104
#define RS_DEFAULT_MIN_TECH_COST
Definition ruleload.h:117
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleload.h:75
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleload.h:95
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleload.h:76
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:150
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:210
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:127
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:250
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:307
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:2222
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:947
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:971
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:901
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:1988
#define FORMAT_VERSION
Definition rulesave.c:56
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3389
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:671
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2347
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:330
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:1049
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:379
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:3043
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1078
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:106
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:798
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1248
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:387
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:547
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:641
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:283
static bool save_luadata(const char *filename)
Definition rulesave.c:3377
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1899
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:996
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:357
static bool save_actions_ruleset(const char *filename, const char *name)
Definition rulesave.c:1111
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:3115
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2453
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:651
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:921
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:270
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:483
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:61
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:3078
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:828
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:86
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:2034
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3350
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:598
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:233
static bool save_action_ui_name(struct section_file *sfile, int act, const char *entry_name)
Definition rulesave.c:872
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4641
int setting_int_get(struct setting *pset)
Definition settings.c:3781
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3355
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3863
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5605
const char * setting_name(const struct setting *pset)
Definition settings.c:3326
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4250
char * setting_str_get(struct setting *pset)
Definition settings.c:3852
bool setting_bool_get(struct setting *pset)
Definition settings.c:3669
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4058
int read_enum_value(const struct setting *pset)
Definition settings.c:3988
#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:1776
#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:100
#define specialist_type_iterate_end
Definition specialist.h:79
#define specialist_type_iterate(sp)
Definition specialist.h:73
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:139
int max_distance
Definition actions.h:122
bool quiet
Definition actions.h:129
char ui_name[MAX_LEN_NAME]
Definition actions.h:125
enum action_target_kind target_kind
Definition actions.h:113
int named_teams
Definition game.h:294
size_t as_count
Definition game.h:293
struct rgbcolor_list * plr_colors
Definition game.h:245
const char ** allowed_govs
Definition game.h:285
int upgrade_veteran_loss
Definition game.h:199
struct rgbcolor * plr_bg_color
Definition game.h:103
int incite_total_factor
Definition game.h:150
int init_vis_radius_sq
Definition game.h:152
bool vision_reveal_tiles
Definition game.h:200
char * description_file
Definition game.h:281
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int base_incite_cost
Definition game.h:134
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:108
struct packet_game_info info
Definition game.h:89
int autoupgrade_veteran_loss
Definition game.h:132
int start_year
Definition game.h:191
int incite_improvement_factor
Definition game.h:149
struct section_file * luadata
Definition game.h:247
char ** embedded_nations
Definition game.h:283
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:109
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:274
const char ** allowed_terrains
Definition game.h:288
struct civ_game::@31::@35::@40 ruledit
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:287
const char ** allowed_styles
Definition game.h:291
struct civ_game::@31::@35 server
size_t embedded_nations_count
Definition game.h:284
int incite_unit_factor
Definition game.h:151
char * ruleset_capabilities
Definition game.h:86
struct civ_game::@30 rgame
int ransom_gold
Definition game.h:175
size_t at_count
Definition game.h:290
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::@42::@44 server
bool ocean_resources
Definition map_types.h:107
struct requirement_vector receiver_reqs
Definition diptreaty.h:59
struct requirement_vector giver_reqs
Definition diptreaty.h:58
enum clause_type type
Definition diptreaty.h:56
struct requirement_vector either_reqs
Definition diptreaty.h:60
bool enabled
Definition diptreaty.h:57
struct section_file * sfile
Definition rulesave.c:792
Definition climisc.h:80
char positive_year_label[MAX_LEN_NAME]
char negative_year_label[MAX_LEN_NAME]
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
bool tech_steal_allow_holes
enum gameloss_style gameloss_style
enum goods_selection_method goods_selection
enum gold_upkeep_style gold_upkeep_style
bool damage_reduces_bombard_rate
int nuke_defender_survival_chance_pct
enum tech_upkeep_style tech_upkeep_style
bool tech_trade_loss_allow_holes
int granary_food_ini[MAX_GRANARY_INIS]
enum free_tech_method free_tech_method
bool steal_maps_reveals_all_cities
bool only_real_fight_makes_veteran
int low_firepower_pearl_harbour
enum tech_leakage_style tech_leakage
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
int civil_war_bonus_celebrating
int min_city_center_output[O_LAST]
char preferred_soundset[MAX_LEN_NAME]
char version[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char alt_dir[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
char name[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:880
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:282
#define A_NEVER
Definition tech.h:51
#define tech_class_iterate_end
Definition tech.h:204
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:108
@ AR_TWO
Definition tech.h:112
@ AR_ROOT
Definition tech.h:113
@ AR_ONE
Definition tech.h:111
#define advance_re_active_iterate_end
Definition tech.h:286
#define A_NONE
Definition tech.h:43
#define tech_class_iterate(_p)
Definition tech.h:198
#define A_LAST
Definition tech.h:45
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:817
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:829
#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
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:1854
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:199
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1578
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1641
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Definition unittype.c:1842
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Definition unittype.c:1905
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1917
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:871
#define combat_bonus_list_iterate_end
Definition unittype.h:489
#define L_FIRST
Definition unittype.h:356
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:487
#define unit_class_iterate(_p)
Definition unittype.h:912
#define unit_class_re_active_iterate_end
Definition unittype.h:928
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:338
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define UTYF_LAST_USER_FLAG
Definition unittype.h:337
#define L_LAST
Definition unittype.h:446
#define unit_class_re_active_iterate(_p)
Definition unittype.h:924
#define uclass_index(_c_)
Definition unittype.h:749
#define unit_class_iterate_end
Definition unittype.h:919
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:128
#define unit_type_re_active_iterate_end
Definition unittype.h:875
const char * freeciv_datafile_version(void)
Definition version.c:186