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

Function update_rest_on_space

src/cmd.c:3482–3503  ·  view source on GitHub ↗

called when 'rest_on_space' is toggled, also called by reset_commands() from initoptions_init() which takes place before key bindings have been processed, and by initoptions_finish() after key bindings so that we can remember anything bound to in 'unrestonspace' */

Source from the content-addressed store, hash-verified

3480 processed, and by initoptions_finish() after key bindings so that we
3481 can remember anything bound to <space> in 'unrestonspace' */
3482void
3483update_rest_on_space(void)
3484{
3485 /* cloned from extcmdlist['.'], then slightly modified to be distinct;
3486 donull is all that's needed for it to operate; command name and
3487 description get shown by help menu's "Info on what a given key does"
3488 (which runs the '&' command) and "Full list of keyboard commands" */
3489 static const struct ext_func_tab restonspace = {
3490 ' ', "wait", "rest one move via 'rest_on_space' option",
3491 donull, (IFBURIED | CMD_M_PREFIX), "waiting"
3492 };
3493 static const struct ext_func_tab *unrestonspace = 0;
3494 struct Cmd_bind *bind = cmdbind_get(' ');
3495
3496 /* when 'rest_on_space' is On, <space> will run the #wait command;
3497 when it is Off, <space> will use 'unrestonspace' which will either
3498 be Null and elicit "Unknown command ' '." or have some non-Null
3499 command bound in player's RC file */
3500 if (bind && bind->cmd != &restonspace)
3501 unrestonspace = bind->cmd;
3502 cmdbind_add(' ', flags.rest_on_space ? &restonspace : unrestonspace, FALSE);
3503}
3504
3505/* commands which accept 'm' prefix to request menu operation or other
3506 alternate behavior; it's also overloaded for move-without-autopickup;

Callers 3

optfn_booleanFunction · 0.85
initoptions_finishFunction · 0.85
reset_commandsFunction · 0.85

Calls 2

cmdbind_getFunction · 0.85
cmdbind_addFunction · 0.85

Tested by

no test coverage detected