Freeciv-3.2
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 "ruleset.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 */
55#define FORMAT_VERSION RSFORMAT_3_2
56
57/**********************************************************************/
60static struct section_file *create_ruleset_file(const char *rsname,
61 const char *rstype)
62{
63 struct section_file *sfile = secfile_new(TRUE);
64 char buf[500];
65
67
68 if (rsname != NULL && rsname[0] != '\0') {
69 fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);
70 } else {
71 fc_snprintf(buf, sizeof(buf), "Template %s data for Freeciv", rstype);
72 }
73
74 secfile_insert_str(sfile, buf, "datafile.description");
75 secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
76 secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
77 secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");
78
79 return sfile;
80}
81
82/**********************************************************************/
85static bool save_default_int(struct section_file *sfile, int value,
86 int default_value, const char *path,
87 const char *entry)
88{
89 if (value != default_value) {
90 if (entry != NULL) {
91 secfile_insert_int(sfile, value,
92 "%s.%s", path, entry);
93 } else {
94 secfile_insert_int(sfile, value,
95 "%s", path);
96 }
97 }
98
99 return TRUE;
100}
101
102/**********************************************************************/
105static bool save_default_bool(struct section_file *sfile, bool value,
106 bool default_value, const char *path,
107 const char *entry)
108{
109 if ((value && !default_value)
110 || (!value && default_value)) {
111 if (entry != NULL) {
112 secfile_insert_bool(sfile, value,
113 "%s.%s", path, entry);
114 } else {
115 secfile_insert_bool(sfile, value,
116 "%s", path);
117 }
118 }
119
120 return TRUE;
121}
122
123/**********************************************************************/
126static bool save_name_translation(struct section_file *sfile,
127 struct name_translation *name,
128 const char *path)
129{
130 struct entry *mod_entry;
131
134 "%s.name", path);
138 secfile_insert_str(sfile,
140 "%s.rule_name", path);
141 }
142
143 return TRUE;
144}
145
146/**********************************************************************/
149static bool save_reqs_vector(struct section_file *sfile,
150 const struct requirement_vector *reqs,
151 const char *path, const char *entry)
152{
153 int i;
154 bool includes_negated = FALSE;
156 bool includes_quiet = FALSE;
157
159 if (!preq->present) {
161 }
162 if (preq->survives) {
164 }
165 if (preq->quiet) {
167 }
169
170 i = 0;
172 secfile_insert_str(sfile,
173 universals_n_name(preq->source.kind),
174 "%s.%s%d.type", path, entry, i);
175 secfile_insert_str(sfile,
176 universal_rule_name(&(preq->source)),
177 "%s.%s%d.name", path, entry, i);
178 secfile_insert_str(sfile,
179 req_range_name(preq->range),
180 "%s.%s%d.range", path, entry, i);
181
182 if (includes_surviving) {
184 preq->survives,
185 "%s.%s%d.survives", path, entry, i);
186 }
187
188 if (includes_negated) {
190 preq->present,
191 "%s.%s%d.present", path, entry, i);
192 }
193
194 if (includes_quiet) {
196 preq->quiet,
197 "%s.%s%d.quiet", path, entry, i);
198 }
199
200 i++;
202
203 return TRUE;
204}
205
206/**********************************************************************/
209static bool save_tech_list(struct section_file *sfile, int *input,
210 const char *path, const char *entry)
211{
212 const char *tech_names[MAX_NUM_TECH_LIST];
213 int set_count;
214 int i;
215
216 set_count = 0;
217 for (i = 0; input[i] != A_LAST && i < MAX_NUM_TECH_LIST; i++) {
219 }
220
221 if (set_count > 0) {
223 "%s.%s", path, entry);
224 }
225
226 return TRUE;
227}
228
229/**********************************************************************/
232static bool save_tech_ref(struct section_file *sfile,
233 const struct advance *padv,
234 const char *path, const char *entry)
235{
236 if (padv == A_NEVER) {
237 secfile_insert_str(sfile, "Never", "%s.%s", path, entry);
238 } else {
240 "%s.%s", path, entry);
241 }
242
243 return TRUE;
244}
245
246/**********************************************************************/
249static bool save_terrain_ref(struct section_file *sfile,
250 const struct terrain *save,
251 const struct terrain *pthis,
252 const char *path, const char *entry)
253{
254 if (save == NULL) {
255 secfile_insert_str(sfile, "none", "%s.%s", path, entry);
256 } else if (save == pthis) {
257 secfile_insert_str(sfile, "yes", "%s.%s", path, entry);
258 } else {
260 "%s.%s", path, entry);
261 }
262
263 return TRUE;
264}
265
266/**********************************************************************/
269static bool save_gov_ref(struct section_file *sfile,
270 const struct government *gov,
271 const char *path, const char *entry)
272{
273 secfile_insert_str(sfile, government_rule_name(gov), "%s.%s", path, entry);
274
275 return TRUE;
276}
277
278/**********************************************************************/
282static bool save_building_list(struct section_file *sfile, int *input,
283 const char *path, const char *entry)
284{
286 int set_count;
287 int i;
288
289 set_count = 0;
290 for (i = 0; input[i] != B_LAST && i < MAX_NUM_BUILDING_LIST; i++) {
292 }
293
294 if (set_count > 0) {
296 "%s.%s", path, entry);
297 }
298
299 return TRUE;
300}
301
302/**********************************************************************/
306static bool save_unit_list(struct section_file *sfile, struct unit_type **input,
307 const char *path, const char *entry)
308{
309 const char *unit_names[MAX_NUM_UNIT_LIST];
310 int set_count;
311 int i;
312
313 set_count = 0;
314 for (i = 0; input[i] != NULL && i < MAX_NUM_UNIT_LIST; i++) {
316 }
317
318 if (set_count > 0) {
320 "%s.%s", path, entry);
321 }
322
323 return TRUE;
324}
325
326/**********************************************************************/
329static bool save_uclass_vec(struct section_file *sfile,
330 bv_unit_classes *bits,
331 const char *path, const char *entry,
332 bool unreachable_only)
333{
334 const char *class_names[UCL_LAST];
335 int classes = 0;
336
338 if (BV_ISSET(*(bits), uclass_index(pcargo))
340 || !unreachable_only)) {
342 }
344
345 if (classes > 0) {
347 "%s.%s", path, entry);
348 }
349
350 return TRUE;
351}
352
353/**********************************************************************/
356static bool save_strvec(struct section_file *sfile,
357 struct strvec *to_save,
358 const char *path, const char *entry)
359{
360 if (to_save != NULL) {
362 const char *sections[sect_count];
363 int i;
364
365 for (i = 0; i < sect_count; i++) {
366 sections[i] = strvec_get(to_save, i);
367 }
368
369 secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
370 }
371
372 return TRUE;
373}
374
375/**********************************************************************/
378static bool save_ruleset_file(struct section_file *sfile, const char *filename)
379{
380 return secfile_save(sfile, filename, 0, FZ_PLAIN);
381}
382
383/**********************************************************************/
386static bool save_buildings_ruleset(const char *filename, const char *name)
387{
388 struct section_file *sfile = create_ruleset_file(name, "building");
389 int sect_idx;
390 int i;
391 bool uflags_building = FALSE;
392
393 if (sfile == NULL) {
394 return FALSE;
395 }
396
397 for (i = 0; i < MAX_NUM_USER_BUILDING_FLAGS; i++) {
399 const char *helptxt = impr_flag_helptxt(i + IF_USER_FLAG_1);
400
401 if (flagname != NULL) {
402 if (!uflags_building) {
405 }
406
407 secfile_insert_str(sfile, flagname, "control.building_flags%d.name", i);
408
409 /* Save the user flag help text even when it is undefined. That makes
410 * the formatting code happy. The resulting "" is ignored when the
411 * ruleset is loaded. */
412 secfile_insert_str(sfile, helptxt,
413 "control.building_flags%d.helptxt", i);
414 }
415 }
416
417 comment_buildings(sfile);
418
419 sect_idx = 0;
421 if (!pb->ruledit_disabled) {
422 char path[512];
423 const char *flag_names[IF_COUNT];
424 int set_count;
425 int flagi;
426
427 fc_snprintf(path, sizeof(path), "building_%d", sect_idx++);
428
429 save_name_translation(sfile, &(pb->name), path);
430
432 "%s.genus", path);
433
434 if (strcmp(pb->graphic_str, "-")) {
435 secfile_insert_str(sfile, pb->graphic_str, "%s.graphic", path);
436 }
437 if (strcmp(pb->graphic_alt, "-")) {
438 secfile_insert_str(sfile, pb->graphic_alt, "%s.graphic_alt", path);
439 }
440 if (strcmp(pb->graphic_alt2, "-")) {
441 secfile_insert_str(sfile, pb->graphic_alt2, "%s.graphic_alt2", path);
442 }
443 if (strcmp(pb->soundtag, "-")) {
444 secfile_insert_str(sfile, pb->soundtag, "%s.sound", path);
445 }
446 if (strcmp(pb->soundtag_alt, "-")) {
447 secfile_insert_str(sfile, pb->soundtag_alt, "%s.sound_alt", path);
448 }
449 if (strcmp(pb->soundtag_alt2, "-")) {
450 secfile_insert_str(sfile, pb->soundtag_alt2, "%s.sound_alt2", path);
451 }
452
453 save_reqs_vector(sfile, &(pb->reqs), path, "reqs");
454 save_reqs_vector(sfile, &(pb->obsolete_by), path, "obsolete_by");
455
456 secfile_insert_int(sfile, pb->build_cost, "%s.build_cost", path);
457 secfile_insert_int(sfile, pb->upkeep, "%s.upkeep", path);
458 secfile_insert_int(sfile, pb->sabotage, "%s.sabotage", path);
459
460 set_count = 0;
461 for (flagi = 0; flagi < IF_COUNT; flagi++) {
464 }
465 }
466
467 if (set_count > 0) {
469 "%s.flags", path);
470 }
471
472 save_strvec(sfile, pb->helptext, path, "helptext");
473 }
475
476 return save_ruleset_file(sfile, filename);
477}
478
479/**********************************************************************/
482static bool save_styles_ruleset(const char *filename, const char *name)
483{
484 struct section_file *sfile = create_ruleset_file(name, "styles");
485 int sect_idx;
486 int i;
487
488 if (sfile == NULL) {
489 return FALSE;
490 }
491
492 comment_styles(sfile);
493
494 sect_idx = 0;
496 char path[512];
497
498 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
499
500 save_name_translation(sfile, &(pstyle->name), path);
502
503 comment_citystyles(sfile);
504
505 sect_idx = 0;
506 for (i = 0; i < game.control.num_city_styles; i++) {
507 char path[512];
508
509 fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++);
510
511 save_name_translation(sfile, &(city_styles[i].name), path);
512
513 secfile_insert_str(sfile, city_styles[i].graphic, "%s.graphic", path);
514 secfile_insert_str(sfile, city_styles[i].graphic_alt, "%s.graphic_alt", path);
515 if (strcmp(city_styles[i].citizens_graphic, "-")) {
516 secfile_insert_str(sfile, city_styles[i].citizens_graphic,
517 "%s.citizens_graphic", path);
518 }
519
520 save_reqs_vector(sfile, &(city_styles[i].reqs), path, "reqs");
521 }
522
523 comment_musicstyles(sfile);
524
525 sect_idx = 0;
527 char path[512];
528
529 fc_snprintf(path, sizeof(path), "musicstyle_%d", sect_idx++);
530
531 secfile_insert_str(sfile, pmus->music_peaceful, "%s.music_peaceful", path);
532 secfile_insert_str(sfile, pmus->music_combat, "%s.music_combat", path);
533
534 save_reqs_vector(sfile, &(pmus->reqs), path, "reqs");
536
537 return save_ruleset_file(sfile, filename);
538}
539
540/**********************************************************************/
547 const int aap,
548 const char *uflags_path,
549 bool (*unexpected_req)(
550 const struct requirement *preq))
551{
553 size_t i;
554 size_t ret;
555
556 const struct action_auto_perf *auto_perf =
558
559 i = 0;
561 fc_assert(req->range == REQ_RANGE_LOCAL);
562
563 if (req->source.kind == VUT_UTFLAG) {
564 fc_assert(!req->present);
565
566 protecor_flag[i++] = req->source.value.unitflag;
567 } else if (unexpected_req(req)) {
568 struct astring astr;
569
570 log_error("Can't handle action auto performer requirement %s",
571 req_to_fstring(req, &astr));
572 astr_free(&astr);
573
574 return FALSE;
575 }
577
580 "%s", uflags_path);
581
582 if (ret != i) {
583 log_error("%s: didn't save all unit type flags.", uflags_path);
584
585 return FALSE;
586 }
587
588 return TRUE;
589}
590
591/**********************************************************************/
597static bool save_action_auto_actions(struct section_file *sfile,
598 const int aap,
599 const char *actions_path)
600{
602 size_t i, j;
603 size_t ret;
604
605 const struct action_auto_perf *auto_perf =
607
608 for (i = 0, j = 0;
609 i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
610 i++) {
611 struct action *paction = action_by_number(auto_perf->alternatives[i]);
612
614 /* Don't mention non enabled actions. */
615 continue;
616 }
617
618 /* This action is included in the output. */
619 unit_acts[j] = auto_perf->alternatives[i];
620 j++;
621 }
622
625 "%s", actions_path);
626
627 if (ret != j) {
628 log_error("%s: didn't save all actions.", actions_path);
629
630 return FALSE;
631 }
632
633 return TRUE;
634}
635
636/**********************************************************************/
640static bool unexpected_non_otype(const struct requirement *req)
641{
642 return !(req->source.kind == VUT_OTYPE && req->present);
643}
644
645/**********************************************************************/
650static bool save_muuk_action_auto(struct section_file *sfile,
651 const int aap,
652 const char *item)
653{
654 char uflags_path[100];
655 char action_path[100];
656
658 "missing_unit_upkeep.%s_protected", item);
660 "missing_unit_upkeep.%s_unit_act", item);
661
665}
666
667/**********************************************************************/
670static bool save_cities_ruleset(const char *filename, const char *name)
671{
672 struct section_file *sfile = create_ruleset_file(name, "cities");
673 int sect_idx;
674
675 if (sfile == NULL) {
676 return FALSE;
677 }
678
679 comment_specialists(sfile);
680
681 sect_idx = 0;
684 char path[512];
685
686 fc_snprintf(path, sizeof(path), "specialist_%d", sect_idx++);
687
688 save_name_translation(sfile, &(s->name), path);
689
692 "%s.short_name", path);
693 }
694
695 save_reqs_vector(sfile, &(s->reqs), path, "reqs");
696
697 secfile_insert_str(sfile, s->graphic_str, "%s.graphic", path);
698 if (strcmp(s->graphic_alt, "-")) {
699 secfile_insert_str(sfile, s->graphic_alt, "%s.graphic_alt", path);
700 }
701
702 save_strvec(sfile, s->helptext, path, "helptext");
703
705
708 "parameters.celebrate_size_limit");
709 }
712 "parameters.add_to_size_limit");
713 }
716 "parameters.angry_citizens");
717 }
720 "parameters.changable_tax");
721 }
722 if (game.info.forced_science != 0) {
724 "parameters.forced_science");
725 }
726 if (game.info.forced_luxury != 100) {
728 "parameters.forced_luxury");
729 }
730 if (game.info.forced_gold != 0) {
732 "parameters.forced_gold");
733 }
736 "parameters.vision_reveal_tiles");
737 }
738 if (game.info.pop_report_zeroes != 1) {
740 "parameters.pop_report_zeroes");
741 }
742
745 "citizen.nationality", NULL);
748 "citizen.ubuilder_nationality", NULL);
751 "citizen.convert_speed", NULL);
752 if (game.info.conquest_convert_pct != 0) {
754 "citizen.conquest_convert_pct");
755 }
756
759 "citizen.partisans_pct");
760 }
761
763 "food");
766 "missing_unit_upkeep.food_wipe");
767 }
768
770 "gold");
773 "missing_unit_upkeep.gold_wipe");
774 }
775
777 "shield");
780 "missing_unit_upkeep.shield_wipe");
781 }
782
783 return save_ruleset_file(sfile, filename);
784}
785
786/**************************************************************************
787 Effect saving callback data structure.
788**************************************************************************/
789typedef struct {
790 int idx;
793
794/**********************************************************************/
797static bool effect_save(struct effect *peffect, void *data)
798{
800 char path[512];
801
802 if (peffect->rulesave.do_not_save) {
803 /* Is supposed to be skipped. */
804 return TRUE;
805 }
806
807 fc_snprintf(path, sizeof(path), "effect_%d", cbdata->idx++);
808
811 "%s.type", path);
812 secfile_insert_int(cbdata->sfile, peffect->value, "%s.value", path);
813
814 save_reqs_vector(cbdata->sfile, &peffect->reqs, path, "reqs");
815
816 if (peffect->rulesave.comment != NULL) {
817 secfile_insert_str(cbdata->sfile, peffect->rulesave.comment,
818 "%s.comment", path);
819 }
820
821 return TRUE;
822}
823
824/**********************************************************************/
827static bool save_effects_ruleset(const char *filename, const char *name)
828{
829 struct section_file *sfile = create_ruleset_file(name, "effect");
830 effect_cb_data data;
831 int i;
832 int sidx;
833
834 if (sfile == NULL) {
835 return FALSE;
836 }
837
838 data.idx = 0;
839 data.sfile = sfile;
840
841 comment_ueffs(sfile);
842
843 sidx = 0;
844 for (i = EFT_USER_EFFECT_1 ; i <= EFT_USER_EFFECT_LAST; i++) {
845 enum effect_type val = user_effect_ai_valued_as(i);
846
847 if (val != i) {
848 char path[512];
849
850 fc_snprintf(path, sizeof(path), "ueff_%d", sidx++);
851
853 "%s.type", path);
855 "%s.ai_valued_as", path);
856 }
857 }
858
859 comment_effects(sfile);
860
861 if (!iterate_effect_cache(effect_save, &data)) {
862 return FALSE;
863 }
864
865 return save_ruleset_file(sfile, filename);
866}
867
868/**********************************************************************/
871static bool save_action_ui_name(struct section_file *sfile,
872 int act, const char *entry_name)
873{
874 const char *ui_name = action_by_number(act)->ui_name;
875
876 if (ui_name == NULL) {
877 fc_assert(ui_name != NULL);
878
879 return FALSE;
880 }
881
882 if (strcmp(ui_name, action_ui_name_default(act))) {
883 secfile_insert_str(sfile, ui_name,
884 "actions.%s", entry_name);
885 }
886
887 return TRUE;
888}
889
890/**********************************************************************/
893static bool save_action_max_range(struct section_file *sfile,
894 action_id act)
895{
896 struct action *paction = action_by_number(act);
897
898 if (paction->max_distance == ACTION_DISTANCE_UNLIMITED) {
900 "actions.%s",
902 } else {
905 "actions",
907 }
908}
909
910/**********************************************************************/
913static bool save_action_range(struct section_file *sfile, action_id act)
914{
915 struct action *paction = action_by_number(act);
916
918 /* Min range can be loaded from the ruleset. */
919 save_default_int(sfile,
920 paction->min_distance,
922 "actions",
924 }
925
927 /* Max range can be loaded from the ruleset. */
928 if (!save_action_max_range(sfile, act)) {
929 return FALSE;
930 }
931 }
932
933 return TRUE;
934}
935
936/**********************************************************************/
939static bool save_action_kind(struct section_file *sfile, action_id act)
940{
942 struct action *paction = action_by_number(act);
943
944 /* Target kind can be loaded from the ruleset. */
946 /* Don't save the default for actions that aren't enabled. */
947 return TRUE;
948 }
949
953 "actions.%s",
955 }
956
957 return TRUE;
958}
959
960/**********************************************************************/
964 action_id act)
965{
967 struct action *paction = action_by_number(act);
968
969 /* Actor consumption can be loaded from the ruleset. */
971 /* Don't save value for actions that aren't enabled. */
972 return TRUE;
973 }
974
975 save_default_bool(sfile,
978 "actions",
980 }
981
982 return TRUE;
983}
984
985/**********************************************************************/
988static bool save_action_blocked_by(struct section_file *sfile,
989 struct action *paction)
990{
992 char comment[1024];
993 int i = 0;
994
996 /* Action blocked by shouldn't be written to the ruleset for this
997 * action. */
998 return TRUE;
999 }
1000
1001 if (!action_is_in_use(paction)) {
1002 /* Don't save value for actions that aren't enabled. */
1003 return TRUE;
1004 }
1005
1006 fc_snprintf(comment, sizeof(comment),
1007 "Forbid \"%s\" if any one of the listed actions are legal.",
1009
1012
1013 if (!action_is_in_use(pblocker)) {
1014 /* Don't save value for actions that aren't enabled. */
1015 continue;
1016 }
1017
1018 if (BV_ISSET(paction->blocked_by, blocker_id)) {
1020 i++;
1021 }
1023
1025 sfile, &action_vec, i, gen_action, comment, "actions.%s",
1027 != i) {
1028 log_error("Didn't save all %s blocking actions.",
1030
1031 return FALSE;
1032 }
1033
1034 return TRUE;
1035}
1036
1037/**********************************************************************/
1042 int performer_slot,
1043 struct action *paction)
1044{
1045 char action_list_path[100];
1046
1048 /* Not relevant. */
1049 return TRUE;
1050 }
1051
1052 if (!action_is_in_use(paction)) {
1053 /* Don't save value for actions that aren't enabled. */
1054 return TRUE;
1055 }
1056
1058 "actions.%s",
1061 return FALSE;
1062 }
1063
1064 return TRUE;
1065}
1066
1067/**********************************************************************/
1070static bool save_bv_actions(struct section_file *sfile,
1071 bv_actions content,
1072 const char *path)
1073{
1075 int i = 0;
1076
1077 action_iterate(act_id) {
1078 struct action *paction = action_by_number(act_id);
1079
1080 if (!action_is_in_use(paction)) {
1081 /* Don't save value for actions that aren't enabled. */
1082 continue;
1083 }
1084
1085 if (BV_ISSET(content, act_id)) {
1086 action_vec[i] = act_id;
1087 i++;
1088 }
1090
1092 "%s", path) != i) {
1093 log_error("Didn't save all of %s.", path);
1094
1095 return FALSE;
1096 }
1097
1098 return TRUE;
1099}
1100/**********************************************************************/
1103static bool save_actions_ruleset(const char *filename, const char *name)
1104{
1105 struct section_file *sfile = create_ruleset_file(name, "actions");
1107 int i = 0;
1108 int sect_idx = 0;
1109
1110 /* TODO: move action logic from save_game_ruleset to here */
1111 if (sfile == NULL) {
1112 return FALSE;
1113 }
1114 {
1115 /* Action auto performers aren't ready to be exposed in the ruleset
1116 * yet. The behavior when two action auto performers for the same
1117 * cause can fire isn't set in stone yet. How is one of them chosen?
1118 * What if all the actions of the chosen action auto performer turned
1119 * out to be illegal but one of the other action auto performers that
1120 * fired has legal actions? These issues can decide what other action
1121 * rules action auto performers can represent in the future. Deciding
1122 * should therefore wait until a rule needs action auto performers to
1123 * work a certain way. */
1124 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
1125 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
1126 * requirement vector to the ruleset. */
1127 const struct action_auto_perf *auto_perf =
1129
1130 comment_auto_attack(sfile);
1131
1132 save_reqs_vector(sfile, &auto_perf->reqs,
1133 "auto_attack", "if_attacker");
1134
1136 "auto_attack.attack_actions");
1137 }
1138
1141 "actions.diplchance_initial_odds")) {
1142 return FALSE;
1143 }
1144
1148 log_error("Didn't save all post success forced actions.");
1149 return FALSE;
1150 }
1151
1154 log_error("Didn't save all post success forced actions.");
1155 return FALSE;
1156 }
1157
1160 log_error("Didn't save all post success forced actions.");
1161 return FALSE;
1162 }
1163
1165 "actions.escape_city")) {
1166 log_error("Didn't save all escape city forced actions.");
1167 return FALSE;
1168 }
1169
1171 "actions.unit_stack_death")) {
1172 log_error("Didn't save all escape unit stack death forced actions.");
1173 return FALSE;
1174 }
1175
1178 "actions.poison_empties_food_stock", NULL);
1179
1182 "actions.steal_maps_reveals_all_cities", NULL);
1183
1185
1186 action_iterate(act_id) {
1187 struct action *act = action_by_number(act_id);
1188
1189 save_action_ui_name(sfile,
1190 act_id, action_ui_name_ruleset_var_name(act_id));
1191 save_action_kind(sfile, act_id);
1192 save_action_range(sfile, act_id);
1194 save_action_blocked_by(sfile, act);
1196
1198
1199 i = 0;
1200 action_iterate(act) {
1201 if (action_by_number(act)->quiet) {
1202 action_vec[i] = act;
1203 i++;
1204 }
1206
1208 "actions.quiet_actions") != i) {
1209 log_error("Didn't save all quiet actions.");
1210
1211 return FALSE;
1212 }
1213
1214 comment_enablers(sfile);
1215 sect_idx = 0;
1217 char path[512];
1218
1219 if (pae->ruledit_disabled) {
1220 continue;
1221 }
1222
1223 fc_snprintf(path, sizeof(path), "actionenabler_%d", sect_idx++);
1224
1226 "%s.action", path);
1227
1228 save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs");
1229 save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs");
1231
1232 return save_ruleset_file(sfile, filename);
1233}
1234
1235/**********************************************************************/
1238static bool save_game_ruleset(const char *filename, const char *name)
1239{
1240 struct section_file *sfile = create_ruleset_file(name, "game");
1241 int sect_idx;
1242 int col_idx;
1243 int set_count;
1244 enum gameloss_style gs;
1245 const char *style_names[32]; /* FIXME: Should determine max length automatically.
1246 * currently it's 3 (bits 0,1, and 2) so there's plenty of
1247 * safety margin here. */
1248 const char *tnames[game.server.ruledit.named_teams];
1249 enum trade_route_type trt;
1250 int i;
1251 bool locks;
1252
1253 if (sfile == NULL) {
1254 return FALSE;
1255 }
1256
1259 "ruledit.description_file");
1260 }
1261
1262 if (game.control.preferred_tileset[0] != '\0') {
1264 "tileset.preferred");
1265 }
1266 if (game.control.preferred_soundset[0] != '\0') {
1268 "soundset.preferred");
1269 }
1270 if (game.control.preferred_musicset[0] != '\0') {
1272 "musicset.preferred");
1273 }
1274
1275 secfile_insert_str(sfile, game.control.name, "about.name");
1276 secfile_insert_str(sfile, game.control.version, "about.version");
1277
1278 if (game.control.alt_dir[0] != '\0') {
1279 secfile_insert_str(sfile, game.control.alt_dir, "about.alt_dir");
1280 }
1281
1282 if (game.ruleset_summary != NULL) {
1283 struct entry *mod_entry;
1284
1286 "about.summary");
1288 }
1289
1290 if (game.ruleset_description != NULL) {
1293 "about.description");
1294 } else {
1296 "about.description");
1297 }
1298 }
1299
1302 "about.capabilities");
1303 } else {
1304 secfile_insert_str(sfile, "", "about.capabilities");
1305 }
1306
1308 "options", "global_init_techs");
1310 "options", "global_init_buildings");
1311
1313 FALSE,
1314 "options.popup_tech_help", NULL);
1317 "civstyle.base_pollution", NULL);
1318
1319 set_count = 0;
1321 if (game.info.gameloss_style & gs) {
1323 }
1324 }
1325
1326 if (set_count > 0) {
1328
1330 "civstyle.gameloss_style");
1331 }
1332
1335 "civstyle.happy_cost", NULL);
1338 "civstyle.food_cost", NULL);
1340 TRUE,
1341 "civstyle.civil_war_enabled", NULL);
1344 "civstyle.civil_war_bonus_celebrating", NULL);
1347 "civstyle.civil_war_bonus_unhappy", NULL);
1348 save_default_bool(sfile,
1351 FALSE,
1352 "civstyle.paradrop_to_transport", NULL);
1355 "civstyle.base_bribe_cost", NULL);
1358 }
1361 "civstyle.ransom_gold", NULL);
1364 "civstyle.pillage_select", NULL);
1367 "civstyle.tech_steal_allow_holes", NULL);
1370 "civstyle.tech_trade_allow_holes", NULL);
1373 "civstyle.tech_trade_loss_allow_holes", NULL);
1376 "civstyle.tech_parasite_allow_holes", NULL);
1379 "civstyle.tech_loss_allow_holes", NULL);
1382 "civstyle.upgrade_veteran_loss", NULL);
1385 "civstyle.autoupgrade_veteran_loss", NULL);
1386
1388
1391 "civstyle.granary_food_ini");
1392
1395 "civstyle.granary_food_inc", NULL);
1396
1398 char buffer[256];
1399
1400 fc_snprintf(buffer, sizeof(buffer),
1401 "civstyle.min_city_center_%s",
1403
1406 buffer, NULL);
1408
1411 "civstyle.init_vis_radius_sq", NULL);
1414 "civstyle.init_city_radius_sq", NULL);
1415
1417
1420 secfile_insert_str(sfile,
1422 "civstyle.gold_upkeep_style");
1423 }
1426 }
1428 "civstyle.homeless_gold_upkeep", NULL);
1430 1, "civstyle.output_granularity", NULL);
1431
1434 }
1436 FALSE, "civstyle.airlift_from_always_enabled", NULL);
1438 TRUE, "civstyle.airlift_to_always_enabled", NULL);
1439
1443 secfile_insert_str(sfile,
1445 "wonder_visibility.small_wonders");
1446 }
1447
1450 "illness.illness_on", NULL);
1453 "illness.illness_base_factor", NULL);
1456 "illness.illness_min_size", NULL);
1459 "illness.illness_trade_infection", NULL);
1462 "illness.illness_pollution_factor", NULL);
1463 comment_incite_cost(sfile);
1466 "incite_cost.base_incite_cost", NULL);
1469 "incite_cost.improvement_factor", NULL);
1472 "incite_cost.unit_factor", NULL);
1475 "incite_cost.total_factor", NULL);
1476
1479 }
1482 "combat_rules.tired_attack", NULL);
1485 }
1488 "combat_rules.only_killing_makes_veteran", NULL);
1491 }
1494 "combat_rules.only_real_fight_makes_veteran", NULL);
1497 }
1500 "combat_rules.combat_odds_scaled_veterancy", NULL);
1503 }
1506 "combat_rules.damage_reduces_bombard_rate", NULL);
1509 }
1511 "combat_rules.low_firepower_badwallattacker", NULL);
1514 }
1516 "combat_rules.low_firepower_pearl_harbour", NULL);
1519 }
1521 "combat_rules.low_firepower_combat_bonus", NULL);
1524 }
1526 "combat_rules.low_firepower_nonnat_bombard", NULL);
1529 }
1532 "combat_rules.nuke_pop_loss_pct", NULL);
1536 }
1539 "combat_rules.nuke_defender_survival_chance_pct", NULL);
1542 "borders.radius_sq_city", NULL);
1545 "borders.size_effect", NULL);
1549 }
1552 "borders.radius_sq_city_permanent", NULL);
1553
1556 "research.tech_cost_style");
1559 }
1562 "research.base_tech_cost", NULL);
1565 }
1568 "research.min_tech_cost", NULL);
1571 "research.tech_leakage");
1574 "research.tech_upkeep_style");
1577 "research.tech_upkeep_divider", NULL);
1580 "research.free_tech_method");
1581
1584 "culture.victory_min_points", NULL);
1587 "culture.victory_lead_pct", NULL);
1590 }
1593 "culture.migration_pml", NULL);
1596 }
1599 "culture.history_interest_pml", NULL);
1600
1603 "calendar.skip_year_0", NULL);
1606 "calendar.start_year", NULL);
1607 if (game.calendar.calendar_fragments != 0) {
1609 }
1611 0, "calendar.fragments", NULL);
1612
1613 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
1614 if (game.calendar.calendar_fragment_name[i][0] != '\0') {
1616 "calendar.fragment_name%d", i);
1617 }
1618 }
1619
1622 "calendar.positive_label");
1623 }
1626 "calendar.negative_label");
1627 }
1628
1629 if (game.plr_bg_color != NULL) {
1630 rgbcolor_save(sfile, game.plr_bg_color, "playercolors.background");
1631 }
1632
1633 col_idx = 0;
1635 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1637
1638
1639 if (game.server.ruledit.named_teams > 0) {
1640 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1642 }
1643
1646 "teams.names");
1647 }
1648
1649 comment_disasters(sfile);
1650
1651 sect_idx = 0;
1653 char path[512];
1655 const char *effect_names[DE_COUNT];
1656
1657 fc_snprintf(path, sizeof(path), "disaster_%d", sect_idx++);
1658
1659 save_name_translation(sfile, &(pd->name), path);
1660 save_reqs_vector(sfile, &(pd->reqs), path, "reqs");
1661 if (pd->frequency != GAME_DEFAULT_DISASTER_FREQ) {
1662 secfile_insert_int(sfile, pd->frequency,
1663 "%s.frequency", path);
1664 }
1665
1666 set_count = 0;
1670 if (BV_ISSET(pd->effects, de)) {
1672 }
1673 }
1674
1675 if (set_count > 0) {
1677 "%s.effects", path);
1678 }
1680
1681 comment_achievements(sfile);
1682
1683 sect_idx = 0;
1685 char path[512];
1686
1687 fc_snprintf(path, sizeof(path), "achievement_%d", sect_idx++);
1688
1689 save_name_translation(sfile, &(pach->name), path);
1690
1692 "%s.type", path);
1693
1694 save_default_bool(sfile, pach->unique,
1696 path, "unique");
1697 save_default_int(sfile, pach->value,
1699 path, "value");
1700 save_default_int(sfile, pach->culture,
1701 0, path, "culture");
1702
1703 secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
1704 if (pach->cons_msg != NULL) {
1705 secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
1706 }
1707
1709
1711
1712 set_count = 0;
1713 for (trt = 0; trt < TRT_LAST; trt++) {
1716
1717 if (set->trade_pct != 100 || strcmp(cancelling, "Active")) {
1718 char path[256];
1719
1720 fc_snprintf(path, sizeof(path),
1721 "trade.settings%d", set_count++);
1722
1724 "%s.type", path);
1725 secfile_insert_int(sfile, set->trade_pct,
1726 "%s.pct", path);
1728 "%s.cancelling", path);
1730 "%s.bonus", path);
1731 }
1732 }
1733
1735 0, "trade.min_trade_route_val", NULL);
1736
1738 FALSE, "trade.reveal_trade_partner", NULL);
1739
1742 "trade.goods_selection");
1743 }
1744
1745 /* Goods */
1746 comment_goods(sfile);
1747
1748 sect_idx = 0;
1750 char path[512];
1751 const char *flag_names[GF_COUNT];
1752 int flagi;
1753
1754 fc_snprintf(path, sizeof(path), "goods_%d", sect_idx++);
1755
1756 save_name_translation(sfile, &(pgood->name), path);
1757
1758 save_reqs_vector(sfile, &(pgood->reqs), path, "reqs");
1759
1760 save_default_int(sfile, pgood->from_pct, 100, path, "from_pct");
1761 save_default_int(sfile, pgood->to_pct, 100, path, "to_pct");
1762 save_default_int(sfile, pgood->onetime_pct, 100, path, "onetime_pct");
1763
1764 set_count = 0;
1765 for (flagi = 0; flagi < GF_COUNT; flagi++) {
1766 if (goods_has_flag(pgood, flagi)) {
1768 }
1769 }
1770
1771 if (set_count > 0) {
1773 "%s.flags", path);
1774 }
1775
1776 save_strvec(sfile, pgood->helptext, path, "helptext");
1778
1779 /* Clauses */
1780 comment_clauses(sfile);
1781
1782 sect_idx = 0;
1783 for (i = 0; i < CLAUSE_COUNT; i++) {
1784 struct clause_info *info = clause_info_get(i);
1785
1786 if (info->enabled) {
1787 char path[512];
1788
1789 fc_snprintf(path, sizeof(path), "clause_%d", sect_idx++);
1790
1792 "%s.type", path);
1793 save_reqs_vector(sfile, &(info->giver_reqs), path, "giver_reqs");
1794 save_reqs_vector(sfile, &(info->receiver_reqs), path, "receiver_reqs");
1795 }
1796 }
1797
1798 /* Counters */
1799 comment_counters(sfile);
1800
1801 sect_idx = 0;
1803 char path[512];
1804
1805 fc_snprintf(path, sizeof(path), "counter_%d", sect_idx++);
1806
1807 save_name_translation(sfile, &(pcounter->name), path);
1808
1809 save_default_int(sfile, pcounter->def, 0, path, "def");
1810 save_default_int(sfile, pcounter->checkpoint, 0, path, "checkpoint");
1811
1812 secfile_insert_str(sfile, counter_behaviour_name(pcounter->type), "%s.type", path);
1813 if ((NULL != pcounter->helptext)
1814 && (0 < strvec_size(pcounter->helptext))) {
1815 save_strvec(sfile, pcounter->helptext, "%s.helptext", path);
1816 }
1817
1819
1820 locks = FALSE;
1823 locks = TRUE;
1824 break;
1825 }
1827
1828 set_count = 0;
1830 struct sf_cb_data info = { pset, FALSE };
1831
1834 "settings.set%d.name", set_count);
1835 switch (setting_type(pset)) {
1836 case SST_BOOL:
1838 "settings.set%d.value", set_count);
1839 break;
1840 case SST_INT:
1842 "settings.set%d.value", set_count);
1843 break;
1844 case SST_STRING:
1846 "settings.set%d.value", set_count);
1847 break;
1848 case SST_ENUM:
1851 "settings.set%d.value", set_count);
1852 break;
1853 case SST_BITWISE:
1856 "settings.set%d.value", set_count);
1857 break;
1858 case SST_COUNT:
1860 secfile_insert_str(sfile, "Unknown setting type",
1861 "settings.set%d.value", set_count);
1862 break;
1863 }
1864
1865 if (locks) {
1867 "settings.set%d.lock", set_count);
1868 }
1869
1870 set_count++;
1871 }
1873
1874 return save_ruleset_file(sfile, filename);
1875}
1876
1877/**********************************************************************/
1880static bool save_governments_ruleset(const char *filename, const char *name)
1881{
1882 struct section_file *sfile = create_ruleset_file(name, "government");
1883 int sect_idx;
1884
1885 if (sfile == NULL) {
1886 return FALSE;
1887 }
1888
1889 save_gov_ref(sfile, game.government_during_revolution, "governments",
1890 "during_revolution");
1891
1892 comment_govs(sfile);
1893
1894 sect_idx = 0;
1896 char path[512];
1897 struct ruler_title *prtitle;
1898
1899 fc_snprintf(path, sizeof(path), "government_%d", sect_idx++);
1900
1901 save_name_translation(sfile, &(pg->name), path);
1902
1903 secfile_insert_str(sfile, pg->graphic_str, "%s.graphic", path);
1904 secfile_insert_str(sfile, pg->graphic_alt, "%s.graphic_alt", path);
1905
1906 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1907
1908 if (pg->ai.better != NULL) {
1909 save_gov_ref(sfile, pg->ai.better, path,
1910 "ai_better");
1911 }
1912
1913 ruler_title_hash_lookup(pg->ruler_titles, NULL,
1914 &prtitle);
1915 if (prtitle != NULL) {
1916 const char *title;
1917
1919 if (title != NULL) {
1921 "%s.ruler_male_title", path);
1922 }
1923
1925 if (title != NULL) {
1927 "%s.ruler_female_title", path);
1928 }
1929 }
1930
1931 save_strvec(sfile, pg->helptext, path, "helptext");
1932
1934
1935 comment_policies(sfile);
1936
1937 sect_idx = 0;
1938 multipliers_iterate(pmul) {
1939 if (!pmul->ruledit_disabled) {
1940 char path[512];
1941
1942 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
1943
1944 save_name_translation(sfile, &(pmul->name), path);
1945
1946 secfile_insert_int(sfile, pmul->start, "%s.start", path);
1947 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
1948 secfile_insert_int(sfile, pmul->step, "%s.step", path);
1949 secfile_insert_int(sfile, pmul->def, "%s.default", path);
1950
1951 save_default_int(sfile, pmul->offset, 0, path, "offset");
1952 save_default_int(sfile, pmul->factor, 100, path, "factor");
1953 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
1954
1955 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
1956
1957 save_strvec(sfile, pmul->helptext, path, "helptext");
1958 }
1960
1961 return save_ruleset_file(sfile, filename);
1962}
1963
1964/**********************************************************************/
1967static bool save_traits(struct trait_limits *traits,
1968 struct trait_limits *default_traits,
1969 struct section_file *sfile,
1970 const char *secname, const char *field_prefix)
1971{
1972 enum trait tr;
1973
1974 /* FIXME: Use specenum trait names without duplicating them here.
1975 * Just needs to take care of case.
1976 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
1977 const char *trait_names[] = {
1978 "expansionist",
1979 "trader",
1980 "aggressive",
1981 "builder",
1982 NULL
1983 };
1984
1985 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != NULL;
1986 tr = trait_next(tr)) {
1987 int default_default;
1988
1989 default_default = (traits[tr].min + traits[tr].max) / 2;
1990
1991 if ((default_traits == NULL && traits[tr].min != TRAIT_DEFAULT_VALUE)
1992 || (default_traits != NULL && traits[tr].min != default_traits[tr].min)) {
1993 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
1994 trait_names[tr]);
1995 }
1996 if ((default_traits == NULL && traits[tr].max != TRAIT_DEFAULT_VALUE)
1997 || (default_traits != NULL && traits[tr].max != default_traits[tr].max)) {
1998 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
1999 trait_names[tr]);
2000 }
2001 if (default_default != traits[tr].fixed) {
2002 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
2003 trait_names[tr]);
2004 }
2005 }
2006
2007 return TRUE;
2008}
2009
2010/**********************************************************************/
2013static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
2014 int sect_idx)
2015{
2016 char path[512];
2017 int max_items = nation_city_list_size(pnat->server.default_cities);
2018 char *city_str[max_items];
2021 const char *list_items[max_items];
2022 int set_count;
2023 int subsect_idx;
2024
2025 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
2026
2027 if (pnat->translation_domain == NULL) {
2028 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
2029 } else {
2030 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
2031 }
2032
2033 save_name_translation(sfile, &(pnat->adjective), path);
2034 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
2035
2036 set_count = 0;
2038 if (nation_is_in_set(pnat, pset)) {
2040 }
2045 }
2047
2048 if (set_count > 0) {
2049 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
2050 }
2051
2052 set_count = 0;
2053 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
2056 if (set_count > 0) {
2057 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
2058 }
2059
2060 subsect_idx = 0;
2062 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
2063 path, subsect_idx);
2064 secfile_insert_str(sfile,
2067 "%s.leaders%d.sex", path, subsect_idx++);
2069
2070 if (pnat->server.rgb != NULL) {
2071 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
2072 }
2073
2074 save_traits(pnat->server.traits, game.server.default_traits,
2075 sfile, path, "trait_");
2076
2077 if (!pnat->is_playable) {
2078 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
2079 }
2080
2081 if (pnat->barb_type != NOT_A_BARBARIAN) {
2082 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
2083 "%s.barbarian_type", path);
2084 }
2085
2086 if (strcmp(pnat->flag_graphic_str, "-")) {
2087 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
2088 }
2089 if (strcmp(pnat->flag_graphic_alt, "-")) {
2090 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
2091 }
2092
2093 subsect_idx = 0;
2095 struct ruler_title *prtitle;
2096
2097 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
2099 "%s.ruler_titles%d.government", path, subsect_idx);
2101 "%s.ruler_titles%d.male_title", path, subsect_idx);
2103 "%s.ruler_titles%d.female_title", path, subsect_idx++);
2104 }
2106
2107 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
2108
2109 set_count = 0;
2110 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
2113 if (set_count > 0) {
2114 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
2115 }
2116
2117 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
2118 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
2119 save_unit_list(sfile, pnat->init_units, path, "init_units");
2120
2121 if (pnat->init_government) {
2122 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
2123 "%s.init_government", path);
2124 }
2125
2126 set_count = 0;
2127 nation_city_list_iterate(pnat->server.default_cities, pncity) {
2128 bool list_started = FALSE;
2129
2131 + strlen(")")
2132 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
2133
2136 case NCP_DISLIKE:
2137 strcat(city_str[set_count], " (!river");
2139 break;
2140 case NCP_LIKE:
2141 strcat(city_str[set_count], " (river");
2143 break;
2144 case NCP_NONE:
2145 break;
2146 }
2147
2149 const char *pref = NULL;
2150
2152 case NCP_DISLIKE:
2153 pref = "!";
2154 break;
2155 case NCP_LIKE:
2156 pref = "";
2157 break;
2158 case NCP_NONE:
2159 pref = NULL;
2160 break;
2161 }
2162
2163 if (pref != NULL) {
2164 if (list_started) {
2165 strcat(city_str[set_count], ", ");
2166 } else {
2167 strcat(city_str[set_count], " (");
2169 }
2172 }
2173
2175
2176 if (list_started) {
2177 strcat(city_str[set_count], ")");
2178 }
2179
2181 set_count++;
2183 if (set_count > 0) {
2184 int i;
2185
2186 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
2187
2188 for (i = 0; i < set_count; i++) {
2189 FC_FREE(city_str[i]);
2190 }
2191 }
2192
2193 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
2194
2195 return TRUE;
2196}
2197
2198/**********************************************************************/
2201static bool save_nations_ruleset(const char *filename, const char *name,
2202 struct rule_data *data)
2203{
2204 struct section_file *sfile = create_ruleset_file(name, "nation");
2205
2206 if (sfile == NULL) {
2207 return FALSE;
2208 }
2209
2210 if (data->nationlist != NULL || game.server.ruledit.embedded_nations != NULL) {
2212 if (data->nationlist != NULL) {
2213 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2214 }
2216 int i;
2217 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2218
2219 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2220 * resrictions */
2221 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2223 }
2224
2227 "ruledit.embedded_nations");
2228 free(tmp);
2229 }
2230 }
2231
2233 "default_traits", "");
2234
2235 if (data->nationlist == NULL) {
2239 "compatibility.allowed_govs");
2240 }
2244 "compatibility.allowed_terrains");
2245 }
2249 "compatibility.allowed_styles");
2250 }
2251 }
2252
2253 if (game.default_government != NULL) {
2255 "compatibility.default_government");
2256 }
2257
2258 if (data->nationlist != NULL) {
2259 secfile_insert_include(sfile, data->nationlist);
2260
2262 int sect_idx;
2263
2264 comment_nations(sfile);
2265
2267 sect_idx++) {
2268 struct nation_type *pnat
2270
2271 if (pnat == NULL) {
2272 log_error("Embedded nation \"%s\" not found!",
2274 } else {
2275 save_nation(sfile, pnat, sect_idx);
2276 }
2277 }
2278 }
2279 } else {
2280 int sect_idx = 0;
2281
2282 comment_nationsets(sfile);
2283
2285 char path[512];
2286
2287 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2288
2289 /* We don't use save_name_translation() for this as name and rule_name must
2290 * always be saved separately */
2291 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2292 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2293 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2295
2296 comment_nationgroups(sfile);
2297
2298 sect_idx = 0;
2300 char path[512];
2301
2302 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2303
2304 save_name_translation(sfile, &(pgroup->name), path);
2305
2306 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2307 if (pgroup->hidden) {
2308 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2309 }
2311
2312 comment_nations(sfile);
2313
2314 sect_idx = 0;
2316 save_nation(sfile, pnat, sect_idx++);
2318 }
2319
2320 return save_ruleset_file(sfile, filename);
2321}
2322
2323/**********************************************************************/
2326static bool save_techs_ruleset(const char *filename, const char *name)
2327{
2328 struct section_file *sfile = create_ruleset_file(name, "tech");
2329 int i;
2330 int sect_idx;
2332 bool uflags_tech = FALSE;
2333
2334 if (sfile == NULL) {
2335 return FALSE;
2336 }
2337
2338 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2339 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2340 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2341
2342 if (flagname != NULL) {
2343 if (!uflags_tech) {
2344 comment_uflags_tech(sfile);
2345 uflags_tech = TRUE;
2346 }
2347
2348 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2349
2350 /* Save the user flag help text even when it is undefined. That makes
2351 * the formatting code happy. The resulting "" is ignored when the
2352 * ruleset is loaded. */
2353 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2354 }
2355 }
2356
2357 comment_tech_classes(sfile);
2358
2359 sect_idx = 0;
2361 char path[512];
2362
2363 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2364
2365 save_name_translation(sfile, &(ptclass->name), path);
2367
2368 comment_techs(sfile);
2369
2370 sect_idx = 0;
2372 if (pa->require[AR_ONE] != A_NEVER) {
2373 char path[512];
2374 const char *flag_names[TF_COUNT];
2375 int set_count;
2376 int flagi;
2377
2378 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2379
2380 save_name_translation(sfile, &(pa->name), path);
2381
2382 if (game.control.num_tech_classes > 0) {
2383 if (pa->tclass != NULL) {
2385 "%s.class", path);
2386 }
2387 }
2388
2389 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2390 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2391 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2392 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2393 }
2394
2395 save_reqs_vector(sfile, &(pa->research_reqs), path,
2396 "research_reqs");
2397
2398 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2399 if (strcmp("-", pa->graphic_alt)) {
2400 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2401 }
2402 if (pa->bonus_message != NULL) {
2403 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2404 }
2405
2406 set_count = 0;
2407 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2410 }
2411 }
2412
2413 if (set_count > 0) {
2415 "%s.flags", path);
2416 }
2417 if (pa->cost >= 0) {
2418 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2419 }
2420
2421 save_strvec(sfile, pa->helptext, path, "helptext");
2422 }
2423
2425
2426 return save_ruleset_file(sfile, filename);
2427}
2428
2429/**********************************************************************/
2432static bool save_terrain_ruleset(const char *filename, const char *name)
2433{
2434 struct section_file *sfile = create_ruleset_file(name, "terrain");
2435 int sect_idx;
2436 int i;
2437 bool uflags_terr = FALSE;
2438 bool uflags_extra = FALSE;
2439
2440 if (sfile == NULL) {
2441 return FALSE;
2442 }
2443
2444 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2446 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2447
2448 if (flagname != NULL) {
2449 if (!uflags_terr) {
2451 uflags_terr = TRUE;
2452 }
2453
2454 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2455
2456 /* Save the user flag help text even when it is undefined. That makes
2457 * the formatting code happy. The resulting "" is ignored when the
2458 * ruleset is loaded. */
2459 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2460 }
2461 }
2462
2463 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2465 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2466
2467 if (flagname != NULL) {
2468 if (!uflags_extra) {
2469 /* TODO: Uncomment this, once there's a way to stop
2470 * the comment getting written inside preceding
2471 * terrain flags table. */
2472 /* comment_uflags_extra(sfile); */
2474 }
2475
2476 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2477
2478 /* Save the user flag help text even when it is undefined. That makes
2479 * the formatting code happy. The resulting "" is ignored when the
2480 * ruleset is loaded. */
2481 secfile_insert_str(sfile, helptxt,
2482 "control.extra_flags%d.helptxt", i);
2483 }
2484 }
2485
2486 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2487 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2488 "parameters.ocean_reclaim_requirement");
2489 }
2490 if (terrain_control.land_channel_requirement_pct <= 100) {
2491 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2492 "parameters.land_channel_requirement");
2493 }
2494 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2495 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2496 "parameters.thaw_requirement");
2497 }
2498 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2499 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2500 "parameters.freeze_requirement");
2501 }
2502 if (terrain_control.lake_max_size != 0) {
2503 secfile_insert_int(sfile, terrain_control.lake_max_size,
2504 "parameters.lake_max_size");
2505 }
2506 if (terrain_control.min_start_native_area != 0) {
2507 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2508 "parameters.min_start_native_area");
2509 }
2510 if (terrain_control.move_fragments != 3) {
2511 secfile_insert_int(sfile, terrain_control.move_fragments,
2512 "parameters.move_fragments");
2513 }
2514 if (terrain_control.igter_cost != 1) {
2515 secfile_insert_int(sfile, terrain_control.igter_cost,
2516 "parameters.igter_cost");
2517 }
2518 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2519 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2520 "parameters.pythagorean_diagonal");
2521 }
2524 "parameters.ocean_resources");
2525 }
2526
2527 comment_terrains(sfile);
2528
2529 sect_idx = 0;
2531 char path[512];
2532 char identifier[2];
2533 int r;
2534 const char *flag_names[TER_USER_LAST];
2535 const char *puc_names[UCL_LAST];
2536 int flagi;
2537 int set_count;
2538
2539 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2540
2541 save_name_translation(sfile, &(pterr->name), path);
2542
2543 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2544 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2545 secfile_insert_str(sfile, pterr->graphic_alt2, "%s.graphic_alt2", path);
2546 identifier[0] = pterr->identifier;
2547 identifier[1] = '\0';
2548 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2549
2551 "%s.class", path);
2552
2553 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2554 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2555
2557 if (pterr->output[o] != 0) {
2558 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2560 }
2562
2563 /* Check resource count */
2564 for (r = 0; pterr->resources[r] != NULL; r++) {
2565 /* Just increasing r as long as there is resources */
2566 }
2567
2568 {
2569 const char *resource_names[r];
2570 bool save_frequencies = FALSE;
2571
2572 r = 0;
2577 }
2579
2581 "%s.resources", path);
2582
2583 if (save_frequencies) {
2584 secfile_insert_int_vec(sfile, pterr->resource_freq, r,
2585 "%s.resource_freq", path);
2586 }
2587 }
2588
2590 if (pterr->road_output_incr_pct[o] != 0) {
2591 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2592 "%s.road_%s_incr_pct", path,
2594 }
2596
2597 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2598 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2599
2600 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2601 "cultivate_result");
2602 secfile_insert_int(sfile, pterr->cultivate_time,
2603 "%s.cultivate_time", path);
2604
2605 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2606 "plant_result");
2607 secfile_insert_int(sfile, pterr->plant_time,
2608 "%s.plant_time", path);
2609
2610 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2611 "%s.irrigation_food_incr", path);
2612 secfile_insert_int(sfile, pterr->irrigation_time,
2613 "%s.irrigation_time", path);
2614
2615 secfile_insert_int(sfile, pterr->mining_shield_incr,
2616 "%s.mining_shield_incr", path);
2617 secfile_insert_int(sfile, pterr->mining_time,
2618 "%s.mining_time", path);
2619
2620 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2621 "transform_result");
2622 secfile_insert_int(sfile, pterr->transform_time,
2623 "%s.transform_time", path);
2624
2625 if (pterr->animal != NULL) {
2627 "%s.animal", path);
2628 } else {
2629 secfile_insert_str(sfile, "None",
2630 "%s.animal", path);
2631 }
2632
2633 secfile_insert_int(sfile, pterr->placing_time,
2634 "%s.placing_time", path);
2635 secfile_insert_int(sfile, pterr->pillage_time,
2636 "%s.pillage_time", path);
2637
2638 i = 0;
2639 extra_type_iterate(pextra) {
2640 int rmtime = pterr->extra_removal_times[extra_index(pextra)];
2641
2642 if (rmtime != 0) {
2643 secfile_insert_str(sfile, extra_rule_name(pextra),
2644 "%s.extra_settings%d.extra",
2645 path, i);
2647 "%s.extra_settings%d.removal_time",
2648 path, i++);
2649 }
2651
2652 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2653 "warmer_wetter_result");
2654 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2655 "warmer_drier_result");
2656 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2657 "cooler_wetter_result");
2658 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2659 "cooler_drier_result");
2660
2661 set_count = 0;
2662 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2665 }
2666 }
2667
2668 if (set_count > 0) {
2670 "%s.flags", path);
2671 }
2672
2673 {
2675
2679 if (pterr->property[mtp] != 0) {
2680 secfile_insert_int(sfile, pterr->property[mtp],
2681 "%s.property_%s", path,
2683 }
2684 }
2685 }
2686
2687 set_count = 0;
2689 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2691 }
2693
2694 if (set_count > 0) {
2696 "%s.native_to", path);
2697 }
2698
2699 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2700
2701 save_strvec(sfile, pterr->helptext, path, "helptext");
2702
2704
2705 comment_resources(sfile);
2706
2707 sect_idx = 0;
2709 if (!pres->ruledit_disabled) {
2710 char path[512];
2711 char identifier[2];
2712
2713 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2714
2716 "%s.extra", path);
2717
2719 if (pres->data.resource->output[o] != 0) {
2720 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2721 path, get_output_identifier(o));
2722 }
2724
2725 if (pres->data.resource->id_old_save != '\0') {
2726 identifier[0] = pres->data.resource->id_old_save;
2727 identifier[1] = '\0';
2728 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2729 }
2730 }
2732
2733 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2734 "extraui.ui_name_base_fortress");
2735 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2736 "extraui.ui_name_base_airbase");
2737
2738 comment_extras(sfile);
2739
2740 sect_idx = 0;
2742 char path[512];
2743 const char *flag_names[EF_COUNT];
2744 const char *cause_names[EC_COUNT];
2745 const char *puc_names[UCL_LAST];
2746 const char *extra_names[MAX_EXTRA_TYPES];
2747 int flagi;
2748 int causei;
2749 int set_count;
2750 bool worker_cause;
2751
2752 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2753
2754 save_name_translation(sfile, &(pextra->name), path);
2755
2756 secfile_insert_str(sfile, extra_category_name(pextra->category),
2757 "%s.category", path);
2758
2759 set_count = 0;
2760 for (causei = 0; causei < EC_COUNT; causei++) {
2761 if (is_extra_caused_by(pextra, causei)) {
2763 }
2764 }
2765
2766 if (set_count > 0) {
2768 "%s.causes", path);
2769 }
2770
2771 set_count = 0;
2772 for (causei = 0; causei < ERM_COUNT; causei++) {
2773 if (is_extra_removed_by(pextra, causei)) {
2775 }
2776 }
2777
2778 if (set_count > 0) {
2780 "%s.rmcauses", path);
2781 }
2782
2783 if (strcmp(pextra->graphic_str, "-")) {
2784 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2785 }
2786 if (strcmp(pextra->graphic_alt, "-")) {
2787 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2788 }
2789 if (strcmp(pextra->activity_gfx, "-")) {
2790 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2791 }
2792 if (strcmp(pextra->act_gfx_alt, "-")) {
2793 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2794 }
2795 if (strcmp(pextra->act_gfx_alt2, "-")) {
2796 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2797 }
2798 if (strcmp(pextra->rmact_gfx, "-")) {
2799 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2800 }
2801 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2802 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2803 }
2804
2805 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2806 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2807 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2808 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2809
2811 if ((!pextra->buildable && worker_cause)
2812 || (pextra->buildable && !worker_cause)) {
2813 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2814 }
2815 if (!pextra->generated) {
2816 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2817 }
2818 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2819 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2820 if (pextra->build_time_factor != 1) {
2821 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2822 }
2823 if (pextra->removal_time_factor != 1) {
2824 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2825 }
2826 if (pextra->infracost != 0) {
2827 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2828 }
2829 if (pextra->defense_bonus != 0) {
2830 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2831 }
2832 if (pextra->eus != EUS_NORMAL) {
2834 "%s.unit_seen", path);
2835 }
2837 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2838 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2839 }
2841 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2842 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2843 path);
2844 }
2845
2846 set_count = 0;
2848 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2850 }
2852
2853 if (set_count > 0) {
2855 "%s.native_to", path);
2856 }
2857
2858 if (pextra->no_aggr_near_city >= 0) {
2859 secfile_insert_int(sfile, pextra->no_aggr_near_city,
2860 "%s.no_aggr_near_city", path);
2861 }
2862
2863 set_count = 0;
2864 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2865 if (extra_has_flag(pextra, flagi)) {
2867 }
2868 }
2869
2870 if (set_count > 0) {
2872 "%s.flags", path);
2873 }
2874
2875 set_count = 0;
2877 if (!can_extras_coexist(pextra, confl)) {
2879 }
2881
2882 if (set_count > 0) {
2884 "%s.conflicts", path);
2885 }
2886
2887 set_count = 0;
2888 extra_type_iterate(top) {
2889 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2891 }
2893
2894 if (set_count > 0) {
2896 "%s.hidden_by", path);
2897 }
2898
2899 set_count = 0;
2900 extra_type_iterate(top) {
2901 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2903 }
2905
2906 if (set_count > 0) {
2908 "%s.bridged_over", path);
2909 }
2910
2911 save_strvec(sfile, pextra->helptext, path, "helptext");
2912
2914
2915 comment_bases(sfile);
2916
2917 sect_idx = 0;
2919 if (!pextra->ruledit_disabled) {
2920 char path[512];
2921 struct base_type *pbase = extra_base_get(pextra);
2922
2923 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2924
2925 secfile_insert_str(sfile, extra_rule_name(pextra),
2926 "%s.extra", path);
2927
2929 "%s.gui_type", path);
2930
2931 if (pbase->border_sq >= 0) {
2932 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
2933 }
2934 if (pbase->vision_main_sq >= 0) {
2935 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
2936 }
2937 if (pbase->vision_invis_sq >= 0) {
2938 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
2939 }
2940 if (pbase->vision_subs_sq >= 0) {
2941 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
2942 }
2943 }
2945
2946 comment_roads(sfile);
2947
2948 sect_idx = 0;
2950 if (!pextra->ruledit_disabled) {
2951 struct road_type *proad = extra_road_get(pextra);
2952 char path[512];
2953 const char *flag_names[RF_COUNT];
2954 int flagi;
2955 int set_count;
2956
2957 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
2958
2959 secfile_insert_str(sfile, extra_rule_name(pextra),
2960 "%s.extra", path);
2961
2962 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
2963
2964 if (proad->move_mode != RMM_FAST_ALWAYS) {
2965 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
2966 "%s.move_mode", path);
2967 }
2968
2970 if (proad->tile_incr_const[o] != 0) {
2971 secfile_insert_int(sfile, proad->tile_incr_const[o],
2972 "%s.%s_incr_const", path, get_output_identifier(o));
2973 }
2974 if (proad->tile_incr[o] != 0) {
2975 secfile_insert_int(sfile, proad->tile_incr[o],
2976 "%s.%s_incr", path, get_output_identifier(o));
2977 }
2978 if (proad->tile_bonus[o] != 0) {
2979 secfile_insert_int(sfile, proad->tile_bonus[o],
2980 "%s.%s_bonus", path, get_output_identifier(o));
2981 }
2983
2984 switch (proad->compat) {
2985 case ROCO_ROAD:
2986 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
2987 break;
2988 case ROCO_RAILROAD:
2989 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
2990 break;
2991 case ROCO_RIVER:
2992 secfile_insert_str(sfile, "River", "%s.compat_special", path);
2993 break;
2994 case ROCO_NONE:
2995 secfile_insert_str(sfile, "None", "%s.compat_special", path);
2996 break;
2997 }
2998
3000 "%s.gui_type", path);
3001
3002 set_count = 0;
3003 for (flagi = 0; flagi < RF_COUNT; flagi++) {
3004 if (road_has_flag(proad, flagi)) {
3006 }
3007 }
3008
3009 if (set_count > 0) {
3011 "%s.flags", path);
3012 }
3013 }
3015
3016 return save_ruleset_file(sfile, filename);
3017}
3018
3019/**********************************************************************/
3022static bool save_veteran_system(struct section_file *sfile, const char *path,
3023 struct veteran_system *vsystem)
3024{
3025 const char *vlist_name[vsystem->levels];
3026 int vlist_power[vsystem->levels];
3027 int vlist_raise[vsystem->levels];
3028 int vlist_wraise[vsystem->levels];
3029 int vlist_move[vsystem->levels];
3030 int i;
3031
3032 for (i = 0; i < vsystem->levels; i++) {
3033 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
3034 vlist_power[i] = vsystem->definitions[i].power_fact;
3035 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
3036 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
3037 vlist_move[i] = vsystem->definitions[i].move_bonus;
3038 }
3039
3041 "%s.veteran_names", path);
3043 "%s.veteran_power_fact", path);
3045 "%s.veteran_base_raise_chance", path);
3047 "%s.veteran_work_raise_chance", path);
3049 "%s.veteran_move_bonus", path);
3050
3051 return TRUE;
3052}
3053
3054/**********************************************************************/
3057static bool save_combat_bonuses(struct section_file *sfile,
3058 struct unit_type *put,
3059 char *path)
3060{
3061 int i;
3062 bool has_quiet = FALSE;
3063
3065 if (pbonus->quiet) {
3066 has_quiet = TRUE;
3067 }
3069
3070 i = 0;
3071
3074 "%s.bonuses%d.flag", path, i);
3076 "%s.bonuses%d.type", path, i);
3077 secfile_insert_int(sfile, pbonus->value,
3078 "%s.bonuses%d.value", path, i);
3079
3080 if (has_quiet) {
3081 secfile_insert_bool(sfile, pbonus->quiet,
3082 "%s.bonuses%d.quiet", path, i);
3083 }
3084
3085 i++;
3087
3088 return TRUE;
3089}
3090
3091/**********************************************************************/
3094static bool save_units_ruleset(const char *filename, const char *name)
3095{
3096 struct section_file *sfile = create_ruleset_file(name, "unit");
3097 int i;
3098 int sect_idx;
3099 bool uflags_utype = FALSE;
3100 bool uflags_uclass = FALSE;
3101
3102 if (sfile == NULL) {
3103 return FALSE;
3104 }
3105
3106 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
3108 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
3109
3110 if (flagname != NULL) {
3111 if (!uflags_utype) {
3112 comment_uflags_utype(sfile);
3114 }
3115
3116 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
3117
3118 /* Save the user flag help text even when it is undefined. That makes
3119 * the formatting code happy. The resulting "" is ignored when the
3120 * ruleset is loaded. */
3121 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
3122 }
3123 }
3124
3125 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
3127 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
3128
3129 if (flagname != NULL) {
3130 if (!uflags_uclass) {
3131 /* TODO: Uncomment this, once there's a way to stop
3132 * the comment getting written inside preceding
3133 * utype flags table. */
3134 /* comment_uflags_uclass(sfile); */
3136 }
3137
3138 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
3139
3140 /* Save the user flag help text even when it is undefined. That makes
3141 * the formatting code happy. The resulting "" is ignored when the
3142 * ruleset is loaded. */
3143 secfile_insert_str(sfile, helptxt,
3144 "control.class_flags%d.helptxt", i);
3145 }
3146 }
3147
3148 save_veteran_system(sfile, "veteran_system", game.veteran);
3149
3150 comment_uclasses(sfile);
3151
3152 sect_idx = 0;
3154 char path[512];
3155 const char *flag_names[UCF_COUNT];
3156 int flagi;
3157 int set_count;
3158
3159 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
3160
3161 save_name_translation(sfile, &(puc->name), path);
3162
3163 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
3164 "%s.min_speed", path);
3165 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
3166 if (puc->non_native_def_pct != 100) {
3167 secfile_insert_int(sfile, puc->non_native_def_pct,
3168 "%s.non_native_def_pct", path);
3169 }
3170
3171 set_count = 0;
3172 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
3173 if (uclass_has_flag(puc, flagi)) {
3175 }
3176 }
3177
3178 if (set_count > 0) {
3180 "%s.flags", path);
3181 }
3182
3183 save_strvec(sfile, puc->helptext, path, "helptext");
3184
3186
3187 comment_utypes(sfile);
3188
3189 sect_idx = 0;
3191 if (!put->ruledit_disabled) {
3192 char path[512];
3193 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
3194 int flagi;
3195 int set_count;
3196
3197 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
3198
3199 save_name_translation(sfile, &(put->name), path);
3200
3201 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
3202 "%s.class", path);
3203
3204 save_reqs_vector(sfile, &(put->build_reqs), path, "reqs");
3205
3206 if (put->obsoleted_by != NULL) {
3207 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
3208 "%s.obsolete_by", path);
3209 }
3210
3211 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
3212 if (strcmp("-", put->graphic_alt)) {
3213 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
3214 }
3215 if (strcmp("-", put->graphic_alt2)) {
3216 secfile_insert_str(sfile, put->graphic_alt2, "%s.graphic_alt2", path);
3217 }
3218 if (strcmp("-", put->sound_move)) {
3219 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
3220 }
3221 if (strcmp("-", put->sound_move_alt)) {
3222 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
3223 }
3224 if (strcmp("-", put->sound_fight)) {
3225 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
3226 }
3227 if (strcmp("-", put->sound_fight_alt)) {
3228 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
3229 }
3230
3231 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
3232 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
3233 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
3234 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
3235 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
3236 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3237 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3238
3239 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3240 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3241 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3242
3243 if (put->vlayer != V_MAIN) {
3245 "%s.vision_layer", path);
3246 }
3247
3248 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3249 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3250 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3251 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3252
3254 if (put->upkeep[o] != 0) {
3255 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3256 path, get_output_identifier(o));
3257 }
3259
3260 if (put->converted_to != NULL) {
3261 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3262 "%s.convert_to", path);
3263 }
3264 if (put->convert_time != 1) {
3265 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3266 }
3267
3268 save_combat_bonuses(sfile, put, path);
3269 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3270
3271 if (put->veteran != NULL) {
3272 save_veteran_system(sfile, path, put->veteran);
3273 }
3274
3275 if (put->paratroopers_range != 0) {
3276 secfile_insert_int(sfile, put->paratroopers_range,
3277 "%s.paratroopers_range", path);
3278 }
3279 if (put->bombard_rate != 0) {
3280 secfile_insert_int(sfile, put->bombard_rate,
3281 "%s.bombard_rate", path);
3282 }
3283 if (put->city_slots != 0) {
3284 secfile_insert_int(sfile, put->city_slots,
3285 "%s.city_slots", path);
3286 }
3287 if (put->city_size != 1) {
3288 secfile_insert_int(sfile, put->city_size,
3289 "%s.city_size", path);
3290 }
3291
3292 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3293 "%s.tp_defense", path);
3294
3295 set_count = 0;
3296 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3297 if (utype_has_flag(put, flagi)) {
3299 }
3300 }
3301
3302 if (set_count > 0) {
3304 "%s.flags", path);
3305 }
3306
3307 set_count = 0;
3308 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3309 if (utype_has_role(put, flagi)) {
3311 }
3312 }
3313
3314 if (set_count > 0) {
3316 "%s.roles", path);
3317 }
3318
3319 save_strvec(sfile, put->helptext, path, "helptext");
3320 }
3322
3323 return save_ruleset_file(sfile, filename);
3324}
3325
3326/**********************************************************************/
3329static bool save_script_lua(const char *filename, const char *name,
3330 const char *buffer)
3331{
3332 if (buffer != NULL) {
3333 FILE *ffile = fc_fopen(filename, "w");
3334 int full_len = strlen(buffer);
3335 int len;
3336
3337 if (ffile != NULL) {
3338 len = fwrite(buffer, 1, full_len, ffile);
3339
3340 if (len != full_len) {
3341 return FALSE;
3342 }
3343
3344 fclose(ffile);
3345 } else {
3346 return FALSE;
3347 }
3348 }
3349
3350 return TRUE;
3351}
3352
3353/**********************************************************************/
3356static bool save_luadata(const char *filename)
3357{
3358 if (game.server.luadata != NULL) {
3359 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3360 }
3361
3362 return TRUE;
3363}
3364
3365/**********************************************************************/
3368bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3369{
3370 if (make_dir(path)) {
3371 bool success = TRUE;
3372 char filename[500];
3373
3374 if (success) {
3375 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3376 success = save_buildings_ruleset(filename, name);
3377 }
3378
3379 if (success) {
3380 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3381 success = save_styles_ruleset(filename, name);
3382 }
3383
3384 if (success) {
3385 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3386 success = save_cities_ruleset(filename, name);
3387 }
3388
3389 if (success) {
3390 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3391 success = save_effects_ruleset(filename, name);
3392 }
3393
3394 if (success) {
3395 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3396 success = save_game_ruleset(filename, name);
3397 }
3398
3399 if (success) {
3400 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3402 }
3403
3404 if (success) {
3405 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3406 success = save_nations_ruleset(filename, name, data);
3407 }
3408
3409 if (success) {
3410 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3411 success = save_techs_ruleset(filename, name);
3412 }
3413
3414 if (success) {
3415 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3416 success = save_terrain_ruleset(filename, name);
3417 }
3418
3419 if (success) {
3420 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3421 success = save_units_ruleset(filename, name);
3422 }
3423
3424 if (success) {
3425 fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path);
3426 success = save_actions_ruleset(filename, name);
3427 }
3428
3429 if (success) {
3430 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3432 }
3433
3434 if (success) {
3435 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3437 }
3438
3439 if (success) {
3440 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3441 success = save_luadata(filename);
3442 }
3443
3444 return success;
3445 } else {
3446 log_error(_("Failed to create directory %s"), path);
3447 return FALSE;
3448 }
3449
3450 return TRUE;
3451}
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:7113
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7749
void action_array_end(action_id *act_array, int size)
Definition actions.c:6471
bool action_is_in_use(struct action *paction)
Definition actions.c:6400
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7923
const char * action_rule_name(const struct action *action)
Definition actions.c:1968
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:7593
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:7272
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:7439
const char * action_ui_name_default(int act)
Definition actions.c:6773
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:6439
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:6508
#define action_enablers_iterate_end
Definition actions.h:517
#define enabler_get_action(_enabler_)
Definition actions.h:431
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:609
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:607
static struct action * action_by_number(action_id act_id)
Definition actions.h:633
#define NUM_ACTIONS
Definition actions.h:313
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:615
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:614
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:355
#define ACTION_AUTO_POST_WIPE_UNITS
Definition actions.h:616
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:608
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:610
#define action_iterate_end
Definition actions.h:463
#define MAX_NUM_ACTIONS
Definition actions.h:312
#define action_enablers_iterate(_enabler_)
Definition actions.h:511
#define action_iterate(_act_)
Definition actions.h:459
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:606
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:611
#define ACTION_NONE
Definition actions.h:309
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:153
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
const char * get_output_identifier(Output_type_id output)
Definition city.c:618
static const struct city struct citystyle * city_styles
Definition city.c:83
#define output_type_iterate(output)
Definition city.h:833
#define output_type_iterate_end
Definition city.h:839
void comment_borders_radius_permanent(struct section_file *sfile)
Definition comments.c:808
char * uflags_building
Definition comments.c:52
void comment_uflags_utype(struct section_file *sfile)
Definition comments.c:465
void comment_combat_rules_nuke_defender_survival(struct section_file *sfile)
Definition comments.c:764
void comment_roads(struct section_file *sfile)
Definition comments.c:401
void comment_civstyle_granary(struct section_file *sfile)
Definition comments.c:594
void comment_research_tech_leakage(struct section_file *sfile)
Definition comments.c:844
void comment_actions_ui_names(struct section_file *sfile)
Definition comments.c:782
void comment_uclasses(struct section_file *sfile)
Definition comments.c:353
void comment_calendar_fragments(struct section_file *sfile)
Definition comments.c:888
void comment_actions_quiet_actions(struct section_file *sfile)
Definition comments.c:799
void comment_uflags_terrain(struct section_file *sfile)
Definition comments.c:481
void comment_citystyles(struct section_file *sfile)
Definition comments.c:417
void comment_govs(struct section_file *sfile)
Definition comments.c:337
void comment_combat_rules_low_fp_pearl_harbour(struct section_file *sfile)
Definition comments.c:725
void comment_research_base_tech_cost(struct section_file *sfile)
Definition comments.c:826
void comment_research_tech_cost_style(struct section_file *sfile)
Definition comments.c:817
void comment_combat_rules_only_killing_veteran(struct section_file *sfile)
Definition comments.c:675
void comment_bases(struct section_file *sfile)
Definition comments.c:393
void comment_terrains(struct section_file *sfile)
Definition comments.c:369
void comment_uflags_tech(struct section_file *sfile)
Definition comments.c:497
void comment_file_header(struct section_file *sfile)
Definition comments.c:305
void comment_effects(struct section_file *sfile)
Definition comments.c:433
void comment_actions_dc_initial_odds(struct section_file *sfile)
Definition comments.c:790
void comment_combat_rules_scaled_veterancy(struct section_file *sfile)
Definition comments.c:695
void comment_research_upkeep_style(struct section_file *sfile)
Definition comments.c:853
void comment_disasters(struct section_file *sfile)
Definition comments.c:449
void comment_clauses(struct section_file *sfile)
Definition comments.c:569
void comment_goods(struct section_file *sfile)
Definition comments.c:521
char * uflags_tech
Definition comments.c:51
void comment_civstyle_gameloss_style(struct section_file *sfile)
Definition comments.c:612
char * uflags_extra
Definition comments.c:50
void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
Definition comments.c:621
void comment_extras(struct section_file *sfile)
Definition comments.c:385
void comment_combat_rules_low_fp_nonnat_bombard(struct section_file *sfile)
Definition comments.c:745
void comment_ueffs(struct section_file *sfile)
Definition comments.c:441
void comment_techs(struct section_file *sfile)
Definition comments.c:329
void comment_nations(struct section_file *sfile)
Definition comments.c:545
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:513
void comment_combat_rules_low_fp_combat_bonus(struct section_file *sfile)
Definition comments.c:735
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:586
void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile)
Definition comments.c:630
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:553
void comment_specialists(struct section_file *sfile)
Definition comments.c:537
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:425
void comment_civstyle_airlift_always(struct section_file *sfile)
Definition comments.c:639
void comment_resources(struct section_file *sfile)
Definition comments.c:377
void comment_civstyle_ransom_gold(struct section_file *sfile)
Definition comments.c:603
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:321
void comment_culture_migration_pml(struct section_file *sfile)
Definition comments.c:879
void comment_combat_rules_only_real_fight_veteran(struct section_file *sfile)
Definition comments.c:685
char * uflags_uclass
Definition comments.c:48
void comment_research_free_tech_method(struct section_file *sfile)
Definition comments.c:862
void comment_combat_rules_nuke_pop_loss(struct section_file *sfile)
Definition comments.c:755
void comment_utypes(struct section_file *sfile)
Definition comments.c:361
char * uflags_utype
Definition comments.c:47
void comment_research_min_tech_cost(struct section_file *sfile)
Definition comments.c:835
void comment_culture_history_interest(struct section_file *sfile)
Definition comments.c:871
void comment_policies(struct section_file *sfile)
Definition comments.c:345
void comment_combat_rules_low_fp_badwallattacker(struct section_file *sfile)
Definition comments.c:715
void comment_achievements(struct section_file *sfile)
Definition comments.c:457
void comment_combat_rules_damage_reduces_bombard_rate(struct section_file *sfile)
Definition comments.c:705
void comment_counters(struct section_file *sfile)
Definition comments.c:577
void comment_styles(struct section_file *sfile)
Definition comments.c:409
void comment_combat_rules_tired_attack(struct section_file *sfile)
Definition comments.c:666
void comment_uflags_building(struct section_file *sfile)
Definition comments.c:505
void comment_buildings(struct section_file *sfile)
Definition comments.c:313
void comment_enablers(struct section_file *sfile)
Definition comments.c:529
void comment_nationsets(struct section_file *sfile)
Definition comments.c:561
void comment_wonder_visibility_small_wonders(struct section_file *sfile)
Definition comments.c:648
void comment_incite_cost(struct section_file *sfile)
Definition comments.c:657
void comment_auto_attack(struct section_file *sfile)
Definition comments.c:774
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:276
#define disaster_type_iterate(_p)
Definition disaster.h:80
#define disaster_type_iterate_end
Definition disaster.h:86
struct @21::@22 reqs
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1323
enum effect_type user_effect_ai_valued_as(enum effect_type real)
Definition effects.c:1359
#define EFT_USER_EFFECT_LAST
Definition effects.h:358
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:974
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1032
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:861
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:962
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:1003
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:681
@ ROCO_RAILROAD
Definition fc_types.h:1254
@ ROCO_NONE
Definition fc_types.h:1254
@ ROCO_RIVER
Definition fc_types.h:1254
@ ROCO_ROAD
Definition fc_types.h:1254
#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:392
#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:420
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:864
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:850
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:856
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:853
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:836
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:809
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:767
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:763
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:801
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:888
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:860
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:874
#define RS_DEFAULT_HAPPY_COST
Definition game.h:841
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:878
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:815
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:765
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:498
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:879
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:849
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:870
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:783
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:828
#define GAME_DEFAULT_START_YEAR
Definition game.h:739
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:789
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:868
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:761
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:832
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:793
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:852
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:880
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:775
#define RS_DEFAULT_FOOD_COST
Definition game.h:845
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:805
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:797
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:389
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:819
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:779
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:771
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:785
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:120
#define governments_re_active_iterate(_p)
Definition government.h:125
#define governments_re_active_iterate_end
Definition government.h:129
#define governments_iterate_end
Definition government.h:123
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:69
#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:410
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:149
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:209
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:126
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:249
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:306
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:2201
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:939
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:963
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:893
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:1967
#define FORMAT_VERSION
Definition rulesave.c:55
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3368
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:670
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2326
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:329
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:1041
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:378
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:3022
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1070
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:105
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:797
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1238
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:386
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:546
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:640
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:282
static bool save_luadata(const char *filename)
Definition rulesave.c:3356
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1880
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:988
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:356
static bool save_actions_ruleset(const char *filename, const char *name)
Definition rulesave.c:1103
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:3094
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2432
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:650
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:913
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:269
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:482
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:60
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:3057
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:827
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:85
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:2013
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3329
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:597
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:232
static bool save_action_ui_name(struct section_file *sfile, int act, const char *entry_name)
Definition rulesave.c:871
char * get_parser_buffer(void)
Definition ruleset.c:562
char * get_script_buffer(void)
Definition ruleset.c:554
#define RS_DEFAULT_CONVERT_SPEED
Definition ruleset.h:119
#define RS_DEFAULT_UBUILD_NAT
Definition ruleset.h:118
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleset.h:105
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleset.h:82
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleset.h:99
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleset.h:83
#define GAME_DEFAULT_ACH_VALUE
Definition ruleset.h:76
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleset.h:81
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleset.h:92
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleset.h:94
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleset.h:107
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleset.h:102
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleset.h:84
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleset.h:95
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleset.h:97
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleset.h:85
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleset.h:80
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleset.h:75
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleset.h:104
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleset.h:77
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleset.h:78
#define RS_DEFAULT_BASE_TECH_COST
Definition ruleset.h:109
#define RULESET_CAPABILITIES
Definition ruleset.h:24
#define RS_DEFAULT_NATIONALITY
Definition ruleset.h:117
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleset.h:72
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleset.h:79
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleset.h:87
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleset.h:71
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleset.h:103
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleset.h:100
#define RS_DEFAULT_MIN_TECH_COST
Definition ruleset.h:113
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleset.h:73
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleset.h:93
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleset.h:74
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4674
int setting_int_get(struct setting *pset)
Definition settings.c:3778
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3352
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3860
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5638
const char * setting_name(const struct setting *pset)
Definition settings.c:3323
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4247
char * setting_str_get(struct setting *pset)
Definition settings.c:3849
bool setting_bool_get(struct setting *pset)
Definition settings.c:3666
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4055
int read_enum_value(const struct setting *pset)
Definition settings.c:3985
#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)
Definition shared.c:1779
#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:393
int max_distance
Definition actions.h:376
bool quiet
Definition actions.h:383
char ui_name[MAX_LEN_NAME]
Definition actions.h:379
enum action_target_kind target_kind
Definition actions.h:367
int named_teams
Definition game.h:293
size_t as_count
Definition game.h:292
struct rgbcolor_list * plr_colors
Definition game.h:244
const char ** allowed_govs
Definition game.h:284
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:280
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:246
char ** embedded_nations
Definition game.h:282
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:109
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:273
const char ** allowed_terrains
Definition game.h:287
struct civ_game::@31::@35::@40 ruledit
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:286
const char ** allowed_styles
Definition game.h:290
struct civ_game::@31::@35 server
size_t embedded_nations_count
Definition game.h:283
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:289
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:106
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
bool enabled
Definition diptreaty.h:57
struct section_file * sfile
Definition rulesave.c:791
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:903
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:974
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:507
#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:423
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:342
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:299
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:435
#define advance_re_active_iterate(_p)
Definition tech.h:281
#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:285
#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:373
#define terrain_type_iterate_end
Definition terrain.h:379
#define MAX_NUM_TERRAINS
Definition terrain.h:64
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:152
#define terrain_resources_iterate_end
Definition terrain.h:401
#define terrain_resources_iterate(pterrain, _res, _freq)
Definition terrain.h:392
#define RESOURCE_FREQUENCY_DEFAULT
Definition terrain.h:208
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:766
#define unit_type_re_active_iterate(_p)
Definition unittype.h:864
#define combat_bonus_list_iterate_end
Definition unittype.h:482
#define L_FIRST
Definition unittype.h:349
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:480
#define unit_class_iterate(_p)
Definition unittype.h:905
#define unit_class_re_active_iterate_end
Definition unittype.h:921
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:332
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617
#define UTYF_LAST_USER_FLAG
Definition unittype.h:331
#define L_LAST
Definition unittype.h:439
#define unit_class_re_active_iterate(_p)
Definition unittype.h:917
#define uclass_index(_c_)
Definition unittype.h:742
#define unit_class_iterate_end
Definition unittype.h:912
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:128
#define unit_type_re_active_iterate_end
Definition unittype.h:868
const char * freeciv_datafile_version(void)
Definition version.c:186