Bug #1893 » 1893_S3_2.patch
| tools/ruleutil/rulesave.c | ||
|---|---|---|
|
sections[i] = strvec_get(to_save, i);
|
||
|
}
|
||
|
secfile_insert_str_vec(sfile, sections, sect_count, "%s.%s", path, entry);
|
||
|
secfile_insert_str_vec_gt_marking(sfile, sections, sect_count,
|
||
|
"%s.%s", path, entry);
|
||
|
}
|
||
|
return TRUE;
|
||
| ... | ... | |
|
save_name_translation(sfile, &(s->name), path);
|
||
|
if (strcmp(rule_name_get(&s->name), rule_name_get(&s->abbreviation))) {
|
||
|
secfile_insert_str(sfile, rule_name_get(&s->abbreviation),
|
||
|
"%s.short_name", path);
|
||
|
struct entry *pentry =
|
||
|
secfile_insert_str(sfile, rule_name_get(&s->abbreviation),
|
||
|
"%s.short_name", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
save_reqs_vector(sfile, &(s->reqs), path, "reqs");
|
||
| ... | ... | |
|
}
|
||
|
if (strcmp(ui_name, action_ui_name_default(act))) {
|
||
|
secfile_insert_str(sfile, ui_name,
|
||
|
"actions.%s", entry_name);
|
||
|
struct entry *pentry =
|
||
|
secfile_insert_str(sfile, ui_name,
|
||
|
"actions.%s", entry_name);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
return TRUE;
|
||
| ... | ... | |
|
enum trade_route_type trt;
|
||
|
int i;
|
||
|
bool locks;
|
||
|
struct entry *pentry;
|
||
|
if (sfile == NULL) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
}
|
||
|
if (game.ruleset_summary != NULL) {
|
||
|
struct entry *mod_entry;
|
||
|
mod_entry = secfile_insert_str(sfile, game.ruleset_summary,
|
||
|
"about.summary");
|
||
|
entry_str_set_gt_marking(mod_entry, TRUE);
|
||
|
pentry = secfile_insert_str(sfile, game.ruleset_summary,
|
||
|
"about.summary");
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
if (game.ruleset_description != NULL) {
|
||
| ... | ... | |
|
}
|
||
|
if (strcmp(game.calendar.positive_year_label, RS_DEFAULT_POS_YEAR_LABEL)) {
|
||
|
secfile_insert_str(sfile, game.calendar.positive_year_label,
|
||
|
"calendar.positive_label");
|
||
|
pentry = secfile_insert_str(sfile, game.calendar.positive_year_label,
|
||
|
"calendar.positive_label");
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
if (strcmp(game.calendar.negative_year_label, RS_DEFAULT_NEG_YEAR_LABEL)) {
|
||
|
secfile_insert_str(sfile, game.calendar.negative_year_label,
|
||
|
"calendar.negative_label");
|
||
|
pentry = secfile_insert_str(sfile, game.calendar.negative_year_label,
|
||
|
"calendar.negative_label");
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
if (game.plr_bg_color != NULL) {
|
||
| ... | ... | |
|
tnames[i] = team_slot_rule_name(team_slot_by_number(i));
|
||
|
}
|
||
|
secfile_insert_str_vec(sfile, tnames,
|
||
|
game.server.ruledit.named_teams,
|
||
|
"teams.names");
|
||
|
secfile_insert_str_vec_gt_marking(sfile, tnames,
|
||
|
game.server.ruledit.named_teams,
|
||
|
"teams.names");
|
||
|
}
|
||
|
comment_disasters(sfile);
|
||
| ... | ... | |
|
save_default_int(sfile, pach->culture,
|
||
|
0, path, "culture");
|
||
|
secfile_insert_str(sfile, pach->first_msg, "%s.first_msg", path);
|
||
|
pentry = secfile_insert_str(sfile, pach->first_msg,
|
||
|
"%s.first_msg", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
if (pach->cons_msg != NULL) {
|
||
|
secfile_insert_str(sfile, pach->cons_msg, "%s.cons_msg", path);
|
||
|
pentry = secfile_insert_str(sfile, pach->cons_msg,
|
||
|
"%s.cons_msg", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
} achievements_iterate_end;
|
||
| ... | ... | |
|
{
|
||
|
struct section_file *sfile = create_ruleset_file(name, "government");
|
||
|
int sect_idx;
|
||
|
struct entry *pentry;
|
||
|
if (sfile == NULL) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
title = ruler_title_male_untranslated_name(prtitle);
|
||
|
if (title != NULL) {
|
||
|
secfile_insert_str(sfile, title,
|
||
|
"%s.ruler_male_title", path);
|
||
|
pentry = secfile_insert_str(sfile, title,
|
||
|
"%s.ruler_male_title", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
title = ruler_title_female_untranslated_name(prtitle);
|
||
|
if (title != NULL) {
|
||
|
secfile_insert_str(sfile, title,
|
||
|
"%s.ruler_female_title", path);
|
||
|
pentry = secfile_insert_str(sfile, title,
|
||
|
"%s.ruler_female_title", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
int sect_idx;
|
||
|
struct advance *a_none = advance_by_number(A_NONE);
|
||
|
bool uflags_tech = FALSE;
|
||
|
struct entry *pentry;
|
||
|
if (sfile == NULL) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
uflags_tech = TRUE;
|
||
|
}
|
||
|
secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
|
||
|
pentry = secfile_insert_str(sfile, flagname,
|
||
|
"control.flags%d.name", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
/* Save the user flag help text even when it is undefined. That makes
|
||
|
* the formatting code happy. The resulting "" is ignored when the
|
||
|
* ruleset is loaded. */
|
||
|
secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
|
||
|
pentry = secfile_insert_str(sfile, helptxt,
|
||
|
"control.flags%d.helptxt", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
secfile_insert_str(sfile, pa->graphic_alt, "%s.graphic_alt", path);
|
||
|
}
|
||
|
if (pa->bonus_message != NULL) {
|
||
|
secfile_insert_str(sfile, pa->bonus_message, "%s.bonus_message", path);
|
||
|
pentry = secfile_insert_str(sfile, pa->bonus_message,
|
||
|
"%s.bonus_message", path);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
set_count = 0;
|
||
| ... | ... | |
|
int i;
|
||
|
bool uflags_terr = FALSE;
|
||
|
bool uflags_extra = FALSE;
|
||
|
struct entry *pentry;
|
||
|
if (sfile == NULL) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
uflags_terr = TRUE;
|
||
|
}
|
||
|
secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
|
||
|
pentry = secfile_insert_str(sfile, flagname,
|
||
|
"control.flags%d.name", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
/* Save the user flag help text even when it is undefined. That makes
|
||
|
* the formatting code happy. The resulting "" is ignored when the
|
||
|
* ruleset is loaded. */
|
||
|
secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
|
||
|
pentry = secfile_insert_str(sfile, helptxt,
|
||
|
"control.flags%d.helptxt", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
uflags_extra = TRUE;
|
||
|
}
|
||
|
secfile_insert_str(sfile, flagname, "control.extra_flags%d.name", i);
|
||
|
pentry = secfile_insert_str(sfile, flagname,
|
||
|
"control.extra_flags%d.name", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
/* Save the user flag help text even when it is undefined. That makes
|
||
|
* the formatting code happy. The resulting "" is ignored when the
|
||
|
* ruleset is loaded. */
|
||
|
secfile_insert_str(sfile, helptxt,
|
||
|
"control.extra_flags%d.helptxt", i);
|
||
|
pentry = secfile_insert_str(sfile, helptxt,
|
||
|
"control.extra_flags%d.helptxt", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
} extra_type_by_cause_iterate_end;
|
||
|
secfile_insert_str(sfile, terrain_control.gui_type_base0,
|
||
|
"extraui.ui_name_base_fortress");
|
||
|
secfile_insert_str(sfile, terrain_control.gui_type_base1,
|
||
|
"extraui.ui_name_base_airbase");
|
||
|
pentry = secfile_insert_str(sfile, terrain_control.gui_type_base0,
|
||
|
"extraui.ui_name_base_fortress");
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
pentry = secfile_insert_str(sfile, terrain_control.gui_type_base1,
|
||
|
"extraui.ui_name_base_airbase");
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
comment_extras(sfile);
|
||
| ... | ... | |
|
vlist_move[i] = vsystem->definitions[i].move_bonus;
|
||
|
}
|
||
|
secfile_insert_str_vec(sfile, vlist_name, vsystem->levels,
|
||
|
"%s.veteran_names", path);
|
||
|
secfile_insert_str_vec_gt_marking(sfile, vlist_name, vsystem->levels,
|
||
|
"%s.veteran_names", path);
|
||
|
secfile_insert_int_vec(sfile, vlist_power, vsystem->levels,
|
||
|
"%s.veteran_power_fact", path);
|
||
|
secfile_insert_int_vec(sfile, vlist_raise, vsystem->levels,
|
||
| ... | ... | |
|
int sect_idx;
|
||
|
bool uflags_utype = FALSE;
|
||
|
bool uflags_uclass = FALSE;
|
||
|
struct entry *pentry;
|
||
|
if (sfile == NULL) {
|
||
|
return FALSE;
|
||
| ... | ... | |
|
uflags_utype = TRUE;
|
||
|
}
|
||
|
secfile_insert_str(sfile, flagname, "control.flags%d.name", i);
|
||
|
pentry = secfile_insert_str(sfile, flagname,
|
||
|
"control.flags%d.name", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
/* Save the user flag help text even when it is undefined. That makes
|
||
|
* the formatting code happy. The resulting "" is ignored when the
|
||
|
* ruleset is loaded. */
|
||
|
secfile_insert_str(sfile, helptxt, "control.flags%d.helptxt", i);
|
||
|
pentry = secfile_insert_str(sfile, helptxt,
|
||
|
"control.flags%d.helptxt", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
uflags_uclass = TRUE;
|
||
|
}
|
||
|
secfile_insert_str(sfile, flagname, "control.class_flags%d.name", i);
|
||
|
pentry = secfile_insert_str(sfile, flagname,
|
||
|
"control.class_flags%d.name", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
/* Save the user flag help text even when it is undefined. That makes
|
||
|
* the formatting code happy. The resulting "" is ignored when the
|
||
|
* ruleset is loaded. */
|
||
|
secfile_insert_str(sfile, helptxt,
|
||
|
"control.class_flags%d.helptxt", i);
|
||
|
pentry = secfile_insert_str(sfile, helptxt,
|
||
|
"control.class_flags%d.helptxt", i);
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
| utility/registry_ini.c | ||
|---|---|---|
|
size_t secfile_insert_str_vec_full(struct section_file *secfile,
|
||
|
const char *const *strings, size_t dim,
|
||
|
const char *comment, bool allow_replace,
|
||
|
bool no_escape, const char *path, ...)
|
||
|
bool no_escape, bool gt_marking,
|
||
|
const char *path, ...)
|
||
|
{
|
||
|
char fullpath[MAX_LEN_SECPATH];
|
||
|
size_t i, ret = 0;
|
||
|
va_list args;
|
||
|
struct entry *pentry;
|
||
|
SECFILE_RETURN_VAL_IF_FAIL(secfile, NULL, NULL != secfile, 0);
|
||
| ... | ... | |
|
/* NB: 'path,0' is actually 'path'. See comment in the head
|
||
|
* of the file. */
|
||
|
if (dim > 0
|
||
|
&& NULL != secfile_insert_str_full(secfile, strings[0], comment,
|
||
|
allow_replace, no_escape, FALSE,
|
||
|
"%s", fullpath)) {
|
||
|
ret++;
|
||
|
if (dim > 0) {
|
||
|
pentry = secfile_insert_str_full(secfile, strings[0], comment,
|
||
|
allow_replace, no_escape, FALSE,
|
||
|
"%s", fullpath);
|
||
|
if (NULL != pentry) {
|
||
|
ret++;
|
||
|
if (gt_marking) {
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
for (i = 1; i < dim; i++) {
|
||
|
if (NULL != secfile_insert_str_full(secfile, strings[i], comment,
|
||
|
allow_replace, no_escape, FALSE,
|
||
|
"%s,%d", fullpath, (int) i)) {
|
||
|
pentry = secfile_insert_str_full(secfile, strings[i], comment,
|
||
|
allow_replace, no_escape, FALSE,
|
||
|
"%s,%d", fullpath, (int) i);
|
||
|
if (NULL != pentry) {
|
||
|
ret++;
|
||
|
if (gt_marking) {
|
||
|
entry_str_set_gt_marking(pentry, TRUE);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| utility/registry_ini.h | ||
|---|---|---|
|
comment, path, ...) \
|
||
|
secfile_insert_str_full(secfile, string, comment, TRUE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
size_t secfile_insert_str_vec_full(struct section_file *secfile,
|
||
|
const char *const *strings, size_t dim,
|
||
|
const char *comment, bool allow_replace,
|
||
|
bool no_escape, const char *path, ...)
|
||
|
fc__attribute((__format__(__printf__, 7, 8)));
|
||
|
bool no_escape, bool gt_marking,
|
||
|
const char *path, ...)
|
||
|
fc__attribute((__format__(__printf__, 8, 9)));
|
||
|
#define secfile_insert_str_vec(secfile, strings, dim, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, NULL, FALSE, FALSE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
NULL, FALSE, FALSE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_insert_str_vec_gt_marking(secfile, strings, dim, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
NULL, FALSE, FALSE, TRUE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_insert_str_vec_noescape(secfile, strings, dim, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, NULL, FALSE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
NULL, FALSE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_insert_str_vec_comment(secfile, strings, dim, \
|
||
|
comment, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, comment, FALSE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
comment, FALSE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_insert_str_vec_noescape_comment(secfile, strings, dim, \
|
||
|
comment, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, comment, FALSE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
comment, FALSE, TRUE, FALSE \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_replace_str_vec(secfile, strings, dim, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, NULL, TRUE, FALSE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
NULL, TRUE, FALSE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_replace_str_vec_noescape(secfile, strings, dim, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, NULL, TRUE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
NULL, TRUE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_replace_str_vec_comment(secfile, strings, dim, \
|
||
|
comment, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, comment, TRUE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
comment, TRUE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
#define secfile_replace_str_vec_noescape_comment(secfile, strings, dim, \
|
||
|
comment, path, ...) \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, comment, TRUE, TRUE, \
|
||
|
secfile_insert_str_vec_full(secfile, strings, dim, \
|
||
|
comment, TRUE, TRUE, FALSE, \
|
||
|
path, ## __VA_ARGS__)
|
||
|
struct entry *secfile_insert_plain_enum_full(struct section_file *secfile,
|
||
| ... | ... | |
|
secfile_data_t data, const char *path, ...)
|
||
|
fc__warn_unused_result
|
||
|
fc__attribute((__format__ (__printf__, 6, 7)));
|
||
|
|
||
|
/* Sections functions. */
|
||
|
struct section *secfile_section_by_name(const struct section_file *secfile,
|
||
|
const char *section_name);
|
||