Freeciv-3.1
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 "registry.h"
20#include "string_vector.h"
21
22/* common */
23#include "achievements.h"
24#include "game.h"
25#include "government.h"
26#include "map.h"
27#include "movement.h"
28#include "multipliers.h"
29#include "specialist.h"
30#include "style.h"
31#include "unittype.h"
32#include "version.h"
33
34/* server */
35#include "ruleset.h"
36#include "settings.h"
37
38/* tools/ruleutil */
39#include "comments.h"
40
41#include "rulesave.h"
42
43/* Ruleset format version */
44/*
45 * 1 - Freeciv-2.6
46 * 10 - Freeciv-3.0
47 * 20 - Freeciv-3.1
48 */
49#define FORMAT_VERSION RSFORMAT_3_1
50
51/**********************************************************************/
54static struct section_file *create_ruleset_file(const char *rsname,
55 const char *rstype)
56{
57 struct section_file *sfile = secfile_new(TRUE);
58 char buf[500];
59
61
62 if (rsname != NULL && rsname[0] != '\0') {
63 fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);
64 } else {
65 fc_snprintf(buf, sizeof(buf), "Template %s data for Freeciv", rstype);
66 }
67
68 secfile_insert_str(sfile, buf, "datafile.description");
69 secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
70 secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
71 secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");
72
73 return sfile;
74}
75
76/**********************************************************************/
79static bool save_default_int(struct section_file *sfile, int value,
80 int default_value, const char *path, const char *entry)
81{
82 if (value != default_value) {
83 if (entry != NULL) {
84 secfile_insert_int(sfile, value,
85 "%s.%s", path, entry);
86 } else {
87 secfile_insert_int(sfile, value,
88 "%s", path);
89 }
90 }
91
92 return TRUE;
93}
94
95/**********************************************************************/
98static bool save_default_bool(struct section_file *sfile, bool value,
99 bool default_value, const char *path, const char *entry)
100{
101 if ((value && !default_value)
102 || (!value && default_value)) {
103 if (entry != NULL) {
104 secfile_insert_bool(sfile, value,
105 "%s.%s", path, entry);
106 } else {
107 secfile_insert_bool(sfile, value,
108 "%s", path);
109 }
110 }
111
112 return TRUE;
113}
114
115/**********************************************************************/
118static bool save_name_translation(struct section_file *sfile,
119 struct name_translation *name,
120 const char *path)
121{
122 struct entry *mod_entry;
123
124 mod_entry = secfile_insert_str(sfile,
126 "%s.name", path);
127 entry_str_set_gt_marking(mod_entry, TRUE);
130 secfile_insert_str(sfile,
132 "%s.rule_name", path);
133 }
134
135 return TRUE;
136}
137
138/**********************************************************************/
141static bool save_reqs_vector(struct section_file *sfile,
142 const struct requirement_vector *reqs,
143 const char *path, const char *entry)
144{
145 int i;
146 bool includes_negated = FALSE;
147 bool includes_surviving = FALSE;
148 bool includes_quiet = FALSE;
149
151 if (!preq->present) {
152 includes_negated = TRUE;
153 }
154 if (preq->survives) {
155 includes_surviving = TRUE;
156 }
157 if (preq->quiet) {
158 includes_quiet = TRUE;
159 }
161
162 i = 0;
164 secfile_insert_str(sfile,
165 universals_n_name(preq->source.kind),
166 "%s.%s%d.type", path, entry, i);
167 secfile_insert_str(sfile,
168 universal_rule_name(&(preq->source)),
169 "%s.%s%d.name", path, entry, i);
170 secfile_insert_str(sfile,
171 req_range_name(preq->range),
172 "%s.%s%d.range", path, entry, i);
173
174 if (includes_surviving) {
176 preq->survives,
177 "%s.%s%d.survives", path, entry, i);
178 }
179
180 if (includes_negated) {
182 preq->present,
183 "%s.%s%d.present", path, entry, i);
184 }
185
186 if (includes_quiet) {
188 preq->quiet,
189 "%s.%s%d.quiet", path, entry, i);
190 }
191
192 i++;
194
195 return TRUE;
196}
197
198/**********************************************************************/
201static bool save_tech_list(struct section_file *sfile, int *input,
202 const char *path, const char *entry)
203{
204 const char *tech_names[MAX_NUM_TECH_LIST];
205 int set_count;
206 int i;
207
208 set_count = 0;
209 for (i = 0; input[i] != A_LAST && i < MAX_NUM_TECH_LIST; i++) {
210 tech_names[set_count++] = advance_rule_name(advance_by_number(input[i]));
211 }
212
213 if (set_count > 0) {
214 secfile_insert_str_vec(sfile, tech_names, set_count,
215 "%s.%s", path, entry);
216 }
217
218 return TRUE;
219}
220
221/**********************************************************************/
224static bool save_tech_ref(struct section_file *sfile,
225 const struct advance *padv,
226 const char *path, const char *entry)
227{
228 if (padv == A_NEVER) {
229 secfile_insert_str(sfile, "Never", "%s.%s", path, entry);
230 } else {
232 "%s.%s", path, entry);
233 }
234
235 return TRUE;
236}
237
238/**********************************************************************/
241static bool save_terrain_ref(struct section_file *sfile,
242 const struct terrain *save,
243 const struct terrain *pthis,
244 const char *path, const char *entry)
245{
246 if (save == NULL) {
247 secfile_insert_str(sfile, "none", "%s.%s", path, entry);
248 } else if (save == pthis) {
249 secfile_insert_str(sfile, "yes", "%s.%s", path, entry);
250 } else {
252 "%s.%s", path, entry);
253 }
254
255 return TRUE;
256}
257
258/**********************************************************************/
261static bool save_gov_ref(struct section_file *sfile,
262 const struct government *gov,
263 const char *path, const char *entry)
264{
265 secfile_insert_str(sfile, government_rule_name(gov), "%s.%s", path, entry);
266
267 return TRUE;
268}
269
270/**********************************************************************/
274static bool save_building_list(struct section_file *sfile, int *input,
275 const char *path, const char *entry)
276{
277 const char *building_names[MAX_NUM_BUILDING_LIST];
278 int set_count;
279 int i;
280
281 set_count = 0;
282 for (i = 0; input[i] != B_LAST && i < MAX_NUM_BUILDING_LIST; i++) {
283 building_names[set_count++] = improvement_rule_name(improvement_by_number(input[i]));
284 }
285
286 if (set_count > 0) {
287 secfile_insert_str_vec(sfile, building_names, set_count,
288 "%s.%s", path, entry);
289 }
290
291 return TRUE;
292}
293
294/**********************************************************************/
298static bool save_unit_list(struct section_file *sfile, struct unit_type **input,
299 const char *path, const char *entry)
300{
301 const char *unit_names[MAX_NUM_UNIT_LIST];
302 int set_count;
303 int i;
304
305 set_count = 0;
306 for (i = 0; input[i] != NULL && i < MAX_NUM_UNIT_LIST; i++) {
307 unit_names[set_count++] = utype_rule_name(input[i]);
308 }
309
310 if (set_count > 0) {
311 secfile_insert_str_vec(sfile, unit_names, set_count,
312 "%s.%s", path, entry);
313 }
314
315 return TRUE;
316}
317
318/**********************************************************************/
321static bool save_uclass_vec(struct section_file *sfile,
322 bv_unit_classes *bits,
323 const char *path, const char *entry,
324 bool unreachable_only)
325{
326 const char *class_names[UCL_LAST];
327 int classes = 0;
328
329 unit_class_iterate(pcargo) {
330 if (BV_ISSET(*(bits), uclass_index(pcargo))
331 && (uclass_has_flag(pcargo, UCF_UNREACHABLE)
332 || !unreachable_only)) {
333 class_names[classes++] = uclass_rule_name(pcargo);
334 }
336
337 if (classes > 0) {
338 secfile_insert_str_vec(sfile, class_names, classes,
339 "%s.%s", path, entry);
340 }
341
342 return TRUE;
343}
344
345/**********************************************************************/
348static bool save_strvec(struct section_file *sfile,
349 struct strvec *to_save,
350 const char *path, const char *entry)
351{
352 if (to_save != NULL) {
353 int sect_count = strvec_size(to_save);
354 const char *sections[sect_count];
355 int i;
356
357 for (i = 0; i < sect_count; i++) {
358 sections[i] = strvec_get(to_save, i);
359 }
360
361 secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
362 }
363
364 return TRUE;
365}
366
367/**********************************************************************/
370static bool save_ruleset_file(struct section_file *sfile, const char *filename)
371{
372 return secfile_save(sfile, filename, 0, FZ_PLAIN);
373}
374
375/**********************************************************************/
378static bool save_buildings_ruleset(const char *filename, const char *name)
379{
380 struct section_file *sfile = create_ruleset_file(name, "building");
381 int sect_idx;
382
383 if (sfile == NULL) {
384 return FALSE;
385 }
386
387 comment_buildings(sfile);
388
389 sect_idx = 0;
391 if (!pb->ruledit_disabled) {
392 char path[512];
393 const char *flag_names[IF_COUNT];
394 int set_count;
395 int flagi;
396
397 fc_snprintf(path, sizeof(path), "building_%d", sect_idx++);
398
399 save_name_translation(sfile, &(pb->name), path);
400
401 secfile_insert_str(sfile, impr_genus_id_name(pb->genus),
402 "%s.genus", path);
403
404 if (strcmp(pb->graphic_str, "-")) {
405 secfile_insert_str(sfile, pb->graphic_str, "%s.graphic", path);
406 }
407 if (strcmp(pb->graphic_alt, "-")) {
408 secfile_insert_str(sfile, pb->graphic_alt, "%s.graphic_alt", path);
409 }
410 if (strcmp(pb->soundtag, "-")) {
411 secfile_insert_str(sfile, pb->soundtag, "%s.sound", path);
412 }
413 if (strcmp(pb->soundtag_alt, "-")) {
414 secfile_insert_str(sfile, pb->soundtag_alt, "%s.sound_alt", path);
415 }
416
417 save_reqs_vector(sfile, &(pb->reqs), path, "reqs");
418 save_reqs_vector(sfile, &(pb->obsolete_by), path, "obsolete_by");
419
420 secfile_insert_int(sfile, pb->build_cost, "%s.build_cost", path);
421 secfile_insert_int(sfile, pb->upkeep, "%s.upkeep", path);
422 secfile_insert_int(sfile, pb->sabotage, "%s.sabotage", path);
423
424 set_count = 0;
425 for (flagi = 0; flagi < IF_COUNT; flagi++) {
426 if (improvement_has_flag(pb, flagi)) {
427 flag_names[set_count++] = impr_flag_id_name(flagi);
428 }
429 }
430
431 if (set_count > 0) {
432 secfile_insert_str_vec(sfile, flag_names, set_count,
433 "%s.flags", path);
434 }
435
436 save_strvec(sfile, pb->helptext, path, "helptext");
437 }
439
440 return save_ruleset_file(sfile, filename);
441}
442
443/**********************************************************************/
446static bool save_styles_ruleset(const char *filename, const char *name)
447{
448 struct section_file *sfile = create_ruleset_file(name, "styles");
449 int sect_idx;
450 int i;
451
452 if (sfile == NULL) {
453 return FALSE;
454 }
455
456 comment_styles(sfile);
457
458 sect_idx = 0;
460 char path[512];
461
462 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
463
464 save_name_translation(sfile, &(pstyle->name), path);
466
467 comment_citystyles(sfile);
468
469 sect_idx = 0;
470 for (i = 0; i < game.control.styles_count; i++) {
471 char path[512];
472
473 fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++);
474
475 save_name_translation(sfile, &(city_styles[i].name), path);
476
477 secfile_insert_str(sfile, city_styles[i].graphic, "%s.graphic", path);
478 secfile_insert_str(sfile, city_styles[i].graphic_alt, "%s.graphic_alt", path);
479 if (strcmp(city_styles[i].citizens_graphic, "-")) {
480 secfile_insert_str(sfile, city_styles[i].citizens_graphic,
481 "%s.citizens_graphic", path);
482 }
483
484 save_reqs_vector(sfile, &(city_styles[i].reqs), path, "reqs");
485 }
486
487 comment_musicstyles(sfile);
488
489 sect_idx = 0;
491 char path[512];
492
493 fc_snprintf(path, sizeof(path), "musicstyle_%d", sect_idx++);
494
495 secfile_insert_str(sfile, pmus->music_peaceful, "%s.music_peaceful", path);
496 secfile_insert_str(sfile, pmus->music_combat, "%s.music_combat", path);
497
498 save_reqs_vector(sfile, &(pmus->reqs), path, "reqs");
500
501 return save_ruleset_file(sfile, filename);
502}
503
504/**********************************************************************/
511 const int aap,
512 const char *uflags_path,
513 bool (*unexpected_req)(
514 const struct requirement *preq))
515{
516 enum unit_type_flag_id protecor_flag[MAX_NUM_USER_UNIT_FLAGS];
517 size_t i;
518 size_t ret;
519
520 const struct action_auto_perf *auto_perf =
522
523 i = 0;
524 requirement_vector_iterate(&auto_perf->reqs, req) {
525 fc_assert(req->range == REQ_RANGE_LOCAL);
526
527 if (req->source.kind == VUT_UTFLAG) {
528 fc_assert(!req->present);
529
530 protecor_flag[i++] = req->source.value.unitflag;
531 } else if (unexpected_req(req)) {
532 struct astring astr;
533
534 log_error("Can't handle action auto performer requirement %s",
535 req_to_fstring(req, &astr));
536 astr_free(&astr);
537
538 return FALSE;
539 }
541
542 ret = secfile_insert_enum_vec(sfile, &protecor_flag, i,
543 unit_type_flag_id,
544 "%s", uflags_path);
545
546 if (ret != i) {
547 log_error("%s: didn't save all unit type flags.", uflags_path);
548
549 return FALSE;
550 }
551
552 return TRUE;
553}
554
555/**********************************************************************/
561static bool save_action_auto_actions(struct section_file *sfile,
562 const int aap,
563 const char *actions_path)
564{
565 enum gen_action unit_acts[MAX_NUM_ACTIONS];
566 size_t i, j;
567 size_t ret;
568
569 const struct action_auto_perf *auto_perf =
571
572 for (i = 0, j = 0;
573 i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
574 i++) {
575 struct action *paction = action_by_number(auto_perf->alternatives[i]);
576
577 if (!action_is_in_use(paction)) {
578 /* Don't mention non enabled actions. */
579 continue;
580 }
581
582 /* This action is included in the output. */
583 unit_acts[j] = auto_perf->alternatives[i];
584 j++;
585 }
586
587 action_list_end((action_id *)unit_acts, j);
588 ret = secfile_insert_enum_vec(sfile, &unit_acts, j, gen_action,
589 "%s", actions_path);
590
591 if (ret != j) {
592 log_error("%s: didn't save all actions.", actions_path);
593
594 return FALSE;
595 }
596
597 return TRUE;
598}
599
600/**********************************************************************/
604static bool unexpected_non_otype(const struct requirement *req)
605{
606 return !(req->source.kind == VUT_OTYPE && req->present);
607}
608
609/**********************************************************************/
614static bool save_muuk_action_auto(struct section_file *sfile,
615 const int aap,
616 const char *item)
617{
618 char uflags_path[100];
619 char action_path[100];
620
621 fc_snprintf(uflags_path, sizeof(uflags_path),
622 "missing_unit_upkeep.%s_protected", item);
623 fc_snprintf(action_path, sizeof(action_path),
624 "missing_unit_upkeep.%s_unit_act", item);
625
626 return (save_action_auto_uflag_block(sfile, aap, uflags_path,
628 && save_action_auto_actions(sfile, aap, action_path));
629}
630
631/**********************************************************************/
634static bool save_cities_ruleset(const char *filename, const char *name)
635{
636 struct section_file *sfile = create_ruleset_file(name, "cities");
637 int sect_idx;
638
639 if (sfile == NULL) {
640 return FALSE;
641 }
642
643 comment_specialists(sfile);
644
645 sect_idx = 0;
647 struct specialist *s = specialist_by_number(sp);
648 char path[512];
649
650 fc_snprintf(path, sizeof(path), "specialist_%d", sect_idx++);
651
652 save_name_translation(sfile, &(s->name), path);
653
654 if (strcmp(rule_name_get(&s->name), rule_name_get(&s->abbreviation))) {
656 "%s.short_name", path);
657 }
658
659 save_reqs_vector(sfile, &(s->reqs), path, "reqs");
660
661 secfile_insert_str(sfile, s->graphic_str, "%s.graphic", path);
662 if (strcmp(s->graphic_alt, "-")) {
663 secfile_insert_str(sfile, s->graphic_alt, "%s.graphic_alt", path);
664 }
665
666 save_strvec(sfile, s->helptext, path, "helptext");
667
669
672 "parameters.celebrate_size_limit");
673 }
676 "parameters.add_to_size_limit");
677 }
680 "parameters.angry_citizens");
681 }
684 "parameters.changable_tax");
685 }
686 if (game.info.forced_science != 0) {
688 "parameters.forced_science");
689 }
690 if (game.info.forced_luxury != 100) {
692 "parameters.forced_luxury");
693 }
694 if (game.info.forced_gold != 0) {
696 "parameters.forced_gold");
697 }
700 "parameters.vision_reveal_tiles");
701 }
702 if (game.info.pop_report_zeroes != 1) {
704 "parameters.pop_report_zeroes");
705 }
708 "citizen.nationality");
709 }
712 "citizen.convert_speed");
713 }
714 if (game.info.conquest_convert_pct != 0) {
716 "citizen.conquest_convert_pct");
717 }
720 "citizen.partisans_pct");
721 }
722
724 "food");
727 "missing_unit_upkeep.food_wipe");
728 }
729
731 "gold");
734 "missing_unit_upkeep.gold_wipe");
735 }
736
738 "shield");
741 "missing_unit_upkeep.shield_wipe");
742 }
743
744 return save_ruleset_file(sfile, filename);
745}
746
747/**************************************************************************
748 Effect saving callback data structure.
749**************************************************************************/
750typedef struct {
751 int idx;
754
755/**********************************************************************/
758static bool effect_save(struct effect *peffect, void *data)
759{
760 effect_cb_data *cbdata = (effect_cb_data *)data;
761 char path[512];
762
763 if (peffect->ruledit_do_not_save) {
764 /* Is supposed to be skipped. */
765 return TRUE;
766 }
767
768 fc_snprintf(path, sizeof(path), "effect_%d", cbdata->idx++);
769
771 effect_type_name(peffect->type),
772 "%s.type", path);
773 secfile_insert_int(cbdata->sfile, peffect->value, "%s.value", path);
774
775 save_reqs_vector(cbdata->sfile, &peffect->reqs, path, "reqs");
776
777 return TRUE;
778}
779
780/**********************************************************************/
783static bool save_effects_ruleset(const char *filename, const char *name)
784{
785 struct section_file *sfile = create_ruleset_file(name, "effect");
786 effect_cb_data data;
787
788 if (sfile == NULL) {
789 return FALSE;
790 }
791
792 data.idx = 0;
793 data.sfile = sfile;
794
795 comment_effects(sfile);
796
797 if (!iterate_effect_cache(effect_save, &data)) {
798 return FALSE;
799 }
800
801 return save_ruleset_file(sfile, filename);
802}
803
804/**********************************************************************/
807static bool save_action_ui_name(struct section_file *sfile,
808 int act, const char *entry_name)
809{
810 const char *ui_name = action_by_number(act)->ui_name;
811
812 if (ui_name == NULL) {
813 return FALSE;
814 }
815
816 if (strcmp(ui_name, action_ui_name_default(act))) {
817 secfile_insert_str(sfile, ui_name,
818 "actions.%s", entry_name);
819 }
820
821 return TRUE;
822}
823
824/**********************************************************************/
827static bool save_action_max_range(struct section_file *sfile,
828 action_id act)
829{
830 struct action *paction = action_by_number(act);
831
832 if (paction->max_distance == ACTION_DISTANCE_UNLIMITED) {
834 "actions.%s",
836 } else {
839 "actions",
841 }
842}
843
844/**********************************************************************/
847static bool save_action_range(struct section_file *sfile, action_id act)
848{
849 struct action *paction = action_by_number(act);
850
851 if (action_min_range_ruleset_var_name(act) != NULL) {
852 /* Min range can be loaded from the ruleset. */
853 save_default_int(sfile,
854 paction->min_distance,
856 "actions",
858 }
859
860 if (action_max_range_ruleset_var_name(act) != NULL) {
861 /* Max range can be loaded from the ruleset. */
862 if (!save_action_max_range(sfile, act)) {
863 return FALSE;
864 }
865 }
866
867 return TRUE;
868}
869
870/**********************************************************************/
873static bool save_action_kind(struct section_file *sfile, action_id act)
874{
875 if (action_target_kind_ruleset_var_name(act) != NULL) {
876 struct action *paction = action_by_number(act);
877
878 /* Target kind can be loaded from the ruleset. */
879 if (!action_is_in_use(paction)) {
880 /* Don't save the default for actions that aren't enabled. */
881 return TRUE;
882 }
883
886 action_target_kind,
887 "actions.%s",
889 }
890
891 return TRUE;
892}
893
894/**********************************************************************/
898 action_id act)
899{
901 struct action *paction = action_by_number(act);
902
903 /* Actor consumption can be loaded from the ruleset. */
904 if (!action_is_in_use(paction)) {
905 /* Don't save value for actions that aren't enabled. */
906 return TRUE;
907 }
908
909 save_default_bool(sfile,
912 "actions",
914 }
915
916 return TRUE;
917}
918
919/**********************************************************************/
922static bool save_action_blocked_by(struct section_file *sfile,
923 struct action *paction)
924{
925 enum gen_action action_vec[MAX_NUM_ACTIONS];
926 char comment[1024];
927 int i = 0;
928
929 if (action_blocked_by_ruleset_var_name(paction) == NULL) {
930 /* Action blocked by shouldn't be written to the ruleset for this
931 * action. */
932 return TRUE;
933 }
934
935 if (!action_is_in_use(paction)) {
936 /* Don't save value for actions that aren't enabled. */
937 return TRUE;
938 }
939
940 fc_snprintf(comment, sizeof(comment),
941 "Forbid \"%s\" if any one of the listed actions are legal.",
942 action_rule_name(paction));
943
944 action_iterate(blocker_id) {
945 struct action *pblocker = action_by_number(blocker_id);
946
947 if (!action_is_in_use(pblocker)) {
948 /* Don't save value for actions that aren't enabled. */
949 continue;
950 }
951
952 if (BV_ISSET(paction->blocked_by, blocker_id)) {
953 action_vec[i] = blocker_id;
954 i++;
955 }
957
959 sfile, &action_vec, i, gen_action, comment, "actions.%s",
961 != i) {
962 log_error("Didn't save all %s blocking actions.",
963 action_rule_name(paction));
964
965 return FALSE;
966 }
967
968 return TRUE;
969}
970
971/**********************************************************************/
976 int performer_slot,
977 struct action *paction)
978{
979 char action_list_path[100];
980
981 if (action_post_success_forced_ruleset_var_name(paction) == NULL) {
982 /* Not relevant. */
983 return TRUE;
984 }
985
986 if (!action_is_in_use(paction)) {
987 /* Don't save value for actions that aren't enabled. */
988 return TRUE;
989 }
990
991 fc_snprintf(action_list_path, sizeof(action_list_path),
992 "actions.%s",
994 if (!save_action_auto_actions(sfile, performer_slot, action_list_path)) {
995 return FALSE;
996 }
997
998 return TRUE;
999}
1000
1001/**********************************************************************/
1004static bool save_bv_actions(struct section_file *sfile,
1005 bv_actions content,
1006 const char *path)
1007{
1008 enum gen_action action_vec[MAX_NUM_ACTIONS];
1009 int i = 0;
1010
1011 action_iterate(act_id) {
1012 struct action *paction = action_by_number(act_id);
1013
1014 if (!action_is_in_use(paction)) {
1015 /* Don't save value for actions that aren't enabled. */
1016 continue;
1017 }
1018
1019 if (BV_ISSET(content, act_id)) {
1020 action_vec[i] = act_id;
1021 i++;
1022 }
1024
1025 if (secfile_insert_enum_vec(sfile, &action_vec, i, gen_action,
1026 "%s", path) != i) {
1027 log_error("Didn't save all of %s.", path);
1028
1029 return FALSE;
1030 }
1031
1032 return TRUE;
1033}
1034
1035/**********************************************************************/
1038static bool save_game_ruleset(const char *filename, const char *name)
1039{
1040 struct section_file *sfile = create_ruleset_file(name, "game");
1041 int sect_idx;
1042 int col_idx;
1043 int set_count;
1044 enum gameloss_style gs;
1045 const char *style_names[32]; /* FIXME: Should determine max length automatically.
1046 * currently it's 3 (bits 0,1, and 2) so there's plenty of
1047 * safety margin here. */
1048 const char *tnames[game.server.ruledit.named_teams];
1049 enum trade_route_type trt;
1050 int i;
1051 enum gen_action action_vec[MAX_NUM_ACTIONS];
1052 bool locks;
1053
1054 if (sfile == NULL) {
1055 return FALSE;
1056 }
1057
1058 if (game.server.ruledit.description_file != NULL) {
1060 "ruledit.description_file");
1061 }
1062
1063 if (game.control.preferred_tileset[0] != '\0') {
1065 "tileset.preferred");
1066 }
1067 if (game.control.preferred_soundset[0] != '\0') {
1069 "soundset.preferred");
1070 }
1071 if (game.control.preferred_musicset[0] != '\0') {
1073 "musicset.preferred");
1074 }
1075
1076 secfile_insert_str(sfile, game.control.name, "about.name");
1077 secfile_insert_str(sfile, game.control.version, "about.version");
1078
1079 if (game.control.alt_dir[0] != '\0') {
1080 secfile_insert_str(sfile, game.control.alt_dir, "about.alt_dir");
1081 }
1082
1083 if (game.ruleset_summary != NULL) {
1084 struct entry *mod_entry;
1085
1086 mod_entry = secfile_insert_str(sfile, game.ruleset_summary,
1087 "about.summary");
1088 entry_str_set_gt_marking(mod_entry, TRUE);
1089 }
1090
1091 if (game.ruleset_description != NULL) {
1092 if (game.server.ruledit.description_file == NULL) {
1094 "about.description");
1095 } else {
1097 "about.description");
1098 }
1099 }
1100
1101 if (game.ruleset_capabilities != NULL) {
1103 "about.capabilities");
1104 } else {
1105 secfile_insert_str(sfile, "", "about.capabilities");
1106 }
1107
1109 "options", "global_init_techs");
1111 "options", "global_init_buildings");
1112
1114 FALSE,
1115 "options.popup_tech_help", NULL);
1118 "civstyle.base_pollution", NULL);
1119
1120 set_count = 0;
1121 for (gs = gameloss_style_begin(); gs != gameloss_style_end(); gs = gameloss_style_next(gs)) {
1122 if (game.info.gameloss_style & gs) {
1123 style_names[set_count++] = gameloss_style_name(gs);
1124 }
1125 }
1126
1127 if (set_count > 0) {
1128 secfile_insert_str_vec(sfile, style_names, set_count,
1129 "civstyle.gameloss_style");
1130 }
1131
1134 "civstyle.happy_cost", NULL);
1137 "civstyle.food_cost", NULL);
1139 TRUE,
1140 "civstyle.civil_war_enabled", NULL);
1143 "civstyle.civil_war_bonus_celebrating", NULL);
1146 "civstyle.civil_war_bonus_unhappy", NULL);
1147 save_default_bool(sfile,
1148 BV_ISSET(action_by_number(ACTION_PARADROP)->sub_results,
1149 ACT_SUB_RES_MAY_EMBARK),
1150 FALSE,
1151 "civstyle.paradrop_to_transport", NULL);
1154 "civstyle.base_bribe_cost", NULL);
1157 "civstyle.ransom_gold", NULL);
1160 "civstyle.pillage_select", NULL);
1163 "civstyle.tech_steal_allow_holes", NULL);
1166 "civstyle.tech_trade_allow_holes", NULL);
1169 "civstyle.tech_trade_loss_allow_holes", NULL);
1172 "civstyle.tech_parasite_allow_holes", NULL);
1175 "civstyle.tech_loss_allow_holes", NULL);
1178 "civstyle.upgrade_veteran_loss", NULL);
1181 "civstyle.autoupgrade_veteran_loss", NULL);
1182
1185 "civstyle.granary_food_ini");
1186
1189 "civstyle.granary_food_inc", NULL);
1190
1192 char buffer[256];
1193
1194 fc_snprintf(buffer, sizeof(buffer),
1195 "civstyle.min_city_center_%s",
1197
1200 buffer, NULL);
1202
1205 "civstyle.init_vis_radius_sq", NULL);
1208 "civstyle.init_city_radius_sq", NULL);
1209 if (0 != fc_strcasecmp(gold_upkeep_style_name(game.info.gold_upkeep_style),
1211 secfile_insert_str(sfile,
1212 gold_upkeep_style_name(game.info.gold_upkeep_style),
1213 "civstyle.gold_upkeep_style");
1214 }
1216 1, "civstyle.output_granularity", NULL);
1218 FALSE, "civstyle.airlift_from_always_enabled", NULL);
1220 TRUE, "civstyle.airlift_to_always_enabled", NULL);
1221
1222 if (fc_strcasecmp(wonder_visib_type_name(game.info.small_wonder_visibility),
1224 secfile_insert_str(sfile,
1225 wonder_visib_type_name(game.info.small_wonder_visibility),
1226 "wonder_visibility.small_wonders");
1227 }
1228
1231 "illness.illness_on", NULL);
1234 "illness.illness_base_factor", NULL);
1237 "illness.illness_min_size", NULL);
1240 "illness.illness_trade_infection", NULL);
1243 "illness.illness_pollution_factor", NULL);
1246 "incite_cost.base_incite_cost", NULL);
1249 "incite_cost.improvement_factor", NULL);
1252 "incite_cost.unit_factor", NULL);
1255 "incite_cost.total_factor", NULL);
1256
1257 {
1258 /* Action auto performers aren't ready to be exposed in the ruleset
1259 * yet. The behavior when two action auto performers for the same
1260 * cause can fire isn't set in stone yet. How is one of them chosen?
1261 * What if all the actions of the chosen action auto performer turned
1262 * out to be illegal but one of the other action auto performers that
1263 * fired has legal actions? These issues can decide what other action
1264 * rules action auto performers can represent in the future. Deciding
1265 * should therefore wait until a rule needs action auto performers to
1266 * work a certain way. */
1267 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
1268 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
1269 * requirement vector to the ruleset. */
1270 const struct action_auto_perf *auto_perf =
1272
1274 "auto_attack.attack_actions");
1275
1276 save_reqs_vector(sfile, &auto_perf->reqs,
1277 "auto_attack", "if_attacker");
1278 }
1279
1281 "actions.diplchance_initial_odds")) {
1282 return FALSE;
1283 }
1284
1287 ACTION_SPY_BRIBE_UNIT))) {
1288 log_error("Didn't save all post success forced actions.");
1289 return FALSE;
1290 }
1291
1293 action_by_number(ACTION_ATTACK))) {
1294 log_error("Didn't save all post success forced actions.");
1295 return FALSE;
1296 }
1297
1299 "actions.escape_city")) {
1300 log_error("Didn't save all escape city forced actions.");
1301 return FALSE;
1302 }
1303
1305 "actions.unit_stack_death")) {
1306 log_error("Didn't save all escape unit stack death forced actions.");
1307 return FALSE;
1308 }
1309
1312 "actions.poison_empties_food_stock", NULL);
1313
1316 "actions.steal_maps_reveals_all_cities", NULL);
1317
1318 action_iterate(act_id) {
1319 struct action *act = action_by_number(act_id);
1320
1321 save_action_ui_name(sfile,
1322 act_id, action_ui_name_ruleset_var_name(act_id));
1323 save_action_kind(sfile, act_id);
1324 save_action_range(sfile, act_id);
1326 save_action_blocked_by(sfile, act);
1328
1329 i = 0;
1330 action_iterate(act) {
1331 if (action_by_number(act)->quiet) {
1332 action_vec[i] = act;
1333 i++;
1334 }
1336
1337 if (secfile_insert_enum_vec(sfile, &action_vec, i, gen_action,
1338 "actions.quiet_actions") != i) {
1339 log_error("Didn't save all quiet actions.");
1340
1341 return FALSE;
1342 }
1343
1344 comment_enablers(sfile);
1345 sect_idx = 0;
1347 char path[512];
1348
1349 if (pae->ruledit_disabled) {
1350 continue;
1351 }
1352
1353 fc_snprintf(path, sizeof(path), "actionenabler_%d", sect_idx++);
1354
1355 secfile_insert_str(sfile, action_id_rule_name(pae->action),
1356 "%s.action", path);
1357
1358 save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs");
1359 save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs");
1361
1364 "combat_rules.tired_attack", NULL);
1367 "combat_rules.only_killing_makes_veteran", NULL);
1370 "combat_rules.only_real_fight_makes_veteran", NULL);
1373 "combat_rules.combat_odds_scaled_veterancy", NULL);
1376 "combat_rules.damage_reduces_bombard_rate", NULL);
1378 "combat_rules.low_firepower_badwallattacker", NULL);
1380 "combat_rules.low_firepower_pearl_harbour", NULL);
1382 "combat_rules.low_firepower_combat_bonus", NULL);
1384 "combat_rules.low_firepower_nonnat_bombard", NULL);
1387 "combat_rules.nuke_pop_loss_pct", NULL);
1390 "combat_rules.nuke_defender_survival_chance_pct", NULL);
1393 "borders.radius_sq_city", NULL);
1396 "borders.size_effect", NULL);
1399 "borders.radius_sq_city_permanent", NULL);
1400 secfile_insert_str(sfile, tech_cost_style_name(game.info.tech_cost_style),
1401 "research.tech_cost_style");
1404 "research.base_tech_cost", NULL);
1405 secfile_insert_str(sfile, tech_leakage_style_name(game.info.tech_leakage),
1406 "research.tech_leakage");
1407 secfile_insert_str(sfile, tech_upkeep_style_name(game.info.tech_upkeep_style),
1408 "research.tech_upkeep_style");
1411 "research.tech_upkeep_divider", NULL);
1412 secfile_insert_str(sfile, free_tech_method_name(game.info.free_tech_method),
1413 "research.free_tech_method");
1414
1417 "culture.victory_min_points", NULL);
1420 "culture.victory_lead_pct", NULL);
1423 "culture.migration_pml", NULL);
1426 "culture.history_interest_pml", NULL);
1427
1430 "calendar.skip_year_0", NULL);
1433 "calendar.start_year", NULL);
1435 0, "calendar.fragments", NULL);
1436
1437 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
1438 if (game.calendar.calendar_fragment_name[i][0] != '\0') {
1440 "calendar.fragment_name%d", i);
1441 }
1442 }
1443
1446 "calendar.positive_label");
1447 }
1450 "calendar.negative_label");
1451 }
1452
1453 if (game.plr_bg_color != NULL) {
1454 rgbcolor_save(sfile, game.plr_bg_color, "playercolors.background");
1455 }
1456
1457 col_idx = 0;
1459 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1461
1462
1463 if (game.server.ruledit.named_teams > 0) {
1464 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1466 }
1467
1468 secfile_insert_str_vec(sfile, tnames,
1470 "teams.names");
1471 }
1472
1473 comment_disasters(sfile);
1474
1475 sect_idx = 0;
1477 char path[512];
1478 enum disaster_effect_id de;
1479 const char *effect_names[DE_COUNT];
1480
1481 fc_snprintf(path, sizeof(path), "disaster_%d", sect_idx++);
1482
1483 save_name_translation(sfile, &(pd->name), path);
1484 save_reqs_vector(sfile, &(pd->reqs), path, "reqs");
1485 if (pd->frequency != GAME_DEFAULT_DISASTER_FREQ) {
1486 secfile_insert_int(sfile, pd->frequency,
1487 "%s.frequency", path);
1488 }
1489
1490 set_count = 0;
1491 for (de = disaster_effect_id_begin();
1492 de != disaster_effect_id_end();
1493 de = disaster_effect_id_next(de)) {
1494 if (BV_ISSET(pd->effects, de)) {
1495 effect_names[set_count++] = disaster_effect_id_name(de);
1496 }
1497 }
1498
1499 if (set_count > 0) {
1500 secfile_insert_str_vec(sfile, effect_names, set_count,
1501 "%s.effects", path);
1502 }
1504
1505 comment_achievements(sfile);
1506
1507 sect_idx = 0;
1508 achievements_iterate(pach) {
1509 char path[512];
1510
1511 fc_snprintf(path, sizeof(path), "achievement_%d", sect_idx++);
1512
1513 save_name_translation(sfile, &(pach->name), path);
1514
1515 secfile_insert_str(sfile, achievement_type_name(pach->type),
1516 "%s.type", path);
1517
1518 save_default_bool(sfile, pach->unique,
1520 path, "unique");
1521 save_default_int(sfile, pach->value,
1523 path, "value");
1524 save_default_int(sfile, pach->culture,
1525 0, path, "culture");
1526
1527 secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
1528 if (pach->cons_msg != NULL) {
1529 secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
1530 }
1531
1533
1535
1536 set_count = 0;
1537 for (trt = 0; trt < TRT_LAST; trt++) {
1540
1541 if (set->trade_pct != 100 || strcmp(cancelling, "Active")) {
1542 char path[256];
1543
1544 fc_snprintf(path, sizeof(path),
1545 "trade.settings%d", set_count++);
1546
1548 "%s.type", path);
1549 secfile_insert_int(sfile, set->trade_pct,
1550 "%s.pct", path);
1552 "%s.cancelling", path);
1553 secfile_insert_str(sfile, trade_route_bonus_type_name(set->bonus_type),
1554 "%s.bonus", path);
1555 }
1556 }
1557
1559 0, "trade.min_trade_route_val", NULL);
1560
1562 secfile_insert_str(sfile, goods_selection_method_name(game.info.goods_selection),
1563 "trade.goods_selection");
1564 }
1565
1566 /* Goods */
1567 comment_goods(sfile);
1568
1569 sect_idx = 0;
1571 char path[512];
1572 const char *flag_names[GF_COUNT];
1573 int flagi;
1574
1575 fc_snprintf(path, sizeof(path), "goods_%d", sect_idx++);
1576
1577 save_name_translation(sfile, &(pgood->name), path);
1578
1579 save_reqs_vector(sfile, &(pgood->reqs), path, "reqs");
1580
1581 save_default_int(sfile, pgood->from_pct, 100, path, "from_pct");
1582 save_default_int(sfile, pgood->to_pct, 100, path, "to_pct");
1583 save_default_int(sfile, pgood->onetime_pct, 100, path, "onetime_pct");
1584
1585 set_count = 0;
1586 for (flagi = 0; flagi < GF_COUNT; flagi++) {
1587 if (goods_has_flag(pgood, flagi)) {
1588 flag_names[set_count++] = goods_flag_id_name(flagi);
1589 }
1590 }
1591
1592 if (set_count > 0) {
1593 secfile_insert_str_vec(sfile, flag_names, set_count,
1594 "%s.flags", path);
1595 }
1596
1597 save_strvec(sfile, pgood->helptext, path, "helptext");
1599
1600 /* Clauses */
1601 comment_clauses(sfile);
1602
1603 sect_idx = 0;
1604 for (i = 0; i < CLAUSE_COUNT; i++) {
1605 struct clause_info *info = clause_info_get(i);
1606
1607 if (info->enabled) {
1608 char path[512];
1609
1610 fc_snprintf(path, sizeof(path), "clause_%d", sect_idx++);
1611
1612 secfile_insert_str(sfile, clause_type_name(info->type),
1613 "%s.type", path);
1614 save_reqs_vector(sfile, &(info->giver_reqs), path, "giver_reqs");
1615 save_reqs_vector(sfile, &(info->receiver_reqs), path, "receiver_reqs");
1616 }
1617 }
1618
1619 locks = FALSE;
1620 settings_iterate(SSET_ALL, pset) {
1621 if (setting_locked(pset)) {
1622 locks = TRUE;
1623 break;
1624 }
1626
1627 set_count = 0;
1628 settings_iterate(SSET_ALL, pset) {
1629 if (setting_get_setdef(pset) == SETDEF_RULESET || setting_locked(pset)) {
1630 secfile_insert_str(sfile, setting_name(pset),
1631 "settings.set%d.name", set_count);
1632 switch (setting_type(pset)) {
1633 case SST_BOOL:
1635 "settings.set%d.value", set_count);
1636 break;
1637 case SST_INT:
1639 "settings.set%d.value", set_count);
1640 break;
1641 case SST_STRING:
1643 "settings.set%d.value", set_count);
1644 break;
1645 case SST_ENUM:
1648 "settings.set%d.value", set_count);
1649 break;
1650 case SST_BITWISE:
1653 "settings.set%d.value", set_count);
1654 break;
1655 case SST_COUNT:
1656 fc_assert(setting_type(pset) != SST_COUNT);
1657 secfile_insert_str(sfile, "Unknown setting type",
1658 "settings.set%d.value", set_count);
1659 break;
1660 }
1661
1662 if (locks) {
1664 "settings.set%d.lock", set_count);
1665 }
1666
1667 set_count++;
1668 }
1670
1671 return save_ruleset_file(sfile, filename);
1672}
1673
1674/**********************************************************************/
1677static bool save_governments_ruleset(const char *filename, const char *name)
1678{
1679 struct section_file *sfile = create_ruleset_file(name, "government");
1680 int sect_idx;
1681
1682 if (sfile == NULL) {
1683 return FALSE;
1684 }
1685
1686 save_gov_ref(sfile, game.government_during_revolution, "governments",
1687 "during_revolution");
1688
1689 comment_govs(sfile);
1690
1691 sect_idx = 0;
1693 char path[512];
1694 struct ruler_title *prtitle;
1695
1696 fc_snprintf(path, sizeof(path), "government_%d", sect_idx++);
1697
1698 save_name_translation(sfile, &(pg->name), path);
1699
1700 secfile_insert_str(sfile, pg->graphic_str, "%s.graphic", path);
1701 secfile_insert_str(sfile, pg->graphic_alt, "%s.graphic_alt", path);
1702
1703 save_reqs_vector(sfile, &(pg->reqs), path, "reqs");
1704
1705 if (pg->ai.better != NULL) {
1706 save_gov_ref(sfile, pg->ai.better, path,
1707 "ai_better");
1708 }
1709
1710 ruler_title_hash_lookup(pg->ruler_titles, NULL,
1711 &prtitle);
1712 if (prtitle != NULL) {
1713 const char *title;
1714
1716 if (title != NULL) {
1718 "%s.ruler_male_title", path);
1719 }
1720
1722 if (title != NULL) {
1724 "%s.ruler_female_title", path);
1725 }
1726 }
1727
1728 save_strvec(sfile, pg->helptext, path, "helptext");
1729
1731
1732 comment_policies(sfile);
1733
1734 sect_idx = 0;
1735 multipliers_iterate(pmul) {
1736 if (!pmul->ruledit_disabled) {
1737 char path[512];
1738
1739 fc_snprintf(path, sizeof(path), "multiplier_%d", sect_idx++);
1740
1741 save_name_translation(sfile, &(pmul->name), path);
1742
1743 secfile_insert_int(sfile, pmul->start, "%s.start", path);
1744 secfile_insert_int(sfile, pmul->stop, "%s.stop", path);
1745 secfile_insert_int(sfile, pmul->step, "%s.step", path);
1746 secfile_insert_int(sfile, pmul->def, "%s.default", path);
1747
1748 save_default_int(sfile, pmul->offset, 0, path, "offset");
1749 save_default_int(sfile, pmul->factor, 100, path, "factor");
1750 save_default_int(sfile, pmul->minimum_turns, 0, path, "minimum_turns");
1751
1752 save_reqs_vector(sfile, &(pmul->reqs), path, "reqs");
1753
1754 save_strvec(sfile, pmul->helptext, path, "helptext");
1755 }
1757
1758 return save_ruleset_file(sfile, filename);
1759}
1760
1761/**********************************************************************/
1764static bool save_traits(struct trait_limits *traits,
1765 struct trait_limits *default_traits,
1766 struct section_file *sfile,
1767 const char *secname, const char *field_prefix)
1768{
1769 enum trait tr;
1770
1771 /* FIXME: Use specenum trait names without duplicating them here.
1772 * Just needs to take care of case.
1773 * This list is also duplicated in ruleset.c:ruleset_load_traits() */
1774 const char *trait_names[] = {
1775 "expansionist",
1776 "trader",
1777 "aggressive",
1778 "builder",
1779 NULL
1780 };
1781
1782 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != NULL;
1783 tr = trait_next(tr)) {
1784 int default_default;
1785
1786 default_default = (traits[tr].min + traits[tr].max) / 2;
1787
1788 if ((default_traits == NULL && traits[tr].min != TRAIT_DEFAULT_VALUE)
1789 || (default_traits != NULL && traits[tr].min != default_traits[tr].min)) {
1790 secfile_insert_int(sfile, traits[tr].min, "%s.%s%s_min", secname, field_prefix,
1791 trait_names[tr]);
1792 }
1793 if ((default_traits == NULL && traits[tr].max != TRAIT_DEFAULT_VALUE)
1794 || (default_traits != NULL && traits[tr].max != default_traits[tr].max)) {
1795 secfile_insert_int(sfile, traits[tr].max, "%s.%s%s_max", secname, field_prefix,
1796 trait_names[tr]);
1797 }
1798 if (default_default != traits[tr].fixed) {
1799 secfile_insert_int(sfile, traits[tr].fixed, "%s.%s%s_default", secname, field_prefix,
1800 trait_names[tr]);
1801 }
1802 }
1803
1804 return TRUE;
1805}
1806
1807/**********************************************************************/
1810static bool save_nation(struct section_file *sfile, struct nation_type *pnat,
1811 int sect_idx)
1812{
1813 char path[512];
1814 int max_items = nation_city_list_size(pnat->server.default_cities);
1815 char *city_str[max_items];
1816 max_items = MAX(max_items, MAX_NUM_NATION_SETS + MAX_NUM_NATION_GROUPS);
1817 max_items = MAX(max_items, game.control.nation_count);
1818 const char *list_items[max_items];
1819 int set_count;
1820 int subsect_idx;
1821
1822 fc_snprintf(path, sizeof(path), "nation_%d", sect_idx++);
1823
1824 if (pnat->translation_domain == NULL) {
1825 secfile_insert_str(sfile, "freeciv-core", "%s.translation_domain", path);
1826 } else {
1827 secfile_insert_str(sfile, pnat->translation_domain, "%s.translation_domain", path);
1828 }
1829
1830 save_name_translation(sfile, &(pnat->adjective), path);
1831 secfile_insert_str(sfile, untranslated_name(&(pnat->noun_plural)), "%s.plural", path);
1832
1833 set_count = 0;
1834 nation_sets_iterate(pset) {
1835 if (nation_is_in_set(pnat, pset)) {
1836 list_items[set_count++] = nation_set_rule_name(pset);
1837 }
1839 nation_groups_iterate(pgroup) {
1840 if (nation_is_in_group(pnat, pgroup)) {
1841 list_items[set_count++] = nation_group_rule_name(pgroup);
1842 }
1844
1845 if (set_count > 0) {
1846 secfile_insert_str_vec(sfile, list_items, set_count, "%s.groups", path);
1847 }
1848
1849 set_count = 0;
1851 list_items[set_count++] = nation_rule_name(pconfl);
1853 if (set_count > 0) {
1854 secfile_insert_str_vec(sfile, list_items, set_count, "%s.conflicts_with", path);
1855 }
1856
1857 subsect_idx = 0;
1858 nation_leader_list_iterate(pnat->leaders, pleader) {
1859 secfile_insert_str(sfile, nation_leader_name(pleader), "%s.leaders%d.name",
1860 path, subsect_idx);
1861 secfile_insert_str(sfile, nation_leader_is_male(pleader) ? "Male" : "Female",
1862 "%s.leaders%d.sex", path, subsect_idx++);
1864
1865 if (pnat->server.rgb != NULL) {
1866 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
1867 }
1868
1870 sfile, path, "trait_");
1871
1872 if (!pnat->is_playable) {
1873 secfile_insert_bool(sfile, pnat->is_playable, "%s.is_playable", path);
1874 }
1875
1876 if (pnat->barb_type != NOT_A_BARBARIAN) {
1877 secfile_insert_str(sfile, barbarian_type_name(pnat->barb_type),
1878 "%s.barbarian_type", path);
1879 }
1880
1881 if (strcmp(pnat->flag_graphic_str, "-")) {
1882 secfile_insert_str(sfile, pnat->flag_graphic_str, "%s.flag", path);
1883 }
1884 if (strcmp(pnat->flag_graphic_alt, "-")) {
1885 secfile_insert_str(sfile, pnat->flag_graphic_alt, "%s.flag_alt", path);
1886 }
1887
1888 subsect_idx = 0;
1889 governments_iterate(pgov) {
1890 struct ruler_title *prtitle;
1891
1892 if (ruler_title_hash_lookup(pgov->ruler_titles, pnat, &prtitle)) {
1894 "%s.ruler_titles%d.government", path, subsect_idx);
1896 "%s.ruler_titles%d.male_title", path, subsect_idx);
1898 "%s.ruler_titles%d.female_title", path, subsect_idx++);
1899 }
1901
1902 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
1903
1904 set_count = 0;
1906 list_items[set_count++] = nation_rule_name(pconfl);
1908 if (set_count > 0) {
1909 secfile_insert_str_vec(sfile, list_items, set_count, "%s.civilwar_nations", path);
1910 }
1911
1912 save_tech_list(sfile, pnat->init_techs, path, "init_techs");
1913 save_building_list(sfile, pnat->init_buildings, path, "init_buildings");
1914 save_unit_list(sfile, pnat->init_units, path, "init_units");
1915
1916 if (pnat->init_government) {
1918 "%s.init_government", path);
1919 }
1920
1921 set_count = 0;
1923 bool list_started = FALSE;
1924
1925 city_str[set_count] = fc_malloc(strlen(nation_city_name(pncity)) + strlen(" (!river")
1926 + strlen(")")
1927 + MAX_NUM_TERRAINS * (strlen(", ") + MAX_LEN_NAME));
1928
1929 strcpy(city_str[set_count], nation_city_name(pncity));
1930 switch (nation_city_river_preference(pncity)) {
1931 case NCP_DISLIKE:
1932 strcat(city_str[set_count], " (!river");
1933 list_started = TRUE;
1934 break;
1935 case NCP_LIKE:
1936 strcat(city_str[set_count], " (river");
1937 list_started = TRUE;
1938 break;
1939 case NCP_NONE:
1940 break;
1941 }
1942
1943 terrain_type_iterate(pterr) {
1944 const char *pref = NULL;
1945
1946 switch (nation_city_terrain_preference(pncity, pterr)) {
1947 case NCP_DISLIKE:
1948 pref = "!";
1949 break;
1950 case NCP_LIKE:
1951 pref = "";
1952 break;
1953 case NCP_NONE:
1954 pref = NULL;
1955 break;
1956 }
1957
1958 if (pref != NULL) {
1959 if (list_started) {
1960 strcat(city_str[set_count], ", ");
1961 } else {
1962 strcat(city_str[set_count], " (");
1963 list_started = TRUE;
1964 }
1965 strcat(city_str[set_count], pref);
1966 strcat(city_str[set_count], terrain_rule_name(pterr));
1967 }
1968
1970
1971 if (list_started) {
1972 strcat(city_str[set_count], ")");
1973 }
1974
1975 list_items[set_count] = city_str[set_count];
1976 set_count++;
1978 if (set_count > 0) {
1979 int i;
1980
1981 secfile_insert_str_vec(sfile, list_items, set_count, "%s.cities", path);
1982
1983 for (i = 0; i < set_count; i++) {
1984 FC_FREE(city_str[i]);
1985 }
1986 }
1987
1988 secfile_insert_str(sfile, pnat->legend, "%s.legend", path);
1989
1990 return TRUE;
1991}
1992
1993/**********************************************************************/
1996static bool save_nations_ruleset(const char *filename, const char *name,
1997 struct rule_data *data)
1998{
1999 struct section_file *sfile = create_ruleset_file(name, "nation");
2000
2001 if (sfile == NULL) {
2002 return FALSE;
2003 }
2004
2005 if (data->nationlist != NULL || game.server.ruledit.embedded_nations != NULL) {
2007 if (data->nationlist != NULL) {
2008 secfile_insert_str(sfile, data->nationlist, "ruledit.nationlist");
2009 }
2010 if (game.server.ruledit.embedded_nations != NULL) {
2011 int i;
2012 const char **tmp = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
2013
2014 /* Dance around the secfile_insert_str_vec() parameter type (requires extra const)
2015 * resrictions */
2016 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
2017 tmp[i] = game.server.ruledit.embedded_nations[i];
2018 }
2019
2020 secfile_insert_str_vec(sfile, tmp,
2022 "ruledit.embedded_nations");
2023 free(tmp);
2024 }
2025 }
2026
2028 "default_traits", "");
2029
2030 if (data->nationlist == NULL) {
2031 if (game.server.ruledit.allowed_govs != NULL) {
2034 "compatibility.allowed_govs");
2035 }
2036 if (game.server.ruledit.allowed_terrains != NULL) {
2039 "compatibility.allowed_terrains");
2040 }
2041 if (game.server.ruledit.allowed_styles != NULL) {
2044 "compatibility.allowed_styles");
2045 }
2046 }
2047
2048 if (game.default_government != NULL) {
2050 "compatibility.default_government");
2051 }
2052
2053 if (data->nationlist != NULL) {
2054 secfile_insert_include(sfile, data->nationlist);
2055
2056 if (game.server.ruledit.embedded_nations != NULL) {
2057 int sect_idx;
2058
2059 comment_nations(sfile);
2060
2061 for (sect_idx = 0; sect_idx < game.server.ruledit.embedded_nations_count;
2062 sect_idx++) {
2063 struct nation_type *pnat
2065
2066 if (pnat == NULL) {
2067 log_error("Embedded nation \"%s\" not found!",
2069 } else {
2070 save_nation(sfile, pnat, sect_idx);
2071 }
2072 }
2073 }
2074 } else {
2075 int sect_idx = 0;
2076
2077 comment_nationsets(sfile);
2078
2079 nation_sets_iterate(pset) {
2080 char path[512];
2081
2082 fc_snprintf(path, sizeof(path), "nset_%d", sect_idx++);
2083
2084 /* We don't use save_name_translation() for this as name and rule_name must
2085 * always be saved separately */
2086 secfile_insert_str(sfile, nation_set_untranslated_name(pset), "%s.name", path);
2087 secfile_insert_str(sfile, nation_set_rule_name(pset), "%s.rule_name", path);
2088 secfile_insert_str(sfile, nation_set_description(pset), "%s.description", path);
2090
2091 comment_nationgroups(sfile);
2092
2093 sect_idx = 0;
2094 nation_groups_iterate(pgroup) {
2095 char path[512];
2096
2097 fc_snprintf(path, sizeof(path), "ngroup_%d", sect_idx++);
2098
2099 save_name_translation(sfile, &(pgroup->name), path);
2100
2101 secfile_insert_int(sfile, pgroup->server.match, "%s.match", path);
2102 if (pgroup->hidden) {
2103 secfile_insert_bool(sfile, pgroup->hidden, "%s.hidden", path);
2104 }
2106
2107 comment_nations(sfile);
2108
2109 sect_idx = 0;
2110 nations_iterate(pnat) {
2111 save_nation(sfile, pnat, sect_idx++);
2113 }
2114
2115 return save_ruleset_file(sfile, filename);
2116}
2117
2118/**********************************************************************/
2121static bool save_techs_ruleset(const char *filename, const char *name)
2122{
2123 struct section_file *sfile = create_ruleset_file(name, "tech");
2124 int i;
2125 int sect_idx;
2126 struct advance *a_none = advance_by_number(A_NONE);
2127
2128
2129 if (sfile == NULL) {
2130 return FALSE;
2131 }
2132
2133 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
2134 const char *flagname = tech_flag_id_name_cb(i + TECH_USER_1);
2135 const char *helptxt = tech_flag_helptxt(i + TECH_USER_1);
2136
2137 if (flagname != NULL) {
2138 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2139
2140 /* Save the user flag help text even when it is undefined. That makes
2141 * the formatting code happy. The resulting "" is ignored when the
2142 * ruleset is loaded. */
2143 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2144 }
2145 }
2146
2147 comment_tech_classes(sfile);
2148
2149 sect_idx = 0;
2150 tech_class_iterate(ptclass) {
2151 char path[512];
2152
2153 fc_snprintf(path, sizeof(path), "techclass_%d", sect_idx++);
2154
2155 save_name_translation(sfile, &(ptclass->name), path);
2157
2158 comment_techs(sfile);
2159
2160 sect_idx = 0;
2162 if (pa->require[AR_ONE] != A_NEVER) {
2163 char path[512];
2164 const char *flag_names[TF_COUNT];
2165 int set_count;
2166 int flagi;
2167
2168 fc_snprintf(path, sizeof(path), "advance_%d", sect_idx++);
2169
2170 save_name_translation(sfile, &(pa->name), path);
2171
2172 if (game.control.num_tech_classes > 0) {
2173 if (pa->tclass != NULL) {
2174 secfile_insert_str(sfile, tech_class_rule_name(pa->tclass),
2175 "%s.class", path);
2176 }
2177 }
2178
2179 save_tech_ref(sfile, pa->require[AR_ONE], path, "req1");
2180 save_tech_ref(sfile, pa->require[AR_TWO], path, "req2");
2181 if (pa->require[AR_ROOT] != a_none && !pa->inherited_root_req) {
2182 save_tech_ref(sfile, pa->require[AR_ROOT], path, "root_req");
2183 }
2184
2185 save_reqs_vector(sfile, &(pa->research_reqs), path,
2186 "research_reqs");
2187
2188 secfile_insert_str(sfile, pa->graphic_str, "%s.graphic", path);
2189 if (strcmp("-", pa->graphic_alt)) {
2190 secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
2191 }
2192 if (pa->bonus_message != NULL) {
2193 secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
2194 }
2195
2196 set_count = 0;
2197 for (flagi = 0; flagi < TF_COUNT; flagi++) {
2198 if (advance_has_flag(advance_index(pa), flagi)) {
2199 flag_names[set_count++] = tech_flag_id_name(flagi);
2200 }
2201 }
2202
2203 if (set_count > 0) {
2204 secfile_insert_str_vec(sfile, flag_names, set_count,
2205 "%s.flags", path);
2206 }
2207 if (pa->cost >= 0) {
2208 secfile_insert_int(sfile, pa->cost, "%s.cost", path);
2209 }
2210
2211 save_strvec(sfile, pa->helptext, path, "helptext");
2212 }
2213
2215
2216 return save_ruleset_file(sfile, filename);
2217}
2218
2219/**********************************************************************/
2222static bool save_terrain_ruleset(const char *filename, const char *name)
2223{
2224 struct section_file *sfile = create_ruleset_file(name, "terrain");
2225 int sect_idx;
2226 int i;
2227
2228 if (sfile == NULL) {
2229 return FALSE;
2230 }
2231
2232 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
2233 const char *flagname = terrain_flag_id_name_cb(i + TER_USER_1);
2234 const char *helptxt = terrain_flag_helptxt(i + TER_USER_1);
2235
2236 if (flagname != NULL) {
2237 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2238
2239 /* Save the user flag help text even when it is undefined. That makes
2240 * the formatting code happy. The resulting "" is ignored when the
2241 * ruleset is loaded. */
2242 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2243 }
2244 }
2245
2246 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2247 const char *flagname = extra_flag_id_name_cb(i + EF_USER_FLAG_1);
2248 const char *helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
2249
2250 if (flagname != NULL) {
2251 secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
2252
2253 /* Save the user flag help text even when it is undefined. That makes
2254 * the formatting code happy. The resulting "" is ignored when the
2255 * ruleset is loaded. */
2256 secfile_insert_str(sfile, helptxt,
2257 "control.extra_flags%d.helptxt", i);
2258 }
2259 }
2260
2261 if (terrain_control.ocean_reclaim_requirement_pct <= 100) {
2262 secfile_insert_int(sfile, terrain_control.ocean_reclaim_requirement_pct,
2263 "parameters.ocean_reclaim_requirement");
2264 }
2265 if (terrain_control.land_channel_requirement_pct <= 100) {
2266 secfile_insert_int(sfile, terrain_control.land_channel_requirement_pct,
2267 "parameters.land_channel_requirement");
2268 }
2269 if (terrain_control.terrain_thaw_requirement_pct <= 100) {
2270 secfile_insert_int(sfile, terrain_control.terrain_thaw_requirement_pct,
2271 "parameters.thaw_requirement");
2272 }
2273 if (terrain_control.terrain_freeze_requirement_pct <= 100) {
2274 secfile_insert_int(sfile, terrain_control.terrain_freeze_requirement_pct,
2275 "parameters.freeze_requirement");
2276 }
2277 if (terrain_control.lake_max_size != 0) {
2278 secfile_insert_int(sfile, terrain_control.lake_max_size,
2279 "parameters.lake_max_size");
2280 }
2281 if (terrain_control.min_start_native_area != 0) {
2282 secfile_insert_int(sfile, terrain_control.min_start_native_area,
2283 "parameters.min_start_native_area");
2284 }
2285 if (terrain_control.move_fragments != 3) {
2286 secfile_insert_int(sfile, terrain_control.move_fragments,
2287 "parameters.move_fragments");
2288 }
2289 if (terrain_control.igter_cost != 1) {
2290 secfile_insert_int(sfile, terrain_control.igter_cost,
2291 "parameters.igter_cost");
2292 }
2293 if (terrain_control.pythagorean_diagonal != RS_DEFAULT_PYTHAGOREAN_DIAGONAL) {
2294 secfile_insert_bool(sfile, terrain_control.pythagorean_diagonal,
2295 "parameters.pythagorean_diagonal");
2296 }
2299 "parameters.ocean_resources");
2300 }
2301
2302 comment_terrains(sfile);
2303
2304 sect_idx = 0;
2305 terrain_type_iterate(pterr) {
2306 char path[512];
2307 char identifier[2];
2308 int r;
2309 const char *flag_names[TER_USER_LAST];
2310 const char *puc_names[UCL_LAST];
2311 int flagi;
2312 int set_count;
2313
2314 fc_snprintf(path, sizeof(path), "terrain_%d", sect_idx++);
2315
2316 save_name_translation(sfile, &(pterr->name), path);
2317
2318 secfile_insert_str(sfile, pterr->graphic_str, "%s.graphic", path);
2319 secfile_insert_str(sfile, pterr->graphic_alt, "%s.graphic_alt", path);
2320 identifier[0] = pterr->identifier;
2321 identifier[1] = '\0';
2322 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2323
2324 secfile_insert_str(sfile, terrain_class_name(pterr->tclass),
2325 "%s.class", path);
2326
2327 secfile_insert_int(sfile, pterr->movement_cost, "%s.movement_cost", path);
2328 secfile_insert_int(sfile, pterr->defense_bonus, "%s.defense_bonus", path);
2329
2331 if (pterr->output[o] != 0) {
2332 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2334 }
2336
2337 /* Check resource count */
2338 for (r = 0; pterr->resources[r] != NULL; r++) {
2339 /* Just increasing r as long as there is resources */
2340 }
2341
2342 {
2343 const char *resource_names[r];
2344
2345 for (r = 0; pterr->resources[r] != NULL; r++) {
2346 resource_names[r] = extra_rule_name(pterr->resources[r]);
2347 }
2348
2349 secfile_insert_str_vec(sfile, resource_names, r,
2350 "%s.resources", path);
2351 }
2352
2354 if (pterr->road_output_incr_pct[o] != 0) {
2355 secfile_insert_int(sfile, pterr->road_output_incr_pct[o],
2356 "%s.road_%s_incr_pct", path,
2358 }
2360
2361 secfile_insert_int(sfile, pterr->base_time, "%s.base_time", path);
2362 secfile_insert_int(sfile, pterr->road_time, "%s.road_time", path);
2363
2364 save_terrain_ref(sfile, pterr->cultivate_result, pterr, path,
2365 "cultivate_result");
2366 secfile_insert_int(sfile, pterr->cultivate_time,
2367 "%s.cultivate_time", path);
2368
2369 save_terrain_ref(sfile, pterr->plant_result, pterr, path,
2370 "plant_result");
2371 secfile_insert_int(sfile, pterr->plant_time,
2372 "%s.plant_time", path);
2373
2374 secfile_insert_int(sfile, pterr->irrigation_food_incr,
2375 "%s.irrigation_food_incr", path);
2376 secfile_insert_int(sfile, pterr->irrigation_time,
2377 "%s.irrigation_time", path);
2378
2379 secfile_insert_int(sfile, pterr->mining_shield_incr,
2380 "%s.mining_shield_incr", path);
2381 secfile_insert_int(sfile, pterr->mining_time,
2382 "%s.mining_time", path);
2383
2384 save_terrain_ref(sfile, pterr->transform_result, pterr, path,
2385 "transform_result");
2386 secfile_insert_int(sfile, pterr->transform_time,
2387 "%s.transform_time", path);
2388
2389 if (pterr->animal != NULL) {
2390 secfile_insert_str(sfile, utype_rule_name(pterr->animal),
2391 "%s.animal", path);
2392 } else {
2393 secfile_insert_str(sfile, "None",
2394 "%s.animal", path);
2395 }
2396
2397 secfile_insert_int(sfile, pterr->placing_time,
2398 "%s.placing_time", path);
2399 secfile_insert_int(sfile, pterr->pillage_time,
2400 "%s.pillage_time", path);
2401 secfile_insert_int(sfile, pterr->clean_pollution_time,
2402 "%s.clean_pollution_time", path);
2403 secfile_insert_int(sfile, pterr->clean_fallout_time,
2404 "%s.clean_fallout_time", path);
2405
2406 save_terrain_ref(sfile, pterr->warmer_wetter_result, pterr, path,
2407 "warmer_wetter_result");
2408 save_terrain_ref(sfile, pterr->warmer_drier_result, pterr, path,
2409 "warmer_drier_result");
2410 save_terrain_ref(sfile, pterr->cooler_wetter_result, pterr, path,
2411 "cooler_wetter_result");
2412 save_terrain_ref(sfile, pterr->cooler_drier_result, pterr, path,
2413 "cooler_drier_result");
2414
2415 set_count = 0;
2416 for (flagi = 0; flagi < TER_USER_LAST; flagi++) {
2417 if (terrain_has_flag(pterr, flagi)) {
2418 flag_names[set_count++] = terrain_flag_id_name(flagi);
2419 }
2420 }
2421
2422 if (set_count > 0) {
2423 secfile_insert_str_vec(sfile, flag_names, set_count,
2424 "%s.flags", path);
2425 }
2426
2427 {
2428 enum mapgen_terrain_property mtp;
2429
2430 for (mtp = mapgen_terrain_property_begin();
2431 mtp != mapgen_terrain_property_end();
2432 mtp = mapgen_terrain_property_next(mtp)) {
2433 if (pterr->property[mtp] != 0) {
2434 secfile_insert_int(sfile, pterr->property[mtp],
2435 "%s.property_%s", path,
2436 mapgen_terrain_property_name(mtp));
2437 }
2438 }
2439 }
2440
2441 set_count = 0;
2442 unit_class_iterate(puc) {
2443 if (BV_ISSET(pterr->native_to, uclass_index(puc))) {
2444 puc_names[set_count++] = uclass_rule_name(puc);
2445 }
2447
2448 if (set_count > 0) {
2449 secfile_insert_str_vec(sfile, puc_names, set_count,
2450 "%s.native_to", path);
2451 }
2452
2453 rgbcolor_save(sfile, pterr->rgb, "%s.color", path);
2454
2455 save_strvec(sfile, pterr->helptext, path, "helptext");
2456
2458
2459 comment_resources(sfile);
2460
2461 sect_idx = 0;
2462 extra_type_by_cause_iterate(EC_RESOURCE, pres) {
2463 if (!pres->ruledit_disabled) {
2464 char path[512];
2465 char identifier[2];
2466
2467 fc_snprintf(path, sizeof(path), "resource_%d", sect_idx++);
2468
2470 "%s.extra", path);
2471
2473 if (pres->data.resource->output[o] != 0) {
2474 secfile_insert_int(sfile, pres->data.resource->output[o], "%s.%s",
2475 path, get_output_identifier(o));
2476 }
2478
2479 identifier[0] = pres->data.resource->id_old_save;
2480 identifier[1] = '\0';
2481 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2482 }
2484
2485 secfile_insert_str(sfile, terrain_control.gui_type_base0,
2486 "extraui.ui_name_base_fortress");
2487 secfile_insert_str(sfile, terrain_control.gui_type_base1,
2488 "extraui.ui_name_base_airbase");
2489
2490 comment_extras(sfile);
2491
2492 sect_idx = 0;
2494 char path[512];
2495 const char *flag_names[EF_COUNT];
2496 const char *cause_names[EC_COUNT];
2497 const char *puc_names[UCL_LAST];
2498 const char *extra_names[MAX_EXTRA_TYPES];
2499 int flagi;
2500 int causei;
2501 int set_count;
2502 bool worker_cause;
2503
2504 fc_snprintf(path, sizeof(path), "extra_%d", sect_idx++);
2505
2506 save_name_translation(sfile, &(pextra->name), path);
2507
2508 secfile_insert_str(sfile, extra_category_name(pextra->category),
2509 "%s.category", path);
2510
2511 set_count = 0;
2512 for (causei = 0; causei < EC_COUNT; causei++) {
2513 if (is_extra_caused_by(pextra, causei)) {
2514 cause_names[set_count++] = extra_cause_name(causei);
2515 }
2516 }
2517
2518 if (set_count > 0) {
2519 secfile_insert_str_vec(sfile, cause_names, set_count,
2520 "%s.causes", path);
2521 }
2522
2523 set_count = 0;
2524 for (causei = 0; causei < ERM_COUNT; causei++) {
2525 if (is_extra_removed_by(pextra, causei)) {
2526 cause_names[set_count++] = extra_rmcause_name(causei);
2527 }
2528 }
2529
2530 if (set_count > 0) {
2531 secfile_insert_str_vec(sfile, cause_names, set_count,
2532 "%s.rmcauses", path);
2533 }
2534
2535 if (strcmp(pextra->graphic_str, "-")) {
2536 secfile_insert_str(sfile, pextra->graphic_str, "%s.graphic", path);
2537 }
2538 if (strcmp(pextra->graphic_alt, "-")) {
2539 secfile_insert_str(sfile, pextra->graphic_alt, "%s.graphic_alt", path);
2540 }
2541 if (strcmp(pextra->activity_gfx, "-")) {
2542 secfile_insert_str(sfile, pextra->activity_gfx, "%s.activity_gfx", path);
2543 }
2544 if (strcmp(pextra->act_gfx_alt, "-")) {
2545 secfile_insert_str(sfile, pextra->act_gfx_alt, "%s.act_gfx_alt", path);
2546 }
2547 if (strcmp(pextra->act_gfx_alt2, "-")) {
2548 secfile_insert_str(sfile, pextra->act_gfx_alt2, "%s.act_gfx_alt2", path);
2549 }
2550 if (strcmp(pextra->rmact_gfx, "-")) {
2551 secfile_insert_str(sfile, pextra->rmact_gfx, "%s.rmact_gfx", path);
2552 }
2553 if (strcmp(pextra->rmact_gfx_alt, "-")) {
2554 secfile_insert_str(sfile, pextra->rmact_gfx_alt, "%s.rmact_gfx_alt", path);
2555 }
2556
2557 save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
2558 save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
2559 save_reqs_vector(sfile, &(pextra->appearance_reqs), path, "appearance_reqs");
2560 save_reqs_vector(sfile, &(pextra->disappearance_reqs), path, "disappearance_reqs");
2561
2562 worker_cause = is_extra_caused_by_worker_action(pextra);
2563 if ((!pextra->buildable && worker_cause)
2564 || (pextra->buildable && !worker_cause)) {
2565 secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);
2566 }
2567 if (!pextra->generated) {
2568 secfile_insert_bool(sfile, pextra->generated, "%s.generated", path);
2569 }
2570 secfile_insert_int(sfile, pextra->build_time, "%s.build_time", path);
2571 secfile_insert_int(sfile, pextra->removal_time, "%s.removal_time", path);
2572 if (pextra->build_time_factor != 1) {
2573 secfile_insert_int(sfile, pextra->build_time_factor, "%s.build_time_factor", path);
2574 }
2575 if (pextra->removal_time_factor != 1) {
2576 secfile_insert_int(sfile, pextra->removal_time_factor, "%s.removal_time_factor", path);
2577 }
2578 if (pextra->infracost != 0) {
2579 secfile_insert_int(sfile, pextra->infracost, "%s.infracost", path);
2580 }
2581 if (pextra->defense_bonus != 0) {
2582 secfile_insert_int(sfile, pextra->defense_bonus, "%s.defense_bonus", path);
2583 }
2584 if (pextra->eus != EUS_NORMAL) {
2585 secfile_insert_str(sfile, extra_unit_seen_type_name(pextra->eus),
2586 "%s.unit_seen", path);
2587 }
2588 if (is_extra_caused_by(pextra, EC_APPEARANCE)
2589 && pextra->appearance_chance != RS_DEFAULT_EXTRA_APPEARANCE) {
2590 secfile_insert_int(sfile, pextra->appearance_chance, "%s.appearance_chance", path);
2591 }
2592 if (is_extra_removed_by(pextra, ERM_DISAPPEARANCE)
2593 && pextra->disappearance_chance != RS_DEFAULT_EXTRA_DISAPPEARANCE) {
2594 secfile_insert_int(sfile, pextra->disappearance_chance, "%s.disappearance_chance",
2595 path);
2596 }
2597
2598 set_count = 0;
2599 unit_class_iterate(puc) {
2600 if (BV_ISSET(pextra->native_to, uclass_index(puc))) {
2601 puc_names[set_count++] = uclass_rule_name(puc);
2602 }
2604
2605 if (set_count > 0) {
2606 secfile_insert_str_vec(sfile, puc_names, set_count,
2607 "%s.native_to", path);
2608 }
2609
2610 set_count = 0;
2611 for (flagi = 0; flagi < EF_COUNT; flagi++) {
2612 if (extra_has_flag(pextra, flagi)) {
2613 flag_names[set_count++] = extra_flag_id_name(flagi);
2614 }
2615 }
2616
2617 if (set_count > 0) {
2618 secfile_insert_str_vec(sfile, flag_names, set_count,
2619 "%s.flags", path);
2620 }
2621
2622 set_count = 0;
2623 extra_type_iterate(confl) {
2624 if (!can_extras_coexist(pextra, confl)) {
2625 extra_names[set_count++] = extra_rule_name(confl);
2626 }
2628
2629 if (set_count > 0) {
2630 secfile_insert_str_vec(sfile, extra_names, set_count,
2631 "%s.conflicts", path);
2632 }
2633
2634 set_count = 0;
2635 extra_type_iterate(top) {
2636 if (BV_ISSET(pextra->hidden_by, extra_index(top))) {
2637 extra_names[set_count++] = extra_rule_name(top);
2638 }
2640
2641 if (set_count > 0) {
2642 secfile_insert_str_vec(sfile, extra_names, set_count,
2643 "%s.hidden_by", path);
2644 }
2645
2646 set_count = 0;
2647 extra_type_iterate(top) {
2648 if (BV_ISSET(pextra->bridged_over, extra_index(top))) {
2649 extra_names[set_count++] = extra_rule_name(top);
2650 }
2652
2653 if (set_count > 0) {
2654 secfile_insert_str_vec(sfile, extra_names, set_count,
2655 "%s.bridged_over", path);
2656 }
2657
2658 save_strvec(sfile, pextra->helptext, path, "helptext");
2659
2661
2662 comment_bases(sfile);
2663
2664 sect_idx = 0;
2665 extra_type_by_cause_iterate(EC_BASE, pextra) {
2666 if (!pextra->ruledit_disabled) {
2667 char path[512];
2668 struct base_type *pbase = extra_base_get(pextra);
2669
2670 fc_snprintf(path, sizeof(path), "base_%d", sect_idx++);
2671
2672 secfile_insert_str(sfile, extra_rule_name(pextra),
2673 "%s.extra", path);
2674
2675 secfile_insert_str(sfile, base_gui_type_name(pbase->gui_type),
2676 "%s.gui_type", path);
2677
2678 if (pbase->border_sq >= 0) {
2679 secfile_insert_int(sfile, pbase->border_sq, "%s.border_sq", path);
2680 }
2681 if (pbase->vision_main_sq >= 0) {
2682 secfile_insert_int(sfile, pbase->vision_main_sq, "%s.vision_main_sq", path);
2683 }
2684 if (pbase->vision_invis_sq >= 0) {
2685 secfile_insert_int(sfile, pbase->vision_invis_sq, "%s.vision_invis_sq", path);
2686 }
2687 if (pbase->vision_subs_sq >= 0) {
2688 secfile_insert_int(sfile, pbase->vision_subs_sq, "%s.vision_subs_sq", path);
2689 }
2690 }
2692
2693 comment_roads(sfile);
2694
2695 sect_idx = 0;
2696 extra_type_by_cause_iterate(EC_ROAD, pextra) {
2697 if (!pextra->ruledit_disabled) {
2698 struct road_type *proad = extra_road_get(pextra);
2699 char path[512];
2700 const char *flag_names[RF_COUNT];
2701 int flagi;
2702 int set_count;
2703
2704 fc_snprintf(path, sizeof(path), "road_%d", sect_idx++);
2705
2706 secfile_insert_str(sfile, extra_rule_name(pextra),
2707 "%s.extra", path);
2708
2709 secfile_insert_int(sfile, proad->move_cost, "%s.move_cost", path);
2710
2711 if (proad->move_mode != RMM_FAST_ALWAYS) {
2712 secfile_insert_str(sfile, road_move_mode_name(proad->move_mode),
2713 "%s.move_mode", path);
2714 }
2715
2717 if (proad->tile_incr_const[o] != 0) {
2718 secfile_insert_int(sfile, proad->tile_incr_const[o],
2719 "%s.%s_incr_const", path, get_output_identifier(o));
2720 }
2721 if (proad->tile_incr[o] != 0) {
2722 secfile_insert_int(sfile, proad->tile_incr[o],
2723 "%s.%s_incr", path, get_output_identifier(o));
2724 }
2725 if (proad->tile_bonus[o] != 0) {
2726 secfile_insert_int(sfile, proad->tile_bonus[o],
2727 "%s.%s_bonus", path, get_output_identifier(o));
2728 }
2730
2731 switch (proad->compat) {
2732 case ROCO_ROAD:
2733 secfile_insert_str(sfile, "Road", "%s.compat_special", path);
2734 break;
2735 case ROCO_RAILROAD:
2736 secfile_insert_str(sfile, "Railroad", "%s.compat_special", path);
2737 break;
2738 case ROCO_RIVER:
2739 secfile_insert_str(sfile, "River", "%s.compat_special", path);
2740 break;
2741 case ROCO_NONE:
2742 secfile_insert_str(sfile, "None", "%s.compat_special", path);
2743 break;
2744 }
2745
2746 secfile_insert_str(sfile, road_gui_type_name(proad->gui_type),
2747 "%s.gui_type", path);
2748
2749 set_count = 0;
2750 for (flagi = 0; flagi < RF_COUNT; flagi++) {
2751 if (road_has_flag(proad, flagi)) {
2752 flag_names[set_count++] = road_flag_id_name(flagi);
2753 }
2754 }
2755
2756 if (set_count > 0) {
2757 secfile_insert_str_vec(sfile, flag_names, set_count,
2758 "%s.flags", path);
2759 }
2760 }
2762
2763 return save_ruleset_file(sfile, filename);
2764}
2765
2766/**********************************************************************/
2769static bool save_veteran_system(struct section_file *sfile, const char *path,
2770 struct veteran_system *vsystem)
2771{
2772 const char *vlist_name[vsystem->levels];
2773 int vlist_power[vsystem->levels];
2774 int vlist_raise[vsystem->levels];
2775 int vlist_wraise[vsystem->levels];
2776 int vlist_move[vsystem->levels];
2777 int i;
2778
2779 for (i = 0; i < vsystem->levels; i++) {
2780 vlist_name[i] = rule_name_get(&(vsystem->definitions[i].name));
2781 vlist_power[i] = vsystem->definitions[i].power_fact;
2782 vlist_raise[i] = vsystem->definitions[i].base_raise_chance;
2783 vlist_wraise[i] = vsystem->definitions[i].work_raise_chance;
2784 vlist_move[i] = vsystem->definitions[i].move_bonus;
2785 }
2786
2787 secfile_insert_str_vec(sfile, vlist_name, vsystem->levels,
2788 "%s.veteran_names", path);
2789 secfile_insert_int_vec(sfile, vlist_power, vsystem->levels,
2790 "%s.veteran_power_fact", path);
2791 secfile_insert_int_vec(sfile, vlist_raise, vsystem->levels,
2792 "%s.veteran_base_raise_chance", path);
2793 secfile_insert_int_vec(sfile, vlist_wraise, vsystem->levels,
2794 "%s.veteran_work_raise_chance", path);
2795 secfile_insert_int_vec(sfile, vlist_move, vsystem->levels,
2796 "%s.veteran_move_bonus", path);
2797
2798 return TRUE;
2799}
2800
2801/**********************************************************************/
2804static bool save_combat_bonuses(struct section_file *sfile,
2805 struct unit_type *put,
2806 char *path)
2807{
2808 int i;
2809 bool has_quiet = FALSE;
2810
2811 combat_bonus_list_iterate(put->bonuses, pbonus) {
2812 if (pbonus->quiet) {
2813 has_quiet = TRUE;
2814 }
2816
2817 i = 0;
2818
2819 combat_bonus_list_iterate(put->bonuses, pbonus) {
2820 secfile_insert_str(sfile, unit_type_flag_id_name(pbonus->flag),
2821 "%s.bonuses%d.flag", path, i);
2822 secfile_insert_str(sfile, combat_bonus_type_name(pbonus->type),
2823 "%s.bonuses%d.type", path, i);
2824 secfile_insert_int(sfile, pbonus->value,
2825 "%s.bonuses%d.value", path, i);
2826
2827 if (has_quiet) {
2828 secfile_insert_bool(sfile, pbonus->quiet,
2829 "%s.bonuses%d.quiet", path, i);
2830 }
2831
2832 i++;
2834
2835 return TRUE;
2836}
2837
2838/**********************************************************************/
2841static bool save_units_ruleset(const char *filename, const char *name)
2842{
2843 struct section_file *sfile = create_ruleset_file(name, "unit");
2844 int i;
2845 int sect_idx;
2846
2847 if (sfile == NULL) {
2848 return FALSE;
2849 }
2850
2851 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
2852 const char *flagname = unit_type_flag_id_name_cb(i + UTYF_USER_FLAG_1);
2853 const char *helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
2854
2855 if (flagname != NULL) {
2856 secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
2857
2858 /* Save the user flag help text even when it is undefined. That makes
2859 * the formatting code happy. The resulting "" is ignored when the
2860 * ruleset is loaded. */
2861 secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
2862 }
2863 }
2864
2865 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
2866 const char *flagname = unit_class_flag_id_name_cb(i + UCF_USER_FLAG_1);
2867 const char *helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
2868
2869 if (flagname != NULL) {
2870 secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
2871
2872 /* Save the user flag help text even when it is undefined. That makes
2873 * the formatting code happy. The resulting "" is ignored when the
2874 * ruleset is loaded. */
2875 secfile_insert_str(sfile, helptxt,
2876 "control.class_flags%d.helptxt", i);
2877 }
2878 }
2879
2880 save_veteran_system(sfile, "veteran_system", game.veteran);
2881
2882 comment_uclasses(sfile);
2883
2884 sect_idx = 0;
2886 char path[512];
2887 const char *flag_names[UCF_COUNT];
2888 int flagi;
2889 int set_count;
2890
2891 fc_snprintf(path, sizeof(path), "unitclass_%d", sect_idx++);
2892
2893 save_name_translation(sfile, &(puc->name), path);
2894
2895 secfile_insert_int(sfile, puc->min_speed / SINGLE_MOVE,
2896 "%s.min_speed", path);
2897 secfile_insert_int(sfile, puc->hp_loss_pct, "%s.hp_loss_pct", path);
2898 if (puc->non_native_def_pct != 100) {
2899 secfile_insert_int(sfile, puc->non_native_def_pct,
2900 "%s.non_native_def_pct", path);
2901 }
2902
2903 set_count = 0;
2904 for (flagi = 0; flagi < UCF_COUNT; flagi++) {
2905 if (uclass_has_flag(puc, flagi)) {
2906 flag_names[set_count++] = unit_class_flag_id_name(flagi);
2907 }
2908 }
2909
2910 if (set_count > 0) {
2911 secfile_insert_str_vec(sfile, flag_names, set_count,
2912 "%s.flags", path);
2913 }
2914
2915 save_strvec(sfile, puc->helptext, path, "helptext");
2916
2918
2919 comment_utypes(sfile);
2920
2921 sect_idx = 0;
2923 if (!put->ruledit_disabled) {
2924 char path[512];
2925 const char *flag_names[UTYF_LAST_USER_FLAG + 1];
2926 int flagi;
2927 int set_count;
2928
2929 fc_snprintf(path, sizeof(path), "unit_%d", sect_idx++);
2930
2931 save_name_translation(sfile, &(put->name), path);
2932
2933 secfile_insert_str(sfile, uclass_rule_name(put->uclass),
2934 "%s.class", path);
2935
2936 save_tech_ref(sfile, put->require_advance, path, "tech_req");
2937
2938 /* Extract the government requirement from the requirement vector so
2939 * it can be written in the old format.
2940 * The build_reqs requirement vector isn't ready to be exposed in the
2941 * ruleset yet. */
2942 requirement_vector_iterate(&put->build_reqs, preq) {
2943 if (preq->source.kind == VUT_GOVERNMENT) {
2944 fc_assert_msg(preq->range == REQ_RANGE_PLAYER,
2945 "can't convert non player range to the rs format");
2946 fc_assert_msg(preq->present,
2947 "can't convert not present reqs to the rs format");
2948 secfile_insert_str(sfile,
2949 universal_rule_name(&preq->source),
2950 "%s.gov_req", path);
2951 break;
2952 }
2954
2955 /* Extract the improvement requirement from the requirement vector so
2956 * it can be written in the old format.
2957 * The build_reqs requirement vector isn't ready to be exposed in the
2958 * ruleset yet. */
2959 requirement_vector_iterate(&put->build_reqs, preq) {
2960 if (preq->source.kind == VUT_IMPROVEMENT) {
2961 fc_assert_msg(preq->range == REQ_RANGE_CITY,
2962 "can't convert non player range to the rs format");
2963 fc_assert_msg(preq->present,
2964 "can't convert not present reqs to the rs format");
2965 secfile_insert_str(sfile,
2966 universal_rule_name(&preq->source),
2967 "%s.impr_req", path);
2968 break;
2969 }
2971
2972 if (put->obsoleted_by != NULL) {
2973 secfile_insert_str(sfile, utype_rule_name(put->obsoleted_by),
2974 "%s.obsolete_by", path);
2975 }
2976
2977 secfile_insert_str(sfile, put->graphic_str, "%s.graphic", path);
2978 if (strcmp("-", put->graphic_alt)) {
2979 secfile_insert_str(sfile, put->graphic_alt, "%s.graphic_alt", path);
2980 }
2981 if (strcmp("-", put->sound_move)) {
2982 secfile_insert_str(sfile, put->sound_move, "%s.sound_move", path);
2983 }
2984 if (strcmp("-", put->sound_move_alt)) {
2985 secfile_insert_str(sfile, put->sound_move_alt, "%s.sound_move_alt", path);
2986 }
2987 if (strcmp("-", put->sound_fight)) {
2988 secfile_insert_str(sfile, put->sound_fight, "%s.sound_fight", path);
2989 }
2990 if (strcmp("-", put->sound_fight_alt)) {
2991 secfile_insert_str(sfile, put->sound_fight_alt, "%s.sound_fight_alt", path);
2992 }
2993
2994 secfile_insert_int(sfile, put->build_cost, "%s.build_cost", path);
2995 secfile_insert_int(sfile, put->pop_cost, "%s.pop_cost", path);
2996 secfile_insert_int(sfile, put->attack_strength, "%s.attack", path);
2997 secfile_insert_int(sfile, put->defense_strength, "%s.defense", path);
2998 secfile_insert_int(sfile, put->move_rate / SINGLE_MOVE, "%s.move_rate", path);
2999 secfile_insert_int(sfile, put->vision_radius_sq, "%s.vision_radius_sq", path);
3000 secfile_insert_int(sfile, put->transport_capacity, "%s.transport_cap", path);
3001
3002 save_uclass_vec(sfile, &(put->cargo), path, "cargo", FALSE);
3003 save_uclass_vec(sfile, &(put->embarks), path, "embarks", TRUE);
3004 save_uclass_vec(sfile, &(put->disembarks), path, "disembarks", TRUE);
3005
3006 if (put->vlayer != V_MAIN) {
3007 secfile_insert_str(sfile, vision_layer_name(put->vlayer),
3008 "%s.vision_layer", path);
3009 }
3010
3011 secfile_insert_int(sfile, put->hp, "%s.hitpoints", path);
3012 secfile_insert_int(sfile, put->firepower, "%s.firepower", path);
3013 secfile_insert_int(sfile, put->fuel, "%s.fuel", path);
3014 secfile_insert_int(sfile, put->happy_cost, "%s.uk_happy", path);
3015
3017 if (put->upkeep[o] != 0) {
3018 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3019 path, get_output_identifier(o));
3020 }
3022
3023 if (put->converted_to != NULL) {
3024 secfile_insert_str(sfile, utype_rule_name(put->converted_to),
3025 "%s.convert_to", path);
3026 }
3027 if (put->convert_time != 1) {
3028 secfile_insert_int(sfile, put->convert_time, "%s.convert_time", path);
3029 }
3030
3031 save_combat_bonuses(sfile, put, path);
3032 save_uclass_vec(sfile, &(put->targets), path, "targets", TRUE);
3033
3034 if (put->veteran != NULL) {
3035 save_veteran_system(sfile, path, put->veteran);
3036 }
3037
3038 if (put->paratroopers_range != 0) {
3039 secfile_insert_int(sfile, put->paratroopers_range,
3040 "%s.paratroopers_range", path);
3041 }
3042 if (put->bombard_rate != 0) {
3043 secfile_insert_int(sfile, put->bombard_rate,
3044 "%s.bombard_rate", path);
3045 }
3046 if (put->city_slots != 0) {
3047 secfile_insert_int(sfile, put->city_slots,
3048 "%s.city_slots", path);
3049 }
3050 if (put->city_size != 1) {
3051 secfile_insert_int(sfile, put->city_size,
3052 "%s.city_size", path);
3053 }
3054
3055 secfile_insert_str(sfile, transp_def_type_name(put->tp_defense),
3056 "%s.tp_defense", path);
3057
3058 set_count = 0;
3059 for (flagi = 0; flagi <= UTYF_LAST_USER_FLAG; flagi++) {
3060 if (utype_has_flag(put, flagi)) {
3061 flag_names[set_count++] = unit_type_flag_id_name(flagi);
3062 }
3063 }
3064
3065 if (set_count > 0) {
3066 secfile_insert_str_vec(sfile, flag_names, set_count,
3067 "%s.flags", path);
3068 }
3069
3070 set_count = 0;
3071 for (flagi = L_FIRST; flagi < L_LAST; flagi++) {
3072 if (utype_has_role(put, flagi)) {
3073 flag_names[set_count++] = unit_role_id_name(flagi);
3074 }
3075 }
3076
3077 if (set_count > 0) {
3078 secfile_insert_str_vec(sfile, flag_names, set_count,
3079 "%s.roles", path);
3080 }
3081
3082 save_strvec(sfile, put->helptext, path, "helptext");
3083 }
3085
3086 return save_ruleset_file(sfile, filename);
3087}
3088
3089/**********************************************************************/
3092static bool save_script_lua(const char *filename, const char *name,
3093 const char *buffer)
3094{
3095 if (buffer != NULL) {
3096 FILE *ffile = fc_fopen(filename, "w");
3097 int full_len = strlen(buffer);
3098 int len;
3099
3100 if (ffile != NULL) {
3101 len = fwrite(buffer, 1, full_len, ffile);
3102
3103 if (len != full_len) {
3104 return FALSE;
3105 }
3106
3107 fclose(ffile);
3108 } else {
3109 return FALSE;
3110 }
3111 }
3112
3113 return TRUE;
3114}
3115
3116/**********************************************************************/
3119static bool save_luadata(const char *filename)
3120{
3121 if (game.server.luadata != NULL) {
3122 return secfile_save(game.server.luadata, filename, 0, FZ_PLAIN);
3123 }
3124
3125 return TRUE;
3126}
3127
3128/**********************************************************************/
3131bool save_ruleset(const char *path, const char *name, struct rule_data *data)
3132{
3133 if (make_dir(path)) {
3134 bool success = TRUE;
3135 char filename[500];
3136
3137 if (success) {
3138 fc_snprintf(filename, sizeof(filename), "%s/buildings.ruleset", path);
3139 success = save_buildings_ruleset(filename, name);
3140 }
3141
3142 if (success) {
3143 fc_snprintf(filename, sizeof(filename), "%s/styles.ruleset", path);
3144 success = save_styles_ruleset(filename, name);
3145 }
3146
3147 if (success) {
3148 fc_snprintf(filename, sizeof(filename), "%s/cities.ruleset", path);
3149 success = save_cities_ruleset(filename, name);
3150 }
3151
3152 if (success) {
3153 fc_snprintf(filename, sizeof(filename), "%s/effects.ruleset", path);
3154 success = save_effects_ruleset(filename, name);
3155 }
3156
3157 if (success) {
3158 fc_snprintf(filename, sizeof(filename), "%s/game.ruleset", path);
3159 success = save_game_ruleset(filename, name);
3160 }
3161
3162 if (success) {
3163 fc_snprintf(filename, sizeof(filename), "%s/governments.ruleset", path);
3164 success = save_governments_ruleset(filename, name);
3165 }
3166
3167 if (success) {
3168 fc_snprintf(filename, sizeof(filename), "%s/nations.ruleset", path);
3169 success = save_nations_ruleset(filename, name, data);
3170 }
3171
3172 if (success) {
3173 fc_snprintf(filename, sizeof(filename), "%s/techs.ruleset", path);
3174 success = save_techs_ruleset(filename, name);
3175 }
3176
3177 if (success) {
3178 fc_snprintf(filename, sizeof(filename), "%s/terrain.ruleset", path);
3179 success = save_terrain_ruleset(filename, name);
3180 }
3181
3182 if (success) {
3183 fc_snprintf(filename, sizeof(filename), "%s/units.ruleset", path);
3184 success = save_units_ruleset(filename, name);
3185 }
3186
3187 if (success) {
3188 fc_snprintf(filename, sizeof(filename), "%s/script.lua", path);
3189 success = save_script_lua(filename, name, get_script_buffer());
3190 }
3191
3192 if (success) {
3193 fc_snprintf(filename, sizeof(filename), "%s/parser.lua", path);
3194 success = save_script_lua(filename, name, get_parser_buffer());
3195 }
3196
3197 if (success) {
3198 fc_snprintf(filename, sizeof(filename), "%s/luadata.txt", path);
3199 success = save_luadata(filename);
3200 }
3201
3202 return success;
3203 } else {
3204 log_error(_("Failed to create directory %s"), path);
3205 return FALSE;
3206 }
3207
3208 return TRUE;
3209}
#define achievements_iterate_end
#define achievements_iterate(_ach_)
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:7962
void action_list_end(action_id *act_list, int size)
Definition actions.c:7397
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:9030
bool action_is_in_use(struct action *paction)
Definition actions.c:7326
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:9172
const char * action_rule_name(const struct action *action)
Definition actions.c:1876
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1899
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:8895
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:8173
int action_min_range_default(enum action_result result)
Definition actions.c:8091
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:8394
const char * action_ui_name_default(int act)
Definition actions.c:7660
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:7365
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:7434
int action_max_range_default(enum action_result result)
Definition actions.c:8308
#define action_enablers_iterate_end
Definition actions.h:526
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:617
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:615
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
#define NUM_ACTIONS
Definition actions.h:297
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:621
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:620
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:352
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:616
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:618
#define action_iterate_end
Definition actions.h:472
#define MAX_NUM_ACTIONS
Definition actions.h:296
#define action_enablers_iterate(_enabler_)
Definition actions.h:520
#define action_iterate(_act_)
Definition actions.h:467
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:614
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:619
#define ACTION_NONE
Definition actions.h:293
void astr_free(struct astring *astr)
Definition astring.c:153
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
struct citystyle * city_styles
Definition city.c:79
const char * get_output_identifier(Output_type_id output)
Definition city.c:614
#define output_type_iterate(output)
Definition city.h:821
#define output_type_iterate_end
Definition city.h:827
void comment_roads(struct section_file *sfile)
Definition comments.c:261
void comment_uclasses(struct section_file *sfile)
Definition comments.c:213
void comment_citystyles(struct section_file *sfile)
Definition comments.c:277
void comment_govs(struct section_file *sfile)
Definition comments.c:197
void comment_bases(struct section_file *sfile)
Definition comments.c:253
void comment_terrains(struct section_file *sfile)
Definition comments.c:229
void comment_file_header(struct section_file *sfile)
Definition comments.c:165
void comment_effects(struct section_file *sfile)
Definition comments.c:293
void comment_disasters(struct section_file *sfile)
Definition comments.c:301
void comment_clauses(struct section_file *sfile)
Definition comments.c:373
void comment_goods(struct section_file *sfile)
Definition comments.c:325
void comment_extras(struct section_file *sfile)
Definition comments.c:245
void comment_techs(struct section_file *sfile)
Definition comments.c:189
void comment_nations(struct section_file *sfile)
Definition comments.c:349
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:317
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:381
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:357
void comment_specialists(struct section_file *sfile)
Definition comments.c:341
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:285
void comment_resources(struct section_file *sfile)
Definition comments.c:237
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:181
void comment_utypes(struct section_file *sfile)
Definition comments.c:221
void comment_policies(struct section_file *sfile)
Definition comments.c:205
void comment_achievements(struct section_file *sfile)
Definition comments.c:309
void comment_styles(struct section_file *sfile)
Definition comments.c:269
void comment_buildings(struct section_file *sfile)
Definition comments.c:173
void comment_enablers(struct section_file *sfile)
Definition comments.c:333
void comment_nationsets(struct section_file *sfile)
Definition comments.c:365
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:273
#define disaster_type_iterate(_p)
Definition disaster.h:80
#define disaster_type_iterate_end
Definition disaster.h:86
struct @21::@22 reqs
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1245
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:923
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:981
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:810
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:911
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:952
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:195
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define is_extra_caused_by(e, c)
Definition extras.h:196
#define extra_index(_e_)
Definition extras.h:177
#define extra_type_re_active_iterate_end
Definition extras.h:305
#define extra_base_get(_e_)
Definition extras.h:184
#define extra_road_get(_e_)
Definition extras.h:185
#define extra_type_re_active_iterate(_p)
Definition extras.h:301
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define MAX_NUM_USER_EXTRA_FLAGS
Definition extras.h:80
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
@ ROCO_RAILROAD
Definition fc_types.h:1105
@ ROCO_NONE
Definition fc_types.h:1105
@ ROCO_RIVER
Definition fc_types.h:1105
@ ROCO_ROAD
Definition fc_types.h:1105
#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:359
#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:387
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:57
struct world wld
Definition game.c:58
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:840
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:826
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:832
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:829
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:812
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:785
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:743
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:739
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:777
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:866
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:836
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:850
#define RS_DEFAULT_HAPPY_COST
Definition game.h:817
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:858
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:791
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:741
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:480
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:859
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:825
#define RS_DEFAULT_BASE_TECH_COST
Definition game.h:854
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:846
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:759
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:804
#define GAME_DEFAULT_START_YEAR
Definition game.h:715
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:765
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:844
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:737
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:808
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:769
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:828
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:860
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:751
#define RS_DEFAULT_FOOD_COST
Definition game.h:821
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:781
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:773
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:371
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:795
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:755
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:747
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:761
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:382
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:373
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
#define governments_iterate(NAME_pgov)
Definition government.h:121
#define governments_re_active_iterate(_p)
Definition government.h:126
#define governments_re_active_iterate_end
Definition government.h:130
#define governments_iterate_end
Definition government.h:124
const char * title
Definition repodlgs.c:1313
struct impr_type * improvement_by_number(const Impr_type_id id)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
#define improvement_re_active_iterate_end
#define improvement_re_active_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
@ FZ_PLAIN
Definition ioz.h:37
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
struct terrain_misc terrain_control
Definition map.c:69
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
#define SINGLE_MOVE
Definition movement.h:24
#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:411
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:289
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:421
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1078
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:796
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1098
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:836
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:827
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:433
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:120
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:280
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:56
#define nation_list_iterate(nationlist, pnation)
Definition nation.h:83
#define nation_sets_iterate_end
Definition nation.h:304
#define nation_sets_iterate(NAME_pset)
Definition nation.h:300
#define nations_iterate_end
Definition nation.h:335
@ NCP_NONE
Definition nation.h:40
@ NCP_DISLIKE
Definition nation.h:39
@ NCP_LIKE
Definition nation.h:41
#define nation_city_list_iterate(citylist, pncity)
Definition nation.h:47
#define nation_list_iterate_end
Definition nation.h:85
#define nation_city_list_iterate_end
Definition nation.h:49
#define nations_iterate(NAME_pnation)
Definition nation.h:332
#define nation_leader_list_iterate_end
Definition nation.h:58
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:310
#define nation_groups_iterate_end
Definition nation.h:314
int len
Definition packhand.c:125
struct section_file * secfile_new(bool allow_duplicates)
const char * entry_name(const struct entry *pentry)
bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
bool secfile_save(const struct section_file *secfile, const char *filename, int compression_level, enum fz_method compression_method)
struct section * secfile_insert_include(struct section_file *secfile, const char *filename)
struct entry * secfile_insert_filereference(struct section_file *secfile, const char *filename, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_enum_vec(secfile, enumerators, dim, specenum_type, path,...)
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
#define secfile_insert_int_vec(secfile, values, dim, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_insert_enum_vec_comment(secfile, enumerators, dim, specenum_type, comment, path,...)
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
const char * universal_rule_name(const struct universal *psource)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
Definition rgbcolor.c:121
#define rgbcolor_list_iterate_end
Definition rgbcolor.h:45
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)
Definition rgbcolor.h:43
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:410
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:141
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:201
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:118
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:241
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:298
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:1996
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:873
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:897
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:827
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:1764
#define FORMAT_VERSION
Definition rulesave.c:49
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3131
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:634
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2121
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:321
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:975
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:370
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:2769
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1004
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:98
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:758
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1038
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:378
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:510
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:604
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:274
static bool save_luadata(const char *filename)
Definition rulesave.c:3119
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1677
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:922
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:348
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:2841
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2222
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:614
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:847
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:261
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:446
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:54
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:2804
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:783
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:79
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:1810
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3092
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:561
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:224
static bool save_action_ui_name(struct section_file *sfile, int act, const char *entry_name)
Definition rulesave.c:807
char * get_parser_buffer(void)
Definition ruleset.c:553
char * get_script_buffer(void)
Definition ruleset.c:545
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleset.h:107
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleset.h:84
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleset.h:101
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleset.h:85
#define GAME_DEFAULT_ACH_VALUE
Definition ruleset.h:78
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleset.h:83
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleset.h:94
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleset.h:96
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleset.h:109
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleset.h:104
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleset.h:86
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleset.h:97
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleset.h:99
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleset.h:87
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleset.h:82
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleset.h:77
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleset.h:106
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleset.h:79
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleset.h:80
#define RULESET_CAPABILITIES
Definition ruleset.h:24
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleset.h:72
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleset.h:81
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleset.h:89
#define GAME_DEFAULT_NATIONALITY
Definition ruleset.h:74
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleset.h:71
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleset.h:105
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleset.h:102
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleset.h:73
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleset.h:95
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleset.h:76
#define GAME_DEFAULT_CONVERT_SPEED
Definition ruleset.h:75
int setting_int_get(struct setting *pset)
Definition settings.c:3608
bool setting_locked(const struct setting *pset)
Definition settings.c:4420
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3191
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3690
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5349
const char * setting_name(const struct setting *pset)
Definition settings.c:3162
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4056
char * setting_str_get(struct setting *pset)
Definition settings.c:3679
bool setting_bool_get(struct setting *pset)
Definition settings.c:3496
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:3875
int read_enum_value(const struct setting *pset)
Definition settings.c:3805
#define settings_iterate(_level, _pset)
Definition settings.h:177
#define settings_iterate_end
Definition settings.h:183
bool make_dir(const char *pathname)
Definition shared.c:1772
#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)
struct requirement_vector reqs
Definition actions.h:574
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:578
bool actor_consuming_always
Definition actions.h:412
int max_distance
Definition actions.h:395
bool quiet
Definition actions.h:402
enum action_result result
Definition actions.h:382
char ui_name[MAX_LEN_NAME]
Definition actions.h:398
bv_actions blocked_by
Definition actions.h:406
enum action_target_kind target_kind
Definition actions.h:386
int min_distance
Definition actions.h:395
bool inherited_root_req
Definition tech.h:133
int border_sq
Definition base.h:44
int vision_main_sq
Definition base.h:45
enum base_gui_type gui_type
Definition base.h:43
int vision_invis_sq
Definition base.h:46
int vision_subs_sq
Definition base.h:47
struct civ_game::@29 rgame
int named_teams
Definition game.h:286
size_t as_count
Definition game.h:285
struct rgbcolor_list * plr_colors
Definition game.h:242
const char ** allowed_govs
Definition game.h:277
int upgrade_veteran_loss
Definition game.h:198
struct rgbcolor * plr_bg_color
Definition game.h:102
int incite_total_factor
Definition game.h:149
int init_vis_radius_sq
Definition game.h:151
struct civ_game::@30::@34 server
bool vision_reveal_tiles
Definition game.h:199
char * description_file
Definition game.h:273
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
int base_incite_cost
Definition game.h:133
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:107
struct packet_game_info info
Definition game.h:89
int autoupgrade_veteran_loss
Definition game.h:131
int start_year
Definition game.h:190
int incite_improvement_factor
Definition game.h:148
struct section_file * luadata
Definition game.h:244
char ** embedded_nations
Definition game.h:275
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:108
struct civ_game::@30::@34::@39 ruledit
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:270
const char ** allowed_terrains
Definition game.h:280
char * ruleset_description
Definition game.h:85
size_t ag_count
Definition game.h:279
const char ** allowed_styles
Definition game.h:283
size_t embedded_nations_count
Definition game.h:276
int incite_unit_factor
Definition game.h:150
char * ruleset_capabilities
Definition game.h:86
int ransom_gold
Definition game.h:174
size_t at_count
Definition game.h:282
struct veteran_system * veteran
Definition game.h:100
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::@41::@43 server
bool ocean_resources
Definition map_types.h:105
struct requirement_vector receiver_reqs
Definition diptreaty.h:57
struct requirement_vector giver_reqs
Definition diptreaty.h:56
enum clause_type type
Definition diptreaty.h:54
bool enabled
Definition diptreaty.h:55
struct section_file * sfile
Definition rulesave.c:752
int value
Definition effects.h:349
bool ruledit_do_not_save
Definition effects.h:357
struct requirement_vector reqs
Definition effects.h:353
enum effect_type type
Definition effects.h:341
Definition climisc.h:82
int init_buildings[MAX_NUM_BUILDING_LIST]
Definition nation.h:122
struct nation_list * conflicts_with
Definition nation.h:139
struct name_translation noun_plural
Definition nation.h:101
char flag_graphic_str[MAX_LEN_NAME]
Definition nation.h:102
struct name_translation adjective
Definition nation.h:100
struct rgbcolor * rgb
Definition nation.h:142
struct trait_limits * traits
Definition nation.h:144
char flag_graphic_alt[MAX_LEN_NAME]
Definition nation.h:103
struct government * init_government
Definition nation.h:123
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:124
struct nation_leader_list * leaders
Definition nation.h:104
char * legend
Definition nation.h:106
enum barbarian_type barb_type
Definition nation.h:109
char * translation_domain
Definition nation.h:99
struct nation_type::@50::@52 server
struct nation_style * style
Definition nation.h:105
struct nation_city_list * default_cities
Definition nation.h:130
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:121
struct nation_list * civilwar_nations
Definition nation.h:134
bool is_playable
Definition nation.h:108
char positive_year_label[MAX_LEN_NAME]
char negative_year_label[MAX_LEN_NAME]
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
bool tech_steal_allow_holes
enum gameloss_style gameloss_style
enum goods_selection_method goods_selection
enum gold_upkeep_style gold_upkeep_style
bool damage_reduces_bombard_rate
int nuke_defender_survival_chance_pct
enum tech_upkeep_style tech_upkeep_style
bool tech_trade_loss_allow_holes
int granary_food_ini[MAX_GRANARY_INIS]
enum free_tech_method free_tech_method
bool steal_maps_reveals_all_cities
bool only_real_fight_makes_veteran
int low_firepower_pearl_harbour
enum tech_leakage_style tech_leakage
bool airlift_from_always_enabled
bool only_killing_makes_veteran
bool poison_empties_food_stock
bv_actions diplchance_initial_odds
bool tech_trade_allow_holes
int low_firepower_nonnat_bombard
bool tech_parasite_allow_holes
int low_firepower_combat_bonus
int border_city_permanent_radius_sq
int low_firepower_badwallattacker
bool airlift_to_always_enabled
enum wonder_visib_type small_wonder_visibility
enum tech_cost_style tech_cost_style
bool combat_odds_scaled_veterancy
int civil_war_bonus_celebrating
int min_city_center_output[O_LAST]
char preferred_soundset[MAX_LEN_NAME]
char version[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char alt_dir[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
struct universal source
enum road_gui_type gui_type
Definition road.h:84
enum road_move_mode move_mode
Definition road.h:79
int tile_bonus[O_LAST]
Definition road.h:82
int tile_incr_const[O_LAST]
Definition road.h:80
int tile_incr[O_LAST]
Definition road.h:81
int move_cost
Definition road.h:78
enum road_compat compat
Definition road.h:83
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
struct combat_bonus_list * bonuses
Definition unittype.h:507
enum universals_n kind
Definition fc_types.h:758
int base_raise_chance
Definition unittype.h:471
struct name_translation name
Definition unittype.h:468
int work_raise_chance
Definition unittype.h:472
struct veteran_level * definitions
Definition unittype.h:478
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:969
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:506
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * tech_flag_id_name_cb(enum tech_flag_id flag)
Definition tech.c:423
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:342
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Definition tech.c:216
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:299
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:435
#define advance_re_active_iterate(_p)
Definition tech.h:275
#define A_NEVER
Definition tech.h:51
#define tech_class_iterate_end
Definition tech.h:204
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:108
@ AR_TWO
Definition tech.h:112
@ AR_ROOT
Definition tech.h:113
@ AR_ONE
Definition tech.h:111
#define advance_re_active_iterate_end
Definition tech.h:279
#define A_NONE
Definition tech.h:43
#define tech_class_iterate(_p)
Definition tech.h:198
#define A_LAST
Definition tech.h:45
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:805
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:235
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:817
#define terrain_type_iterate(_p)
Definition terrain.h:358
#define terrain_type_iterate_end
Definition terrain.h:364
#define MAX_NUM_TERRAINS
Definition terrain.h:64
#define terrain_has_flag(terr, flag)
Definition terrain.h:269
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:146
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:1906
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:193
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1693
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Definition unittype.c:1894
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Definition unittype.c:1957
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1969
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
#define unit_type_re_active_iterate(_p)
Definition unittype.h:853
#define combat_bonus_list_iterate_end
Definition unittype.h:463
#define L_FIRST
Definition unittype.h:333
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:461
#define unit_class_iterate(_p)
Definition unittype.h:879
#define unit_class_re_active_iterate_end
Definition unittype.h:895
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:316
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
#define UTYF_LAST_USER_FLAG
Definition unittype.h:315
#define L_LAST
Definition unittype.h:420
#define unit_class_re_active_iterate(_p)
Definition unittype.h:891
#define uclass_index(_c_)
Definition unittype.h:729
#define unit_class_iterate_end
Definition unittype.h:886
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:113
#define unit_type_re_active_iterate_end
Definition unittype.h:857
const char * freeciv_datafile_version(void)
Definition version.c:186