Freeciv-3.3
Loading...
Searching...
No Matches
rulesave.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20#include "registry.h"
21#include "string_vector.h"
22
23/* common */
24#include "achievements.h"
25#include "counters.h"
26#include "game.h"
27#include "government.h"
28#include "map.h"
29#include "movement.h"
30#include "multipliers.h"
31#include "nation.h"
32#include "rgbcolor.h"
33#include "sex.h"
34#include "specialist.h"
35#include "style.h"
36#include "unittype.h"
37#include "version.h"
38
39/* server */
40#include "ruleload.h"
41#include "settings.h"
42
43/* tools/ruleutil */
44#include "comments.h"
45
46#include "rulesave.h"
47
48/* Ruleset format version */
49/*
50 * 1 - Freeciv-2.6
51 * 10 - Freeciv-3.0
52 * 20 - Freeciv-3.1
53 * 30 - Freeciv-3.2
54 * 40 - Freeciv-3.3
55 */
56#define FORMAT_VERSION RSFORMAT_CURRENT
57
58/**********************************************************************/
61static struct section_file *create_ruleset_file(const char *rsname,
62 const char *rstype)
63{
64 struct section_file *sfile = secfile_new(TRUE);
65 char buf[500];
66
68
69 if (rsname != nullptr && rsname[0] != '\0') {
70 fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);
71 } else {
72 fc_snprintf(buf, sizeof(buf), "Template %s data for Freeciv", rstype);
73 }
74
75 secfile_insert_str(sfile, buf, "datafile.description");
76 secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
77 secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
78 secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");
79
80 return sfile;
81}
82
83/**********************************************************************/
86static bool save_default_int(struct section_file *sfile, int value,
87 int default_value, const char *path,
88 const char *entry)
89{
90 if (value != default_value) {
91 if (entry != nullptr) {
92 secfile_insert_int(sfile, value,
93 "%s.%s", path, entry);
94 } else {
95 secfile_insert_int(sfile, value,
96 "%s", path);
97 }
98 }
99
100 return TRUE;
101}
102
103/**********************************************************************/
106static bool save_default_bool(struct section_file *sfile, bool value,
107 bool default_value, const char *path,
108 const char *entry)
109{
110 if ((value && !default_value)
111 || (!value && default_value)) {
112 if (entry != nullptr) {
113 secfile_insert_bool(sfile, value,
114 "%s.%s", path, entry);
115 } else {
116 secfile_insert_bool(sfile, value,
117 "%s", path);
118 }
119 }
120
121 return TRUE;
122}
123
124/**********************************************************************/
127static bool save_name_translation(struct section_file *sfile,
128 struct name_translation *name,
129 const char *path)
130{
131 struct entry *mod_entry;
132
135 "%s.name", path);
139 secfile_insert_str(sfile,
141 "%s.rule_name", path);
142 }
143
144 return TRUE;
145}
146
147/**********************************************************************/
150static bool save_reqs_vector(struct section_file *sfile,
151 const struct requirement_vector *reqs,
152 const char *path, const char *entry)
153{
154 int i;
155 bool includes_negated = FALSE;
157 bool includes_quiet = FALSE;
158
160 if (!preq->present) {
162 }
163 if (preq->survives) {
165 }
166 if (preq->quiet) {
168 }
170
171 i = 0;
173 secfile_insert_str(sfile,
174 universals_n_name(preq->source.kind),
175 "%s.%s%d.type", path, entry, i);
176 secfile_insert_str(sfile,
177 universal_rule_name(&(preq->source)),
178 "%s.%s%d.name", path, entry, i);
179 secfile_insert_str(sfile,
180 req_range_name(preq->range),
181 "%s.%s%d.range", path, entry, i);
182
183 if (includes_surviving) {
185 preq->survives,
186 "%s.%s%d.survives", path, entry, i);
187 }
188
189 if (includes_negated) {
191 preq->present,
192 "%s.%s%d.present", path, entry, i);
193 }
194
195 if (includes_quiet) {
197 preq->quiet,
198 "%s.%s%d.quiet", path, entry, i);
199 }
200
201 i++;
203
204 return TRUE;
205}
206
207/**********************************************************************/
210static bool save_tech_list(struct section_file *sfile, int *input,
211 const char *path, const char *entry)
212{
213 const char *tech_names[MAX_NUM_TECH_LIST];
214 int set_count;
215 int i;
216
217 set_count = 0;
218 for (i = 0; input[i] != A_LAST && i < MAX_NUM_TECH_LIST; i++) {
220 }
221
222 if (set_count > 0) {
224 "%s.%s", path, entry);
225 }
226
227 return TRUE;
228}
229
230/**********************************************************************/
233static bool save_tech_ref(struct section_file *sfile,
234 const struct advance *padv,
235 const char *path, const char *entry)
236{
237 if (padv == A_NEVER) {
238 secfile_insert_str(sfile, "Never", "%s.%s", path, entry);
239 } else {
241 "%s.%s", path, entry);
242 }
243
244 return TRUE;
245}
246
247/**********************************************************************/
250static bool save_terrain_ref(struct section_file *sfile,
251 const struct terrain *save,
252 const struct terrain *pthis,
253 const char *path, const char *entry)
254{
255 if (save == nullptr) {
256 secfile_insert_str(sfile, "none", "%s.%s", path, entry);
257 } else if (save == pthis) {
258 secfile_insert_str(sfile, "yes", "%s.%s", path, entry);
259 } else {
261 "%s.%s", path, entry);
262 }
263
264 return TRUE;
265}
266
267/**********************************************************************/
270static bool save_gov_ref(struct section_file *sfile,
271 const struct government *gov,
272 const char *path, const char *entry)
273{
274 secfile_insert_str(sfile, government_rule_name(gov), "%s.%s", path, entry);
275
276 return TRUE;
277}
278
279/**********************************************************************/
283static bool save_building_list(struct section_file *sfile, int *input,
284 const char *path, const char *entry)
285{
287 int set_count;
288 int i;
289
290 set_count = 0;
291 for (i = 0; input[i] != B_LAST && i < MAX_NUM_BUILDING_LIST; i++) {
293 }
294
295 if (set_count > 0) {
297 "%s.%s", path, entry);
298 }
299
300 return TRUE;
301}
302
303/**********************************************************************/
307static bool save_unit_list(struct section_file *sfile, struct unit_type **input,
308 const char *path, const char *entry)
309{
310 const char *unit_names[MAX_NUM_UNIT_LIST];
311 int set_count;
312 int i;
313
314 set_count = 0;
315 for (i = 0; input[i] != nullptr && i < MAX_NUM_UNIT_LIST; i++) {
317 }
318
319 if (set_count > 0) {
321 "%s.%s", path, entry);
322 }
323
324 return TRUE;
325}
326
327/**********************************************************************/
330static bool save_uclass_vec(struct section_file *sfile,
331 bv_unit_classes *bits,
332 const char *path, const char *entry,
333 bool unreachable_only)
334{
335 const char *class_names[UCL_LAST];
336 int classes = 0;
337
339 if (BV_ISSET(*(bits), uclass_index(pcargo))
341 || !unreachable_only)) {
343 }
345
346 if (classes > 0) {
348 "%s.%s", path, entry);
349 }
350
351 return TRUE;
352}
353
354/**********************************************************************/
357static bool save_strvec(struct section_file *sfile,
358 struct strvec *to_save,
359 const char *path, const char *entry)
360{
361 if (to_save != nullptr) {
363 const char *sections[sect_count];
364 int i;
365
366 for (i = 0; i < sect_count; i++) {
367 sections[i] = strvec_get(to_save, i);
368 }
369
370 secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
371 }
372
373 return TRUE;
374}
375
376/**********************************************************************/
379static bool save_ruleset_file(struct section_file *sfile, const char *filename)
380{
381 return secfile_save(sfile, filename, 0, FZ_PLAIN);
382}
383
384/**********************************************************************/
387static bool save_buildings_ruleset(const char *filename, const char *name)
388{
389 struct section_file *sfile = create_ruleset_file(name, "building");
390 int sect_idx;
391 int i;
392 bool uflags_building = FALSE;
393
394 if (sfile == nullptr) {
395 return FALSE;
396 }
397
398 for (i = 0; i < MAX_NUM_USER_BUILDING_FLAGS; i++) {
400 const char *helptxt = impr_flag_helptxt(i + IF_USER_FLAG_1);
401
402 if (flagname != nullptr) {
403 if (!uflags_building) {
406 }
407
408 secfile_insert_str(sfile, flagname, "control.building_flags%d.name", i);
409
410 /* Save the user flag help text even when it is undefined. That makes
411 * the formatting code happy. The resulting "" is ignored when the
412 * ruleset is loaded. */
413 secfile_insert_str(sfile, helptxt,
414 "control.building_flags%d.helptxt", i);
415 }
416 }
417
418 comment_buildings(sfile);
419
420 sect_idx = 0;
422 if (!pb->ruledit_disabled) {
423 char path[512];
424 const char *flag_names[IF_COUNT];
425 int set_count;
426 int flagi;
427
428 fc_snprintf(path, sizeof(path), "building_%d", sect_idx++);
429
430 save_name_translation(sfile, &(pb->name), path);
431
433 "%s.genus", path);
434
435 if (strcmp(pb->graphic_str, "-")) {
436 secfile_insert_str(sfile, pb->graphic_str, "%s.graphic", path);
437 }
438 if (strcmp(pb->graphic_alt, "-")) {
439 secfile_insert_str(sfile, pb->graphic_alt, "%s.graphic_alt", path);
440 }
441 if (strcmp(pb->graphic_alt2, "-")) {
442 secfile_insert_str(sfile, pb->graphic_alt2, "%s.graphic_alt2", path);
443 }
444 if (strcmp(pb->soundtag, "-")) {
445 secfile_insert_str(sfile, pb->soundtag, "%s.sound", path);
446 }
447 if (strcmp(pb->soundtag_alt, "-")) {
448 secfile_insert_str(sfile, pb->soundtag_alt, "%s.sound_alt", path);
449 }
450 if (strcmp(pb->soundtag_alt2, "-")) {
451 secfile_insert_str(sfile, pb->soundtag_alt2, "%s.sound_alt2", path);
452 }
453
454 save_reqs_vector(sfile, &(pb->reqs), path, "reqs");
455 save_reqs_vector(sfile, &(pb->obsolete_by), path, "obsolete_by");
456
457 secfile_insert_int(sfile, pb->build_cost, "%s.build_cost", path);
458 secfile_insert_int(sfile, pb->upkeep, "%s.upkeep", path);
459 secfile_insert_int(sfile, pb->sabotage, "%s.sabotage", path);
460
461 set_count = 0;
462 for (flagi = 0; flagi < IF_COUNT; flagi++) {
465 }
466 }
467
468 if (set_count > 0) {
470 "%s.flags", path);
471 }
472
473 save_strvec(sfile, pb->helptext, path, "helptext");
474 }
476
477 return save_ruleset_file(sfile, filename);
478}
479
480/**********************************************************************/
483static bool save_styles_ruleset(const char *filename, const char *name)
484{
485 struct section_file *sfile = create_ruleset_file(name, "styles");
486 int sect_idx;
487 int i;
488
489 if (sfile == nullptr) {
490 return FALSE;
491 }
492
493 comment_styles(sfile);
494
495 sect_idx = 0;
497 char path[512];
498
499 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
500
501 save_name_translation(sfile, &(pstyle->name), path);
503
504 comment_citystyles(sfile);
505
506 sect_idx = 0;
507 for (i = 0; i < game.control.num_city_styles; i++) {
508 char path[512];
509
510 fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++);
511
512 save_name_translation(sfile, &(city_styles[i].name), path);
513
514 secfile_insert_str(sfile, city_styles[i].graphic, "%s.graphic", path);
515 secfile_insert_str(sfile, city_styles[i].graphic_alt, "%s.graphic_alt", path);
516 if (strcmp(city_styles[i].citizens_graphic, "-")) {
517 secfile_insert_str(sfile, city_styles[i].citizens_graphic,
518 "%s.citizens_graphic", path);
519 }
520
521 save_reqs_vector(sfile, &(city_styles[i].reqs), path, "reqs");
522 }
523
524 comment_musicstyles(sfile);
525
526 sect_idx = 0;
528 char path[512];
529
530 fc_snprintf(path, sizeof(path), "musicstyle_%d", sect_idx++);
531
532 secfile_insert_str(sfile, pmus->music_peaceful, "%s.music_peaceful", path);
533 secfile_insert_str(sfile, pmus->music_combat, "%s.music_combat", path);
534
535 save_reqs_vector(sfile, &(pmus->reqs), path, "reqs");
537
538 return save_ruleset_file(sfile, filename);
539}
540
541/**********************************************************************/
548 const int aap,
549 const char *uflags_path,
550 bool (*unexpected_req)(
551 const struct requirement *preq))
552{
554 size_t i;
555 size_t ret;
556
557 const struct action_auto_perf *auto_perf =
559
560 i = 0;
562 fc_assert(req->range == REQ_RANGE_LOCAL);
563
564 if (req->source.kind == VUT_UTFLAG) {
565 fc_assert(!req->present);
566
567 protecor_flag[i++] = req->source.value.unitflag;
568 } else if (unexpected_req(req)) {
569 struct astring astr;
570
571 log_error("Can't handle action auto performer requirement %s",
572 req_to_fstring(req, &astr));
573 astr_free(&astr);
574
575 return FALSE;
576 }
578
581 "%s", uflags_path);
582
583 if (ret != i) {
584 log_error("%s: didn't save all unit type flags.", uflags_path);
585
586 return FALSE;
587 }
588
589 return TRUE;
590}
591
592/**********************************************************************/
598static bool save_action_auto_actions(struct section_file *sfile,
599 const int aap,
600 const char *actions_path)
601{
603 size_t i, j;
604 size_t ret;
605
606 const struct action_auto_perf *auto_perf
608
609 for (i = 0, j = 0;
610 i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
611 i++) {
612 struct action *paction = action_by_number(auto_perf->alternatives[i]);
613
615 /* Don't mention non enabled actions. */
616 continue;
617 }
618
619 /* This action is included in the output. */
620 unit_acts[j] = auto_perf->alternatives[i];
621 j++;
622 }
623
626 "%s", actions_path);
627
628 if (ret != j) {
629 log_error("%s: didn't save all actions.", actions_path);
630
631 return FALSE;
632 }
633
634 return TRUE;
635}
636
637/**********************************************************************/
641static bool unexpected_non_otype(const struct requirement *req)
642{
643 return !(req->source.kind == VUT_OTYPE && req->present);
644}
645
646/**********************************************************************/
651static bool save_muuk_action_auto(struct section_file *sfile,
652 const int aap,
653 const char *item)
654{
655 char uflags_path[100];
656 char action_path[100];
657
659 "missing_unit_upkeep.%s_protected", item);
661 "missing_unit_upkeep.%s_unit_act", item);
662
666}
667
668/**********************************************************************/
671static bool save_cities_ruleset(const char *filename, const char *name)
672{
673 struct section_file *sfile = create_ruleset_file(name, "cities");
674 int sect_idx;
675
676 if (sfile == nullptr) {
677 return FALSE;
678 }
679
680 comment_specialists(sfile);
681
682 sect_idx = 0;
685 char path[512];
686
687 fc_snprintf(path, sizeof(path), "specialist_%d", sect_idx++);
688
689 save_name_translation(sfile, &(s->name), path);
690
693 "%s.short_name", path);
694 }
695
696 save_reqs_vector(sfile, &(s->reqs), path, "reqs");
697
698 secfile_insert_str(sfile, s->graphic_str, "%s.graphic", path);
699 if (strcmp(s->graphic_alt, "-")) {
700 secfile_insert_str(sfile, s->graphic_alt, "%s.graphic_alt", path);
701 }
702
703 save_strvec(sfile, s->helptext, path, "helptext");
704
706
709 "parameters.celebrate_size_limit");
710 }
713 "parameters.add_to_size_limit");
714 }
717 "parameters.angry_citizens");
718 }
721 "parameters.changable_tax");
722 }
723 if (game.info.forced_science != 0) {
725 "parameters.forced_science");
726 }
727 if (game.info.forced_luxury != 100) {
729 "parameters.forced_luxury");
730 }
731 if (game.info.forced_gold != 0) {
733 "parameters.forced_gold");
734 }
737 "parameters.vision_reveal_tiles");
738 }
739 if (game.info.pop_report_zeroes != 1) {
741 "parameters.pop_report_zeroes");
742 }
743
746 "citizen.nationality", nullptr);
749 "citizen.ubuilder_nationality", nullptr);
752 "citizen.convert_speed", nullptr);
753 if (game.info.conquest_convert_pct != 0) {
755 "citizen.conquest_convert_pct");
756 }
757
760 "citizen.partisans_pct");
761 }
762
764 "food");
767 "missing_unit_upkeep.food_wipe");
768 }
769
771 "gold");
774 "missing_unit_upkeep.gold_wipe");
775 }
776
778 "shield");
781 "missing_unit_upkeep.shield_wipe");
782 }
783
784 return save_ruleset_file(sfile, filename);
785}
786
787/**************************************************************************
788 Effect saving callback data structure.
789**************************************************************************/
790typedef struct {
791 int idx;
794
795/**********************************************************************/
798static bool effect_save(struct effect *peffect, void *data)
799{
801 char path[512];
802
803 if (peffect->rulesave.do_not_save) {
804 /* Is supposed to be skipped. */
805 return TRUE;
806 }
807
808 fc_snprintf(path, sizeof(path), "effect_%d", cbdata->idx++);
809
812 "%s.type", path);
813 secfile_insert_int(cbdata->sfile, peffect->value, "%s.value", path);
814
815 save_reqs_vector(cbdata->sfile, &peffect->reqs, path, "reqs");
816
817 if (peffect->rulesave.comment != nullptr) {
818 secfile_insert_str(cbdata->sfile, peffect->rulesave.comment,
819 "%s.comment", path);
820 }
821
822 return TRUE;
823}
824
825/**********************************************************************/
828static bool save_effects_ruleset(const char *filename, const char *name)
829{
830 struct section_file *sfile = create_ruleset_file(name, "effect");
831 effect_cb_data data;
832 int i;
833 int sidx;
834
835 if (sfile == nullptr) {
836 return FALSE;
837 }
838
839 data.idx = 0;
840 data.sfile = sfile;
841
842 comment_ueffs(sfile);
843
844 sidx = 0;
845 for (i = EFT_USER_EFFECT_1 ; i <= EFT_USER_EFFECT_LAST; i++) {
846 enum effect_type val = user_effect_ai_valued_as(i);
847
848 if (val != i) {
849 char path[512];
850
851 fc_snprintf(path, sizeof(path), "ueff_%d", sidx++);
852
854 "%s.type", path);
856 "%s.ai_valued_as", path);
857 }
858 }
859
860 comment_effects(sfile);
861
862 if (!iterate_effect_cache(effect_save, &data)) {
863 return FALSE;
864 }
865
866 return save_ruleset_file(sfile, filename);
867}
868
869/**********************************************************************/
872static bool save_action_max_range(struct section_file *sfile,
873 action_id act)
874{
875 struct action *paction = action_by_number(act);
876
877 if (paction->max_distance == ACTION_DISTANCE_UNLIMITED) {
879 "actions.%s",
880 action_max_range_ruleset_var_name(act)) != nullptr;
881 } else {
884 "actions",
886 }
887}
888
889/**********************************************************************/
892static bool save_action_range(struct section_file *sfile, action_id act)
893{
894 struct action *paction = action_by_number(act);
895
896 if (action_min_range_ruleset_var_name(act) != nullptr) {
897 /* Min range can be loaded from the ruleset. */
898 save_default_int(sfile,
899 paction->min_distance,
901 "actions",
903 }
904
905 if (action_max_range_ruleset_var_name(act) != nullptr) {
906 /* Max range can be loaded from the ruleset. */
907 if (!save_action_max_range(sfile, act)) {
908 return FALSE;
909 }
910 }
911
912 return TRUE;
913}
914
915/**********************************************************************/
918static bool save_action_kind(struct section_file *sfile, action_id act)
919{
920 if (action_target_kind_ruleset_var_name(act) != nullptr) {
921 struct action *paction = action_by_number(act);
922
923 /* Target kind can be loaded from the ruleset. */
925 /* Don't save the default for actions that aren't enabled. */
926 return TRUE;
927 }
928
932 "actions.%s",
934 }
935
936 return TRUE;
937}
938
939/**********************************************************************/
943 action_id act)
944{
946 struct action *paction = action_by_number(act);
947
948 /* Actor consumption can be loaded from the ruleset. */
950 /* Don't save value for actions that aren't enabled. */
951 return TRUE;
952 }
953
954 save_default_bool(sfile,
957 "actions",
959 }
960
961 return TRUE;
962}
963
964/**********************************************************************/
967static bool save_action_blocked_by(struct section_file *sfile,
968 struct action *paction)
969{
971 char comment[1024];
972 int i = 0;
973
975 /* Action blocked by shouldn't be written to the ruleset for this
976 * action. */
977 return TRUE;
978 }
979
981 /* Don't save value for actions that aren't enabled. */
982 return TRUE;
983 }
984
985 fc_snprintf(comment, sizeof(comment),
986 "Forbid \"%s\" if any one of the listed actions are legal.",
988
991
993 /* Don't save value for actions that aren't enabled. */
994 continue;
995 }
996
997 if (BV_ISSET(paction->blocked_by, blocker_id)) {
999 i++;
1000 }
1002
1004 sfile, &action_vec, i, gen_action, comment, "actions.%s",
1006 != i) {
1007 log_error("Didn't save all %s blocking actions.",
1009
1010 return FALSE;
1011 }
1012
1013 return TRUE;
1014}
1015
1016/**********************************************************************/
1021 int performer_slot,
1022 struct action *paction)
1023{
1024 char action_list_path[100];
1025
1027 /* Not relevant. */
1028 return TRUE;
1029 }
1030
1031 if (!action_is_in_use(paction)) {
1032 /* Don't save value for actions that aren't enabled. */
1033 return TRUE;
1034 }
1035
1037 "actions.%s",
1040 return FALSE;
1041 }
1042
1043 return TRUE;
1044}
1045
1046/**********************************************************************/
1049static bool save_bv_actions(struct section_file *sfile,
1050 bv_actions content,
1051 const char *path)
1052{
1054 int i = 0;
1055
1056 action_iterate(act_id) {
1057 struct action *paction = action_by_number(act_id);
1058
1059 if (!action_is_in_use(paction)) {
1060 /* Don't save value for actions that aren't enabled. */
1061 continue;
1062 }
1063
1064 if (BV_ISSET(content, act_id)) {
1065 action_vec[i] = act_id;
1066 i++;
1067 }
1069
1071 "%s", path) != i) {
1072 log_error("Didn't save all of %s.", path);
1073
1074 return FALSE;
1075 }
1076
1077 return TRUE;
1078}
1079/**********************************************************************/
1082static bool save_actions_ruleset(const char *filename, const char *name)
1083{
1084 struct section_file *sfile = create_ruleset_file(name, "actions");
1086 int i = 0;
1087 int sect_idx = 0;
1088
1089 /* TODO: move action logic from save_game_ruleset to here */
1090 if (sfile == nullptr) {
1091 return FALSE;
1092 }
1093 {
1094 /* Action auto performers aren't ready to be exposed in the ruleset
1095 * yet. The behavior when two action auto performers for the same
1096 * cause can fire isn't set in stone yet. How is one of them chosen?
1097 * What if all the actions of the chosen action auto performer turned
1098 * out to be illegal but one of the other action auto performers that
1099 * fired has legal actions? These issues can decide what other action
1100 * rules action auto performers can represent in the future. Deciding
1101 * should therefore wait until a rule needs action auto performers to
1102 * work a certain way. */
1103 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
1104 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
1105 * requirement vector to the ruleset. */
1106 const struct action_auto_perf *auto_perf =
1108
1109 comment_auto_attack(sfile);
1110
1111 save_reqs_vector(sfile, &auto_perf->reqs,
1112 "auto_attack", "if_attacker");
1113
1115 "auto_attack.attack_actions");
1116 }
1117
1120 "actions.diplchance_initial_odds")) {
1121 return FALSE;
1122 }
1123
1127 log_error("Didn't save all post success forced actions.");
1128 return FALSE;
1129 }
1130
1134 log_error("Didn't save all post success forced actions.");
1135 return FALSE;
1136 }
1137
1140 log_error("Didn't save all post success forced actions.");
1141 return FALSE;
1142 }
1143
1146 log_error("Didn't save all post success forced actions.");
1147 return FALSE;
1148 }
1149
1151 "actions.escape_city")) {
1152 log_error("Didn't save all escape city forced actions.");
1153 return FALSE;
1154 }
1155
1157 "actions.unit_stack_death")) {
1158 log_error("Didn't save all escape unit stack death forced actions.");
1159 return FALSE;
1160 }
1161
1164 "actions.poison_empties_food_stock", nullptr);
1165
1168 "actions.steal_maps_reveals_all_cities", nullptr);
1169
1170 action_iterate(act_id) {
1171 struct action *act = action_by_number(act_id);
1172
1173 save_action_kind(sfile, act_id);
1174 save_action_range(sfile, act_id);
1176 save_action_blocked_by(sfile, act);
1178
1180
1181 i = 0;
1182 action_iterate(act) {
1183 if (action_by_number(act)->quiet) {
1184 action_vec[i] = act;
1185 i++;
1186 }
1188
1190 "actions.quiet_actions") != i) {
1191 log_error("Didn't save all quiet actions.");
1192
1193 return FALSE;
1194 }
1195
1196 comment_actions(sfile);
1197 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
1198 struct action *paction = action_by_number(i);
1199
1200 if (!action_is_in_use(paction)) {
1201 /* Don't mention non enabled actions. */
1202 continue;
1203 }
1204
1205 if (paction->configured) {
1206 char path[512];
1207 const char *ui_name;
1208
1209 fc_snprintf(path, sizeof(path), "action_%d", i);
1210
1212 "%s.action", path);
1213
1214 if (!action_id_is_internal(i)) {
1215 ui_name = paction->ui_name;
1216
1217 if (ui_name == nullptr) {
1218 fc_assert(ui_name != nullptr);
1219
1220 return FALSE;
1221 }
1222
1225 "%s.ui_name", path);
1226 }
1227 }
1228 }
1229 }
1230
1231 comment_enablers(sfile);
1232 sect_idx = 0;
1234 char path[512];
1235
1236 if (pae->rulesave.ruledit_disabled) {
1237 continue;
1238 }
1239
1240 fc_snprintf(path, sizeof(path), "enabler_%d", sect_idx++);
1241
1243 "%s.action", path);
1244
1245 save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs");
1246 save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs");
1247
1248 if (pae->rulesave.comment != nullptr) {
1249 secfile_insert_str(sfile, pae->rulesave.comment, "%s.comment", path);
1250 }
1252
1253 return save_ruleset_file(sfile, filename);
1254}
1255
1256/**********************************************************************/
1259static bool save_game_ruleset(const char *filename, const char *name)
1260{
1261 struct section_file *sfile = create_ruleset_file(name, "game");
1262 int sect_idx;
1263 int col_idx;
1264 int set_count;
1265 enum gameloss_style gs;
1266 const char *style_names[32]; /* FIXME: Should determine max length automatically.
1267 * currently it's 3 (bits 0,1, and 2) so there's plenty of
1268 * safety margin here. */
1269 const char *tnames[game.server.ruledit.named_teams];
1270 enum trade_route_type trt;
1271 int i;
1272 bool locks;
1273
1274 if (sfile == nullptr) {
1275 return FALSE;
1276 }
1277
1278 if (game.server.ruledit.description_file != nullptr) {
1280 "ruledit.description_file");
1281 }
1282
1286 "ruledit.std_tileset_compat");
1287 }
1288
1289 if (game.control.preferred_tileset[0] != '\0') {
1291 "tileset.preferred");
1292 }
1293 if (game.control.preferred_soundset[0] != '\0') {
1295 "soundset.preferred");
1296 }
1297 if (game.control.preferred_musicset[0] != '\0') {
1299 "musicset.preferred");
1300 }
1301
1302 secfile_insert_str(sfile, game.control.name, "about.name");
1303 secfile_insert_str(sfile, game.control.version, "about.version");
1304
1305 if (game.control.alt_dir[0] != '\0') {
1306 secfile_insert_str(sfile, game.control.alt_dir, "about.alt_dir");
1307 }
1308
1309 if (game.ruleset_summary != nullptr) {
1310 struct entry *mod_entry;
1311
1313 "about.summary");
1315 }
1316
1317 if (game.ruleset_description != nullptr) {
1318 if (game.server.ruledit.description_file == nullptr) {
1320 "about.description");
1321 } else {
1323 "about.description");
1324 }
1325 }
1326
1327 if (game.ruleset_capabilities != nullptr) {
1329 "about.capabilities");
1330 } else {
1331 secfile_insert_str(sfile, "", "about.capabilities");
1332 }
1333
1335 "options", "global_init_techs");
1337 "options", "global_init_buildings");
1338
1340 FALSE,
1341 "options.popup_tech_help", nullptr);
1344 "civstyle.base_pollution", nullptr);
1345
1346 set_count = 0;
1348 if (game.info.gameloss_style & gs) {
1350 }
1351 }
1352
1353 if (set_count > 0) {
1355
1357 "civstyle.gameloss_style");
1358 }
1359
1362 "civstyle.happy_cost", nullptr);
1365 "civstyle.food_cost", nullptr);
1366 save_default_bool(sfile,
1369 FALSE,
1370 "civstyle.paradrop_to_transport", nullptr);
1373 "civstyle.base_bribe_cost", nullptr);
1376 }
1379 "civstyle.ransom_gold", nullptr);
1382 "civstyle.pillage_select", nullptr);
1385 "civstyle.tech_steal_allow_holes", nullptr);
1388 "civstyle.tech_trade_allow_holes", nullptr);
1391 "civstyle.tech_trade_loss_allow_holes", nullptr);
1394 "civstyle.tech_parasite_allow_holes", nullptr);
1397 "civstyle.tech_loss_allow_holes", nullptr);
1400 "civstyle.upgrade_veteran_loss", nullptr);
1403 "civstyle.autoupgrade_veteran_loss", nullptr);
1404
1406
1409 "civstyle.granary_food_ini");
1410
1413 "civstyle.granary_food_inc", nullptr);
1414
1416 char buffer[256];
1417
1418 fc_snprintf(buffer, sizeof(buffer),
1419 "civstyle.min_city_center_%s",
1421
1424 buffer, nullptr);
1426
1429 "civstyle.init_vis_radius_sq", nullptr);
1432 "civstyle.init_city_radius_sq", nullptr);
1433
1435
1438 secfile_insert_str(sfile,
1440 "civstyle.gold_upkeep_style");
1441 }
1444 }
1446 "civstyle.homeless_gold_upkeep", nullptr);
1448 1, "civstyle.output_granularity", nullptr);
1449
1452 }
1454 FALSE, "civstyle.airlift_from_always_enabled", nullptr);
1456 TRUE, "civstyle.airlift_to_always_enabled", nullptr);
1457
1461 secfile_insert_str(sfile,
1463 "wonder_visibility.small_wonders");
1464 }
1465
1468 "illness.illness_on", nullptr);
1471 "illness.illness_base_factor", nullptr);
1474 "illness.illness_min_size", nullptr);
1477 "illness.illness_trade_infection", nullptr);
1480 "illness.illness_pollution_factor", nullptr);
1481 comment_incite_cost(sfile);
1484 "incite_cost.base_incite_cost", nullptr);
1487 "incite_cost.improvement_factor", nullptr);
1490 "incite_cost.unit_factor", nullptr);
1493 "incite_cost.total_factor", nullptr);
1494
1497 }
1500 "combat_rules.tired_attack", nullptr);
1503 }
1506 "combat_rules.only_killing_makes_veteran", nullptr);
1509 }
1512 "combat_rules.only_real_fight_makes_veteran", nullptr);
1515 }
1518 "combat_rules.combat_odds_scaled_veterancy", nullptr);
1521 }
1524 "combat_rules.damage_reduces_bombard_rate", nullptr);
1527 }
1529 "combat_rules.low_firepower_badwallattacker", nullptr);
1532 }
1534 "combat_rules.low_firepower_pearl_harbor", nullptr);
1537 }
1539 "combat_rules.low_firepower_combat_bonus", nullptr);
1542 }
1544 "combat_rules.low_firepower_nonnat_bombard", nullptr);
1547 }
1550 "combat_rules.nuke_pop_loss_pct", nullptr);
1554 }
1557 "combat_rules.nuke_defender_survival_chance_pct", nullptr);
1560 "borders.radius_sq_city", nullptr);
1563 "borders.size_effect", nullptr);
1567 }
1570 "borders.radius_sq_city_permanent", nullptr);
1571
1574 "research.tech_cost_style");
1577 }
1580 "research.base_tech_cost", nullptr);
1583 }
1586 "research.min_tech_cost", nullptr);
1589 "research.tech_leakage");
1592 "research.tech_upkeep_style");
1595 "research.tech_upkeep_divider", nullptr);
1598 "research.free_tech_method");
1599
1602 "culture.victory_min_points", nullptr);
1605 "culture.victory_lead_pct", nullptr);
1608 }
1611 "culture.migration_pml", nullptr);
1614 }
1617 "culture.history_interest_pml", nullptr);
1620 }
1623 "world_peace.victory_turns", nullptr);
1624
1627 "calendar.skip_year_0", nullptr);
1630 "calendar.start_year", nullptr);
1631 if (game.calendar.calendar_fragments != 0) {
1633 }
1635 0, "calendar.fragments", nullptr);
1636
1637 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
1638 if (game.calendar.calendar_fragment_name[i][0] != '\0') {
1640 "calendar.fragment_name%d", i);
1641 }
1642 }
1643
1646 "calendar.positive_label");
1647 }
1650 "calendar.negative_label");
1651 }
1652
1653 if (game.plr_bg_color != nullptr) {
1654 rgbcolor_save(sfile, game.plr_bg_color, "playercolors.background");
1655 }
1656
1657 col_idx = 0;
1659 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1661
1662
1663 if (game.server.ruledit.named_teams > 0) {
1664 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1666 }
1667
1670 "teams.names");
1671 }
1672
1673 comment_disasters(sfile);
1674
1675 sect_idx = 0;
1677 char path[512];
1679 const char *effect_names[DE_COUNT];
1680
1681 fc_snprintf(path, sizeof(path), "disaster_%d", sect_idx++);
1682
1683 save_name_translation(sfile, &(pd->name), path);
1684 save_reqs_vector(sfile, &(pd->reqs), path, "reqs");
1685 if (pd->frequency != GAME_DEFAULT_DISASTER_FREQ) {
1686 secfile_insert_int(sfile, pd->frequency,
1687 "%s.frequency", path);
1688 }
1689
1690 set_count = 0;
1694 if (BV_ISSET(pd->effects, de)) {
1696 }
1697 }
1698
1699 if (set_count > 0) {
1701 "%s.effects", path);
1702 }
1704
1705 comment_achievements(sfile);
1706
1707 sect_idx = 0;
1709 char path[512];
1710
1711 fc_snprintf(path, sizeof(path), "achievement_%d", sect_idx++);
1712
1713 save_name_translation(sfile, &(pach->name), path);
1714
1716 "%s.type", path);
1717
1718 save_default_bool(sfile, pach->unique,
1720 path, "unique");
1721 save_default_int(sfile, pach->value,
1723 path, "value");
1724 save_default_int(sfile, pach->culture,
1725 0, path, "culture");
1726
1727 secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
1728 if (pach->cons_msg != nullptr) {
1729 secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
1730 }
1731
1733
1735
1736 set_count = 0;
1737 for (trt = 0; trt < TRT_LAST; trt++) {
1740
1741 if (set->trade_pct != 100 || strcmp(cancelling, "Active")) {
1742 char path[256];
1743
1744 fc_snprintf(path, sizeof(path),
1745 "trade.settings%d", set_count++);
1746
1748 "%s.type", path);
1749 secfile_insert_int(sfile, set->trade_pct,
1750 "%s.pct", path);
1752 "%s.cancelling", path);
1754 "%s.bonus", path);
1755 }
1756 }
1757
1759 0, "trade.min_trade_route_val", nullptr);
1760
1762 FALSE, "trade.reveal_trade_partner", nullptr);
1763
1766 "trade.goods_selection");
1767 }
1768
1769 /* Goods */
1770 comment_goods(sfile);
1771
1772 sect_idx = 0;
1774 char path[512];
1775 const char *flag_names[GF_COUNT];
1776 int flagi;
1777
1778 fc_snprintf(path, sizeof(path), "goods_%d", sect_idx++);
1779
1780 save_name_translation(sfile, &(pgood->name), path);
1781
1782 save_reqs_vector(sfile, &(pgood->reqs), path, "reqs");
1783
1784 save_default_int(sfile, pgood->from_pct, 100, path, "from_pct");
1785 save_default_int(sfile, pgood->to_pct, 100, path, "to_pct");
1786 save_default_int(sfile, pgood->onetime_pct, 100, path, "onetime_pct");
1787 save_default_int(sfile, pgood->select_priority, 1, path, "select_priority");
1788 save_default_int(sfile, pgood->replace_priority, 1, path, "replace_priority");
1789
1790 set_count = 0;
1791 for (flagi = 0; flagi < GF_COUNT; flagi++) {
1792 if (goods_has_flag(pgood, flagi)) {
1794 }
1795 }
1796
1797 if (set_count > 0) {
1799 "%s.flags", path);
1800 }
1801
1802 save_strvec(sfile, pgood->helptext, path, "helptext");
1804
1805 /* Clauses */
1806 comment_clauses(sfile);
1807
1808 sect_idx = 0;
1809 for (i = 0; i < CLAUSE_COUNT; i++) {
1810 struct clause_info *info = clause_info_get(i);
1811
1812 if (info->enabled) {
1813 char path[512];
1814
1815 fc_snprintf(path, sizeof(path), "clause_%d", sect_idx++);
1816
1818 "%s.type", path);
1819 save_reqs_vector(sfile, &(info->giver_reqs), path, "giver_reqs");
1820 save_reqs_vector(sfile, &(info->receiver_reqs), path, "receiver_reqs");
1821 save_reqs_vector(sfile, &(info->either_reqs), path, "either_reqs");
1822 }
1823 }
1824
1825 /* Counters */
1826 comment_counters(sfile);
1827
1828 sect_idx = 0;
1830 char path[512];
1831
1832 fc_snprintf(path, sizeof(path), "counter_%d", sect_idx++);
1833
1834 save_name_translation(sfile, &(pcounter->name), path);
1835
1836 save_default_int(sfile, pcounter->def, 0, path, "def");
1837 save_default_int(sfile, pcounter->checkpoint, 0, path, "checkpoint");
1838
1839 secfile_insert_str(sfile, counter_behaviour_name(pcounter->type), "%s.type", path);
1840
1841 if (pcounter->helptext != nullptr
1842 && strvec_size(pcounter->helptext) > 0) {
1843 save_strvec(sfile, pcounter->helptext, "%s.helptext", path);
1844 }
1846
1847 locks = FALSE;
1850 locks = TRUE;
1851 break;
1852 }
1854
1855 set_count = 0;
1857 struct sf_cb_data info = { pset, FALSE };
1858
1861 "settings.set%d.name", set_count);
1862 switch (setting_type(pset)) {
1863 case SST_BOOL:
1865 "settings.set%d.value", set_count);
1866 break;
1867 case SST_INT:
1869 "settings.set%d.value", set_count);
1870 break;
1871 case SST_STRING:
1873 "settings.set%d.value", set_count);
1874 break;
1875 case SST_ENUM:
1878 "settings.set%d.value", set_count);
1879 break;
1880 case SST_BITWISE:
1883 "settings.set%d.value", set_count);
1884 break;
1885 case SST_COUNT:
1887 secfile_insert_str(sfile, "Unknown setting type",
1888 "settings.set%d.value", set_count);
1889 break;
1890 }
1891
1892 if (locks) {
1894 "settings.set%d.lock", set_count);
1895 }
1896
1897 set_count++;
1898 }
1900
1901 return save_ruleset_file(sfile, filename);
1902}
1903
1904/**********************************************************************/
1907static bool save_governments_ruleset(const char *filename, const char *name)
1908{
1909 struct section_file *sfile = create_ruleset_file(name, "government");
1910 int sect_idx;
1911
1912 if (sfile == nullptr) {
1913 return FALSE;
1914 }
1915
1916 save_gov_ref(sfile, game.government_during_revolution, "governments",
1917 "during_revolution");
1918
1919 comment_govs(sfile);
1920
1921 sect_idx = 0;
1923 char path[512];
1924 struct ruler_title *prtitle;
1925
1926 fc_snprintf(path, sizeof(path), "government_%d", sect_idx++);
1927
1928 save_name_translation(sfile, &(pg->name), path);
1929
1930 secfile_insert_str(sfile, pg->graphic_str, "%s.graphic", path);
1931 secfile_insert_str(sfile, pg->graphic_alt, "%s.graphic_alt", path);
1932 secfile_insert_str(sfile, pg->sound_str, "%s.sound", path);
1933 secfile_insert_str(sfile, pg->sound_alt, "%s.sound_alt", path);
1934
1935 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1936
1937 if (pg->ai.better != nullptr) {
1938 save_gov_ref(sfile, pg->ai.better, path,
1939 "ai_better");
1940 }
1941
1942 ruler_title_hash_lookup(pg->ruler_titles, nullptr,
1943 &prtitle);
1944 if (prtitle != nullptr) {
1945 const char *title;
1946
1948 if (title != nullptr) {
1950 "%s.ruler_male_title", path);
1951 }
1952
1954 if (title != nullptr) {
1956 "%s.ruler_female_title", path);
1957 }
1958 }
1959
1960 save_strvec(sfile, pg->helptext, path, "helptext");
1961
1963
1964 comment_policies(sfile);
1965
1966 sect_idx = 0;
1967 multipliers_iterate(pmul) {
1968 if (!pmul->ruledit_disabled) {
1969 char path[512];
1970
1971 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
1972
1973 save_name_translation(sfile, &(pmul->name), path);
1974
1975 secfile_insert_int(sfile, pmul->start, "%s.start", path);
1976 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
1977 secfile_insert_int(sfile, pmul->step, "%s.step", path);
1978 secfile_insert_int(sfile, pmul->def, "%s.default", path);
1979
1980 save_default_int(sfile, pmul->offset, 0, path, "offset");
1981 save_default_int(sfile, pmul->factor, 100, path, "factor");
1982 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
1983
1984 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
1985
1986 save_strvec(sfile, pmul->helptext, path, "helptext");
1987 }
1989
1990 return save_ruleset_file(sfile, filename);
1991}
1992
1993/**********************************************************************/
1996static bool save_traits(struct trait_limits *traits,
1997 struct trait_limits *default_traits,
1998 struct section_file *sfile,
1999 const char *secname, const char *field_prefix)
2000{
2001 enum trait tr;
2002
2003 /* FIXME: Use specenum trait names without duplicating them here.
2004 * Just needs to take care of case.
2005 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
2006 const char *trait_names[] = {
2007 "expansionist",
2008 "trader",
2009 "aggressive",
2010 "builder",
2011 nullptr
2012 };
2013
2014 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != nullptr;
2015 tr = trait_next(tr)) {
2016 int default_default;
2017
2018 default_default = (traits[tr].min + traits[tr].max) / 2;
2019
2020 if ((default_traits == nullptr && traits[tr].min != TRAIT_DEFAULT_VALUE)
2021 || (default_traits != nullptr && traits[tr].min != default_traits[tr].min)) {
2022 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
2023 trait_names[tr]);
2024 }
2025 if ((default_traits == nullptr && traits[tr].max != TRAIT_DEFAULT_VALUE)
2026 || (default_traits != nullptr && traits[tr].max != default_traits[tr].max)) {
2027 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
2028 trait_names[tr]);
2029 }
2030 if (default_default != traits[tr].fixed) {
2031 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
2032 trait_names[tr]);
2033 }
2034 }
2035
2036 return TRUE;
2037}
2038
2039/**********************************************************************/
2042static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
2043 int sect_idx)
2044{
2045 char path[512];
2046 int max_items = nation_city_list_size(pnat->server.default_cities);
2047 char *city_str[max_items];
2050 const char *list_items[max_items];
2051 int set_count;
2052 int subsect_idx;
2053
2054 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
2055
2056 if (pnat->translation_domain == nullptr) {
2057 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
2058 } else {
2059 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
2060 }
2061
2062 save_name_translation(sfile, &(pnat->adjective), path);
2063 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
2064
2065 set_count = 0;
2067 if (nation_is_in_set(pnat, pset)) {
2069 }
2074 }
2076
2077 if (set_count > 0) {
2078 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
2079 }
2080
2081 set_count = 0;
2082 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
2085 if (set_count > 0) {
2086 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
2087 }
2088
2089 subsect_idx = 0;
2091 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
2092 path, subsect_idx);
2093 secfile_insert_str(sfile,
2096 "%s.leaders%d.sex", path, subsect_idx++);
2098
2099 if (pnat->server.rgb != nullptr) {
2100 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
2101 }
2102
2103 save_traits(pnat->server.traits, game.server.default_traits,
2104 sfile, path, "trait_");
2105
2106 if (!pnat->is_playable) {
2107 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
2108 }
2109
2110 if (pnat->barb_type != NOT_A_BARBARIAN) {
2111 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
2112 "%s.barbarian_type", path);
2113 }
2114
2115 if (strcmp(pnat->flag_graphic_str, "-")) {
2116 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
2117 }
2118 if (strcmp(pnat->flag_graphic_alt, "-")) {
2119 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
2120 }
2121
2122 subsect_idx = 0;
2124 struct ruler_title *prtitle;
2125
2126 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
2128 "%s.ruler_titles%d.government", path, subsect_idx);
2130 "%s.ruler_titles%d.male_title", path, subsect_idx);
2132 "%s.ruler_titles%d.female_title", path, subsect_idx++);
2133 }
2135
2136 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
2137
2138 set_count = 0;
2139 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
2142 if (set_count > 0) {
2143 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
2144 }
2145
2146 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
2147 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
2148 save_unit_list(sfile, pnat->init_units, path, "init_units");
2149
2150 if (pnat->init_government) {
2151 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
2152 "%s.init_government", path);
2153 }
2154
2155 set_count = 0;
2156 nation_city_list_iterate(pnat->server.default_cities, pncity) {
2157 bool list_started = FALSE;
2158
2160 + strlen(")")
2161 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
2162
2165 case NCP_DISLIKE:
2166 strcat(city_str[set_count], " (!river");
2168 break;
2169 case NCP_LIKE:
2170 strcat(city_str[set_count], " (river");
2172 break;
2173 case NCP_NONE:
2174 break;
2175 }
2176
2178 const char *pref = nullptr;
2179
2181 case NCP_DISLIKE:
2182 pref = "!";
2183 break;
2184 case NCP_LIKE:
2185 pref = "";
2186 break;
2187 case NCP_NONE:
2188 pref = nullptr;
2189 break;
2190 }
2191
2192 if (pref != nullptr) {
2193 if (list_started) {
2194 strcat(city_str[set_count], ", ");
2195 } else {
2196 strcat(city_str[set_count], " (");
2198 }
2201 }
2202
2204
2205 if (list_started) {
2206 strcat(city_str[set_count], ")");
2207 }
2208
2210 set_count++;
2212 if (set_count > 0) {
2213 int i;
2214
2215 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
2216
2217 for (i = 0; i < set_count; i++) {
2218 FC_FREE(city_str[i]);
2219 }
2220 }
2221
2222 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
2223
2224 return TRUE;
2225}
2226
2227/**********************************************************************/
2230static bool save_nations_ruleset(const char *filename, const char *name,
2231 struct rule_data *data)
2232{
2233 struct section_file *sfile = create_ruleset_file(name, "nation");
2234
2235 if (sfile == nullptr) {
2236 return FALSE;
2237 }
2238
2239 if (data->nationlist != nullptr || game.server.ruledit.embedded_nations != nullptr) {
2241 if (data->nationlist != nullptr) {
2242 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2243 }
2244 if (game.server.ruledit.embedded_nations != nullptr) {
2245 int i;
2246 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2247
2248 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2249 * resrictions */
2250 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2252 }
2253
2256 "ruledit.embedded_nations");
2257 free(tmp);
2258 }
2259 }
2260
2261 save_traits(game.server.default_traits, nullptr, sfile,
2262 "default_traits", "");
2263
2264 if (data->nationlist == nullptr) {
2265 if (game.server.ruledit.allowed_govs != nullptr) {
2268 "compatibility.allowed_govs");
2269 }
2270 if (game.server.ruledit.allowed_terrains != nullptr) {
2273 "compatibility.allowed_terrains");
2274 }
2275 if (game.server.ruledit.allowed_styles != nullptr) {
2278 "compatibility.allowed_styles");
2279 }
2280 }
2281
2282 if (game.default_government != nullptr) {
2284 "compatibility.default_government");
2285 }
2286
2287 if (data->nationlist != nullptr) {
2288 secfile_insert_include(sfile, data->nationlist);
2289
2290 if (game.server.ruledit.embedded_nations != nullptr) {
2291 int sect_idx;
2292
2293 comment_nations(sfile);
2294
2296 sect_idx++) {
2297 struct nation_type *pnat
2299
2300 if (pnat == nullptr) {
2301 log_error("Embedded nation \"%s\" not found!",
2303 } else {
2304 save_nation(sfile, pnat, sect_idx);
2305 }
2306 }
2307 }
2308 } else {
2309 int sect_idx = 0;
2310
2311 comment_nationsets(sfile);
2312
2314 char path[512];
2315
2316 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2317
2318 /* We don't use save_name_translation() for this as name and rule_name must
2319 * always be saved separately */
2320 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2321 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2322 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2324
2325 comment_nationgroups(sfile);
2326
2327 sect_idx = 0;
2329 char path[512];
2330
2331 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2332
2333 save_name_translation(sfile, &(pgroup->name), path);
2334
2335 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2336 if (pgroup->hidden) {
2337 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2338 }
2340
2341 comment_nations(sfile);
2342
2343 sect_idx = 0;
2345 save_nation(sfile, pnat, sect_idx++);
2347 }
2348
2349 return save_ruleset_file(sfile, filename);
2350}
2351
2352/**********************************************************************/
2355static bool save_techs_ruleset(const char *filename, const char *name)
2356{
2357 struct section_file *sfile = create_ruleset_file(name, "tech");
2358 int i;
2359 int sect_idx;
2361 bool uflags_tech = FALSE;
2362
2363 if (sfile == nullptr) {
2364 return FALSE;
2365 }
2366
2367 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2368 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2369 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2370
2371 if (flagname != nullptr) {
2372 if (!uflags_tech) {
2373 comment_uflags_tech(sfile);
2374 uflags_tech = TRUE;
2375 }
2376
2377 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2378
2379 /* Save the user flag help text even when it is undefined. That makes
2380 * the formatting code happy. The resulting "" is ignored when the
2381 * ruleset is loaded. */
2382 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2383 }
2384 }
2385
2386 comment_tech_classes(sfile);
2387
2388 sect_idx = 0;
2390 char path[512];
2391
2392 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2393
2394 save_name_translation(sfile, &(ptclass->name), path);
2396
2397 comment_techs(sfile);
2398
2399 sect_idx = 0;
2401 if (pa->require[AR_ONE] != A_NEVER) {
2402 char path[512];
2403 const char *flag_names[TF_COUNT];
2404 int set_count;
2405 int flagi;
2406
2407 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2408
2409 save_name_translation(sfile, &(pa->name), path);
2410
2411 if (game.control.num_tech_classes > 0) {
2412 if (pa->tclass != nullptr) {
2414 "%s.class", path);
2415 }
2416 }
2417
2418 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2419 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2420 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2421 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2422 }
2423
2424 save_reqs_vector(sfile, &(pa->research_reqs), path,
2425 "research_reqs");
2426
2427 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2428 if (strcmp("-", pa->graphic_alt)) {
2429 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2430 }
2431 if (pa->bonus_message != nullptr) {
2432 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2433 }
2434
2435 set_count = 0;
2436 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2439 }
2440 }
2441
2442 if (set_count > 0) {
2444 "%s.flags", path);
2445 }
2446 if (pa->cost >= 0) {
2447 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2448 }
2449
2450 save_strvec(sfile, pa->helptext, path, "helptext");
2451 }
2452
2454
2455 return save_ruleset_file(sfile, filename);
2456}
2457
2458/**********************************************************************/
2461static bool save_terrain_ruleset(const char *filename, const char *name)
2462{
2463 struct section_file *sfile = create_ruleset_file(name, "terrain");
2464 int sect_idx;
2465 int i;
2466 bool uflags_terr = FALSE;
2467 bool uflags_extra = FALSE;
2468
2469 if (sfile == nullptr) {
2470 return FALSE;
2471 }
2472
2473 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2475 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2476
2477 if (flagname != nullptr) {
2478 if (!uflags_terr) {
2480 uflags_terr = TRUE;
2481 }
2482
2483 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2484
2485 /* Save the user flag help text even when it is undefined. That makes
2486 * the formatting code happy. The resulting "" is ignored when the
2487 * ruleset is loaded. */
2488 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2489 }
2490 }
2491
2492 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2494 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2495
2496 if (flagname != nullptr) {
2497 if (!uflags_extra) {
2498 /* TODO: Uncomment this, once there's a way to stop
2499 * the comment getting written inside preceding
2500 * terrain flags table. */
2501 /* comment_uflags_extra(sfile); */
2503 }
2504
2505 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2506
2507 /* Save the user flag help text even when it is undefined. That makes
2508 * the formatting code happy. The resulting "" is ignored when the
2509 * ruleset is loaded. */
2510 secfile_insert_str(sfile, helptxt,
2511 "control.extra_flags%d.helptxt", i);
2512 }
2513 }
2514
2515 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2516 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2517 "parameters.ocean_reclaim_requirement");
2518 }
2519 if (terrain_control.land_channel_requirement_pct <= 100) {
2520 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2521 "parameters.land_channel_requirement");
2522 }
2523 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2524 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2525 "parameters.thaw_requirement");
2526 }
2527 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2528 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2529 "parameters.freeze_requirement");
2530 }
2531 if (terrain_control.lake_max_size != 0) {
2532 secfile_insert_int(sfile, terrain_control.lake_max_size,
2533 "parameters.lake_max_size");
2534 }
2535 if (terrain_control.min_start_native_area != 0) {
2536 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2537 "parameters.min_start_native_area");
2538 }
2539 if (terrain_control.move_fragments != 3) {
2540 secfile_insert_int(sfile, terrain_control.move_fragments,
2541 "parameters.move_fragments");
2542 }
2543 if (terrain_control.igter_cost != 1) {
2544 secfile_insert_int(sfile, terrain_control.igter_cost,
2545 "parameters.igter_cost");
2546 }
2547 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2548 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2549 "parameters.pythagorean_diagonal");
2550 }
2553 "parameters.ocean_resources");
2554 }
2555
2556 comment_terrains(sfile);
2557
2558 sect_idx = 0;
2560 char path[512];
2561 char identifier[2];
2562 int r;
2563 const char *flag_names[TER_USER_LAST];
2564 const char *puc_names[UCL_LAST];
2565 int flagi;
2566 int set_count;
2567
2568 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2569
2570 save_name_translation(sfile, &(pterr->name), path);
2571
2572 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2573 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2574 secfile_insert_str(sfile, pterr->graphic_alt2, "%s.graphic_alt2", path);
2575 identifier[0] = pterr->identifier;
2576 identifier[1] = '\0';
2577 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2578
2580 "%s.class", path);
2581
2582 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2583 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2584
2586 if (pterr->output[o] != 0) {
2587 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2589 }
2591
2592 /* Check resource count */
2593 for (r = 0; pterr->resources[r] != nullptr; r++) {
2594 /* Just increasing r as long as there is resources */
2595 }
2596
2597 {
2598 const char *resource_names[r];
2599 bool save_frequencies = FALSE;
2600
2601 r = 0;
2606 }
2608
2610 "%s.resources", path);
2611
2612 if (save_frequencies) {
2613 secfile_insert_int_vec(sfile, pterr->resource_freq, r,
2614 "%s.resource_freq", path);
2615 }
2616 }
2617
2619 if (pterr->road_output_incr_pct[o] != 0) {
2620 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2621 "%s.road_%s_incr_pct", path,
2623 }
2625
2626 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2627 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2628
2629 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2630 "cultivate_result");
2631 secfile_insert_int(sfile, pterr->cultivate_time,
2632 "%s.cultivate_time", path);
2633
2634 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2635 "plant_result");
2636 secfile_insert_int(sfile, pterr->plant_time,
2637 "%s.plant_time", path);
2638
2639 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2640 "%s.irrigation_food_incr", path);
2641 secfile_insert_int(sfile, pterr->irrigation_time,
2642 "%s.irrigation_time", path);
2643
2644 secfile_insert_int(sfile, pterr->mining_shield_incr,
2645 "%s.mining_shield_incr", path);
2646 secfile_insert_int(sfile, pterr->mining_time,
2647 "%s.mining_time", path);
2648
2649 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2650 "transform_result");
2651 secfile_insert_int(sfile, pterr->transform_time,
2652 "%s.transform_time", path);
2653
2654 if (pterr->animal != nullptr) {
2656 "%s.animal", path);
2657 } else {
2658 secfile_insert_str(sfile, "None",
2659 "%s.animal", path);
2660 }
2661
2662 secfile_insert_int(sfile, pterr->placing_time,
2663 "%s.placing_time", path);
2664 secfile_insert_int(sfile, pterr->pillage_time,
2665 "%s.pillage_time", path);
2666
2667 i = 0;
2668 extra_type_iterate(pextra) {
2669 int rmtime = pterr->extra_removal_times[extra_index(pextra)];
2670
2671 if (rmtime != 0) {
2672 secfile_insert_str(sfile, extra_rule_name(pextra),
2673 "%s.extra_settings%d.extra",
2674 path, i);
2676 "%s.extra_settings%d.removal_time",
2677 path, i++);
2678 }
2680
2681 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2682 "warmer_wetter_result");
2683 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2684 "warmer_drier_result");
2685 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2686 "cooler_wetter_result");
2687 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2688 "cooler_drier_result");
2689
2690 set_count = 0;
2691 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2694 }
2695 }
2696
2697 if (set_count > 0) {
2699 "%s.flags", path);
2700 }
2701
2702 {
2704
2708 if (pterr->property[mtp] != 0) {
2709 secfile_insert_int(sfile, pterr->property[mtp],
2710 "%s.property_%s", path,
2712 }
2713 }
2714 }
2715
2716 set_count = 0;
2718 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2720 }
2722
2723 if (set_count > 0) {
2725 "%s.native_to", path);
2726 }
2727
2728 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2729
2730 save_strvec(sfile, pterr->helptext, path, "helptext");
2731
2733
2734 comment_resources(sfile);
2735
2736 sect_idx = 0;
2738 if (!pres->ruledit_disabled) {
2739 char path[512];
2740 char identifier[2];
2741
2742 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2743
2745 "%s.extra", path);
2746
2748 if (pres->data.resource->output[o] != 0) {
2749 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2750 path, get_output_identifier(o));
2751 }
2753
2754 if (pres->data.resource->id_old_save != '\0') {
2755 identifier[0] = pres->data.resource->id_old_save;
2756 identifier[1] = '\0';
2757 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2758 }
2759 }
2761
2762 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2763 "extraui.ui_name_base_fortress");
2764 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2765 "extraui.ui_name_base_airbase");
2766
2767 comment_extras(sfile);
2768
2769 sect_idx = 0;
2771 char path[512];
2772 const char *flag_names[EF_COUNT];
2773 const char *cause_names[EC_COUNT];
2774 const char *puc_names[UCL_LAST];
2775 const char *extra_names[MAX_EXTRA_TYPES];
2776 int flagi;
2777 int causei;
2778 int set_count;
2779 bool worker_cause;
2780
2781 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2782
2783 save_name_translation(sfile, &(pextra->name), path);
2784
2785 secfile_insert_str(sfile, extra_category_name(pextra->category),
2786 "%s.category", path);
2787
2788 set_count = 0;
2789 for (causei = 0; causei < EC_COUNT; causei++) {
2790 if (is_extra_caused_by(pextra, causei)) {
2792 }
2793 }
2794
2795 if (set_count > 0) {
2797 "%s.causes", path);
2798 }
2799
2800 set_count = 0;
2801 for (causei = 0; causei < ERM_COUNT; causei++) {
2802 if (is_extra_removed_by(pextra, causei)) {
2804 }
2805 }
2806
2807 if (set_count > 0) {
2809 "%s.rmcauses", path);
2810 }
2811
2812 if (strcmp(pextra->graphic_str, "-")) {
2813 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2814 }
2815 if (strcmp(pextra->graphic_alt, "-")) {
2816 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2817 }
2818 if (strcmp(pextra->activity_gfx, "-")) {
2819 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2820 }
2821 if (strcmp(pextra->act_gfx_alt, "-")) {
2822 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2823 }
2824 if (strcmp(pextra->act_gfx_alt2, "-")) {
2825 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2826 }
2827 if (strcmp(pextra->rmact_gfx, "-")) {
2828 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2829 }
2830 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2831 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2832 }
2833
2834 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2835 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2836 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2837 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2838
2840 if ((!pextra->buildable && worker_cause)
2841 || (pextra->buildable && !worker_cause)) {
2842 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2843 }
2844 if (!pextra->generated) {
2845 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2846 }
2847 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2848 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2849 if (pextra->build_time_factor != 1) {
2850 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2851 }
2852 if (pextra->removal_time_factor != 1) {
2853 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2854 }
2855 if (pextra->infracost != 0) {
2856 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2857 }
2858 if (pextra->defense_bonus != 0) {
2859 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2860 }
2861 if (pextra->eus != EUS_NORMAL) {
2863 "%s.unit_seen", path);
2864 }
2866 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2867 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2868 }
2870 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2871 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2872 path);
2873 }
2874
2875 set_count = 0;
2877 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2879 }
2881
2882 if (set_count > 0) {
2884 "%s.native_to", path);
2885 }
2886
2887 if (pextra->no_aggr_near_city >= 0) {
2888 secfile_insert_int(sfile, pextra->no_aggr_near_city,
2889 "%s.no_aggr_near_city", path);
2890 }
2891
2892 set_count = 0;
2893 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2894 if (extra_has_flag(pextra, flagi)) {
2896 }
2897 }
2898
2899 if (set_count > 0) {
2901 "%s.flags", path);
2902 }
2903
2904 set_count = 0;
2906 if (!can_extras_coexist(pextra, confl)) {
2908 }
2910
2911 if (set_count > 0) {
2913 "%s.conflicts", path);
2914 }
2915
2916 set_count = 0;
2917 extra_type_iterate(top) {
2918 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2920 }
2922
2923 if (set_count > 0) {
2925 "%s.hidden_by", path);
2926 }
2927
2928 set_count = 0;
2929 extra_type_iterate(top) {
2930 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2932 }
2934
2935 if (set_count > 0) {
2937 "%s.bridged_over", path);
2938 }
2939
2940 save_strvec(sfile, pextra->helptext, path, "helptext");
2941
2943
2944 comment_bases(sfile);
2945
2946 sect_idx = 0;
2948 if (!pextra->ruledit_disabled) {
2949 char path[512];
2950 struct base_type *pbase = extra_base_get(pextra);
2951
2952 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2953
2954 secfile_insert_str(sfile, extra_rule_name(pextra),
2955 "%s.extra", path);
2956
2958 "%s.gui_type", path);
2959
2960 if (pbase->border_sq >= 0) {
2961 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
2962 }
2963 if (pbase->vision_main_sq >= 0) {
2964 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
2965 }
2966 if (pbase->vision_invis_sq >= 0) {
2967 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
2968 }
2969 if (pbase->vision_subs_sq >= 0) {
2970 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
2971 }
2972 }
2974
2975 comment_roads(sfile);
2976
2977 sect_idx = 0;
2979 if (!pextra->ruledit_disabled) {
2980 struct road_type *proad = extra_road_get(pextra);
2981 char path[512];
2982 const char *flag_names[RF_COUNT];
2983 int flagi;
2984 int set_count;
2985
2986 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
2987
2988 secfile_insert_str(sfile, extra_rule_name(pextra),
2989 "%s.extra", path);
2990
2991 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
2992
2993 if (proad->move_mode != RMM_FAST_ALWAYS) {
2994 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
2995 "%s.move_mode", path);
2996 }
2997
2999 if (proad->tile_incr_const[o] != 0) {
3000 secfile_insert_int(sfile, proad->tile_incr_const[o],
3001 "%s.%s_incr_const", path, get_output_identifier(o));
3002 }
3003 if (proad->tile_incr[o] != 0) {
3004 secfile_insert_int(sfile, proad->tile_incr[o],
3005 "%s.%s_incr", path, get_output_identifier(o));
3006 }
3007 if (proad->tile_bonus[o] != 0) {
3008 secfile_insert_int(sfile, proad->tile_bonus[o],
3009 "%s.%s_bonus", path, get_output_identifier(o));
3010 }
3012
3013 switch (proad->compat) {
3014 case ROCO_ROAD:
3015 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
3016 break;
3017 case ROCO_RAILROAD:
3018 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
3019 break;
3020 case ROCO_RIVER:
3021 secfile_insert_str(sfile, "River", "%s.compat_special", path);
3022 break;
3023 case ROCO_NONE:
3024 secfile_insert_str(sfile, "None", "%s.compat_special", path);
3025 break;
3026 }
3027
3029 "%s.gui_type", path);
3030
3031 set_count = 0;
3032 for (flagi = 0; flagi < RF_COUNT; flagi++) {
3033 if (road_has_flag(proad, flagi)) {
3035 }
3036 }
3037
3038 if (set_count > 0) {
3040 "%s.flags", path);
3041 }
3042 }
3044
3045 return save_ruleset_file(sfile, filename);
3046}
3047
3048/**********************************************************************/
3051static bool save_veteran_system(struct section_file *sfile, const char *path,
3052 struct veteran_system *vsystem)
3053{
3054 const char *vlist_name[vsystem->levels];
3055 int vlist_power[vsystem->levels];
3056 int vlist_raise[vsystem->levels];
3057 int vlist_wraise[vsystem->levels];
3058 int vlist_move[vsystem->levels];
3059 int i;
3060
3061 for (i = 0; i < vsystem->levels; i++) {
3062 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
3063 vlist_power[i] = vsystem->definitions[i].power_fact;
3064 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
3065 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
3066 vlist_move[i] = vsystem->definitions[i].move_bonus;
3067 }
3068
3070 "%s.veteran_names", path);
3072 "%s.veteran_power_fact", path);
3074 "%s.veteran_base_raise_chance", path);
3076 "%s.veteran_work_raise_chance", path);
3078 "%s.veteran_move_bonus", path);
3079
3080 return TRUE;
3081}
3082
3083/**********************************************************************/
3086static bool save_combat_bonuses(struct section_file *sfile,
3087 struct unit_type *put,
3088 char *path)
3089{
3090 int i;
3091 bool has_quiet = FALSE;
3092
3094 if (pbonus->quiet) {
3095 has_quiet = TRUE;
3096 }
3098
3099 i = 0;
3100
3103 "%s.bonuses%d.flag", path, i);
3105 "%s.bonuses%d.type", path, i);
3106 secfile_insert_int(sfile, pbonus->value,
3107 "%s.bonuses%d.value", path, i);
3108
3109 if (has_quiet) {
3110 secfile_insert_bool(sfile, pbonus->quiet,
3111 "%s.bonuses%d.quiet", path, i);
3112 }
3113
3114 i++;
3116
3117 return TRUE;
3118}
3119
3120/**********************************************************************/
3123static bool save_units_ruleset(const char *filename, const char *name)
3124{
3125 struct section_file *sfile = create_ruleset_file(name, "unit");
3126 int i;
3127 int sect_idx;
3128 bool uflags_utype = FALSE;
3129 bool uflags_uclass = FALSE;
3130
3131 if (sfile == nullptr) {
3132 return FALSE;
3133 }
3134
3135 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
3137 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
3138
3139 if (flagname != nullptr) {
3140 if (!uflags_utype) {
3141 comment_uflags_utype(sfile);
3143 }
3144
3145 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
3146
3147 /* Save the user flag help text even when it is undefined. That makes
3148 * the formatting code happy. The resulting "" is ignored when the
3149 * ruleset is loaded. */
3150 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
3151 }
3152 }
3153
3154 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
3156 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
3157
3158 if (flagname != nullptr) {
3159 if (!uflags_uclass) {
3160 /* TODO: Uncomment this, once there's a way to stop
3161 * the comment getting written inside preceding
3162 * utype flags table. */
3163 /* comment_uflags_uclass(sfile); */
3165 }
3166
3167 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
3168
3169 /* Save the user flag help text even when it is undefined. That makes
3170 * the formatting code happy. The resulting "" is ignored when the
3171 * ruleset is loaded. */
3172 secfile_insert_str(sfile, helptxt,
3173 "control.class_flags%d.helptxt", i);
3174 }
3175 }
3176
3177 save_veteran_system(sfile, "veteran_system", game.veteran);
3178
3179 comment_uclasses(sfile);
3180
3181 sect_idx = 0;
3183 char path[512];
3184 const char *flag_names[UCF_COUNT];
3185 int flagi;
3186 int set_count;
3187
3188 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
3189
3190 save_name_translation(sfile, &(puc->name), path);
3191
3192 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
3193 "%s.min_speed", path);
3194 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
3195 if (puc->non_native_def_pct != 100) {
3196 secfile_insert_int(sfile, puc->non_native_def_pct,
3197 "%s.non_native_def_pct", path);
3198 }
3199
3200 set_count = 0;
3201 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
3202 if (uclass_has_flag(puc, flagi)) {
3204 }
3205 }
3206
3207 if (set_count > 0) {
3209 "%s.flags", path);
3210 }
3211
3212 save_strvec(sfile, puc->helptext, path, "helptext");
3213
3215
3216 comment_utypes(sfile);
3217
3218 sect_idx = 0;
3220 if (!put->ruledit_disabled) {
3221 char path[512];
3222 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
3223 int flagi;
3224 int set_count;
3225
3226 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
3227
3228 save_name_translation(sfile, &(put->name), path);
3229
3230 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
3231 "%s.class", path);
3232
3233 save_reqs_vector(sfile, &(put->build_reqs), path, "reqs");
3234
3235 if (put->obsoleted_by != nullptr) {
3236 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
3237 "%s.obsolete_by", path);
3238 }
3239
3240 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
3241 if (strcmp("-", put->graphic_alt)) {
3242 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
3243 }
3244 if (strcmp("-", put->graphic_alt2)) {
3245 secfile_insert_str(sfile, put->graphic_alt2, "%s.graphic_alt2", path);
3246 }
3247 if (strcmp("-", put->sound_move)) {
3248 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
3249 }
3250 if (strcmp("-", put->sound_move_alt)) {
3251 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
3252 }
3253 if (strcmp("-", put->sound_fight)) {
3254 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
3255 }
3256 if (strcmp("-", put->sound_fight_alt)) {
3257 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
3258 }
3259
3260 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
3261 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
3262 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
3263 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
3264 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
3265 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3266 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3267
3268 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3269 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3270 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3271
3272 if (put->vlayer != V_MAIN) {
3274 "%s.vision_layer", path);
3275 }
3276
3277 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3278 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3279 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3280 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3281
3283 if (put->upkeep[o] != 0) {
3284 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3285 path, get_output_identifier(o));
3286 }
3288
3289 if (put->converted_to != nullptr) {
3290 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3291 "%s.convert_to", path);
3292 }
3293 if (put->convert_time != 1) {
3294 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3295 }
3296
3297 save_combat_bonuses(sfile, put, path);
3298 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3299
3300 if (put->veteran != nullptr) {
3301 save_veteran_system(sfile, path, put->veteran);
3302 }
3303
3304 if (put->paratroopers_range != 0) {
3305 secfile_insert_int(sfile, put->paratroopers_range,
3306 "%s.paratroopers_range", path);
3307 }
3308 if (put->bombard_rate != 0) {
3309 secfile_insert_int(sfile, put->bombard_rate,
3310 "%s.bombard_rate", path);
3311 }
3312 if (put->city_slots != 0) {
3313 secfile_insert_int(sfile, put->city_slots,
3314 "%s.city_slots", path);
3315 }
3316 if (put->city_size != 1) {
3317 secfile_insert_int(sfile, put->city_size,
3318 "%s.city_size", path);
3319 }
3320
3321 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3322 "%s.tp_defense", path);
3323
3324 set_count = 0;
3325 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3326 if (utype_has_flag(put, flagi)) {
3328 }
3329 }
3330
3331 if (set_count > 0) {
3333 "%s.flags", path);
3334 }
3335
3336 set_count = 0;
3337 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3338 if (utype_has_role(put, flagi)) {
3340 }
3341 }
3342
3343 if (set_count > 0) {
3345 "%s.roles", path);
3346 }
3347
3348 save_strvec(sfile, put->helptext, path, "helptext");
3349 }
3351
3352 return save_ruleset_file(sfile, filename);
3353}
3354
3355/**********************************************************************/
3358static bool save_script_lua(const char *filename, const char *name,
3359 const char *buffer)
3360{
3361 if (buffer != nullptr) {
3362 FILE *ffile = fc_fopen(filename, "w");
3363 int full_len = strlen(buffer);
3364 int len;
3365
3366 if (ffile != nullptr) {
3367 len = fwrite(buffer, 1, full_len, ffile);
3368
3369 if (len != full_len) {
3370 return FALSE;
3371 }
3372
3373 fclose(ffile);
3374 } else {
3375 return FALSE;
3376 }
3377 }
3378
3379 return TRUE;
3380}
3381
3382/**********************************************************************/
3385static bool save_luadata(const char *filename)
3386{
3387 if (game.server.luadata != nullptr) {
3388 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3389 }
3390
3391 return TRUE;
3392}
3393
3394/**********************************************************************/
3397bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3398{
3399 if (make_dir(path, DIRMODE_DEFAULT)) {
3400 bool success = TRUE;
3401 char filename[500];
3402
3403 if (success) {
3404 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3405 success = save_buildings_ruleset(filename, name);
3406 }
3407
3408 if (success) {
3409 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3410 success = save_styles_ruleset(filename, name);
3411 }
3412
3413 if (success) {
3414 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3415 success = save_cities_ruleset(filename, name);
3416 }
3417
3418 if (success) {
3419 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3420 success = save_effects_ruleset(filename, name);
3421 }
3422
3423 if (success) {
3424 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3425 success = save_game_ruleset(filename, name);
3426 }
3427
3428 if (success) {
3429 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3431 }
3432
3433 if (success) {
3434 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3435 success = save_nations_ruleset(filename, name, data);
3436 }
3437
3438 if (success) {
3439 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3440 success = save_techs_ruleset(filename, name);
3441 }
3442
3443 if (success) {
3444 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3445 success = save_terrain_ruleset(filename, name);
3446 }
3447
3448 if (success) {
3449 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3450 success = save_units_ruleset(filename, name);
3451 }
3452
3453 if (success) {
3454 fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path);
3455 success = save_actions_ruleset(filename, name);
3456 }
3457
3458 if (success) {
3459 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3461 }
3462
3463 if (success) {
3464 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3466 }
3467
3468 if (success) {
3469 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3470 success = save_luadata(filename);
3471 }
3472
3473 return success;
3474 } else {
3475 log_error(_("Failed to create directory %s"), path);
3476 return FALSE;
3477 }
3478
3479 return TRUE;
3480}
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:6469
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:7179
void action_array_end(action_id *act_array, int size)
Definition actions.c:5770
bool action_is_in_use(struct action *paction)
Definition actions.c:5676
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:7373
const char * action_rule_name(const struct action *action)
Definition actions.c:1216
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:7006
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:6647
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:6834
const char * action_ui_name_default(int act)
Definition actions.c:6105
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:5738
bool action_id_is_internal(action_id act)
Definition actions.c:5714
#define action_enablers_iterate_end
Definition actions.h:279
#define enabler_get_action(_enabler_)
Definition actions.h:182
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:371
#define ACTION_AUTO_POST_BRIBE_UNIT
Definition actions.h:372
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:369
static struct action * action_by_number(action_id act_id)
Definition actions.h:396
#define NUM_ACTIONS
Definition actions.h:59
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:378
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:377
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:101
#define ACTION_AUTO_POST_WIPE_UNITS
Definition actions.h:379
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:370
#define action_iterate_end
Definition actions.h:214
#define MAX_NUM_ACTIONS
Definition actions.h:58
#define ACTION_AUTO_POST_BRIBE_STACK
Definition actions.h:373
#define action_enablers_iterate(_enabler_)
Definition actions.h:273
#define action_iterate(_act_)
Definition actions.h:210
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:368
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:374
#define ACTION_NONE
Definition actions.h:55
int actres_min_range_default(enum action_result result)
Definition actres.c:376
int actres_max_range_default(enum action_result result)
Definition actres.c:466
void astr_free(struct astring *astr)
Definition astring.c:148
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
const char * get_output_identifier(Output_type_id output)
Definition city.c:619
static const struct city struct citystyle * city_styles
Definition city.c:84
#define output_type_iterate(output)
Definition city.h:842
#define output_type_iterate_end
Definition city.h:848
void comment_borders_radius_permanent(struct section_file *sfile)
Definition comments.c:815
char * uflags_building
Definition comments.c:53
void comment_uflags_utype(struct section_file *sfile)
Definition comments.c:472
void comment_world_peace_turns(struct section_file *sfile)
Definition comments.c:896
void comment_combat_rules_nuke_defender_survival(struct section_file *sfile)
Definition comments.c:779
void comment_roads(struct section_file *sfile)
Definition comments.c:408
void comment_civstyle_granary(struct section_file *sfile)
Definition comments.c:609
void comment_research_tech_leakage(struct section_file *sfile)
Definition comments.c:851
void comment_uclasses(struct section_file *sfile)
Definition comments.c:360
void comment_calendar_fragments(struct section_file *sfile)
Definition comments.c:905
void comment_actions_quiet_actions(struct section_file *sfile)
Definition comments.c:806
void comment_uflags_terrain(struct section_file *sfile)
Definition comments.c:488
void comment_combat_rules_low_fp_pearl_harbor(struct section_file *sfile)
Definition comments.c:740
void comment_citystyles(struct section_file *sfile)
Definition comments.c:424
void comment_std_tileset_compat(struct section_file *sfile)
Definition comments.c:915
void comment_govs(struct section_file *sfile)
Definition comments.c:344
void comment_research_base_tech_cost(struct section_file *sfile)
Definition comments.c:833
void comment_research_tech_cost_style(struct section_file *sfile)
Definition comments.c:824
void comment_combat_rules_only_killing_veteran(struct section_file *sfile)
Definition comments.c:690
void comment_bases(struct section_file *sfile)
Definition comments.c:400
void comment_terrains(struct section_file *sfile)
Definition comments.c:376
void comment_uflags_tech(struct section_file *sfile)
Definition comments.c:504
void comment_file_header(struct section_file *sfile)
Definition comments.c:312
void comment_effects(struct section_file *sfile)
Definition comments.c:440
void comment_actions_dc_initial_odds(struct section_file *sfile)
Definition comments.c:797
void comment_combat_rules_scaled_veterancy(struct section_file *sfile)
Definition comments.c:710
void comment_research_upkeep_style(struct section_file *sfile)
Definition comments.c:860
void comment_disasters(struct section_file *sfile)
Definition comments.c:456
void comment_clauses(struct section_file *sfile)
Definition comments.c:584
void comment_goods(struct section_file *sfile)
Definition comments.c:528
char * uflags_tech
Definition comments.c:52
void comment_civstyle_gameloss_style(struct section_file *sfile)
Definition comments.c:627
char * uflags_extra
Definition comments.c:51
void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
Definition comments.c:636
void comment_extras(struct section_file *sfile)
Definition comments.c:392
void comment_combat_rules_low_fp_nonnat_bombard(struct section_file *sfile)
Definition comments.c:760
void comment_ueffs(struct section_file *sfile)
Definition comments.c:448
void comment_techs(struct section_file *sfile)
Definition comments.c:336
void comment_nations(struct section_file *sfile)
Definition comments.c:560
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:520
void comment_combat_rules_low_fp_combat_bonus(struct section_file *sfile)
Definition comments.c:750
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:601
void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile)
Definition comments.c:645
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:568
void comment_specialists(struct section_file *sfile)
Definition comments.c:552
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:432
void comment_civstyle_airlift_always(struct section_file *sfile)
Definition comments.c:654
void comment_resources(struct section_file *sfile)
Definition comments.c:384
void comment_civstyle_ransom_gold(struct section_file *sfile)
Definition comments.c:618
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:328
void comment_culture_migration_pml(struct section_file *sfile)
Definition comments.c:887
void comment_combat_rules_only_real_fight_veteran(struct section_file *sfile)
Definition comments.c:700
char * uflags_uclass
Definition comments.c:49
void comment_research_free_tech_method(struct section_file *sfile)
Definition comments.c:869
void comment_combat_rules_nuke_pop_loss(struct section_file *sfile)
Definition comments.c:770
void comment_utypes(struct section_file *sfile)
Definition comments.c:368
char * uflags_utype
Definition comments.c:48
void comment_research_min_tech_cost(struct section_file *sfile)
Definition comments.c:842
void comment_culture_history_interest(struct section_file *sfile)
Definition comments.c:878
void comment_policies(struct section_file *sfile)
Definition comments.c:352
void comment_combat_rules_low_fp_badwallattacker(struct section_file *sfile)
Definition comments.c:730
void comment_achievements(struct section_file *sfile)
Definition comments.c:464
void comment_combat_rules_damage_reduces_bombard_rate(struct section_file *sfile)
Definition comments.c:720
void comment_actions(struct section_file *sfile)
Definition comments.c:536
void comment_counters(struct section_file *sfile)
Definition comments.c:592
void comment_styles(struct section_file *sfile)
Definition comments.c:416
void comment_combat_rules_tired_attack(struct section_file *sfile)
Definition comments.c:681
void comment_uflags_building(struct section_file *sfile)
Definition comments.c:512
void comment_buildings(struct section_file *sfile)
Definition comments.c:320
void comment_enablers(struct section_file *sfile)
Definition comments.c:544
void comment_nationsets(struct section_file *sfile)
Definition comments.c:576
void comment_wonder_visibility_small_wonders(struct section_file *sfile)
Definition comments.c:663
void comment_incite_cost(struct section_file *sfile)
Definition comments.c:672
void comment_auto_attack(struct section_file *sfile)
Definition comments.c:789
char * incite_cost
Definition comments.c:76
#define counters_re_iterate_end
Definition counters.h:75
#define counters_re_iterate(pcount)
Definition counters.h:67
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:292
#define disaster_type_iterate(_p)
Definition disaster.h:82
#define disaster_type_iterate_end
Definition disaster.h:88
struct @22::@23 reqs
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1321
enum effect_type user_effect_ai_valued_as(enum effect_type real)
Definition effects.c:1357
#define EFT_USER_EFFECT_LAST
Definition effects.h:33
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:988
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1046
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:875
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:976
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:1017
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:203
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_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:510
@ ROCO_RAILROAD
Definition fc_types.h:961
@ ROCO_NONE
Definition fc_types.h:961
@ ROCO_RIVER
Definition fc_types.h:961
@ ROCO_ROAD
Definition fc_types.h:961
#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:248
#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:274
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:874
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:866
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:863
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:849
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:822
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:780
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:776
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:814
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:898
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:870
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:884
#define RS_DEFAULT_HAPPY_COST
Definition game.h:854
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:888
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:828
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:778
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:507
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:889
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:880
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:796
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:841
#define GAME_DEFAULT_START_YEAR
Definition game.h:748
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:802
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:878
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:774
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:845
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:806
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:862
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:890
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:788
#define RS_DEFAULT_FOOD_COST
Definition game.h:858
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:818
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:810
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:398
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:832
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:792
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:784
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:798
const char * 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:38
#define fc_assert(condition)
Definition log.h:177
#define log_error(message,...)
Definition log.h:104
struct terrain_misc terrain_control
Definition map.c:68
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
#define SINGLE_MOVE
Definition movement.h:26
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
#define multipliers_iterate_end
Definition multipliers.h:67
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * untranslated_name(const struct name_translation *ptrans)
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c: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)
bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
bool secfile_save(const struct section_file *secfile, const char *filename, int compression_level, enum fz_method compression_method)
struct section * secfile_insert_include(struct section_file *secfile, const char *filename)
struct entry * secfile_insert_filereference(struct section_file *secfile, const char *filename, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_enum_vec(secfile, enumerators, dim, specenum_type, path,...)
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
#define secfile_insert_int_vec(secfile, values, dim, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_insert_enum_vec_comment(secfile, enumerators, dim, specenum_type, comment, path,...)
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
const char * universal_rule_name(const struct universal *psource)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
Definition rgbcolor.c:121
#define rgbcolor_list_iterate_end
Definition rgbcolor.h:45
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)
Definition rgbcolor.h:43
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:416
char * get_parser_buffer(void)
Definition ruleload.c:564
char * get_script_buffer(void)
Definition ruleload.c:556
#define RS_DEFAULT_CONVERT_SPEED
Definition ruleload.h:123
#define RS_DEFAULT_UBUILD_NAT
Definition ruleload.h:122
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleload.h:109
#define RS_DEFAULT_WORLD_PEACE_TURNS
Definition ruleload.h:99
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleload.h:84
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleload.h:103
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleload.h:85
#define GAME_DEFAULT_ACH_VALUE
Definition ruleload.h:78
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleload.h:83
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleload.h:94
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleload.h:96
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleload.h:111
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleload.h:106
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleload.h:86
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleload.h:97
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleload.h:101
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleload.h:87
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleload.h:82
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleload.h:77
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleload.h:108
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleload.h:79
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleload.h:80
#define RS_DEFAULT_BASE_TECH_COST
Definition ruleload.h:113
#define RULESET_CAPABILITIES
Definition ruleload.h:24
#define RS_DEFAULT_NATIONALITY
Definition ruleload.h:121
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleload.h:74
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleload.h:81
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleload.h:89
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleload.h:73
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleload.h:107
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleload.h:104
#define RS_DEFAULT_MIN_TECH_COST
Definition ruleload.h:117
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleload.h:75
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleload.h:95
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleload.h:76
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:150
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:210
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:127
static bool save_terrain_ref(struct section_file *sfile, const struct terrain *save, const struct terrain *pthis, const char *path, const char *entry)
Definition rulesave.c:250
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:307
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:2230
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:918
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:942
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:872
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:1996
#define FORMAT_VERSION
Definition rulesave.c:56
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3397
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:671
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2355
static bool save_uclass_vec(struct section_file *sfile, bv_unit_classes *bits, const char *path, const char *entry, bool unreachable_only)
Definition rulesave.c:330
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:1020
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:379
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:3051
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1049
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:106
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:798
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1259
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:387
static bool save_action_auto_uflag_block(struct section_file *sfile, const int aap, const char *uflags_path, bool(*unexpected_req)(const struct requirement *preq))
Definition rulesave.c:547
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:641
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:283
static bool save_luadata(const char *filename)
Definition rulesave.c:3385
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1907
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:967
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:357
static bool save_actions_ruleset(const char *filename, const char *name)
Definition rulesave.c:1082
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:3123
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2461
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:651
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:892
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:270
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:483
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:61
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:3086
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:828
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:86
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:2042
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3358
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:598
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:233
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4648
int setting_int_get(struct setting *pset)
Definition settings.c:3788
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3362
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3870
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5612
const char * setting_name(const struct setting *pset)
Definition settings.c:3333
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4257
char * setting_str_get(struct setting *pset)
Definition settings.c:3859
bool setting_bool_get(struct setting *pset)
Definition settings.c:3676
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4065
int read_enum_value(const struct setting *pset)
Definition settings.c:3995
#define settings_iterate(_level, _pset)
Definition settings.h:188
#define settings_iterate_end
Definition settings.h:194
const char * sex_rule_name(sex_t kind)
Definition sex.c:43
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
bool make_dir(const char *pathname, int mode)
Definition shared.c:1779
#define DIRMODE_DEFAULT
Definition shared.h:258
#define MAX(x, y)
Definition shared.h:54
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c: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:140
int max_distance
Definition actions.h:123
bool quiet
Definition actions.h:130
char ui_name[MAX_LEN_NAME]
Definition actions.h:126
enum action_target_kind target_kind
Definition actions.h:114
int named_teams
Definition game.h:301
size_t as_count
Definition game.h:300
struct civ_game::@32::@36::@42 ruledit
struct rgbcolor_list * plr_colors
Definition game.h:252
const char ** allowed_govs
Definition game.h:292
int upgrade_veteran_loss
Definition game.h:206
struct rgbcolor * plr_bg_color
Definition game.h:103
int incite_total_factor
Definition game.h:157
int init_vis_radius_sq
Definition game.h:159
bool vision_reveal_tiles
Definition game.h:207
char * description_file
Definition game.h:288
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int base_incite_cost
Definition game.h:141
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
int autoupgrade_veteran_loss
Definition game.h:139
int start_year
Definition game.h:198
int incite_improvement_factor
Definition game.h:156
struct section_file * luadata
Definition game.h:254
char ** embedded_nations
Definition game.h:290
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:111
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:281
const char ** allowed_terrains
Definition game.h:295
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:294
const char ** allowed_styles
Definition game.h:298
bool std_tileset_compat
Definition game.h:302
struct civ_game::@31 rgame
size_t embedded_nations_count
Definition game.h:291
int incite_unit_factor
Definition game.h:158
char * ruleset_capabilities
Definition game.h:86
int ransom_gold
Definition game.h:182
struct civ_game::@32::@36 server
size_t at_count
Definition game.h:297
struct veteran_system * veteran
Definition game.h:101
struct packet_calendar_info calendar
Definition game.h:90
struct government * default_government
Definition game.h:93
struct government * government_during_revolution
Definition game.h:94
struct civ_map::@44::@46 server
bool ocean_resources
Definition map_types.h:119
struct requirement_vector receiver_reqs
Definition diptreaty.h:61
struct requirement_vector giver_reqs
Definition diptreaty.h:60
enum clause_type type
Definition diptreaty.h:58
struct requirement_vector either_reqs
Definition diptreaty.h:62
bool enabled
Definition diptreaty.h:59
struct section_file * sfile
Definition rulesave.c:792
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
int low_firepower_pearl_harbor
bool damage_reduces_bombard_rate
int nuke_defender_survival_chance_pct
enum tech_upkeep_style tech_upkeep_style
bool tech_trade_loss_allow_holes
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
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 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:608
struct civ_map map
const char * style_rule_name(const struct nation_style *pstyle)
Definition style.c:108
#define music_styles_iterate(_p)
Definition style.h:72
#define music_styles_iterate_end
Definition style.h:79
#define styles_re_active_iterate_end
Definition style.h:60
#define styles_re_active_iterate(_p)
Definition style.h:56
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:505
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * tech_flag_id_name_cb(enum tech_flag_id flag)
Definition tech.c:433
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:352
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Definition tech.c:216
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:309
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:445
#define advance_re_active_iterate(_p)
Definition tech.h:277
#define A_NEVER
Definition tech.h:51
#define tech_class_iterate_end
Definition tech.h:199
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:103
@ AR_TWO
Definition tech.h:107
@ AR_ROOT
Definition tech.h:108
@ AR_ONE
Definition tech.h:106
#define advance_re_active_iterate_end
Definition tech.h:281
#define A_NONE
Definition tech.h:43
#define tech_class_iterate(_p)
Definition tech.h:193
#define A_LAST
Definition tech.h:45
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:817
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:829
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define terrain_type_iterate_end
Definition terrain.h:272
#define MAX_NUM_TERRAINS
Definition terrain.h:69
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:32
#define terrain_resources_iterate_end
Definition terrain.h:294
#define terrain_resources_iterate(pterrain, _res, _freq)
Definition terrain.h:285
#define RESOURCE_FREQUENCY_DEFAULT
Definition terrain.h:101
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
const char * trade_route_type_name(enum trade_route_type type)
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
const char * trade_route_cancelling_type_name(enum trade_route_illegal_cancelling type)
#define goods_type_re_active_iterate_end
#define goods_type_re_active_iterate(_p)
trade_route_type
Definition traderoutes.h:37
@ TRT_LAST
Definition traderoutes.h:48
#define TRAIT_DEFAULT_VALUE
Definition traits.h:32
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Definition unittype.c:1860
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:205
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1584
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1647
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Definition unittype.c:1848
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Definition unittype.c:1911
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1923
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773
#define unit_type_re_active_iterate(_p)
Definition unittype.h:874
#define combat_bonus_list_iterate_end
Definition unittype.h:489
#define L_FIRST
Definition unittype.h:356
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:487
#define unit_class_iterate(_p)
Definition unittype.h:915
#define unit_class_re_active_iterate_end
Definition unittype.h:931
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:338
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define UTYF_LAST_USER_FLAG
Definition unittype.h:337
#define L_LAST
Definition unittype.h:446
#define unit_class_re_active_iterate(_p)
Definition unittype.h:927
#define uclass_index(_c_)
Definition unittype.h:749
#define unit_class_iterate_end
Definition unittype.h:922
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:128
#define unit_type_re_active_iterate_end
Definition unittype.h:878
const char * freeciv_datafile_version(void)
Definition version.c:186