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 secfile_insert_str(sfile, pg->sound_str, "%s.sound", path);
1906 secfile_insert_str(sfile, pg->sound_alt, "%s.sound_alt", path);
1907
1908 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1909
1910 if (pg->ai.better != NULL) {
1911 save_gov_ref(sfile, pg->ai.better, path,
1912 "ai_better");
1913 }
1914
1915 ruler_title_hash_lookup(pg->ruler_titles, NULL,
1916 &prtitle);
1917 if (prtitle != NULL) {
1918 const char *title;
1919
1921 if (title != NULL) {
1923 "%s.ruler_male_title", path);
1924 }
1925
1927 if (title != NULL) {
1929 "%s.ruler_female_title", path);
1930 }
1931 }
1932
1933 save_strvec(sfile, pg->helptext, path, "helptext");
1934
1936
1937 comment_policies(sfile);
1938
1939 sect_idx = 0;
1940 multipliers_iterate(pmul) {
1941 if (!pmul->ruledit_disabled) {
1942 char path[512];
1943
1944 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
1945
1946 save_name_translation(sfile, &(pmul->name), path);
1947
1948 secfile_insert_int(sfile, pmul->start, "%s.start", path);
1949 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
1950 secfile_insert_int(sfile, pmul->step, "%s.step", path);
1951 secfile_insert_int(sfile, pmul->def, "%s.default", path);
1952
1953 save_default_int(sfile, pmul->offset, 0, path, "offset");
1954 save_default_int(sfile, pmul->factor, 100, path, "factor");
1955 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
1956
1957 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
1958
1959 save_strvec(sfile, pmul->helptext, path, "helptext");
1960 }
1962
1963 return save_ruleset_file(sfile, filename);
1964}
1965
1966/**********************************************************************/
1969static bool save_traits(struct trait_limits *traits,
1970 struct trait_limits *default_traits,
1971 struct section_file *sfile,
1972 const char *secname, const char *field_prefix)
1973{
1974 enum trait tr;
1975
1976 /* FIXME: Use specenum trait names without duplicating them here.
1977 * Just needs to take care of case.
1978 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
1979 const char *trait_names[] = {
1980 "expansionist",
1981 "trader",
1982 "aggressive",
1983 "builder",
1984 NULL
1985 };
1986
1987 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != NULL;
1988 tr = trait_next(tr)) {
1989 int default_default;
1990
1991 default_default = (traits[tr].min + traits[tr].max) / 2;
1992
1993 if ((default_traits == NULL && traits[tr].min != TRAIT_DEFAULT_VALUE)
1994 || (default_traits != NULL && traits[tr].min != default_traits[tr].min)) {
1995 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
1996 trait_names[tr]);
1997 }
1998 if ((default_traits == NULL && traits[tr].max != TRAIT_DEFAULT_VALUE)
1999 || (default_traits != NULL && traits[tr].max != default_traits[tr].max)) {
2000 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
2001 trait_names[tr]);
2002 }
2003 if (default_default != traits[tr].fixed) {
2004 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
2005 trait_names[tr]);
2006 }
2007 }
2008
2009 return TRUE;
2010}
2011
2012/**********************************************************************/
2015static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
2016 int sect_idx)
2017{
2018 char path[512];
2019 int max_items = nation_city_list_size(pnat->server.default_cities);
2020 char *city_str[max_items];
2023 const char *list_items[max_items];
2024 int set_count;
2025 int subsect_idx;
2026
2027 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
2028
2029 if (pnat->translation_domain == NULL) {
2030 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
2031 } else {
2032 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
2033 }
2034
2035 save_name_translation(sfile, &(pnat->adjective), path);
2036 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
2037
2038 set_count = 0;
2040 if (nation_is_in_set(pnat, pset)) {
2042 }
2047 }
2049
2050 if (set_count > 0) {
2051 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
2052 }
2053
2054 set_count = 0;
2055 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
2058 if (set_count > 0) {
2059 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
2060 }
2061
2062 subsect_idx = 0;
2064 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
2065 path, subsect_idx);
2066 secfile_insert_str(sfile,
2069 "%s.leaders%d.sex", path, subsect_idx++);
2071
2072 if (pnat->server.rgb != NULL) {
2073 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
2074 }
2075
2076 save_traits(pnat->server.traits, game.server.default_traits,
2077 sfile, path, "trait_");
2078
2079 if (!pnat->is_playable) {
2080 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
2081 }
2082
2083 if (pnat->barb_type != NOT_A_BARBARIAN) {
2084 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
2085 "%s.barbarian_type", path);
2086 }
2087
2088 if (strcmp(pnat->flag_graphic_str, "-")) {
2089 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
2090 }
2091 if (strcmp(pnat->flag_graphic_alt, "-")) {
2092 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
2093 }
2094
2095 subsect_idx = 0;
2097 struct ruler_title *prtitle;
2098
2099 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
2101 "%s.ruler_titles%d.government", path, subsect_idx);
2103 "%s.ruler_titles%d.male_title", path, subsect_idx);
2105 "%s.ruler_titles%d.female_title", path, subsect_idx++);
2106 }
2108
2109 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
2110
2111 set_count = 0;
2112 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
2115 if (set_count > 0) {
2116 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
2117 }
2118
2119 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
2120 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
2121 save_unit_list(sfile, pnat->init_units, path, "init_units");
2122
2123 if (pnat->init_government) {
2124 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
2125 "%s.init_government", path);
2126 }
2127
2128 set_count = 0;
2129 nation_city_list_iterate(pnat->server.default_cities, pncity) {
2130 bool list_started = FALSE;
2131
2133 + strlen(")")
2134 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
2135
2138 case NCP_DISLIKE:
2139 strcat(city_str[set_count], " (!river");
2141 break;
2142 case NCP_LIKE:
2143 strcat(city_str[set_count], " (river");
2145 break;
2146 case NCP_NONE:
2147 break;
2148 }
2149
2151 const char *pref = NULL;
2152
2154 case NCP_DISLIKE:
2155 pref = "!";
2156 break;
2157 case NCP_LIKE:
2158 pref = "";
2159 break;
2160 case NCP_NONE:
2161 pref = NULL;
2162 break;
2163 }
2164
2165 if (pref != NULL) {
2166 if (list_started) {
2167 strcat(city_str[set_count], ", ");
2168 } else {
2169 strcat(city_str[set_count], " (");
2171 }
2174 }
2175
2177
2178 if (list_started) {
2179 strcat(city_str[set_count], ")");
2180 }
2181
2183 set_count++;
2185 if (set_count > 0) {
2186 int i;
2187
2188 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
2189
2190 for (i = 0; i < set_count; i++) {
2191 FC_FREE(city_str[i]);
2192 }
2193 }
2194
2195 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
2196
2197 return TRUE;
2198}
2199
2200/**********************************************************************/
2203static bool save_nations_ruleset(const char *filename, const char *name,
2204 struct rule_data *data)
2205{
2206 struct section_file *sfile = create_ruleset_file(name, "nation");
2207
2208 if (sfile == NULL) {
2209 return FALSE;
2210 }
2211
2212 if (data->nationlist != NULL || game.server.ruledit.embedded_nations != NULL) {
2214 if (data->nationlist != NULL) {
2215 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2216 }
2218 int i;
2219 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2220
2221 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2222 * resrictions */
2223 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2225 }
2226
2229 "ruledit.embedded_nations");
2230 free(tmp);
2231 }
2232 }
2233
2235 "default_traits", "");
2236
2237 if (data->nationlist == NULL) {
2241 "compatibility.allowed_govs");
2242 }
2246 "compatibility.allowed_terrains");
2247 }
2251 "compatibility.allowed_styles");
2252 }
2253 }
2254
2255 if (game.default_government != NULL) {
2257 "compatibility.default_government");
2258 }
2259
2260 if (data->nationlist != NULL) {
2261 secfile_insert_include(sfile, data->nationlist);
2262
2264 int sect_idx;
2265
2266 comment_nations(sfile);
2267
2269 sect_idx++) {
2270 struct nation_type *pnat
2272
2273 if (pnat == NULL) {
2274 log_error("Embedded nation \"%s\" not found!",
2276 } else {
2277 save_nation(sfile, pnat, sect_idx);
2278 }
2279 }
2280 }
2281 } else {
2282 int sect_idx = 0;
2283
2284 comment_nationsets(sfile);
2285
2287 char path[512];
2288
2289 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2290
2291 /* We don't use save_name_translation() for this as name and rule_name must
2292 * always be saved separately */
2293 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2294 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2295 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2297
2298 comment_nationgroups(sfile);
2299
2300 sect_idx = 0;
2302 char path[512];
2303
2304 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2305
2306 save_name_translation(sfile, &(pgroup->name), path);
2307
2308 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2309 if (pgroup->hidden) {
2310 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2311 }
2313
2314 comment_nations(sfile);
2315
2316 sect_idx = 0;
2318 save_nation(sfile, pnat, sect_idx++);
2320 }
2321
2322 return save_ruleset_file(sfile, filename);
2323}
2324
2325/**********************************************************************/
2328static bool save_techs_ruleset(const char *filename, const char *name)
2329{
2330 struct section_file *sfile = create_ruleset_file(name, "tech");
2331 int i;
2332 int sect_idx;
2334 bool uflags_tech = FALSE;
2335
2336 if (sfile == NULL) {
2337 return FALSE;
2338 }
2339
2340 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2341 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2342 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2343
2344 if (flagname != NULL) {
2345 if (!uflags_tech) {
2346 comment_uflags_tech(sfile);
2347 uflags_tech = TRUE;
2348 }
2349
2350 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2351
2352 /* Save the user flag help text even when it is undefined. That makes
2353 * the formatting code happy. The resulting "" is ignored when the
2354 * ruleset is loaded. */
2355 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2356 }
2357 }
2358
2359 comment_tech_classes(sfile);
2360
2361 sect_idx = 0;
2363 char path[512];
2364
2365 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2366
2367 save_name_translation(sfile, &(ptclass->name), path);
2369
2370 comment_techs(sfile);
2371
2372 sect_idx = 0;
2374 if (pa->require[AR_ONE] != A_NEVER) {
2375 char path[512];
2376 const char *flag_names[TF_COUNT];
2377 int set_count;
2378 int flagi;
2379
2380 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2381
2382 save_name_translation(sfile, &(pa->name), path);
2383
2384 if (game.control.num_tech_classes > 0) {
2385 if (pa->tclass != NULL) {
2387 "%s.class", path);
2388 }
2389 }
2390
2391 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2392 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2393 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2394 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2395 }
2396
2397 save_reqs_vector(sfile, &(pa->research_reqs), path,
2398 "research_reqs");
2399
2400 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2401 if (strcmp("-", pa->graphic_alt)) {
2402 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2403 }
2404 if (pa->bonus_message != NULL) {
2405 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2406 }
2407
2408 set_count = 0;
2409 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2412 }
2413 }
2414
2415 if (set_count > 0) {
2417 "%s.flags", path);
2418 }
2419 if (pa->cost >= 0) {
2420 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2421 }
2422
2423 save_strvec(sfile, pa->helptext, path, "helptext");
2424 }
2425
2427
2428 return save_ruleset_file(sfile, filename);
2429}
2430
2431/**********************************************************************/
2434static bool save_terrain_ruleset(const char *filename, const char *name)
2435{
2436 struct section_file *sfile = create_ruleset_file(name, "terrain");
2437 int sect_idx;
2438 int i;
2439 bool uflags_terr = FALSE;
2440 bool uflags_extra = FALSE;
2441
2442 if (sfile == NULL) {
2443 return FALSE;
2444 }
2445
2446 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2448 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2449
2450 if (flagname != NULL) {
2451 if (!uflags_terr) {
2453 uflags_terr = TRUE;
2454 }
2455
2456 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2457
2458 /* Save the user flag help text even when it is undefined. That makes
2459 * the formatting code happy. The resulting "" is ignored when the
2460 * ruleset is loaded. */
2461 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2462 }
2463 }
2464
2465 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2467 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2468
2469 if (flagname != NULL) {
2470 if (!uflags_extra) {
2471 /* TODO: Uncomment this, once there's a way to stop
2472 * the comment getting written inside preceding
2473 * terrain flags table. */
2474 /* comment_uflags_extra(sfile); */
2476 }
2477
2478 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2479
2480 /* Save the user flag help text even when it is undefined. That makes
2481 * the formatting code happy. The resulting "" is ignored when the
2482 * ruleset is loaded. */
2483 secfile_insert_str(sfile, helptxt,
2484 "control.extra_flags%d.helptxt", i);
2485 }
2486 }
2487
2488 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2489 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2490 "parameters.ocean_reclaim_requirement");
2491 }
2492 if (terrain_control.land_channel_requirement_pct <= 100) {
2493 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2494 "parameters.land_channel_requirement");
2495 }
2496 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2497 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2498 "parameters.thaw_requirement");
2499 }
2500 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2501 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2502 "parameters.freeze_requirement");
2503 }
2504 if (terrain_control.lake_max_size != 0) {
2505 secfile_insert_int(sfile, terrain_control.lake_max_size,
2506 "parameters.lake_max_size");
2507 }
2508 if (terrain_control.min_start_native_area != 0) {
2509 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2510 "parameters.min_start_native_area");
2511 }
2512 if (terrain_control.move_fragments != 3) {
2513 secfile_insert_int(sfile, terrain_control.move_fragments,
2514 "parameters.move_fragments");
2515 }
2516 if (terrain_control.igter_cost != 1) {
2517 secfile_insert_int(sfile, terrain_control.igter_cost,
2518 "parameters.igter_cost");
2519 }
2520 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2521 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2522 "parameters.pythagorean_diagonal");
2523 }
2526 "parameters.ocean_resources");
2527 }
2528
2529 comment_terrains(sfile);
2530
2531 sect_idx = 0;
2533 char path[512];
2534 char identifier[2];
2535 int r;
2536 const char *flag_names[TER_USER_LAST];
2537 const char *puc_names[UCL_LAST];
2538 int flagi;
2539 int set_count;
2540
2541 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2542
2543 save_name_translation(sfile, &(pterr->name), path);
2544
2545 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2546 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2547 secfile_insert_str(sfile, pterr->graphic_alt2, "%s.graphic_alt2", path);
2548 identifier[0] = pterr->identifier;
2549 identifier[1] = '\0';
2550 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2551
2553 "%s.class", path);
2554
2555 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2556 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2557
2559 if (pterr->output[o] != 0) {
2560 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2562 }
2564
2565 /* Check resource count */
2566 for (r = 0; pterr->resources[r] != NULL; r++) {
2567 /* Just increasing r as long as there is resources */
2568 }
2569
2570 {
2571 const char *resource_names[r];
2572 bool save_frequencies = FALSE;
2573
2574 r = 0;
2579 }
2581
2583 "%s.resources", path);
2584
2585 if (save_frequencies) {
2586 secfile_insert_int_vec(sfile, pterr->resource_freq, r,
2587 "%s.resource_freq", path);
2588 }
2589 }
2590
2592 if (pterr->road_output_incr_pct[o] != 0) {
2593 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2594 "%s.road_%s_incr_pct", path,
2596 }
2598
2599 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2600 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2601
2602 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2603 "cultivate_result");
2604 secfile_insert_int(sfile, pterr->cultivate_time,
2605 "%s.cultivate_time", path);
2606
2607 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2608 "plant_result");
2609 secfile_insert_int(sfile, pterr->plant_time,
2610 "%s.plant_time", path);
2611
2612 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2613 "%s.irrigation_food_incr", path);
2614 secfile_insert_int(sfile, pterr->irrigation_time,
2615 "%s.irrigation_time", path);
2616
2617 secfile_insert_int(sfile, pterr->mining_shield_incr,
2618 "%s.mining_shield_incr", path);
2619 secfile_insert_int(sfile, pterr->mining_time,
2620 "%s.mining_time", path);
2621
2622 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2623 "transform_result");
2624 secfile_insert_int(sfile, pterr->transform_time,
2625 "%s.transform_time", path);
2626
2627 if (pterr->animal != NULL) {
2629 "%s.animal", path);
2630 } else {
2631 secfile_insert_str(sfile, "None",
2632 "%s.animal", path);
2633 }
2634
2635 secfile_insert_int(sfile, pterr->placing_time,
2636 "%s.placing_time", path);
2637 secfile_insert_int(sfile, pterr->pillage_time,
2638 "%s.pillage_time", path);
2639
2640 i = 0;
2641 extra_type_iterate(pextra) {
2642 int rmtime = pterr->extra_removal_times[extra_index(pextra)];
2643
2644 if (rmtime != 0) {
2645 secfile_insert_str(sfile, extra_rule_name(pextra),
2646 "%s.extra_settings%d.extra",
2647 path, i);
2649 "%s.extra_settings%d.removal_time",
2650 path, i++);
2651 }
2653
2654 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2655 "warmer_wetter_result");
2656 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2657 "warmer_drier_result");
2658 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2659 "cooler_wetter_result");
2660 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2661 "cooler_drier_result");
2662
2663 set_count = 0;
2664 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2667 }
2668 }
2669
2670 if (set_count > 0) {
2672 "%s.flags", path);
2673 }
2674
2675 {
2677
2681 if (pterr->property[mtp] != 0) {
2682 secfile_insert_int(sfile, pterr->property[mtp],
2683 "%s.property_%s", path,
2685 }
2686 }
2687 }
2688
2689 set_count = 0;
2691 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2693 }
2695
2696 if (set_count > 0) {
2698 "%s.native_to", path);
2699 }
2700
2701 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2702
2703 save_strvec(sfile, pterr->helptext, path, "helptext");
2704
2706
2707 comment_resources(sfile);
2708
2709 sect_idx = 0;
2711 if (!pres->ruledit_disabled) {
2712 char path[512];
2713 char identifier[2];
2714
2715 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2716
2718 "%s.extra", path);
2719
2721 if (pres->data.resource->output[o] != 0) {
2722 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2723 path, get_output_identifier(o));
2724 }
2726
2727 if (pres->data.resource->id_old_save != '\0') {
2728 identifier[0] = pres->data.resource->id_old_save;
2729 identifier[1] = '\0';
2730 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2731 }
2732 }
2734
2735 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2736 "extraui.ui_name_base_fortress");
2737 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2738 "extraui.ui_name_base_airbase");
2739
2740 comment_extras(sfile);
2741
2742 sect_idx = 0;
2744 char path[512];
2745 const char *flag_names[EF_COUNT];
2746 const char *cause_names[EC_COUNT];
2747 const char *puc_names[UCL_LAST];
2748 const char *extra_names[MAX_EXTRA_TYPES];
2749 int flagi;
2750 int causei;
2751 int set_count;
2752 bool worker_cause;
2753
2754 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2755
2756 save_name_translation(sfile, &(pextra->name), path);
2757
2758 secfile_insert_str(sfile, extra_category_name(pextra->category),
2759 "%s.category", path);
2760
2761 set_count = 0;
2762 for (causei = 0; causei < EC_COUNT; causei++) {
2763 if (is_extra_caused_by(pextra, causei)) {
2765 }
2766 }
2767
2768 if (set_count > 0) {
2770 "%s.causes", path);
2771 }
2772
2773 set_count = 0;
2774 for (causei = 0; causei < ERM_COUNT; causei++) {
2775 if (is_extra_removed_by(pextra, causei)) {
2777 }
2778 }
2779
2780 if (set_count > 0) {
2782 "%s.rmcauses", path);
2783 }
2784
2785 if (strcmp(pextra->graphic_str, "-")) {
2786 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2787 }
2788 if (strcmp(pextra->graphic_alt, "-")) {
2789 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2790 }
2791 if (strcmp(pextra->activity_gfx, "-")) {
2792 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2793 }
2794 if (strcmp(pextra->act_gfx_alt, "-")) {
2795 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2796 }
2797 if (strcmp(pextra->act_gfx_alt2, "-")) {
2798 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2799 }
2800 if (strcmp(pextra->rmact_gfx, "-")) {
2801 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2802 }
2803 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2804 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2805 }
2806
2807 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2808 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2809 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2810 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2811
2813 if ((!pextra->buildable && worker_cause)
2814 || (pextra->buildable && !worker_cause)) {
2815 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2816 }
2817 if (!pextra->generated) {
2818 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2819 }
2820 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2821 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2822 if (pextra->build_time_factor != 1) {
2823 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2824 }
2825 if (pextra->removal_time_factor != 1) {
2826 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2827 }
2828 if (pextra->infracost != 0) {
2829 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2830 }
2831 if (pextra->defense_bonus != 0) {
2832 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2833 }
2834 if (pextra->eus != EUS_NORMAL) {
2836 "%s.unit_seen", path);
2837 }
2839 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2840 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2841 }
2843 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2844 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2845 path);
2846 }
2847
2848 set_count = 0;
2850 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2852 }
2854
2855 if (set_count > 0) {
2857 "%s.native_to", path);
2858 }
2859
2860 if (pextra->no_aggr_near_city >= 0) {
2861 secfile_insert_int(sfile, pextra->no_aggr_near_city,
2862 "%s.no_aggr_near_city", path);
2863 }
2864
2865 set_count = 0;
2866 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2867 if (extra_has_flag(pextra, flagi)) {
2869 }
2870 }
2871
2872 if (set_count > 0) {
2874 "%s.flags", path);
2875 }
2876
2877 set_count = 0;
2879 if (!can_extras_coexist(pextra, confl)) {
2881 }
2883
2884 if (set_count > 0) {
2886 "%s.conflicts", path);
2887 }
2888
2889 set_count = 0;
2890 extra_type_iterate(top) {
2891 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2893 }
2895
2896 if (set_count > 0) {
2898 "%s.hidden_by", path);
2899 }
2900
2901 set_count = 0;
2902 extra_type_iterate(top) {
2903 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2905 }
2907
2908 if (set_count > 0) {
2910 "%s.bridged_over", path);
2911 }
2912
2913 save_strvec(sfile, pextra->helptext, path, "helptext");
2914
2916
2917 comment_bases(sfile);
2918
2919 sect_idx = 0;
2921 if (!pextra->ruledit_disabled) {
2922 char path[512];
2923 struct base_type *pbase = extra_base_get(pextra);
2924
2925 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2926
2927 secfile_insert_str(sfile, extra_rule_name(pextra),
2928 "%s.extra", path);
2929
2931 "%s.gui_type", path);
2932
2933 if (pbase->border_sq >= 0) {
2934 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
2935 }
2936 if (pbase->vision_main_sq >= 0) {
2937 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
2938 }
2939 if (pbase->vision_invis_sq >= 0) {
2940 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
2941 }
2942 if (pbase->vision_subs_sq >= 0) {
2943 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
2944 }
2945 }
2947
2948 comment_roads(sfile);
2949
2950 sect_idx = 0;
2952 if (!pextra->ruledit_disabled) {
2953 struct road_type *proad = extra_road_get(pextra);
2954 char path[512];
2955 const char *flag_names[RF_COUNT];
2956 int flagi;
2957 int set_count;
2958
2959 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
2960
2961 secfile_insert_str(sfile, extra_rule_name(pextra),
2962 "%s.extra", path);
2963
2964 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
2965
2966 if (proad->move_mode != RMM_FAST_ALWAYS) {
2967 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
2968 "%s.move_mode", path);
2969 }
2970
2972 if (proad->tile_incr_const[o] != 0) {
2973 secfile_insert_int(sfile, proad->tile_incr_const[o],
2974 "%s.%s_incr_const", path, get_output_identifier(o));
2975 }
2976 if (proad->tile_incr[o] != 0) {
2977 secfile_insert_int(sfile, proad->tile_incr[o],
2978 "%s.%s_incr", path, get_output_identifier(o));
2979 }
2980 if (proad->tile_bonus[o] != 0) {
2981 secfile_insert_int(sfile, proad->tile_bonus[o],
2982 "%s.%s_bonus", path, get_output_identifier(o));
2983 }
2985
2986 switch (proad->compat) {
2987 case ROCO_ROAD:
2988 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
2989 break;
2990 case ROCO_RAILROAD:
2991 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
2992 break;
2993 case ROCO_RIVER:
2994 secfile_insert_str(sfile, "River", "%s.compat_special", path);
2995 break;
2996 case ROCO_NONE:
2997 secfile_insert_str(sfile, "None", "%s.compat_special", path);
2998 break;
2999 }
3000
3002 "%s.gui_type", path);
3003
3004 set_count = 0;
3005 for (flagi = 0; flagi < RF_COUNT; flagi++) {
3006 if (road_has_flag(proad, flagi)) {
3008 }
3009 }
3010
3011 if (set_count > 0) {
3013 "%s.flags", path);
3014 }
3015 }
3017
3018 return save_ruleset_file(sfile, filename);
3019}
3020
3021/**********************************************************************/
3024static bool save_veteran_system(struct section_file *sfile, const char *path,
3025 struct veteran_system *vsystem)
3026{
3027 const char *vlist_name[vsystem->levels];
3028 int vlist_power[vsystem->levels];
3029 int vlist_raise[vsystem->levels];
3030 int vlist_wraise[vsystem->levels];
3031 int vlist_move[vsystem->levels];
3032 int i;
3033
3034 for (i = 0; i < vsystem->levels; i++) {
3035 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
3036 vlist_power[i] = vsystem->definitions[i].power_fact;
3037 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
3038 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
3039 vlist_move[i] = vsystem->definitions[i].move_bonus;
3040 }
3041
3043 "%s.veteran_names", path);
3045 "%s.veteran_power_fact", path);
3047 "%s.veteran_base_raise_chance", path);
3049 "%s.veteran_work_raise_chance", path);
3051 "%s.veteran_move_bonus", path);
3052
3053 return TRUE;
3054}
3055
3056/**********************************************************************/
3059static bool save_combat_bonuses(struct section_file *sfile,
3060 struct unit_type *put,
3061 char *path)
3062{
3063 int i;
3064 bool has_quiet = FALSE;
3065
3067 if (pbonus->quiet) {
3068 has_quiet = TRUE;
3069 }
3071
3072 i = 0;
3073
3076 "%s.bonuses%d.flag", path, i);
3078 "%s.bonuses%d.type", path, i);
3079 secfile_insert_int(sfile, pbonus->value,
3080 "%s.bonuses%d.value", path, i);
3081
3082 if (has_quiet) {
3083 secfile_insert_bool(sfile, pbonus->quiet,
3084 "%s.bonuses%d.quiet", path, i);
3085 }
3086
3087 i++;
3089
3090 return TRUE;
3091}
3092
3093/**********************************************************************/
3096static bool save_units_ruleset(const char *filename, const char *name)
3097{
3098 struct section_file *sfile = create_ruleset_file(name, "unit");
3099 int i;
3100 int sect_idx;
3101 bool uflags_utype = FALSE;
3102 bool uflags_uclass = FALSE;
3103
3104 if (sfile == NULL) {
3105 return FALSE;
3106 }
3107
3108 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
3110 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
3111
3112 if (flagname != NULL) {
3113 if (!uflags_utype) {
3114 comment_uflags_utype(sfile);
3116 }
3117
3118 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
3119
3120 /* Save the user flag help text even when it is undefined. That makes
3121 * the formatting code happy. The resulting "" is ignored when the
3122 * ruleset is loaded. */
3123 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
3124 }
3125 }
3126
3127 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
3129 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
3130
3131 if (flagname != NULL) {
3132 if (!uflags_uclass) {
3133 /* TODO: Uncomment this, once there's a way to stop
3134 * the comment getting written inside preceding
3135 * utype flags table. */
3136 /* comment_uflags_uclass(sfile); */
3138 }
3139
3140 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
3141
3142 /* Save the user flag help text even when it is undefined. That makes
3143 * the formatting code happy. The resulting "" is ignored when the
3144 * ruleset is loaded. */
3145 secfile_insert_str(sfile, helptxt,
3146 "control.class_flags%d.helptxt", i);
3147 }
3148 }
3149
3150 save_veteran_system(sfile, "veteran_system", game.veteran);
3151
3152 comment_uclasses(sfile);
3153
3154 sect_idx = 0;
3156 char path[512];
3157 const char *flag_names[UCF_COUNT];
3158 int flagi;
3159 int set_count;
3160
3161 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
3162
3163 save_name_translation(sfile, &(puc->name), path);
3164
3165 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
3166 "%s.min_speed", path);
3167 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
3168 if (puc->non_native_def_pct != 100) {
3169 secfile_insert_int(sfile, puc->non_native_def_pct,
3170 "%s.non_native_def_pct", path);
3171 }
3172
3173 set_count = 0;
3174 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
3175 if (uclass_has_flag(puc, flagi)) {
3177 }
3178 }
3179
3180 if (set_count > 0) {
3182 "%s.flags", path);
3183 }
3184
3185 save_strvec(sfile, puc->helptext, path, "helptext");
3186
3188
3189 comment_utypes(sfile);
3190
3191 sect_idx = 0;
3193 if (!put->ruledit_disabled) {
3194 char path[512];
3195 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
3196 int flagi;
3197 int set_count;
3198
3199 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
3200
3201 save_name_translation(sfile, &(put->name), path);
3202
3203 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
3204 "%s.class", path);
3205
3206 save_reqs_vector(sfile, &(put->build_reqs), path, "reqs");
3207
3208 if (put->obsoleted_by != NULL) {
3209 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
3210 "%s.obsolete_by", path);
3211 }
3212
3213 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
3214 if (strcmp("-", put->graphic_alt)) {
3215 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
3216 }
3217 if (strcmp("-", put->graphic_alt2)) {
3218 secfile_insert_str(sfile, put->graphic_alt2, "%s.graphic_alt2", path);
3219 }
3220 if (strcmp("-", put->sound_move)) {
3221 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
3222 }
3223 if (strcmp("-", put->sound_move_alt)) {
3224 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
3225 }
3226 if (strcmp("-", put->sound_fight)) {
3227 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
3228 }
3229 if (strcmp("-", put->sound_fight_alt)) {
3230 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
3231 }
3232
3233 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
3234 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
3235 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
3236 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
3237 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
3238 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3239 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3240
3241 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3242 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3243 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3244
3245 if (put->vlayer != V_MAIN) {
3247 "%s.vision_layer", path);
3248 }
3249
3250 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3251 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3252 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3253 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3254
3256 if (put->upkeep[o] != 0) {
3257 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3258 path, get_output_identifier(o));
3259 }
3261
3262 if (put->converted_to != NULL) {
3263 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3264 "%s.convert_to", path);
3265 }
3266 if (put->convert_time != 1) {
3267 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3268 }
3269
3270 save_combat_bonuses(sfile, put, path);
3271 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3272
3273 if (put->veteran != NULL) {
3274 save_veteran_system(sfile, path, put->veteran);
3275 }
3276
3277 if (put->paratroopers_range != 0) {
3278 secfile_insert_int(sfile, put->paratroopers_range,
3279 "%s.paratroopers_range", path);
3280 }
3281 if (put->bombard_rate != 0) {
3282 secfile_insert_int(sfile, put->bombard_rate,
3283 "%s.bombard_rate", path);
3284 }
3285 if (put->city_slots != 0) {
3286 secfile_insert_int(sfile, put->city_slots,
3287 "%s.city_slots", path);
3288 }
3289 if (put->city_size != 1) {
3290 secfile_insert_int(sfile, put->city_size,
3291 "%s.city_size", path);
3292 }
3293
3294 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3295 "%s.tp_defense", path);
3296
3297 set_count = 0;
3298 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3299 if (utype_has_flag(put, flagi)) {
3301 }
3302 }
3303
3304 if (set_count > 0) {
3306 "%s.flags", path);
3307 }
3308
3309 set_count = 0;
3310 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3311 if (utype_has_role(put, flagi)) {
3313 }
3314 }
3315
3316 if (set_count > 0) {
3318 "%s.roles", path);
3319 }
3320
3321 save_strvec(sfile, put->helptext, path, "helptext");
3322 }
3324
3325 return save_ruleset_file(sfile, filename);
3326}
3327
3328/**********************************************************************/
3331static bool save_script_lua(const char *filename, const char *name,
3332 const char *buffer)
3333{
3334 if (buffer != NULL) {
3335 FILE *ffile = fc_fopen(filename, "w");
3336 int full_len = strlen(buffer);
3337 int len;
3338
3339 if (ffile != NULL) {
3340 len = fwrite(buffer, 1, full_len, ffile);
3341
3342 if (len != full_len) {
3343 return FALSE;
3344 }
3345
3346 fclose(ffile);
3347 } else {
3348 return FALSE;
3349 }
3350 }
3351
3352 return TRUE;
3353}
3354
3355/**********************************************************************/
3358static bool save_luadata(const char *filename)
3359{
3360 if (game.server.luadata != NULL) {
3361 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3362 }
3363
3364 return TRUE;
3365}
3366
3367/**********************************************************************/
3370bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3371{
3372 if (make_dir(path)) {
3373 bool success = TRUE;
3374 char filename[500];
3375
3376 if (success) {
3377 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3378 success = save_buildings_ruleset(filename, name);
3379 }
3380
3381 if (success) {
3382 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3383 success = save_styles_ruleset(filename, name);
3384 }
3385
3386 if (success) {
3387 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3388 success = save_cities_ruleset(filename, name);
3389 }
3390
3391 if (success) {
3392 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3393 success = save_effects_ruleset(filename, name);
3394 }
3395
3396 if (success) {
3397 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3398 success = save_game_ruleset(filename, name);
3399 }
3400
3401 if (success) {
3402 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3404 }
3405
3406 if (success) {
3407 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3408 success = save_nations_ruleset(filename, name, data);
3409 }
3410
3411 if (success) {
3412 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3413 success = save_techs_ruleset(filename, name);
3414 }
3415
3416 if (success) {
3417 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3418 success = save_terrain_ruleset(filename, name);
3419 }
3420
3421 if (success) {
3422 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3423 success = save_units_ruleset(filename, name);
3424 }
3425
3426 if (success) {
3427 fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path);
3428 success = save_actions_ruleset(filename, name);
3429 }
3430
3431 if (success) {
3432 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3434 }
3435
3436 if (success) {
3437 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3439 }
3440
3441 if (success) {
3442 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3443 success = save_luadata(filename);
3444 }
3445
3446 return success;
3447 } else {
3448 log_error(_("Failed to create directory %s"), path);
3449 return FALSE;
3450 }
3451
3452 return TRUE;
3453}
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:7116
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7757
void action_array_end(action_id *act_array, int size)
Definition actions.c:6469
bool action_is_in_use(struct action *paction)
Definition actions.c:6398
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7933
const char * action_rule_name(const struct action *action)
Definition actions.c:1977
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:7600
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:7276
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:7445
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:6437
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:6506
#define action_enablers_iterate_end
Definition actions.h:519
#define enabler_get_action(_enabler_)
Definition actions.h:433
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:611
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:609
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define NUM_ACTIONS
Definition actions.h:315
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:617
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:616
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:357
#define ACTION_AUTO_POST_WIPE_UNITS
Definition actions.h:618
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:610
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:612
#define action_iterate_end
Definition actions.h:465
#define MAX_NUM_ACTIONS
Definition actions.h:314
#define action_enablers_iterate(_enabler_)
Definition actions.h:513
#define action_iterate(_act_)
Definition actions.h:461
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:608
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:613
#define ACTION_NONE
Definition actions.h:311
int actres_min_range_default(enum action_result result)
Definition actres.c:373
int actres_max_range_default(enum action_result result)
Definition actres.c:462
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:619
static const struct city struct citystyle * city_styles
Definition city.c:84
#define output_type_iterate(output)
Definition city.h:845
#define output_type_iterate_end
Definition city.h:851
void comment_borders_radius_permanent(struct section_file *sfile)
Definition comments.c:809
char * uflags_building
Definition comments.c:53
void comment_uflags_utype(struct section_file *sfile)
Definition comments.c:466
void comment_combat_rules_nuke_defender_survival(struct section_file *sfile)
Definition comments.c:765
void comment_roads(struct section_file *sfile)
Definition comments.c:402
void comment_civstyle_granary(struct section_file *sfile)
Definition comments.c:595
void comment_research_tech_leakage(struct section_file *sfile)
Definition comments.c:845
void comment_actions_ui_names(struct section_file *sfile)
Definition comments.c:783
void comment_uclasses(struct section_file *sfile)
Definition comments.c:354
void comment_calendar_fragments(struct section_file *sfile)
Definition comments.c:889
void comment_actions_quiet_actions(struct section_file *sfile)
Definition comments.c:800
void comment_uflags_terrain(struct section_file *sfile)
Definition comments.c:482
void comment_citystyles(struct section_file *sfile)
Definition comments.c:418
void comment_govs(struct section_file *sfile)
Definition comments.c:338
void comment_combat_rules_low_fp_pearl_harbour(struct section_file *sfile)
Definition comments.c:726
void comment_research_base_tech_cost(struct section_file *sfile)
Definition comments.c:827
void comment_research_tech_cost_style(struct section_file *sfile)
Definition comments.c:818
void comment_combat_rules_only_killing_veteran(struct section_file *sfile)
Definition comments.c:676
void comment_bases(struct section_file *sfile)
Definition comments.c:394
void comment_terrains(struct section_file *sfile)
Definition comments.c:370
void comment_uflags_tech(struct section_file *sfile)
Definition comments.c:498
void comment_file_header(struct section_file *sfile)
Definition comments.c:306
void comment_effects(struct section_file *sfile)
Definition comments.c:434
void comment_actions_dc_initial_odds(struct section_file *sfile)
Definition comments.c:791
void comment_combat_rules_scaled_veterancy(struct section_file *sfile)
Definition comments.c:696
void comment_research_upkeep_style(struct section_file *sfile)
Definition comments.c:854
void comment_disasters(struct section_file *sfile)
Definition comments.c:450
void comment_clauses(struct section_file *sfile)
Definition comments.c:570
void comment_goods(struct section_file *sfile)
Definition comments.c:522
char * uflags_tech
Definition comments.c:52
void comment_civstyle_gameloss_style(struct section_file *sfile)
Definition comments.c:613
char * uflags_extra
Definition comments.c:51
void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
Definition comments.c:622
void comment_extras(struct section_file *sfile)
Definition comments.c:386
void comment_combat_rules_low_fp_nonnat_bombard(struct section_file *sfile)
Definition comments.c:746
void comment_ueffs(struct section_file *sfile)
Definition comments.c:442
void comment_techs(struct section_file *sfile)
Definition comments.c:330
void comment_nations(struct section_file *sfile)
Definition comments.c:546
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:514
void comment_combat_rules_low_fp_combat_bonus(struct section_file *sfile)
Definition comments.c:736
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:587
void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile)
Definition comments.c:631
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:554
void comment_specialists(struct section_file *sfile)
Definition comments.c:538
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:426
void comment_civstyle_airlift_always(struct section_file *sfile)
Definition comments.c:640
void comment_resources(struct section_file *sfile)
Definition comments.c:378
void comment_civstyle_ransom_gold(struct section_file *sfile)
Definition comments.c:604
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:322
void comment_culture_migration_pml(struct section_file *sfile)
Definition comments.c:880
void comment_combat_rules_only_real_fight_veteran(struct section_file *sfile)
Definition comments.c:686
char * uflags_uclass
Definition comments.c:49
void comment_research_free_tech_method(struct section_file *sfile)
Definition comments.c:863
void comment_combat_rules_nuke_pop_loss(struct section_file *sfile)
Definition comments.c:756
void comment_utypes(struct section_file *sfile)
Definition comments.c:362
char * uflags_utype
Definition comments.c:48
void comment_research_min_tech_cost(struct section_file *sfile)
Definition comments.c:836
void comment_culture_history_interest(struct section_file *sfile)
Definition comments.c:872
void comment_policies(struct section_file *sfile)
Definition comments.c:346
void comment_combat_rules_low_fp_badwallattacker(struct section_file *sfile)
Definition comments.c:716
void comment_achievements(struct section_file *sfile)
Definition comments.c:458
void comment_combat_rules_damage_reduces_bombard_rate(struct section_file *sfile)
Definition comments.c:706
void comment_counters(struct section_file *sfile)
Definition comments.c:578
void comment_styles(struct section_file *sfile)
Definition comments.c:410
void comment_combat_rules_tired_attack(struct section_file *sfile)
Definition comments.c:667
void comment_uflags_building(struct section_file *sfile)
Definition comments.c:506
void comment_buildings(struct section_file *sfile)
Definition comments.c:314
void comment_enablers(struct section_file *sfile)
Definition comments.c:530
void comment_nationsets(struct section_file *sfile)
Definition comments.c:562
void comment_wonder_visibility_small_wonders(struct section_file *sfile)
Definition comments.c:649
void comment_incite_cost(struct section_file *sfile)
Definition comments.c:658
void comment_auto_attack(struct section_file *sfile)
Definition comments.c:775
char * incite_cost
Definition comments.c:75
#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:678
@ ROCO_RAILROAD
Definition fc_types.h:1253
@ ROCO_NONE
Definition fc_types.h:1253
@ ROCO_RIVER
Definition fc_types.h:1253
@ ROCO_ROAD
Definition fc_types.h:1253
#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:389
#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:417
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:872
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:858
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:864
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:861
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:844
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:817
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:775
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:771
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:809
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:896
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:868
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:882
#define RS_DEFAULT_HAPPY_COST
Definition game.h:849
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:886
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:823
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:773
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:502
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:887
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:857
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:878
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:791
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:836
#define GAME_DEFAULT_START_YEAR
Definition game.h:743
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:797
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:876
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:769
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:840
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:801
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:860
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:888
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:783
#define RS_DEFAULT_FOOD_COST
Definition game.h:853
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:813
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:805
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:393
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:827
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:787
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:779
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:793
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:124
#define governments_re_active_iterate(_p)
Definition government.h:129
#define governments_re_active_iterate_end
Definition government.h:133
#define governments_iterate_end
Definition government.h:127
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:2203
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:1969
#define FORMAT_VERSION
Definition rulesave.c:55
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3370
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:2328
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:3024
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:3358
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:3096
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2434
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:3059
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:2015
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3331
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:4681
int setting_int_get(struct setting *pset)
Definition settings.c:3785
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3359
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3867
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5645
const char * setting_name(const struct setting *pset)
Definition settings.c:3330
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4254
char * setting_str_get(struct setting *pset)
Definition settings.c:3856
bool setting_bool_get(struct setting *pset)
Definition settings.c:3673
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4062
int read_enum_value(const struct setting *pset)
Definition settings.c:3992
#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:1782
#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:395
int max_distance
Definition actions.h:378
bool quiet
Definition actions.h:385
char ui_name[MAX_LEN_NAME]
Definition actions.h:381
enum action_target_kind target_kind
Definition actions.h:369
int named_teams
Definition game.h:297
size_t as_count
Definition game.h:296
struct rgbcolor_list * plr_colors
Definition game.h:248
const char ** allowed_govs
Definition game.h:288
int upgrade_veteran_loss
Definition game.h:203
struct rgbcolor * plr_bg_color
Definition game.h:103
int incite_total_factor
Definition game.h:154
int init_vis_radius_sq
Definition game.h:156
bool vision_reveal_tiles
Definition game.h:204
char * description_file
Definition game.h:284
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int base_incite_cost
Definition game.h:138
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
int autoupgrade_veteran_loss
Definition game.h:136
int start_year
Definition game.h:195
int incite_improvement_factor
Definition game.h:153
struct section_file * luadata
Definition game.h:250
char ** embedded_nations
Definition game.h:286
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:111
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:277
const char ** allowed_terrains
Definition game.h:291
struct civ_game::@31::@35::@40 ruledit
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:290
const char ** allowed_styles
Definition game.h:294
struct civ_game::@31::@35 server
size_t embedded_nations_count
Definition game.h:287
int incite_unit_factor
Definition game.h:155
char * ruleset_capabilities
Definition game.h:86
struct civ_game::@30 rgame
int ransom_gold
Definition game.h:179
size_t at_count
Definition game.h:293
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:82
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:902
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:867
#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:908
#define unit_class_re_active_iterate_end
Definition unittype.h:924
#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:920
#define uclass_index(_c_)
Definition unittype.h:742
#define unit_class_iterate_end
Definition unittype.h:915
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:128
#define unit_type_re_active_iterate_end
Definition unittype.h:871
const char * freeciv_datafile_version(void)
Definition version.c:186