MCPcopy Index your code
hub / github.com/NetHack/NetHack / optfn_runmode

Function optfn_runmode

src/options.c:3626–3666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3624}
3625
3626staticfn int
3627optfn_runmode(
3628 int optidx, int req, boolean negated,
3629 char *opts, char *op)
3630{
3631 if (req == do_init) {
3632 return optn_ok;
3633 }
3634 if (req == do_set) {
3635 if (negated) {
3636 flags.runmode = RUN_TPORT;
3637 } else if (op != empty_optstr) {
3638 if (str_start_is("teleport", op, TRUE))
3639 flags.runmode = RUN_TPORT;
3640 else if (str_start_is("run", op, TRUE))
3641 flags.runmode = RUN_LEAP;
3642 else if (str_start_is("walk", op, TRUE))
3643 flags.runmode = RUN_STEP;
3644 else if (str_start_is("crawl", op, TRUE))
3645 flags.runmode = RUN_CRAWL;
3646 else {
3647 config_error_add("Unknown %s parameter '%s'",
3648 allopt[optidx].name, op);
3649 return optn_err;
3650 }
3651 } else {
3652 config_error_add("Value is mandatory for %s",
3653 allopt[optidx].name);
3654 return optn_err;
3655 }
3656 return optn_ok;
3657 }
3658 if (req == get_val || req == get_cnf_val) {
3659 Sprintf(opts, "%s", runmodes[flags.runmode]);
3660 return optn_ok;
3661 }
3662 if (req == do_handler) {
3663 return handler_runmode();
3664 }
3665 return optn_ok;
3666}
3667
3668staticfn int
3669optfn_scores(

Callers

nothing calls this directly

Calls 3

str_start_isFunction · 0.85
config_error_addFunction · 0.85
handler_runmodeFunction · 0.85

Tested by

no test coverage detected