Freeciv-3.1: /fast/freeciv/nightly/S3_1/tools/ruleutil/rulesave.c Source File

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/**********************************************************************/
54 static 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
60 comment_file_header(sfile);
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/**********************************************************************/
79 static 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/**********************************************************************/
98 static 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/**********************************************************************/
118 static 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,
125 untranslated_name(name),
126 "%s.name", path);
127 entry_str_set_gt_marking(mod_entry, TRUE);
128 if (strcmp(skip_intl_qualifier_prefix(untranslated_name(name)),
129 rule_name_get(name))) {
130 secfile_insert_str(sfile,
131 rule_name_get(name),
132 "%s.rule_name", path);
133 }
134
135 return TRUE;
136}
137
138/**********************************************************************/
141 static 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
150 requirement_vector_iterate(reqs, preq) {
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 }
160 } requirement_vector_iterate_end;
161
162 i = 0;
163 requirement_vector_iterate(reqs, preq) {
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) {
175 secfile_insert_bool(sfile,
176 preq->survives,
177 "%s.%s%d.survives", path, entry, i);
178 }
179
180 if (includes_negated) {
181 secfile_insert_bool(sfile,
182 preq->present,
183 "%s.%s%d.present", path, entry, i);
184 }
185
186 if (includes_quiet) {
187 secfile_insert_bool(sfile,
188 preq->quiet,
189 "%s.%s%d.quiet", path, entry, i);
190 }
191
192 i++;
193 } requirement_vector_iterate_end;
194
195 return TRUE;
196}
197
198/**********************************************************************/
201 static 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/**********************************************************************/
224 static 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 {
231 secfile_insert_str(sfile, advance_rule_name(padv),
232 "%s.%s", path, entry);
233 }
234
235 return TRUE;
236}
237
238/**********************************************************************/
241 static 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 {
251 secfile_insert_str(sfile, terrain_rule_name(save),
252 "%s.%s", path, entry);
253 }
254
255 return TRUE;
256}
257
258/**********************************************************************/
261 static 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/**********************************************************************/
274 static 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/**********************************************************************/
298 static 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/**********************************************************************/
321 static 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 }
335 } unit_class_iterate_end;
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/**********************************************************************/
348 static 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/**********************************************************************/
370 static bool save_ruleset_file(struct section_file *sfile, const char *filename)
371{
372 return secfile_save(sfile, filename, 0, FZ_PLAIN);
373}
374
375/**********************************************************************/
378 static 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;
390 improvement_re_active_iterate(pb) {
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 }
438 } improvement_re_active_iterate_end;
439
440 return save_ruleset_file(sfile, filename);
441}
442
443/**********************************************************************/
446 static 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;
459 styles_re_active_iterate(pstyle) {
460 char path[512];
461
462 fc_snprintf(path, sizeof(path), "style_%d", sect_idx++);
463
464 save_name_translation(sfile, &(pstyle->name), path);
465 } styles_re_active_iterate_end;
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;
490 music_styles_iterate(pmus) {
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");
499 } music_styles_iterate_end;
500
501 return save_ruleset_file(sfile, filename);
502}
503
504/**********************************************************************/
510 static bool save_action_auto_uflag_block(struct section_file *sfile,
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 =
521 action_auto_perf_by_number(aap);
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 }
540 } requirement_vector_iterate_end;
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/**********************************************************************/
561 static 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 =
570 action_auto_perf_by_number(aap);
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/**********************************************************************/
604 static bool unexpected_non_otype(const struct requirement *req)
605{
606 return !(req->source.kind == VUT_OTYPE && req->present);
607}
608
609/**********************************************************************/
614 static 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,
627 unexpected_non_otype)
628 && save_action_auto_actions(sfile, aap, action_path));
629}
630
631/**********************************************************************/
634 static 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;
646 specialist_type_iterate(sp) {
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))) {
655 secfile_insert_str(sfile, 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
668 } specialist_type_iterate_end;
669
670 if (game.info.celebratesize != GAME_DEFAULT_CELEBRATESIZE) {
671 secfile_insert_int(sfile, game.info.celebratesize,
672 "parameters.celebrate_size_limit");
673 }
674 if (game.info.add_to_size_limit != GAME_DEFAULT_ADDTOSIZE) {
675 secfile_insert_int(sfile, game.info.add_to_size_limit,
676 "parameters.add_to_size_limit");
677 }
678 if (game.info.angrycitizen != GAME_DEFAULT_ANGRYCITIZEN) {
679 secfile_insert_bool(sfile, game.info.angrycitizen,
680 "parameters.angry_citizens");
681 }
682 if (game.info.changable_tax != GAME_DEFAULT_CHANGABLE_TAX) {
683 secfile_insert_bool(sfile, game.info.changable_tax,
684 "parameters.changable_tax");
685 }
686 if (game.info.forced_science != 0) {
687 secfile_insert_int(sfile, game.info.forced_science,
688 "parameters.forced_science");
689 }
690 if (game.info.forced_luxury != 100) {
691 secfile_insert_int(sfile, game.info.forced_luxury,
692 "parameters.forced_luxury");
693 }
694 if (game.info.forced_gold != 0) {
695 secfile_insert_int(sfile, game.info.forced_gold,
696 "parameters.forced_gold");
697 }
698 if (game.server.vision_reveal_tiles != GAME_DEFAULT_VISION_REVEAL_TILES) {
699 secfile_insert_bool(sfile, game.server.vision_reveal_tiles,
700 "parameters.vision_reveal_tiles");
701 }
702 if (game.info.pop_report_zeroes != 1) {
703 secfile_insert_int(sfile, game.info.pop_report_zeroes,
704 "parameters.pop_report_zeroes");
705 }
706 if (game.info.citizen_nationality != GAME_DEFAULT_NATIONALITY) {
707 secfile_insert_bool(sfile, game.info.citizen_nationality,
708 "citizen.nationality");
709 }
710 if (game.info.citizen_convert_speed != GAME_DEFAULT_CONVERT_SPEED) {
711 secfile_insert_int(sfile, game.info.citizen_convert_speed,
712 "citizen.convert_speed");
713 }
714 if (game.info.conquest_convert_pct != 0) {
715 secfile_insert_int(sfile, game.info.conquest_convert_pct,
716 "citizen.conquest_convert_pct");
717 }
718 if (game.info.citizen_partisans_pct != 0) {
719 secfile_insert_int(sfile, game.info.citizen_partisans_pct,
720 "citizen.partisans_pct");
721 }
722
723 save_muuk_action_auto(sfile, ACTION_AUTO_UPKEEP_FOOD,
724 "food");
725 if (game.info.muuk_food_wipe != RS_DEFAULT_MUUK_FOOD_WIPE) {
726 secfile_insert_bool(sfile, game.info.muuk_food_wipe,
727 "missing_unit_upkeep.food_wipe");
728 }
729
730 save_muuk_action_auto(sfile, ACTION_AUTO_UPKEEP_GOLD,
731 "gold");
732 if (game.info.muuk_gold_wipe != RS_DEFAULT_MUUK_GOLD_WIPE) {
733 secfile_insert_bool(sfile, game.info.muuk_gold_wipe,
734 "missing_unit_upkeep.gold_wipe");
735 }
736
737 save_muuk_action_auto(sfile, ACTION_AUTO_UPKEEP_SHIELD,
738 "shield");
739 if (game.info.muuk_shield_wipe != RS_DEFAULT_MUUK_SHIELD_WIPE) {
740 secfile_insert_bool(sfile, game.info.muuk_shield_wipe,
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**************************************************************************/
750 typedef struct {
751 int idx;
752 struct section_file *sfile;
753} effect_cb_data;
754
755/**********************************************************************/
758 static 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
770 secfile_insert_str(cbdata->sfile,
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/**********************************************************************/
783 static 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/**********************************************************************/
807 static 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/**********************************************************************/
827 static 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) {
833 return secfile_insert_str(sfile, RS_ACTION_NO_MAX_DISTANCE,
834 "actions.%s",
835 action_max_range_ruleset_var_name(act)) != NULL;
836 } else {
837 return save_default_int(sfile, action_by_number(act)->max_distance,
838 action_max_range_default(paction->result),
839 "actions",
840 action_max_range_ruleset_var_name(act));
841 }
842}
843
844/**********************************************************************/
847 static 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,
855 action_min_range_default(paction->result),
856 "actions",
857 action_min_range_ruleset_var_name(act));
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/**********************************************************************/
873 static 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
884 secfile_insert_enum(sfile,
885 action_by_number(act)->target_kind,
886 action_target_kind,
887 "actions.%s",
888 action_target_kind_ruleset_var_name(act));
889 }
890
891 return TRUE;
892}
893
894/**********************************************************************/
897 static bool save_action_actor_consuming_always(struct section_file *sfile,
898 action_id act)
899{
900 if (action_actor_consuming_always_ruleset_var_name(act) != NULL) {
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,
910 action_by_number(act)->actor_consuming_always,
911 RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS,
912 "actions",
913 action_actor_consuming_always_ruleset_var_name(act));
914 }
915
916 return TRUE;
917}
918
919/**********************************************************************/
922 static 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 }
956 } action_iterate_end;
957
958 if (secfile_insert_enum_vec_comment(
959 sfile, &action_vec, i, gen_action, comment, "actions.%s",
960 action_blocked_by_ruleset_var_name(paction))
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/**********************************************************************/
975 static bool save_action_post_success_force(struct section_file *sfile,
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",
993 action_post_success_forced_ruleset_var_name(paction));
994 if (!save_action_auto_actions(sfile, performer_slot, action_list_path)) {
995 return FALSE;
996 }
997
998 return TRUE;
999}
1000
1001/**********************************************************************/
1004 static 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 }
1023 } action_iterate_end;
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/**********************************************************************/
1038 static 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) {
1059 secfile_insert_str(sfile, game.server.ruledit.description_file,
1060 "ruledit.description_file");
1061 }
1062
1063 if (game.control.preferred_tileset[0] != '\0') {
1064 secfile_insert_str(sfile, game.control.preferred_tileset,
1065 "tileset.preferred");
1066 }
1067 if (game.control.preferred_soundset[0] != '\0') {
1068 secfile_insert_str(sfile, game.control.preferred_soundset,
1069 "soundset.preferred");
1070 }
1071 if (game.control.preferred_musicset[0] != '\0') {
1072 secfile_insert_str(sfile, game.control.preferred_musicset,
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) {
1093 secfile_insert_str(sfile, game.ruleset_description,
1094 "about.description");
1095 } else {
1096 secfile_insert_filereference(sfile, game.server.ruledit.description_file,
1097 "about.description");
1098 }
1099 }
1100
1101 if (game.ruleset_capabilities != NULL) {
1102 secfile_insert_str(sfile, game.ruleset_capabilities,
1103 "about.capabilities");
1104 } else {
1105 secfile_insert_str(sfile, "", "about.capabilities");
1106 }
1107
1108 save_tech_list(sfile, game.rgame.global_init_techs,
1109 "options", "global_init_techs");
1110 save_building_list(sfile, game.rgame.global_init_buildings,
1111 "options", "global_init_buildings");
1112
1113 save_default_bool(sfile, game.control.popup_tech_help,
1114 FALSE,
1115 "options.popup_tech_help", NULL);
1116 save_default_int(sfile, game.info.base_pollution,
1117 RS_DEFAULT_BASE_POLLUTION,
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
1132 save_default_int(sfile, game.info.happy_cost,
1133 RS_DEFAULT_HAPPY_COST,
1134 "civstyle.happy_cost", NULL);
1135 save_default_int(sfile, game.info.food_cost,
1136 RS_DEFAULT_FOOD_COST,
1137 "civstyle.food_cost", NULL);
1138 save_default_bool(sfile, game.info.civil_war_enabled,
1139 TRUE,
1140 "civstyle.civil_war_enabled", NULL);
1141 save_default_int(sfile, game.info.civil_war_bonus_celebrating,
1142 RS_DEFAULT_CIVIL_WAR_CELEB,
1143 "civstyle.civil_war_bonus_celebrating", NULL);
1144 save_default_int(sfile, game.info.civil_war_bonus_unhappy,
1145 RS_DEFAULT_CIVIL_WAR_UNHAPPY,
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);
1152 save_default_int(sfile, game.info.base_bribe_cost,
1153 RS_DEFAULT_BASE_BRIBE_COST,
1154 "civstyle.base_bribe_cost", NULL);
1155 save_default_int(sfile, game.server.ransom_gold,
1156 RS_DEFAULT_RANSOM_GOLD,
1157 "civstyle.ransom_gold", NULL);
1158 save_default_bool(sfile, game.info.pillage_select,
1159 RS_DEFAULT_PILLAGE_SELECT,
1160 "civstyle.pillage_select", NULL);
1161 save_default_bool(sfile, game.info.tech_steal_allow_holes,
1162 RS_DEFAULT_TECH_STEAL_HOLES,
1163 "civstyle.tech_steal_allow_holes", NULL);
1164 save_default_bool(sfile, game.info.tech_trade_allow_holes,
1165 RS_DEFAULT_TECH_TRADE_HOLES,
1166 "civstyle.tech_trade_allow_holes", NULL);
1167 save_default_bool(sfile, game.info.tech_trade_loss_allow_holes,
1168 RS_DEFAULT_TECH_TRADE_LOSS_HOLES,
1169 "civstyle.tech_trade_loss_allow_holes", NULL);
1170 save_default_bool(sfile, game.info.tech_parasite_allow_holes,
1171 RS_DEFAULT_TECH_PARASITE_HOLES,
1172 "civstyle.tech_parasite_allow_holes", NULL);
1173 save_default_bool(sfile, game.info.tech_loss_allow_holes,
1174 RS_DEFAULT_TECH_LOSS_HOLES,
1175 "civstyle.tech_loss_allow_holes", NULL);
1176 save_default_int(sfile, game.server.upgrade_veteran_loss,
1177 RS_DEFAULT_UPGRADE_VETERAN_LOSS,
1178 "civstyle.upgrade_veteran_loss", NULL);
1179 save_default_int(sfile, game.server.autoupgrade_veteran_loss,
1180 RS_DEFAULT_UPGRADE_VETERAN_LOSS,
1181 "civstyle.autoupgrade_veteran_loss", NULL);
1182
1183 secfile_insert_int_vec(sfile, game.info.granary_food_ini,
1184 game.info.granary_num_inis,
1185 "civstyle.granary_food_ini");
1186
1187 save_default_int(sfile, game.info.granary_food_inc,
1188 RS_DEFAULT_GRANARY_FOOD_INC,
1189 "civstyle.granary_food_inc", NULL);
1190
1191 output_type_iterate(o) {
1192 char buffer[256];
1193
1194 fc_snprintf(buffer, sizeof(buffer),
1195 "civstyle.min_city_center_%s",
1196 get_output_identifier(o));
1197
1198 save_default_int(sfile, game.info.min_city_center_output[o],
1199 RS_DEFAULT_CITY_CENTER_OUTPUT,
1200 buffer, NULL);
1201 } output_type_iterate_end;
1202
1203 save_default_int(sfile, game.server.init_vis_radius_sq,
1204 RS_DEFAULT_VIS_RADIUS_SQ,
1205 "civstyle.init_vis_radius_sq", NULL);
1206 save_default_int(sfile, game.info.init_city_radius_sq,
1207 RS_DEFAULT_CITY_RADIUS_SQ,
1208 "civstyle.init_city_radius_sq", NULL);
1209 if (0 != fc_strcasecmp(gold_upkeep_style_name(game.info.gold_upkeep_style),
1210 RS_DEFAULT_GOLD_UPKEEP_STYLE)) {
1211 secfile_insert_str(sfile,
1212 gold_upkeep_style_name(game.info.gold_upkeep_style),
1213 "civstyle.gold_upkeep_style");
1214 }
1215 save_default_int(sfile, game.info.granularity,
1216 1, "civstyle.output_granularity", NULL);
1217 save_default_bool(sfile, game.info.airlift_from_always_enabled,
1218 FALSE, "civstyle.airlift_from_always_enabled", NULL);
1219 save_default_bool(sfile, game.info.airlift_to_always_enabled,
1220 TRUE, "civstyle.airlift_to_always_enabled", NULL);
1221
1222 if (fc_strcasecmp(wonder_visib_type_name(game.info.small_wonder_visibility),
1223 RS_DEFAULT_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
1229 save_default_bool(sfile, game.info.illness_on,
1230 RS_DEFAULT_ILLNESS_ON,
1231 "illness.illness_on", NULL);
1232 save_default_int(sfile, game.info.illness_base_factor,
1233 RS_DEFAULT_ILLNESS_BASE_FACTOR,
1234 "illness.illness_base_factor", NULL);
1235 save_default_int(sfile, game.info.illness_min_size,
1236 RS_DEFAULT_ILLNESS_MIN_SIZE,
1237 "illness.illness_min_size", NULL);
1238 save_default_int(sfile, game.info.illness_trade_infection,
1239 RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT,
1240 "illness.illness_trade_infection", NULL);
1241 save_default_int(sfile, game.info.illness_pollution_factor,
1242 RS_DEFAULT_ILLNESS_POLLUTION_PCT,
1243 "illness.illness_pollution_factor", NULL);
1244 save_default_int(sfile, game.server.base_incite_cost,
1245 RS_DEFAULT_INCITE_BASE_COST,
1246 "incite_cost.base_incite_cost", NULL);
1247 save_default_int(sfile, game.server.incite_improvement_factor,
1248 RS_DEFAULT_INCITE_IMPROVEMENT_FCT,
1249 "incite_cost.improvement_factor", NULL);
1250 save_default_int(sfile, game.server.incite_unit_factor,
1251 RS_DEFAULT_INCITE_UNIT_FCT,
1252 "incite_cost.unit_factor", NULL);
1253 save_default_int(sfile, game.server.incite_total_factor,
1254 RS_DEFAULT_INCITE_TOTAL_FCT,
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 =
1271 action_auto_perf_by_number(ACTION_AUTO_MOVED_ADJ);
1272
1273 save_action_auto_actions(sfile, ACTION_AUTO_MOVED_ADJ,
1274 "auto_attack.attack_actions");
1275
1276 save_reqs_vector(sfile, &auto_perf->reqs,
1277 "auto_attack", "if_attacker");
1278 }
1279
1280 if (!save_bv_actions(sfile, game.info.diplchance_initial_odds,
1281 "actions.diplchance_initial_odds")) {
1282 return FALSE;
1283 }
1284
1285 if (!save_action_post_success_force(sfile, ACTION_AUTO_POST_BRIBE,
1286 action_by_number(
1287 ACTION_SPY_BRIBE_UNIT))) {
1288 log_error("Didn't save all post success forced actions.");
1289 return FALSE;
1290 }
1291
1292 if (!save_action_post_success_force(sfile, ACTION_AUTO_POST_ATTACK,
1293 action_by_number(ACTION_ATTACK))) {
1294 log_error("Didn't save all post success forced actions.");
1295 return FALSE;
1296 }
1297
1298 if (!save_action_auto_actions(sfile, ACTION_AUTO_ESCAPE_CITY,
1299 "actions.escape_city")) {
1300 log_error("Didn't save all escape city forced actions.");
1301 return FALSE;
1302 }
1303
1304 if (!save_action_auto_actions(sfile, ACTION_AUTO_ESCAPE_STACK,
1305 "actions.unit_stack_death")) {
1306 log_error("Didn't save all escape unit stack death forced actions.");
1307 return FALSE;
1308 }
1309
1310 save_default_bool(sfile, game.info.poison_empties_food_stock,
1311 RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK,
1312 "actions.poison_empties_food_stock", NULL);
1313
1314 save_default_bool(sfile, game.info.steal_maps_reveals_all_cities,
1315 RS_DEFAULT_STEAL_MAP_REVEALS_CITIES,
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);
1325 save_action_actor_consuming_always(sfile, act_id);
1326 save_action_blocked_by(sfile, act);
1327 } action_iterate_end;
1328
1329 i = 0;
1330 action_iterate(act) {
1331 if (action_by_number(act)->quiet) {
1332 action_vec[i] = act;
1333 i++;
1334 }
1335 } action_iterate_end;
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;
1346 action_enablers_iterate(pae) {
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");
1360 } action_enablers_iterate_end;
1361
1362 save_default_bool(sfile, game.info.tired_attack,
1363 RS_DEFAULT_TIRED_ATTACK,
1364 "combat_rules.tired_attack", NULL);
1365 save_default_bool(sfile, game.info.only_killing_makes_veteran,
1366 RS_DEFAULT_ONLY_KILLING_VETERAN,
1367 "combat_rules.only_killing_makes_veteran", NULL);
1368 save_default_bool(sfile, game.info.only_real_fight_makes_veteran,
1369 RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN,
1370 "combat_rules.only_real_fight_makes_veteran", NULL);
1371 save_default_bool(sfile, game.info.combat_odds_scaled_veterancy,
1372 RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY,
1373 "combat_rules.combat_odds_scaled_veterancy", NULL);
1374 save_default_bool(sfile, game.info.damage_reduces_bombard_rate,
1375 RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE,
1376 "combat_rules.damage_reduces_bombard_rate", NULL);
1377 save_default_int(sfile, game.info.low_firepower_badwallattacker, 1,
1378 "combat_rules.low_firepower_badwallattacker", NULL);
1379 save_default_int(sfile, game.info.low_firepower_pearl_harbour, 1,
1380 "combat_rules.low_firepower_pearl_harbour", NULL);
1381 save_default_int(sfile, game.info.low_firepower_combat_bonus, 1,
1382 "combat_rules.low_firepower_combat_bonus", NULL);
1383 save_default_int(sfile, game.info.low_firepower_nonnat_bombard, 1,
1384 "combat_rules.low_firepower_nonnat_bombard", NULL);
1385 save_default_int(sfile, game.info.nuke_pop_loss_pct,
1386 RS_DEFAULT_NUKE_POP_LOSS_PCT,
1387 "combat_rules.nuke_pop_loss_pct", NULL);
1388 save_default_int(sfile, game.info.nuke_defender_survival_chance_pct,
1389 RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT,
1390 "combat_rules.nuke_defender_survival_chance_pct", NULL);
1391 save_default_int(sfile, game.info.border_city_radius_sq,
1392 RS_DEFAULT_BORDER_RADIUS_SQ_CITY,
1393 "borders.radius_sq_city", NULL);
1394 save_default_int(sfile, game.info.border_size_effect,
1395 RS_DEFAULT_BORDER_SIZE_EFFECT,
1396 "borders.size_effect", NULL);
1397 save_default_int(sfile, game.info.border_city_permanent_radius_sq,
1398 RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT,
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");
1402 save_default_int(sfile, game.info.base_tech_cost,
1403 RS_DEFAULT_BASE_TECH_COST,
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");
1409 save_default_int(sfile, game.info.tech_upkeep_divider,
1410 RS_DEFAULT_TECH_UPKEEP_DIVIDER,
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
1415 save_default_int(sfile, game.info.culture_vic_points,
1416 RS_DEFAULT_CULTURE_VIC_POINTS,
1417 "culture.victory_min_points", NULL);
1418 save_default_int(sfile, game.info.culture_vic_lead,
1419 RS_DEFAULT_CULTURE_VIC_LEAD,
1420 "culture.victory_lead_pct", NULL);
1421 save_default_int(sfile, game.info.culture_migration_pml,
1422 RS_DEFAULT_CULTURE_MIGRATION_PML,
1423 "culture.migration_pml", NULL);
1424 save_default_int(sfile, game.info.history_interest_pml,
1425 RS_DEFAULT_HISTORY_INTEREST_PML,
1426 "culture.history_interest_pml", NULL);
1427
1428 save_default_bool(sfile, game.calendar.calendar_skip_0,
1429 RS_DEFAULT_CALENDAR_SKIP_0,
1430 "calendar.skip_year_0", NULL);
1431 save_default_int(sfile, game.server.start_year,
1432 GAME_DEFAULT_START_YEAR,
1433 "calendar.start_year", NULL);
1434 save_default_int(sfile, game.calendar.calendar_fragments,
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') {
1439 secfile_insert_str(sfile, game.calendar.calendar_fragment_name[i],
1440 "calendar.fragment_name%d", i);
1441 }
1442 }
1443
1444 if (strcmp(game.calendar.positive_year_label, RS_DEFAULT_POS_YEAR_LABEL)) {
1445 secfile_insert_str(sfile, game.calendar.positive_year_label,
1446 "calendar.positive_label");
1447 }
1448 if (strcmp(game.calendar.negative_year_label, RS_DEFAULT_NEG_YEAR_LABEL)) {
1449 secfile_insert_str(sfile, game.calendar.negative_year_label,
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;
1458 rgbcolor_list_iterate(game.server.plr_colors, pcol) {
1459 rgbcolor_save(sfile, pcol, "playercolors.colorlist%d", col_idx++);
1460 } rgbcolor_list_iterate_end;
1461
1462
1463 if (game.server.ruledit.named_teams > 0) {
1464 for (i = 0; i < game.server.ruledit.named_teams; i++) {
1465 tnames[i] = team_slot_rule_name(team_slot_by_number(i));
1466 }
1467
1468 secfile_insert_str_vec(sfile, tnames,
1469 game.server.ruledit.named_teams,
1470 "teams.names");
1471 }
1472
1473 comment_disasters(sfile);
1474
1475 sect_idx = 0;
1476 disaster_type_iterate(pd) {
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 }
1503 } disaster_type_iterate_end;
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,
1519 GAME_DEFAULT_ACH_UNIQUE,
1520 path, "unique");
1521 save_default_int(sfile, pach->value,
1522 GAME_DEFAULT_ACH_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
1532 } achievements_iterate_end;
1533
1534 comment_trade_settings(sfile);
1535
1536 set_count = 0;
1537 for (trt = 0; trt < TRT_LAST; trt++) {
1538 struct trade_route_settings *set = trade_route_settings_by_type(trt);
1539 const char *cancelling = trade_route_cancelling_type_name(set->cancelling);
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
1547 secfile_insert_str(sfile, trade_route_type_name(trt),
1548 "%s.type", path);
1549 secfile_insert_int(sfile, set->trade_pct,
1550 "%s.pct", path);
1551 secfile_insert_str(sfile, cancelling,
1552 "%s.cancelling", path);
1553 secfile_insert_str(sfile, trade_route_bonus_type_name(set->bonus_type),
1554 "%s.bonus", path);
1555 }
1556 }
1557
1558 save_default_int(sfile, game.info.min_trade_route_val,
1559 0, "trade.min_trade_route_val", NULL);
1560
1561 if (game.info.goods_selection != RS_DEFAULT_GOODS_SELECTION) {
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;
1570 goods_type_re_active_iterate(pgood) {
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");
1598 } goods_type_re_active_iterate_end;
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 }
1625 } settings_iterate_end;
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:
1634 secfile_insert_bool(sfile, setting_bool_get(pset),
1635 "settings.set%d.value", set_count);
1636 break;
1637 case SST_INT:
1638 secfile_insert_int(sfile, setting_int_get(pset),
1639 "settings.set%d.value", set_count);
1640 break;
1641 case SST_STRING:
1642 secfile_insert_str(sfile, setting_str_get(pset),
1643 "settings.set%d.value", set_count);
1644 break;
1645 case SST_ENUM:
1646 secfile_insert_enum_data(sfile, read_enum_value(pset), FALSE,
1647 setting_enum_secfile_str, pset,
1648 "settings.set%d.value", set_count);
1649 break;
1650 case SST_BITWISE:
1651 secfile_insert_enum_data(sfile, setting_bitwise_get(pset), TRUE,
1652 setting_bitwise_secfile_str, pset,
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) {
1663 secfile_insert_bool(sfile, setting_locked(pset),
1664 "settings.set%d.lock", set_count);
1665 }
1666
1667 set_count++;
1668 }
1669 } settings_iterate_end;
1670
1671 return save_ruleset_file(sfile, filename);
1672}
1673
1674/**********************************************************************/
1677 static 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;
1692 governments_re_active_iterate(pg) {
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
1715 title = ruler_title_male_untranslated_name(prtitle);
1716 if (title != NULL) {
1717 secfile_insert_str(sfile, title,
1718 "%s.ruler_male_title", path);
1719 }
1720
1721 title = ruler_title_female_untranslated_name(prtitle);
1722 if (title != NULL) {
1723 secfile_insert_str(sfile, title,
1724 "%s.ruler_female_title", path);
1725 }
1726 }
1727
1728 save_strvec(sfile, pg->helptext, path, "helptext");
1729
1730 } governments_re_active_iterate_end;
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 }
1756 } multipliers_iterate_end;
1757
1758 return save_ruleset_file(sfile, filename);
1759}
1760
1761/**********************************************************************/
1764 static 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/**********************************************************************/
1810 static 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 }
1838 } nation_sets_iterate_end;
1839 nation_groups_iterate(pgroup) {
1840 if (nation_is_in_group(pnat, pgroup)) {
1841 list_items[set_count++] = nation_group_rule_name(pgroup);
1842 }
1843 } nation_groups_iterate_end;
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;
1850 nation_list_iterate(pnat->server.conflicts_with, pconfl) {
1851 list_items[set_count++] = nation_rule_name(pconfl);
1852 } nation_list_iterate_end;
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++);
1863 } nation_leader_list_iterate_end;
1864
1865 if (pnat->server.rgb != NULL) {
1866 rgbcolor_save(sfile, pnat->server.rgb, "%s.color", path);
1867 }
1868
1869 save_traits(pnat->server.traits, game.server.default_traits,
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)) {
1893 secfile_insert_str(sfile, government_rule_name(pgov),
1894 "%s.ruler_titles%d.government", path, subsect_idx);
1895 secfile_insert_str(sfile, ruler_title_male_untranslated_name(prtitle),
1896 "%s.ruler_titles%d.male_title", path, subsect_idx);
1897 secfile_insert_str(sfile, ruler_title_female_untranslated_name(prtitle),
1898 "%s.ruler_titles%d.female_title", path, subsect_idx++);
1899 }
1900 } governments_iterate_end;
1901
1902 secfile_insert_str(sfile, style_rule_name(pnat->style), "%s.style", path);
1903
1904 set_count = 0;
1905 nation_list_iterate(pnat->server.civilwar_nations, pconfl) {
1906 list_items[set_count++] = nation_rule_name(pconfl);
1907 } nation_list_iterate_end;
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) {
1917 secfile_insert_str(sfile, government_rule_name(pnat->init_government),
1918 "%s.init_government", path);
1919 }
1920
1921 set_count = 0;
1922 nation_city_list_iterate(pnat->server.default_cities, pncity) {
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
1969 } terrain_type_iterate_end;
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++;
1977 } nation_city_list_iterate_end;
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/**********************************************************************/
1996 static 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) {
2006 comment_nations_ruledit(sfile);
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,
2021 game.server.ruledit.embedded_nations_count,
2022 "ruledit.embedded_nations");
2023 free(tmp);
2024 }
2025 }
2026
2027 save_traits(game.server.default_traits, NULL, sfile,
2028 "default_traits", "");
2029
2030 if (data->nationlist == NULL) {
2031 if (game.server.ruledit.allowed_govs != NULL) {
2032 secfile_insert_str_vec(sfile, game.server.ruledit.allowed_govs,
2033 game.server.ruledit.ag_count,
2034 "compatibility.allowed_govs");
2035 }
2036 if (game.server.ruledit.allowed_terrains != NULL) {
2037 secfile_insert_str_vec(sfile, game.server.ruledit.allowed_terrains,
2038 game.server.ruledit.at_count,
2039 "compatibility.allowed_terrains");
2040 }
2041 if (game.server.ruledit.allowed_styles != NULL) {
2042 secfile_insert_str_vec(sfile, game.server.ruledit.allowed_styles,
2043 game.server.ruledit.as_count,
2044 "compatibility.allowed_styles");
2045 }
2046 }
2047
2048 if (game.default_government != NULL) {
2049 secfile_insert_str(sfile, government_rule_name(game.default_government),
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
2064 = nation_by_rule_name(game.server.ruledit.embedded_nations[sect_idx]);
2065
2066 if (pnat == NULL) {
2067 log_error("Embedded nation \"%s\" not found!",
2068 game.server.ruledit.embedded_nations[sect_idx]);
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);
2089 } nation_sets_iterate_end;
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 }
2105 } nation_groups_iterate_end;
2106
2107 comment_nations(sfile);
2108
2109 sect_idx = 0;
2110 nations_iterate(pnat) {
2111 save_nation(sfile, pnat, sect_idx++);
2112 } nations_iterate_end;
2113 }
2114
2115 return save_ruleset_file(sfile, filename);
2116}
2117
2118/**********************************************************************/
2121 static 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);
2156 } tech_class_iterate_end;
2157
2158 comment_techs(sfile);
2159
2160 sect_idx = 0;
2161 advance_re_active_iterate(pa) {
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
2214 } advance_re_active_iterate_end;
2215
2216 return save_ruleset_file(sfile, filename);
2217}
2218
2219/**********************************************************************/
2222 static 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 }
2297 if (wld.map.server.ocean_resources) {
2298 secfile_insert_bool(sfile, TRUE,
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
2330 output_type_iterate(o) {
2331 if (pterr->output[o] != 0) {
2332 secfile_insert_int(sfile, pterr->output[o], "%s.%s", path,
2333 get_output_identifier(o));
2334 }
2335 } output_type_iterate_end;
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
2353 output_type_iterate(o) {
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,
2357 get_output_identifier(o));
2358 }
2359 } output_type_iterate_end;
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 }
2446 } unit_class_iterate_end;
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
2457 } terrain_type_iterate_end;
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
2469 secfile_insert_str(sfile, extra_rule_name(pres),
2470 "%s.extra", path);
2471
2472 output_type_iterate(o) {
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 }
2477 } output_type_iterate_end;
2478
2479 identifier[0] = pres->data.resource->id_old_save;
2480 identifier[1] = '\0';
2481 secfile_insert_str(sfile, identifier, "%s.identifier", path);
2482 }
2483 } extra_type_by_cause_iterate_end;
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;
2493 extra_type_re_active_iterate(pextra) {
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 }
2603 } unit_class_iterate_end;
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 }
2627 } extra_type_iterate_end;
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 }
2639 } extra_type_iterate_end;
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 }
2651 } extra_type_iterate_end;
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
2660 } extra_type_re_active_iterate_end;
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 }
2691 } extra_type_by_cause_iterate_end;
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
2716 output_type_iterate(o) {
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 }
2729 } output_type_iterate_end;
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 }
2761 } extra_type_by_cause_iterate_end;
2762
2763 return save_ruleset_file(sfile, filename);
2764}
2765
2766/**********************************************************************/
2769 static 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/**********************************************************************/
2804 static 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 }
2815 } combat_bonus_list_iterate_end;
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++;
2833 } combat_bonus_list_iterate_end;
2834
2835 return TRUE;
2836}
2837
2838/**********************************************************************/
2841 static 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;
2885 unit_class_re_active_iterate(puc) {
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
2917 } unit_class_re_active_iterate_end;
2918
2919 comment_utypes(sfile);
2920
2921 sect_idx = 0;
2922 unit_type_re_active_iterate(put) {
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 }
2953 } requirement_vector_iterate_end;
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 }
2970 } requirement_vector_iterate_end;
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
3016 output_type_iterate(o) {
3017 if (put->upkeep[o] != 0) {
3018 secfile_insert_int(sfile, put->upkeep[o], "%s.uk_%s",
3019 path, get_output_identifier(o));
3020 }
3021 } output_type_iterate_end;
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 }
3084 } unit_type_re_active_iterate_end;
3085
3086 return save_ruleset_file(sfile, filename);
3087}
3088
3089/**********************************************************************/
3092 static 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/**********************************************************************/
3119 static 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/**********************************************************************/
3131 bool 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}
achievements.h
achievements_iterate_end
#define achievements_iterate_end
Definition achievements.h:70
achievements_iterate
#define achievements_iterate(_ach_)
Definition achievements.h:64
action_min_range_ruleset_var_name
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:7966
action_list_end
void action_list_end(action_id *act_list, int size)
Definition actions.c:7401
action_blocked_by_ruleset_var_name
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:9034
action_is_in_use
bool action_is_in_use(struct action *paction)
Definition actions.c:7330
action_post_success_forced_ruleset_var_name
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:9176
action_rule_name
const char * action_rule_name(const struct action *action)
Definition actions.c:1876
action_id_rule_name
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1899
action_actor_consuming_always_ruleset_var_name
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:8899
action_max_range_ruleset_var_name
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:8177
action_min_range_default
int action_min_range_default(enum action_result result)
Definition actions.c:8095
action_target_kind_ruleset_var_name
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:8398
action_ui_name_default
const char * action_ui_name_default(int act)
Definition actions.c:7664
action_auto_perf_by_number
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Definition actions.c:7369
action_ui_name_ruleset_var_name
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:7438
action_max_range_default
int action_max_range_default(enum action_result result)
Definition actions.c:8312
action_enablers_iterate_end
#define action_enablers_iterate_end
Definition actions.h:526
ACTION_AUTO_MOVED_ADJ
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:617
ACTION_AUTO_UPKEEP_GOLD
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:615
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
NUM_ACTIONS
#define NUM_ACTIONS
Definition actions.h:297
ACTION_AUTO_ESCAPE_STACK
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:621
ACTION_AUTO_ESCAPE_CITY
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:620
ACTION_DISTANCE_UNLIMITED
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:352
ACTION_AUTO_UPKEEP_SHIELD
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:616
ACTION_AUTO_POST_BRIBE
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:618
action_iterate_end
#define action_iterate_end
Definition actions.h:472
MAX_NUM_ACTIONS
#define MAX_NUM_ACTIONS
Definition actions.h:296
action_enablers_iterate
#define action_enablers_iterate(_enabler_)
Definition actions.h:520
action_iterate
#define action_iterate(_act_)
Definition actions.h:467
ACTION_AUTO_UPKEEP_FOOD
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:614
ACTION_AUTO_POST_ATTACK
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:619
ACTION_NONE
#define ACTION_NONE
Definition actions.h:293
astr_free
void astr_free(struct astring *astr)
Definition astring.c:153
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
city_styles
struct citystyle * city_styles
Definition city.c:79
get_output_identifier
const char * get_output_identifier(Output_type_id output)
Definition city.c:614
output_type_iterate
#define output_type_iterate(output)
Definition city.h:812
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:818
comment_roads
void comment_roads(struct section_file *sfile)
Definition comments.c:260
comment_uclasses
void comment_uclasses(struct section_file *sfile)
Definition comments.c:212
comment_citystyles
void comment_citystyles(struct section_file *sfile)
Definition comments.c:276
comment_govs
void comment_govs(struct section_file *sfile)
Definition comments.c:196
comment_bases
void comment_bases(struct section_file *sfile)
Definition comments.c:252
comment_terrains
void comment_terrains(struct section_file *sfile)
Definition comments.c:228
comment_file_header
void comment_file_header(struct section_file *sfile)
Definition comments.c:164
comment_effects
void comment_effects(struct section_file *sfile)
Definition comments.c:292
comment_disasters
void comment_disasters(struct section_file *sfile)
Definition comments.c:300
comment_clauses
void comment_clauses(struct section_file *sfile)
Definition comments.c:372
comment_goods
void comment_goods(struct section_file *sfile)
Definition comments.c:324
comment_extras
void comment_extras(struct section_file *sfile)
Definition comments.c:244
comment_techs
void comment_techs(struct section_file *sfile)
Definition comments.c:188
comment_nations
void comment_nations(struct section_file *sfile)
Definition comments.c:348
comment_trade_settings
void comment_trade_settings(struct section_file *sfile)
Definition comments.c:316
comment_nations_ruledit
void comment_nations_ruledit(struct section_file *sfile)
Definition comments.c:380
comment_nationgroups
void comment_nationgroups(struct section_file *sfile)
Definition comments.c:356
comment_specialists
void comment_specialists(struct section_file *sfile)
Definition comments.c:340
comment_musicstyles
void comment_musicstyles(struct section_file *sfile)
Definition comments.c:284
comment_resources
void comment_resources(struct section_file *sfile)
Definition comments.c:236
comment_tech_classes
void comment_tech_classes(struct section_file *sfile)
Definition comments.c:180
comment_utypes
void comment_utypes(struct section_file *sfile)
Definition comments.c:220
comment_policies
void comment_policies(struct section_file *sfile)
Definition comments.c:204
comment_achievements
void comment_achievements(struct section_file *sfile)
Definition comments.c:308
comment_styles
void comment_styles(struct section_file *sfile)
Definition comments.c:268
comment_buildings
void comment_buildings(struct section_file *sfile)
Definition comments.c:172
comment_enablers
void comment_enablers(struct section_file *sfile)
Definition comments.c:332
comment_nationsets
void comment_nationsets(struct section_file *sfile)
Definition comments.c:364
comments.h
clause_info_get
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:273
disaster_type_iterate
#define disaster_type_iterate(_p)
Definition disaster.h:80
disaster_type_iterate_end
#define disaster_type_iterate_end
Definition disaster.h:86
reqs
struct @21::@22 reqs
iterate_effect_cache
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1245
extra_flag_helptxt
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:923
is_extra_caused_by_worker_action
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:981
extra_has_flag
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:810
extra_flag_id_name_cb
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:911
can_extras_coexist
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:952
extra_rule_name
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:195
is_extra_removed_by
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:291
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:297
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:196
extra_index
#define extra_index(_e_)
Definition extras.h:177
extra_type_re_active_iterate_end
#define extra_type_re_active_iterate_end
Definition extras.h:305
extra_base_get
#define extra_base_get(_e_)
Definition extras.h:184
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:185
extra_type_re_active_iterate
#define extra_type_re_active_iterate(_p)
Definition extras.h:301
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
MAX_NUM_USER_EXTRA_FLAGS
#define MAX_NUM_USER_EXTRA_FLAGS
Definition extras.h:80
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
ROCO_RAILROAD
@ ROCO_RAILROAD
Definition fc_types.h:1105
ROCO_NONE
@ ROCO_NONE
Definition fc_types.h:1105
ROCO_RIVER
@ ROCO_RIVER
Definition fc_types.h:1105
ROCO_ROAD
@ ROCO_ROAD
Definition fc_types.h:1105
MAX_NUM_NATION_SETS
#define MAX_NUM_NATION_SETS
Definition fc_types.h:57
MAX_NUM_BUILDING_LIST
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
action_id
int action_id
Definition fc_types.h:359
MAX_CALENDAR_FRAGMENTS
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:62
MAX_NUM_NATION_GROUPS
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
MAX_NUM_UNIT_LIST
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
MAX_EXTRA_TYPES
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
MAX_NUM_TECH_LIST
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
UCL_LAST
#define UCL_LAST
Definition fc_types.h:387
skip_intl_qualifier_prefix
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game.h
RS_DEFAULT_RANSOM_GOLD
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:840
RS_DEFAULT_CIVIL_WAR_UNHAPPY
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:826
RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:832
RS_DEFAULT_NUKE_POP_LOSS_PCT
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:829
RS_DEFAULT_BASE_POLLUTION
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:812
RS_DEFAULT_INCITE_TOTAL_FCT
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:785
RS_DEFAULT_ILLNESS_BASE_FACTOR
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:743
RS_DEFAULT_NEG_YEAR_LABEL
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:739
RS_DEFAULT_INCITE_IMPROVEMENT_FCT
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:777
RS_ACTION_NO_MAX_DISTANCE
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:866
RS_DEFAULT_BASE_BRIBE_COST
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:836
RS_DEFAULT_TECH_UPKEEP_DIVIDER
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:850
RS_DEFAULT_HAPPY_COST
#define RS_DEFAULT_HAPPY_COST
Definition game.h:817
RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:858
RS_DEFAULT_GRANARY_FOOD_INC
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:791
RS_DEFAULT_ILLNESS_ON
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:741
GAME_DEFAULT_CELEBRATESIZE
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:480
RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:859
RS_DEFAULT_CIVIL_WAR_CELEB
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:825
RS_DEFAULT_BASE_TECH_COST
#define RS_DEFAULT_BASE_TECH_COST
Definition game.h:854
RS_DEFAULT_UPGRADE_VETERAN_LOSS
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:846
RS_DEFAULT_CALENDAR_SKIP_0
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:759
RS_DEFAULT_CITY_RADIUS_SQ
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:804
GAME_DEFAULT_START_YEAR
#define GAME_DEFAULT_START_YEAR
Definition game.h:715
RS_DEFAULT_BORDER_SIZE_EFFECT
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:765
RS_DEFAULT_PILLAGE_SELECT
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:844
RS_DEFAULT_POS_YEAR_LABEL
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:737
RS_DEFAULT_VIS_RADIUS_SQ
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:808
RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:769
RS_DEFAULT_TIRED_ATTACK
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:828
RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:860
RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:751
RS_DEFAULT_FOOD_COST
#define RS_DEFAULT_FOOD_COST
Definition game.h:821
RS_DEFAULT_INCITE_UNIT_FCT
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:781
RS_DEFAULT_INCITE_BASE_COST
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:773
GAME_DEFAULT_ANGRYCITIZEN
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:371
RS_DEFAULT_CITY_CENTER_OUTPUT
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:795
RS_DEFAULT_ILLNESS_POLLUTION_PCT
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:755
RS_DEFAULT_ILLNESS_MIN_SIZE
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:747
RS_DEFAULT_BORDER_RADIUS_SQ_CITY
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:761
ruler_title_female_untranslated_name
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:382
ruler_title_male_untranslated_name
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:373
government_rule_name
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
government.h
governments_iterate
#define governments_iterate(NAME_pgov)
Definition government.h:120
governments_re_active_iterate
#define governments_re_active_iterate(_p)
Definition government.h:125
governments_re_active_iterate_end
#define governments_re_active_iterate_end
Definition government.h:129
governments_iterate_end
#define governments_iterate_end
Definition government.h:123
title
const char * title
Definition repodlgs.c:1313
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:192
improvement_rule_name
const char * improvement_rule_name(const struct impr_type *pimprove)
Definition improvement.c:250
improvement_has_flag
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Definition improvement.c:381
improvement_re_active_iterate_end
#define improvement_re_active_iterate_end
Definition improvement.h:220
improvement_re_active_iterate
#define improvement_re_active_iterate(_p)
Definition improvement.h:216
B_LAST
#define B_LAST
Definition improvement.h:42
name
const char * name
Definition inputfile.c:127
FZ_PLAIN
@ FZ_PLAIN
Definition ioz.h:37
fc_assert_msg
#define fc_assert_msg(condition, message,...)
Definition log.h:181
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_error
#define log_error(message,...)
Definition log.h:103
terrain_control
struct terrain_misc terrain_control
Definition map.c:69
map.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
movement.h
SINGLE_MOVE
#define SINGLE_MOVE
Definition movement.h:24
multipliers.h
multipliers_iterate
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
multipliers_iterate_end
#define multipliers_iterate_end
Definition multipliers.h:67
rule_name_get
static const char * rule_name_get(const struct name_translation *ptrans)
Definition name_translation.h:112
untranslated_name
static const char * untranslated_name(const struct name_translation *ptrans)
Definition name_translation.h:104
nation_city_name
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c:411
nation_rule_name
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
nation_leader_is_male
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:289
nation_city_terrain_preference
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:421
nation_group_rule_name
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1078
nation_set_untranslated_name
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:796
nation_is_in_group
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1098
nation_is_in_set
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:836
nation_set_description
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:827
nation_city_river_preference
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:433
nation_by_rule_name
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:120
nation_leader_name
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:280
nation_set_rule_name
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
nation_leader_list_iterate
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:56
nation_list_iterate
#define nation_list_iterate(nationlist, pnation)
Definition nation.h:83
nation_sets_iterate_end
#define nation_sets_iterate_end
Definition nation.h:304
nation_sets_iterate
#define nation_sets_iterate(NAME_pset)
Definition nation.h:300
nations_iterate_end
#define nations_iterate_end
Definition nation.h:335
NCP_NONE
@ NCP_NONE
Definition nation.h:40
NCP_DISLIKE
@ NCP_DISLIKE
Definition nation.h:39
NCP_LIKE
@ NCP_LIKE
Definition nation.h:41
nation_city_list_iterate
#define nation_city_list_iterate(citylist, pncity)
Definition nation.h:47
nation_list_iterate_end
#define nation_list_iterate_end
Definition nation.h:85
nation_city_list_iterate_end
#define nation_city_list_iterate_end
Definition nation.h:49
nations_iterate
#define nations_iterate(NAME_pnation)
Definition nation.h:332
nation_leader_list_iterate_end
#define nation_leader_list_iterate_end
Definition nation.h:58
nation_groups_iterate
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:310
nation_groups_iterate_end
#define nation_groups_iterate_end
Definition nation.h:314
len
int len
Definition packhand.c:125
registry.h
secfile_new
struct section_file * secfile_new(bool allow_duplicates)
Definition section_file.c:73
entry_name
const char * entry_name(const struct entry *pentry)
Definition registry_ini.c:3246
entry_str_set_gt_marking
bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
Definition registry_ini.c:3503
secfile_save
bool secfile_save(const struct section_file *secfile, const char *filename, int compression_level, enum fz_method compression_method)
Definition registry_ini.c:641
secfile_insert_include
struct section * secfile_insert_include(struct section_file *secfile, const char *filename)
Definition registry_ini.c:1185
secfile_insert_filereference
struct entry * secfile_insert_filereference(struct section_file *secfile, const char *filename, const char *path,...)
Definition registry_ini.c:1333
secfile_insert_int
#define secfile_insert_int(secfile, value, path,...)
Definition registry_ini.h:116
secfile_insert_enum_vec
#define secfile_insert_enum_vec(secfile, enumerators, dim, specenum_type, path,...)
Definition registry_ini.h:320
secfile_insert_enum
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
Definition registry_ini.h:266
secfile_insert_int_vec
#define secfile_insert_int_vec(secfile, values, dim, path,...)
Definition registry_ini.h:133
secfile_insert_str_vec
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
Definition registry_ini.h:201
secfile_insert_str
#define secfile_insert_str(secfile, string, path,...)
Definition registry_ini.h:170
secfile_insert_bool
#define secfile_insert_bool(secfile, value, path,...)
Definition registry_ini.h:79
secfile_insert_enum_vec_comment
#define secfile_insert_enum_vec_comment(secfile, enumerators, dim, specenum_type, comment, path,...)
Definition registry_ini.h:324
secfile_insert_enum_data
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
Definition registry_ini.h:345
req_to_fstring
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
Definition requirements.c:916
universal_rule_name
const char * universal_rule_name(const struct universal *psource)
Definition requirements.c:5392
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:93
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:91
rgbcolor_save
void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
Definition rgbcolor.c:121
rgbcolor_list_iterate_end
#define rgbcolor_list_iterate_end
Definition rgbcolor.h:45
rgbcolor_list_iterate
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)
Definition rgbcolor.h:43
road_has_flag
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:410
save_reqs_vector
static bool save_reqs_vector(struct section_file *sfile, const struct requirement_vector *reqs, const char *path, const char *entry)
Definition rulesave.c:141
save_tech_list
static bool save_tech_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:201
save_name_translation
static bool save_name_translation(struct section_file *sfile, struct name_translation *name, const char *path)
Definition rulesave.c:118
save_terrain_ref
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
save_unit_list
static bool save_unit_list(struct section_file *sfile, struct unit_type **input, const char *path, const char *entry)
Definition rulesave.c:298
save_nations_ruleset
static bool save_nations_ruleset(const char *filename, const char *name, struct rule_data *data)
Definition rulesave.c:1996
save_action_kind
static bool save_action_kind(struct section_file *sfile, action_id act)
Definition rulesave.c:873
save_action_actor_consuming_always
static bool save_action_actor_consuming_always(struct section_file *sfile, action_id act)
Definition rulesave.c:897
save_action_max_range
static bool save_action_max_range(struct section_file *sfile, action_id act)
Definition rulesave.c:827
save_traits
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
FORMAT_VERSION
#define FORMAT_VERSION
Definition rulesave.c:49
save_ruleset
bool save_ruleset(const char *path, const char *name, struct rule_data *data)
Definition rulesave.c:3131
save_cities_ruleset
static bool save_cities_ruleset(const char *filename, const char *name)
Definition rulesave.c:634
save_techs_ruleset
static bool save_techs_ruleset(const char *filename, const char *name)
Definition rulesave.c:2121
save_uclass_vec
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
save_action_post_success_force
static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction)
Definition rulesave.c:975
save_ruleset_file
static bool save_ruleset_file(struct section_file *sfile, const char *filename)
Definition rulesave.c:370
save_veteran_system
static bool save_veteran_system(struct section_file *sfile, const char *path, struct veteran_system *vsystem)
Definition rulesave.c:2769
save_bv_actions
static bool save_bv_actions(struct section_file *sfile, bv_actions content, const char *path)
Definition rulesave.c:1004
save_default_bool
static bool save_default_bool(struct section_file *sfile, bool value, bool default_value, const char *path, const char *entry)
Definition rulesave.c:98
effect_save
static bool effect_save(struct effect *peffect, void *data)
Definition rulesave.c:758
save_game_ruleset
static bool save_game_ruleset(const char *filename, const char *name)
Definition rulesave.c:1038
save_buildings_ruleset
static bool save_buildings_ruleset(const char *filename, const char *name)
Definition rulesave.c:378
save_action_auto_uflag_block
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
unexpected_non_otype
static bool unexpected_non_otype(const struct requirement *req)
Definition rulesave.c:604
save_building_list
static bool save_building_list(struct section_file *sfile, int *input, const char *path, const char *entry)
Definition rulesave.c:274
save_luadata
static bool save_luadata(const char *filename)
Definition rulesave.c:3119
save_governments_ruleset
static bool save_governments_ruleset(const char *filename, const char *name)
Definition rulesave.c:1677
save_action_blocked_by
static bool save_action_blocked_by(struct section_file *sfile, struct action *paction)
Definition rulesave.c:922
save_strvec
static bool save_strvec(struct section_file *sfile, struct strvec *to_save, const char *path, const char *entry)
Definition rulesave.c:348
save_units_ruleset
static bool save_units_ruleset(const char *filename, const char *name)
Definition rulesave.c:2841
save_terrain_ruleset
static bool save_terrain_ruleset(const char *filename, const char *name)
Definition rulesave.c:2222
save_muuk_action_auto
static bool save_muuk_action_auto(struct section_file *sfile, const int aap, const char *item)
Definition rulesave.c:614
save_action_range
static bool save_action_range(struct section_file *sfile, action_id act)
Definition rulesave.c:847
save_gov_ref
static bool save_gov_ref(struct section_file *sfile, const struct government *gov, const char *path, const char *entry)
Definition rulesave.c:261
save_styles_ruleset
static bool save_styles_ruleset(const char *filename, const char *name)
Definition rulesave.c:446
create_ruleset_file
static struct section_file * create_ruleset_file(const char *rsname, const char *rstype)
Definition rulesave.c:54
save_combat_bonuses
static bool save_combat_bonuses(struct section_file *sfile, struct unit_type *put, char *path)
Definition rulesave.c:2804
save_effects_ruleset
static bool save_effects_ruleset(const char *filename, const char *name)
Definition rulesave.c:783
save_default_int
static bool save_default_int(struct section_file *sfile, int value, int default_value, const char *path, const char *entry)
Definition rulesave.c:79
save_nation
static bool save_nation(struct section_file *sfile, struct nation_type *pnat, int sect_idx)
Definition rulesave.c:1810
save_script_lua
static bool save_script_lua(const char *filename, const char *name, const char *buffer)
Definition rulesave.c:3092
save_action_auto_actions
static bool save_action_auto_actions(struct section_file *sfile, const int aap, const char *actions_path)
Definition rulesave.c:561
save_tech_ref
static bool save_tech_ref(struct section_file *sfile, const struct advance *padv, const char *path, const char *entry)
Definition rulesave.c:224
save_action_ui_name
static bool save_action_ui_name(struct section_file *sfile, int act, const char *entry_name)
Definition rulesave.c:807
rulesave.h
get_parser_buffer
char * get_parser_buffer(void)
Definition ruleset.c:553
get_script_buffer
char * get_script_buffer(void)
Definition ruleset.c:545
ruleset.h
RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleset.h:107
RS_DEFAULT_TECH_TRADE_LOSS_HOLES
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleset.h:84
RS_DEFAULT_EXTRA_APPEARANCE
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleset.h:101
RS_DEFAULT_TECH_PARASITE_HOLES
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleset.h:85
GAME_DEFAULT_ACH_VALUE
#define GAME_DEFAULT_ACH_VALUE
Definition ruleset.h:78
RS_DEFAULT_TECH_TRADE_HOLES
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleset.h:83
RS_DEFAULT_CULTURE_VIC_POINTS
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleset.h:94
RS_DEFAULT_CULTURE_MIGRATION_PML
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleset.h:96
RS_DEFAULT_SMALL_WONDER_VISIBILITY
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleset.h:109
RS_DEFAULT_ONLY_KILLING_VETERAN
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleset.h:104
RS_DEFAULT_TECH_LOSS_HOLES
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleset.h:86
RS_DEFAULT_HISTORY_INTEREST_PML
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleset.h:97
RS_DEFAULT_GOODS_SELECTION
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleset.h:99
RS_DEFAULT_PYTHAGOREAN_DIAGONAL
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleset.h:87
RS_DEFAULT_TECH_STEAL_HOLES
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleset.h:82
GAME_DEFAULT_ACH_UNIQUE
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleset.h:77
RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleset.h:106
RS_DEFAULT_MUUK_FOOD_WIPE
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleset.h:79
RS_DEFAULT_MUUK_GOLD_WIPE
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleset.h:80
RULESET_CAPABILITIES
#define RULESET_CAPABILITIES
Definition ruleset.h:24
GAME_DEFAULT_CHANGABLE_TAX
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleset.h:72
RS_DEFAULT_MUUK_SHIELD_WIPE
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleset.h:81
RS_DEFAULT_GOLD_UPKEEP_STYLE
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleset.h:89
GAME_DEFAULT_NATIONALITY
#define GAME_DEFAULT_NATIONALITY
Definition ruleset.h:74
GAME_DEFAULT_ADDTOSIZE
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleset.h:71
RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleset.h:105
RS_DEFAULT_EXTRA_DISAPPEARANCE
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleset.h:102
GAME_DEFAULT_VISION_REVEAL_TILES
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleset.h:73
RS_DEFAULT_CULTURE_VIC_LEAD
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleset.h:95
GAME_DEFAULT_DISASTER_FREQ
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleset.h:76
GAME_DEFAULT_CONVERT_SPEED
#define GAME_DEFAULT_CONVERT_SPEED
Definition ruleset.h:75
setting_int_get
int setting_int_get(struct setting *pset)
Definition settings.c:3608
setting_locked
bool setting_locked(const struct setting *pset)
Definition settings.c:4420
setting_type
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3191
setting_enum_secfile_str
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3690
setting_get_setdef
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5349
setting_name
const char * setting_name(const struct setting *pset)
Definition settings.c:3162
setting_bitwise_get
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4056
setting_str_get
char * setting_str_get(struct setting *pset)
Definition settings.c:3679
setting_bool_get
bool setting_bool_get(struct setting *pset)
Definition settings.c:3496
setting_bitwise_secfile_str
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:3875
read_enum_value
int read_enum_value(const struct setting *pset)
Definition settings.c:3805
settings.h
settings_iterate
#define settings_iterate(_level, _pset)
Definition settings.h:177
settings_iterate_end
#define settings_iterate_end
Definition settings.h:183
make_dir
bool make_dir(const char *pathname)
Definition shared.c:1769
MAX
#define MAX(x, y)
Definition shared.h:54
specialist_by_number
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:100
specialist.h
specialist_type_iterate_end
#define specialist_type_iterate_end
Definition specialist.h:79
specialist_type_iterate
#define specialist_type_iterate(sp)
Definition specialist.h:73
strvec_get
const char * strvec_get(const struct strvec *psv, size_t svindex)
Definition string_vector.c:388
strvec_size
size_t strvec_size(const struct strvec *psv)
Definition string_vector.c:343
string_vector.h
action_auto_perf
Definition actions.h:568
action_auto_perf::reqs
struct requirement_vector reqs
Definition actions.h:574
action_auto_perf::alternatives
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:578
action
Definition actions.h:379
action::actor_consuming_always
bool actor_consuming_always
Definition actions.h:412
action::max_distance
int max_distance
Definition actions.h:395
action::quiet
bool quiet
Definition actions.h:402
action::result
enum action_result result
Definition actions.h:382
action::ui_name
char ui_name[MAX_LEN_NAME]
Definition actions.h:398
action::blocked_by
bv_actions blocked_by
Definition actions.h:406
action::target_kind
enum action_target_kind target_kind
Definition actions.h:386
action::min_distance
int min_distance
Definition actions.h:395
advance
Definition tech.h:124
advance::inherited_root_req
bool inherited_root_req
Definition tech.h:133
astring
Definition astring.h:36
base_type
Definition base.h:41
base_type::border_sq
int border_sq
Definition base.h:44
base_type::vision_main_sq
int vision_main_sq
Definition base.h:45
base_type::gui_type
enum base_gui_type gui_type
Definition base.h:43
base_type::vision_invis_sq
int vision_invis_sq
Definition base.h:46
base_type::vision_subs_sq
int vision_subs_sq
Definition base.h:47
civ_game::rgame
struct civ_game::@29 rgame
civ_game::named_teams
int named_teams
Definition game.h:286
civ_game::as_count
size_t as_count
Definition game.h:285
civ_game::plr_colors
struct rgbcolor_list * plr_colors
Definition game.h:242
civ_game::allowed_govs
const char ** allowed_govs
Definition game.h:277
civ_game::upgrade_veteran_loss
int upgrade_veteran_loss
Definition game.h:198
civ_game::plr_bg_color
struct rgbcolor * plr_bg_color
Definition game.h:102
civ_game::incite_total_factor
int incite_total_factor
Definition game.h:149
civ_game::init_vis_radius_sq
int init_vis_radius_sq
Definition game.h:151
civ_game::server
struct civ_game::@30::@34 server
civ_game::vision_reveal_tiles
bool vision_reveal_tiles
Definition game.h:199
civ_game::description_file
char * description_file
Definition game.h:273
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civ_game::ruleset_summary
char * ruleset_summary
Definition game.h:84
civ_game::base_incite_cost
int base_incite_cost
Definition game.h:133
civ_game::global_init_techs
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:107
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_game::autoupgrade_veteran_loss
int autoupgrade_veteran_loss
Definition game.h:131
civ_game::start_year
int start_year
Definition game.h:190
civ_game::incite_improvement_factor
int incite_improvement_factor
Definition game.h:148
civ_game::luadata
struct section_file * luadata
Definition game.h:244
civ_game::embedded_nations
char ** embedded_nations
Definition game.h:275
civ_game::global_init_buildings
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:108
civ_game::ruledit
struct civ_game::@30::@34::@39 ruledit
civ_game::default_traits
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:270
civ_game::allowed_terrains
const char ** allowed_terrains
Definition game.h:280
civ_game::ruleset_description
char * ruleset_description
Definition game.h:85
civ_game::ag_count
size_t ag_count
Definition game.h:279
civ_game::allowed_styles
const char ** allowed_styles
Definition game.h:283
civ_game::embedded_nations_count
size_t embedded_nations_count
Definition game.h:276
civ_game::incite_unit_factor
int incite_unit_factor
Definition game.h:150
civ_game::ruleset_capabilities
char * ruleset_capabilities
Definition game.h:86
civ_game::ransom_gold
int ransom_gold
Definition game.h:174
civ_game::at_count
size_t at_count
Definition game.h:282
civ_game::veteran
struct veteran_system * veteran
Definition game.h:100
civ_game::calendar
struct packet_calendar_info calendar
Definition game.h:90
civ_game::default_government
struct government * default_government
Definition game.h:93
civ_game::government_during_revolution
struct government * government_during_revolution
Definition game.h:94
civ_map::server
struct civ_map::@41::@43 server
civ_map::ocean_resources
bool ocean_resources
Definition map_types.h:105
clause_info
Definition diptreaty.h:53
clause_info::receiver_reqs
struct requirement_vector receiver_reqs
Definition diptreaty.h:57
clause_info::giver_reqs
struct requirement_vector giver_reqs
Definition diptreaty.h:56
clause_info::type
enum clause_type type
Definition diptreaty.h:54
clause_info::enabled
bool enabled
Definition diptreaty.h:55
effect_cb_data
Definition rulesave.c:750
effect_cb_data::idx
int idx
Definition rulesave.c:751
effect_cb_data::sfile
struct section_file * sfile
Definition rulesave.c:752
effect
Definition effects.h:340
effect::value
int value
Definition effects.h:349
effect::ruledit_do_not_save
bool ruledit_do_not_save
Definition effects.h:357
effect::reqs
struct requirement_vector reqs
Definition effects.h:353
effect::type
enum effect_type type
Definition effects.h:341
entry
Definition registry_ini.c:193
government
Definition government.h:52
item
Definition climisc.h:80
name_translation
Definition name_translation.h:35
nation_type
Definition nation.h:97
nation_type::init_buildings
int init_buildings[MAX_NUM_BUILDING_LIST]
Definition nation.h:122
nation_type::conflicts_with
struct nation_list * conflicts_with
Definition nation.h:139
nation_type::noun_plural
struct name_translation noun_plural
Definition nation.h:101
nation_type::flag_graphic_str
char flag_graphic_str[MAX_LEN_NAME]
Definition nation.h:102
nation_type::adjective
struct name_translation adjective
Definition nation.h:100
nation_type::rgb
struct rgbcolor * rgb
Definition nation.h:142
nation_type::traits
struct trait_limits * traits
Definition nation.h:144
nation_type::flag_graphic_alt
char flag_graphic_alt[MAX_LEN_NAME]
Definition nation.h:103
nation_type::init_government
struct government * init_government
Definition nation.h:123
nation_type::init_units
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:124
nation_type::leaders
struct nation_leader_list * leaders
Definition nation.h:104
nation_type::legend
char * legend
Definition nation.h:106
nation_type::barb_type
enum barbarian_type barb_type
Definition nation.h:109
nation_type::translation_domain
char * translation_domain
Definition nation.h:99
nation_type::server
struct nation_type::@50::@52 server
nation_type::style
struct nation_style * style
Definition nation.h:105
nation_type::default_cities
struct nation_city_list * default_cities
Definition nation.h:130
nation_type::init_techs
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:121
nation_type::civilwar_nations
struct nation_list * civilwar_nations
Definition nation.h:134
nation_type::is_playable
bool is_playable
Definition nation.h:108
packet_calendar_info::positive_year_label
char positive_year_label[MAX_LEN_NAME]
Definition packets_gen.h:254
packet_calendar_info::calendar_skip_0
bool calendar_skip_0
Definition packets_gen.h:258
packet_calendar_info::negative_year_label
char negative_year_label[MAX_LEN_NAME]
Definition packets_gen.h:255
packet_calendar_info::calendar_fragments
int calendar_fragments
Definition packets_gen.h:256
packet_calendar_info::calendar_fragment_name
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
Definition packets_gen.h:257
packet_game_info::tech_steal_allow_holes
bool tech_steal_allow_holes
Definition packets_gen.h:211
packet_game_info::min_trade_route_val
int min_trade_route_val
Definition packets_gen.h:160
packet_game_info::illness_trade_infection
int illness_trade_infection
Definition packets_gen.h:183
packet_game_info::gameloss_style
enum gameloss_style gameloss_style
Definition packets_gen.h:232
packet_game_info::history_interest_pml
int history_interest_pml
Definition packets_gen.h:139
packet_game_info::citizen_partisans_pct
int citizen_partisans_pct
Definition packets_gen.h:146
packet_game_info::celebratesize
int celebratesize
Definition packets_gen.h:140
packet_game_info::goods_selection
enum goods_selection_method goods_selection
Definition packets_gen.h:161
packet_game_info::illness_base_factor
int illness_base_factor
Definition packets_gen.h:179
packet_game_info::illness_min_size
int illness_min_size
Definition packets_gen.h:180
packet_game_info::add_to_size_limit
int add_to_size_limit
Definition packets_gen.h:120
packet_game_info::forced_science
int forced_science
Definition packets_gen.h:157
packet_game_info::granary_num_inis
int granary_num_inis
Definition packets_gen.h:174
packet_game_info::gold_upkeep_style
enum gold_upkeep_style gold_upkeep_style
Definition packets_gen.h:167
packet_game_info::pop_report_zeroes
int pop_report_zeroes
Definition packets_gen.h:142
packet_game_info::damage_reduces_bombard_rate
bool damage_reduces_bombard_rate
Definition packets_gen.h:192
packet_game_info::citizen_nationality
bool citizen_nationality
Definition packets_gen.h:143
packet_game_info::nuke_pop_loss_pct
int nuke_pop_loss_pct
Definition packets_gen.h:197
packet_game_info::nuke_defender_survival_chance_pct
int nuke_defender_survival_chance_pct
Definition packets_gen.h:198
packet_game_info::angrycitizen
int angrycitizen
Definition packets_gen.h:126
packet_game_info::granary_food_inc
int granary_food_inc
Definition packets_gen.h:172
packet_game_info::tech_upkeep_style
enum tech_upkeep_style tech_upkeep_style
Definition packets_gen.h:229
packet_game_info::tech_trade_loss_allow_holes
bool tech_trade_loss_allow_holes
Definition packets_gen.h:213
packet_game_info::granary_food_ini
int granary_food_ini[MAX_GRANARY_INIS]
Definition packets_gen.h:173
packet_game_info::culture_vic_lead
int culture_vic_lead
Definition packets_gen.h:137
packet_game_info::free_tech_method
enum free_tech_method free_tech_method
Definition packets_gen.h:231
packet_game_info::changable_tax
bool changable_tax
Definition packets_gen.h:141
packet_game_info::steal_maps_reveals_all_cities
bool steal_maps_reveals_all_cities
Definition packets_gen.h:209
packet_game_info::init_city_radius_sq
int init_city_radius_sq
Definition packets_gen.h:184
packet_game_info::granularity
int granularity
Definition packets_gen.h:249
packet_game_info::conquest_convert_pct
int conquest_convert_pct
Definition packets_gen.h:145
packet_game_info::muuk_food_wipe
bool muuk_food_wipe
Definition packets_gen.h:200
packet_game_info::tired_attack
bool tired_attack
Definition packets_gen.h:235
packet_game_info::only_real_fight_makes_veteran
bool only_real_fight_makes_veteran
Definition packets_gen.h:190
packet_game_info::low_firepower_pearl_harbour
int low_firepower_pearl_harbour
Definition packets_gen.h:194
packet_game_info::base_pollution
int base_pollution
Definition packets_gen.h:127
packet_game_info::citizen_convert_speed
int citizen_convert_speed
Definition packets_gen.h:144
packet_game_info::forced_gold
int forced_gold
Definition packets_gen.h:155
packet_game_info::illness_pollution_factor
int illness_pollution_factor
Definition packets_gen.h:182
packet_game_info::base_tech_cost
int base_tech_cost
Definition packets_gen.h:128
packet_game_info::happy_cost
int happy_cost
Definition packets_gen.h:176
packet_game_info::civil_war_enabled
bool civil_war_enabled
Definition packets_gen.h:246
packet_game_info::muuk_gold_wipe
bool muuk_gold_wipe
Definition packets_gen.h:201
packet_game_info::food_cost
int food_cost
Definition packets_gen.h:153
packet_game_info::tech_leakage
enum tech_leakage_style tech_leakage
Definition packets_gen.h:227
packet_game_info::airlift_from_always_enabled
bool airlift_from_always_enabled
Definition packets_gen.h:124
packet_game_info::illness_on
bool illness_on
Definition packets_gen.h:181
packet_game_info::civil_war_bonus_unhappy
int civil_war_bonus_unhappy
Definition packets_gen.h:248
packet_game_info::only_killing_makes_veteran
bool only_killing_makes_veteran
Definition packets_gen.h:189
packet_game_info::poison_empties_food_stock
bool poison_empties_food_stock
Definition packets_gen.h:210
packet_game_info::tech_loss_allow_holes
bool tech_loss_allow_holes
Definition packets_gen.h:215
packet_game_info::diplchance_initial_odds
bv_actions diplchance_initial_odds
Definition packets_gen.h:150
packet_game_info::tech_trade_allow_holes
bool tech_trade_allow_holes
Definition packets_gen.h:212
packet_game_info::low_firepower_nonnat_bombard
int low_firepower_nonnat_bombard
Definition packets_gen.h:196
packet_game_info::border_size_effect
int border_size_effect
Definition packets_gen.h:131
packet_game_info::tech_upkeep_divider
int tech_upkeep_divider
Definition packets_gen.h:228
packet_game_info::pillage_select
bool pillage_select
Definition packets_gen.h:208
packet_game_info::tech_parasite_allow_holes
bool tech_parasite_allow_holes
Definition packets_gen.h:214
packet_game_info::muuk_shield_wipe
bool muuk_shield_wipe
Definition packets_gen.h:202
packet_game_info::base_bribe_cost
int base_bribe_cost
Definition packets_gen.h:134
packet_game_info::low_firepower_combat_bonus
int low_firepower_combat_bonus
Definition packets_gen.h:195
packet_game_info::culture_migration_pml
int culture_migration_pml
Definition packets_gen.h:138
packet_game_info::border_city_permanent_radius_sq
int border_city_permanent_radius_sq
Definition packets_gen.h:132
packet_game_info::culture_vic_points
int culture_vic_points
Definition packets_gen.h:136
packet_game_info::low_firepower_badwallattacker
int low_firepower_badwallattacker
Definition packets_gen.h:193
packet_game_info::airlift_to_always_enabled
bool airlift_to_always_enabled
Definition packets_gen.h:125
packet_game_info::small_wonder_visibility
enum wonder_visib_type small_wonder_visibility
Definition packets_gen.h:250
packet_game_info::tech_cost_style
enum tech_cost_style tech_cost_style
Definition packets_gen.h:226
packet_game_info::combat_odds_scaled_veterancy
bool combat_odds_scaled_veterancy
Definition packets_gen.h:191
packet_game_info::civil_war_bonus_celebrating
int civil_war_bonus_celebrating
Definition packets_gen.h:247
packet_game_info::border_city_radius_sq
int border_city_radius_sq
Definition packets_gen.h:130
packet_game_info::forced_luxury
int forced_luxury
Definition packets_gen.h:156
packet_game_info::min_city_center_output
int min_city_center_output[O_LAST]
Definition packets_gen.h:199
packet_ruleset_control::preferred_soundset
char preferred_soundset[MAX_LEN_NAME]
Definition packets_gen.h:1478
packet_ruleset_control::version
char version[MAX_LEN_NAME]
Definition packets_gen.h:1482
packet_ruleset_control::nation_count
int nation_count
Definition packets_gen.h:1471
packet_ruleset_control::preferred_tileset
char preferred_tileset[MAX_LEN_NAME]
Definition packets_gen.h:1477
packet_ruleset_control::popup_tech_help
bool popup_tech_help
Definition packets_gen.h:1480
packet_ruleset_control::styles_count
int styles_count
Definition packets_gen.h:1472
packet_ruleset_control::alt_dir
char alt_dir[MAX_LEN_NAME]
Definition packets_gen.h:1483
packet_ruleset_control::preferred_musicset
char preferred_musicset[MAX_LEN_NAME]
Definition packets_gen.h:1479
packet_ruleset_control::num_tech_classes
int num_tech_classes
Definition packets_gen.h:1458
packet_ruleset_control::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1481
requirement
Definition requirements.h:80
requirement::present
bool present
Definition requirements.h:84
requirement::source
struct universal source
Definition requirements.h:81
road_type
Definition road.h:75
road_type::gui_type
enum road_gui_type gui_type
Definition road.h:84
road_type::move_mode
enum road_move_mode move_mode
Definition road.h:79
road_type::tile_bonus
int tile_bonus[O_LAST]
Definition road.h:82
road_type::tile_incr_const
int tile_incr_const[O_LAST]
Definition road.h:80
road_type::tile_incr
int tile_incr[O_LAST]
Definition road.h:81
road_type::move_cost
int move_cost
Definition road.h:78
road_type::compat
enum road_compat compat
Definition road.h:83
rule_data
Definition rulesave.h:21
rule_data::nationlist
char * nationlist
Definition rulesave.h:22
ruler_title
Definition government.c:187
section_file
Definition section_file.h:36
specialist
Definition specialist.h:29
specialist::reqs
struct requirement_vector reqs
Definition specialist.h:38
specialist::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition specialist.h:36
specialist::helptext
struct strvec * helptext
Definition specialist.h:40
specialist::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition specialist.h:35
specialist::name
struct name_translation name
Definition specialist.h:31
specialist::abbreviation
struct name_translation abbreviation
Definition specialist.h:32
strvec
Definition string_vector.c:29
terrain
Definition terrain.h:176
trade_route_settings
Definition traderoutes.h:75
trade_route_settings::bonus_type
enum trade_route_bonus_type bonus_type
Definition traderoutes.h:78
trade_route_settings::trade_pct
int trade_pct
Definition traderoutes.h:76
trade_route_settings::cancelling
enum trade_route_illegal_cancelling cancelling
Definition traderoutes.h:77
trait_limits
Definition traits.h:43
trait_limits::min
int min
Definition traits.h:44
trait_limits::max
int max
Definition traits.h:45
unit_type
Definition unittype.h:481
unit_type::bonuses
struct combat_bonus_list * bonuses
Definition unittype.h:507
universal::kind
enum universals_n kind
Definition fc_types.h:758
veteran_level::power_fact
int power_fact
Definition unittype.h:469
veteran_level::base_raise_chance
int base_raise_chance
Definition unittype.h:471
veteran_level::name
struct name_translation name
Definition unittype.h:468
veteran_level::move_bonus
int move_bonus
Definition unittype.h:470
veteran_level::work_raise_chance
int work_raise_chance
Definition unittype.h:472
veteran_system
Definition unittype.h:475
veteran_system::definitions
struct veteran_level * definitions
Definition unittype.h:478
veteran_system::levels
int levels
Definition unittype.h:476
world::map
struct civ_map map
Definition world_object.h:38
style_rule_name
const char * style_rule_name(const struct nation_style *pstyle)
Definition style.c:108
style.h
music_styles_iterate
#define music_styles_iterate(_p)
Definition style.h:72
music_styles_iterate_end
#define music_styles_iterate_end
Definition style.h:79
styles_re_active_iterate_end
#define styles_re_active_iterate_end
Definition style.h:60
styles_re_active_iterate
#define styles_re_active_iterate(_p)
Definition style.h:56
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
fc_fopen
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:506
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
team_slot_by_number
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
team_slot_rule_name
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
tech_flag_id_name_cb
const char * tech_flag_id_name_cb(enum tech_flag_id flag)
Definition tech.c:423
tech_class_rule_name
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:342
advance_has_flag
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Definition tech.c:216
advance_rule_name
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:299
advance_index
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
tech_flag_helptxt
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:435
advance_re_active_iterate
#define advance_re_active_iterate(_p)
Definition tech.h:275
A_NEVER
#define A_NEVER
Definition tech.h:51
tech_class_iterate_end
#define tech_class_iterate_end
Definition tech.h:204
MAX_NUM_USER_TECH_FLAGS
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:108
AR_TWO
@ AR_TWO
Definition tech.h:112
AR_ROOT
@ AR_ROOT
Definition tech.h:113
AR_ONE
@ AR_ONE
Definition tech.h:111
advance_re_active_iterate_end
#define advance_re_active_iterate_end
Definition tech.h:279
A_NONE
#define A_NONE
Definition tech.h:43
tech_class_iterate
#define tech_class_iterate(_p)
Definition tech.h:198
A_LAST
#define A_LAST
Definition tech.h:45
terrain_flag_id_name_cb
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:805
terrain_rule_name
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:235
terrain_flag_helptxt
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:817
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:358
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:364
MAX_NUM_TERRAINS
#define MAX_NUM_TERRAINS
Definition terrain.h:64
terrain_has_flag
#define terrain_has_flag(terr, flag)
Definition terrain.h:269
MAX_NUM_USER_TER_FLAGS
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:146
goods_has_flag
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
Definition traderoutes.c:666
trade_route_type_name
const char * trade_route_type_name(enum trade_route_type type)
Definition traderoutes.c:148
trade_route_settings_by_type
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Definition traderoutes.c:201
trade_route_cancelling_type_name
const char * trade_route_cancelling_type_name(enum trade_route_illegal_cancelling type)
Definition traderoutes.c:174
goods_type_re_active_iterate_end
#define goods_type_re_active_iterate_end
Definition traderoutes.h:231
goods_type_re_active_iterate
#define goods_type_re_active_iterate(_p)
Definition traderoutes.h:227
trade_route_type
trade_route_type
Definition traderoutes.h:37
TRT_LAST
@ TRT_LAST
Definition traderoutes.h:48
TRAIT_DEFAULT_VALUE
#define TRAIT_DEFAULT_VALUE
Definition traits.h:32
unit_class_flag_helptxt
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Definition unittype.c:1906
utype_has_role
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:193
utype_rule_name
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
uclass_rule_name
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1693
unit_class_flag_id_name_cb
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Definition unittype.c:1894
unit_type_flag_id_name_cb
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Definition unittype.c:1957
unit_type_flag_helptxt
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1969
unittype.h
uclass_has_flag
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
unit_type_re_active_iterate
#define unit_type_re_active_iterate(_p)
Definition unittype.h:850
combat_bonus_list_iterate_end
#define combat_bonus_list_iterate_end
Definition unittype.h:463
L_FIRST
#define L_FIRST
Definition unittype.h:333
combat_bonus_list_iterate
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:461
unit_class_iterate
#define unit_class_iterate(_p)
Definition unittype.h:876
unit_class_re_active_iterate_end
#define unit_class_re_active_iterate_end
Definition unittype.h:892
MAX_NUM_USER_UNIT_FLAGS
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:316
utype_has_flag
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
UTYF_LAST_USER_FLAG
#define UTYF_LAST_USER_FLAG
Definition unittype.h:315
L_LAST
#define L_LAST
Definition unittype.h:420
unit_class_re_active_iterate
#define unit_class_re_active_iterate(_p)
Definition unittype.h:888
uclass_index
#define uclass_index(_c_)
Definition unittype.h:729
unit_class_iterate_end
#define unit_class_iterate_end
Definition unittype.h:883
MAX_NUM_USER_UCLASS_FLAGS
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:113
unit_type_re_active_iterate_end
#define unit_type_re_active_iterate_end
Definition unittype.h:854
freeciv_datafile_version
const char * freeciv_datafile_version(void)
Definition version.c:186
version.h