Freeciv-3.3: /fast/freeciv/nightly/main/tools/ruleutil/rulesave.c Source File

Freeciv-3.3

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