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

Function optfn_windowborders

src/options.c:4796–4853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4794}
4795
4796staticfn int
4797optfn_windowborders(
4798 int optidx, int req, boolean negated,
4799 char *opts, char *op)
4800{
4801 int retval = optn_ok;
4802
4803 if (req == do_init) {
4804 return optn_ok;
4805 }
4806 if (req == do_set) {
4807 op = string_for_opt(opts, negated);
4808 if (negated && op != empty_optstr) {
4809 bad_negation(allopt[optidx].name, TRUE);
4810 retval = optn_err;
4811 } else {
4812 int itmp;
4813
4814 if (negated)
4815 itmp = 0; /* Off */
4816 else if (op == empty_optstr)
4817 itmp = 1; /* On */
4818 else /* Value supplied; expect 0 (off), 1 (on), 2 (auto)
4819 * or 3 (on for most windows, off for perm_invent)
4820 * or 4 (auto for most windows, off for perm_invent) */
4821 itmp = atoi(op);
4822
4823 if (itmp < 0 || itmp > 4) {
4824 config_error_add("Invalid %s (should be within 0 to 4): %s",
4825 allopt[optidx].name, opts);
4826 retval = optn_silenterr;
4827 } else {
4828 iflags.wc2_windowborders = itmp;
4829 }
4830 }
4831 return retval;
4832 }
4833 if (req == get_val) {
4834 Sprintf(opts, "%s",
4835 (iflags.wc2_windowborders == 0) ? "0=off"
4836 : (iflags.wc2_windowborders == 1) ? "1=on"
4837 : (iflags.wc2_windowborders == 2) ? "2=auto"
4838 : (iflags.wc2_windowborders == 3)
4839 ? "3=on, except off for perm_invent"
4840 : (iflags.wc2_windowborders == 4)
4841 ? "4=auto, except off for perm_invent"
4842 : defopt);
4843 return optn_ok;
4844 }
4845 if (req == get_cnf_val) {
4846 Sprintf(opts, "%i", iflags.wc2_windowborders);
4847 return optn_ok;
4848 }
4849 if (req == do_handler) {
4850 return handler_windowborders();
4851 }
4852 return optn_ok;
4853}

Callers

nothing calls this directly

Calls 4

string_for_optFunction · 0.85
bad_negationFunction · 0.85
config_error_addFunction · 0.85
handler_windowbordersFunction · 0.85

Tested by

no test coverage detected