MCPcopy Create free account
hub / github.com/NetHack/NetHack / all_options_strbuf

Function all_options_strbuf

src/options.c:9677–9748  ·  view source on GitHub ↗

return strbuf of all options, to write to file */

Source from the content-addressed store, hash-verified

9675
9676/* return strbuf of all options, to write to file */
9677void
9678all_options_strbuf(strbuf_t *sbuf)
9679{
9680 const char *name;
9681 char tmp[BUFSZ];
9682 char *buf2;
9683 boolean *bool_p;
9684 int i;
9685
9686 strbuf_init(sbuf);
9687 Sprintf(tmp, "# NetHack config, saved %s\n#\n",
9688 yyyymmddhhmmss((time_t) 0));
9689 strbuf_append(sbuf, tmp);
9690
9691 for (i = 0; (name = allopt[i].name) != 0; i++) {
9692 if (!opt_set_in_config[i])
9693 continue;
9694 switch (allopt[i].opttyp) {
9695 case BoolOpt:
9696 bool_p = allopt[i].addr;
9697 if (!bool_p || bool_p == &flags.female)
9698 break; /* obsolete */
9699 if (*bool_p != allopt[i].initval) {
9700 Sprintf(tmp, "OPTIONS=%s%s\n", *bool_p ? "" : "!", name);
9701 strbuf_append(sbuf, tmp);
9702 }
9703 break;
9704 case CompOpt:
9705 if (!(allopt[i].setwhere == set_in_config
9706 || allopt[i].setwhere == set_gameview
9707 || allopt[i].setwhere == set_in_game))
9708 break;
9709 /* FIXME: get_option_value for:
9710 - menu_deselect_all &c menu control keys,
9711 - term_cols, term_rows */
9712 buf2 = get_option_value(name, TRUE);
9713 if (buf2) {
9714 Snprintf(tmp, sizeof tmp - 1, "OPTIONS=%s:%s", name, buf2);
9715 Strcat(tmp, "\n"); /* guaranteed to fit */
9716 strbuf_append(sbuf, tmp);
9717 }
9718 break;
9719 case OthrOpt:
9720 break;
9721 }
9722 }
9723
9724 /* cond_xyz are closer to regular options than the other 'other opts'
9725 so put them next; [pfx_cond_] will be set if any cond_Foo were
9726 present when RC file was read in or if player made any changes via
9727 status conditions menu; ignore opt_set_in_config[opt_o_status_cond] */
9728 if (opt_set_in_config[pfx_cond_])
9729 all_options_conds(sbuf);
9730
9731#ifdef CHANGE_COLOR
9732 all_options_palette(sbuf);
9733#endif
9734 get_changed_key_binds(sbuf);

Callers 1

do_write_config_fileFunction · 0.85

Calls 13

strbuf_initFunction · 0.85
yyyymmddhhmmssFunction · 0.85
strbuf_appendFunction · 0.85
get_option_valueFunction · 0.85
all_options_condsFunction · 0.85
all_options_paletteFunction · 0.85
get_changed_key_bindsFunction · 0.85
savedsym_strbufFunction · 0.85
all_options_menucolorsFunction · 0.85
all_options_msgtypesFunction · 0.85
all_options_apesFunction · 0.85
all_options_autocompleteFunction · 0.85

Tested by

no test coverage detected