fix rest_on_space

When rest_on_space is On, assign same function as for #wait to the
<space> key.  When Off, set that key to Null instead.  Binding some
other command to <space> when rest_on_space is Off doesn't work but
I would classify that as something to be discouraged anyway.
This commit is contained in:
PatR
2022-01-21 15:51:05 -08:00
parent 75fed4b92b
commit 6a72e48a40
4 changed files with 26 additions and 4 deletions

View File

@@ -980,8 +980,8 @@ changing engraving to an occupation resulted in not dulling a weapon used to
a change to wounded legs handling resulted in not recovering lost dexterity
or receiving the "leg(s) feel better" message if wound time expired
rather than having legs be explicitly healed
turning movement into commands interfered with using pick-axe plus autodig
in downward direction
turning movement into commands broke the rest_on_space option; it also
interfered with using pick-axe plus autodig in downward direction
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -252,6 +252,7 @@ extern const char *key2extcmddesc(uchar);
extern boolean bind_specialkey(uchar, const char *);
extern void parseautocomplete(char *, boolean);
extern void reset_commands(boolean);
extern void update_rest_on_space(void);
extern void rhack(char *);
extern int doextlist(void);
extern int extcmd_via_menu(void);

View File

@@ -2574,9 +2574,10 @@ commands_init(void)
(void) bind_key(M('2'), "twoweapon");
(void) bind_key(M('n'), "name");
(void) bind_key(M('N'), "name");
/* wait_on_space */
#if 0
/* don't do this until the rest_on_space option is set or cleared */
(void) bind_key(' ', "wait");
#endif
}
static boolean
@@ -3573,6 +3574,22 @@ reset_commands(boolean initial)
(void) bind_key_fn(M(g.Cmd.dirchars[i]), move_funcs[i][MV_RUSH]);
}
}
update_rest_on_space();
}
void
update_rest_on_space(void)
{
/* cloned from extcmdlist['.'], then slightly modified to be distinct;
donull is all that's needed for it to operate; command name and
description get shown by help menu's "Info on what a given key does"
(which runs the '&' command) and "Full list of keyboard commands" */
static const struct ext_func_tab restonspace = {
' ', "wait", "rest one move via 'rest_on_space' option",
donull, (IFBURIED | CMD_M_PREFIX), "waiting"
};
g.Cmd.commands[' '] = flags.rest_on_space ? &restonspace : 0;
}
/* commands which accept 'm' prefix to request menu operation */

View File

@@ -4225,6 +4225,9 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op)
case opt_mention_decor:
iflags.prev_decor = STONE;
break;
case opt_rest_on_space:
update_rest_on_space();
break;
}
/* boolean value has been toggled but some option changes can
@@ -5908,6 +5911,7 @@ initoptions_finish(void)
}
}
#endif
update_rest_on_space();
g.opt_initial = FALSE;
return;
}