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

Function optfn_role

src/options.c:3588–3624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3586}
3587
3588staticfn int
3589optfn_role(
3590 int optidx,
3591 int req,
3592 boolean negated,
3593 char *opts,
3594 char *op)
3595{
3596 if (req == do_init) {
3597 return optn_ok;
3598 }
3599 if (req == do_set) {
3600 /* role:string */
3601 if (!parse_role_opt(optidx, negated, allopt[optidx].name, opts, &op))
3602 return optn_silenterr;
3603
3604 if (*op != '!') {
3605 if ((flags.initrole = str2role(op)) == ROLE_NONE) {
3606 config_error_add("Unknown %s '%s'", allopt[optidx].name, op);
3607 return optn_err;
3608 }
3609 nmcpy(svp.pl_character, op, PL_NSIZ); /* Backwards compat */
3610 saveoptstr(optidx, rolestring(flags.initrole, roles, name.m));
3611 }
3612 return optn_ok;
3613 }
3614 if (req == get_val) {
3615 Sprintf(opts, "%s", rolestring(flags.initrole, roles, name.m));
3616 return optn_ok;
3617 }
3618 if (req == get_cnf_val) {
3619 op = get_cnf_role_opt(optidx);
3620 Strcpy(opts, op ? op : "none");
3621 return optn_ok;
3622 }
3623 return optn_ok;
3624}
3625
3626staticfn int
3627optfn_runmode(

Callers

nothing calls this directly

Calls 6

parse_role_optFunction · 0.85
str2roleFunction · 0.85
config_error_addFunction · 0.85
nmcpyFunction · 0.85
saveoptstrFunction · 0.85
get_cnf_role_optFunction · 0.85

Tested by

no test coverage detected