fix movement prefixes

My earlier change resulted in rejecting all commands entered after
a movement prefix key, rather than just ones that aren't supposed to
take any prefix.

This fixes that and also restores the ability to use 'm>' or 'm<' on
stairs to change levels without auto-pickup at the destination.
This commit is contained in:
PatR
2022-02-06 17:46:31 -08:00
parent f233f1d18c
commit b3c5d68399
4 changed files with 45 additions and 40 deletions

View File

@@ -1002,6 +1002,9 @@ cursed scroll of light had special message when wielding Sunsword that didn't
work for wearing gold dragon scales/mail work for wearing gold dragon scales/mail
giving a prefix keystroke other than 'm' prior to a command that doesn't use giving a prefix keystroke other than 'm' prior to a command that doesn't use
prefixes was siliently ignored instead of being rejected prefixes was siliently ignored instead of being rejected
prior revision broke all prefix usage
movement command revamp broke 'm>' and 'm<' on stairs to avoid auto-pickup at
the destination
curses: 'msg_window' option wasn't functional for curses unless the binary curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support also included tty support

View File

@@ -199,6 +199,7 @@ extern boolean status_hilite_menu(void);
/* ### cmd.c ### */ /* ### cmd.c ### */
extern void set_move_cmd(int, int);
extern int do_move_west(void); extern int do_move_west(void);
extern int do_move_northwest(void); extern int do_move_northwest(void);
extern int do_move_north(void); extern int do_move_north(void);

View File

@@ -105,7 +105,6 @@ static int dotravel(void);
static int dotravel_target(void); static int dotravel_target(void);
static int doclicklook(void); static int doclicklook(void);
static int doterrain(void); static int doterrain(void);
static void set_move_cmd(int, int);
static int wiz_wish(void); static int wiz_wish(void);
static int wiz_identify(void); static int wiz_identify(void);
static int wiz_map(void); static int wiz_map(void);
@@ -1844,20 +1843,20 @@ doterrain(void)
return ECMD_OK; /* no time elapses */ return ECMD_OK; /* no time elapses */
} }
static void void
set_move_cmd(int dir, int run) set_move_cmd(int dir, int run)
{ {
u.dz = zdir[dir];
u.dx = xdir[dir];
u.dy = ydir[dir];
/* #reqmenu -prefix disables autopickup during movement */ /* #reqmenu -prefix disables autopickup during movement */
if (iflags.menu_requested) if (iflags.menu_requested)
g.context.nopick = 1; g.context.nopick = 1;
g.context.travel = g.context.travel1 = 0; g.context.travel = g.context.travel1 = 0;
if (!g.domove_attempting) { if (!g.domove_attempting && !u.dz) {
g.context.run = run; g.context.run = run;
g.domove_attempting |= (!run ? DOMOVE_WALK : DOMOVE_RUSH); g.domove_attempting |= (!run ? DOMOVE_WALK : DOMOVE_RUSH);
} }
u.dz = zdir[dir];
u.dx = xdir[dir];
u.dy = ydir[dir];
} }
/* move or attack */ /* move or attack */
@@ -2036,7 +2035,8 @@ int
do_reqmenu(void) do_reqmenu(void)
{ {
if (iflags.menu_requested) { if (iflags.menu_requested) {
Norep("Double %s prefix, canceled.", visctrl(cmd_from_func(do_reqmenu))); Norep("Double %s prefix, canceled.",
visctrl(cmd_from_func(do_reqmenu)));
iflags.menu_requested = FALSE; iflags.menu_requested = FALSE;
return ECMD_CANCEL; return ECMD_CANCEL;
} }
@@ -2135,7 +2135,7 @@ struct ext_func_tab extcmdlist[] = {
{ M('d'), "dip", "dip an object into something", { M('d'), "dip", "dip an object into something",
dodip, AUTOCOMPLETE, NULL }, dodip, AUTOCOMPLETE, NULL },
{ '>', "down", "go down a staircase", { '>', "down", "go down a staircase",
dodown, 0, NULL }, dodown, MOVEMENTCMD, NULL },
{ 'd', "drop", "drop an item", { 'd', "drop", "drop an item",
dodrop, 0, NULL }, dodrop, 0, NULL },
{ 'D', "droptype", "drop specific item types", { 'D', "droptype", "drop specific item types",
@@ -2320,7 +2320,7 @@ struct ext_func_tab extcmdlist[] = {
{ M('u'), "untrap", "untrap something", { M('u'), "untrap", "untrap something",
dountrap, AUTOCOMPLETE, NULL }, dountrap, AUTOCOMPLETE, NULL },
{ '<', "up", "go up a staircase", { '<', "up", "go up a staircase",
doup, 0, NULL }, doup, MOVEMENTCMD, NULL },
{ '\0', "vanquished", "list vanquished monsters", { '\0', "vanquished", "list vanquished monsters",
dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL },
{ M('v'), "version", { M('v'), "version",
@@ -2386,55 +2386,55 @@ struct ext_func_tab extcmdlist[] = {
/* movement commands will be bound by reset_commands() */ /* movement commands will be bound by reset_commands() */
/* move or attack */ /* move or attack */
{ '\0', "movewest", "move west (screen left)", { '\0', "movewest", "move west (screen left)",
do_move_west, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_west, MOVEMENTCMD, NULL },
{ '\0', "movenorthwest", "move northwest (screen upper left)", { '\0', "movenorthwest", "move northwest (screen upper left)",
do_move_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_northwest, MOVEMENTCMD, NULL },
{ '\0', "movenorth", "move north (screen up)", { '\0', "movenorth", "move north (screen up)",
do_move_north, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_north, MOVEMENTCMD, NULL },
{ '\0', "movenortheast", "move northeast (screen upper right)", { '\0', "movenortheast", "move northeast (screen upper right)",
do_move_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_northeast, MOVEMENTCMD, NULL },
{ '\0', "moveeast", "move east (screen right)", { '\0', "moveeast", "move east (screen right)",
do_move_east, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_east, MOVEMENTCMD, NULL },
{ '\0', "movesoutheast", "move southeast (screen lower right)", { '\0', "movesoutheast", "move southeast (screen lower right)",
do_move_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_southeast, MOVEMENTCMD, NULL },
{ '\0', "movesouth", "move south (screen down)", { '\0', "movesouth", "move south (screen down)",
do_move_south, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_south, MOVEMENTCMD, NULL },
{ '\0', "movesouthwest", "move southwest (screen lower left)", { '\0', "movesouthwest", "move southwest (screen lower left)",
do_move_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_move_southwest, MOVEMENTCMD, NULL },
/* rush */ /* rush */
{ '\0', "rushwest", "rush west (screen left)", { '\0', "rushwest", "rush west (screen left)",
do_rush_west, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_west, MOVEMENTCMD, NULL },
{ '\0', "rushnorthwest", "rush northwest (screen upper left)", { '\0', "rushnorthwest", "rush northwest (screen upper left)",
do_rush_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_northwest, MOVEMENTCMD, NULL },
{ '\0', "rushnorth", "rush north (screen up)", { '\0', "rushnorth", "rush north (screen up)",
do_rush_north, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_north, MOVEMENTCMD, NULL },
{ '\0', "rushnortheast", "rush northeast (screen upper right)", { '\0', "rushnortheast", "rush northeast (screen upper right)",
do_rush_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_northeast, MOVEMENTCMD, NULL },
{ '\0', "rusheast", "rush east (screen right)", { '\0', "rusheast", "rush east (screen right)",
do_rush_east, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_east, MOVEMENTCMD, NULL },
{ '\0', "rushsoutheast", "rush southeast (screen lower right)", { '\0', "rushsoutheast", "rush southeast (screen lower right)",
do_rush_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_southeast, MOVEMENTCMD, NULL },
{ '\0', "rushsouth", "rush south (screen down)", { '\0', "rushsouth", "rush south (screen down)",
do_rush_south, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_south, MOVEMENTCMD, NULL },
{ '\0', "rushsouthwest", "rush southwest (screen lower left)", { '\0', "rushsouthwest", "rush southwest (screen lower left)",
do_rush_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_rush_southwest, MOVEMENTCMD, NULL },
/* run */ /* run */
{ '\0', "runwest", "run west (screen left)", { '\0', "runwest", "run west (screen left)",
do_run_west, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_west, MOVEMENTCMD, NULL },
{ '\0', "runnorthwest", "run northwest (screen upper left)", { '\0', "runnorthwest", "run northwest (screen upper left)",
do_run_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_northwest, MOVEMENTCMD, NULL },
{ '\0', "runnorth", "run north (screen up)", { '\0', "runnorth", "run north (screen up)",
do_run_north, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_north, MOVEMENTCMD, NULL },
{ '\0', "runnortheast", "run northeast (screen upper right)", { '\0', "runnortheast", "run northeast (screen upper right)",
do_run_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_northeast, MOVEMENTCMD, NULL },
{ '\0', "runeast", "run east (screen right)", { '\0', "runeast", "run east (screen right)",
do_run_east, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_east, MOVEMENTCMD, NULL },
{ '\0', "runsoutheast", "run southeast (screen lower right)", { '\0', "runsoutheast", "run southeast (screen lower right)",
do_run_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_southeast, MOVEMENTCMD, NULL },
{ '\0', "runsouth", "run south (screen down)", { '\0', "runsouth", "run south (screen down)",
do_run_south, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_south, MOVEMENTCMD, NULL },
{ '\0', "runsouthwest", "run southwest (screen lower left)", { '\0', "runsouthwest", "run southwest (screen lower left)",
do_run_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, do_run_southwest, MOVEMENTCMD, NULL },
/* internal commands: only used by game core, not available for user */ /* internal commands: only used by game core, not available for user */
{ '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL }, { '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL },
@@ -3844,13 +3844,14 @@ rhack(char *cmd)
/* can_do_extcmd() already gave a message */ /* can_do_extcmd() already gave a message */
reset_cmd_vars(); reset_cmd_vars();
res = ECMD_OK; res = ECMD_OK;
} else if (prefix_seen && !(tlist->flags & PREFIXCMD) } else if (prefix_seen
&& !(tlist->flags & (PREFIXCMD | MOVEMENTCMD))
&& (!was_m_prefix || !accept_menu_prefix(tlist))) { && (!was_m_prefix || !accept_menu_prefix(tlist))) {
const char *which; const char *which;
/* got prefix previously but this command doesn't accept one */ /* got prefix previously but this command doesn't accept one */
which = (prefix_seen->ef_funct == do_reqmenu) which = (prefix_seen->ef_funct == do_reqmenu)
? "move or request menu" ? "move-no-pickup or request-menu"
: prefix_seen->ef_txt; : prefix_seen->ef_txt;
pline("The %s command does not accept %s prefix.", pline("The %s command does not accept %s prefix.",
tlist->ef_txt, which); tlist->ef_txt, which);

View File

@@ -981,6 +981,8 @@ dodown(void)
boolean stairs_down = (stway && !stway->up && !stway->isladder), boolean stairs_down = (stway && !stway->up && !stway->isladder),
ladder_down = (stway && !stway->up && stway->isladder); ladder_down = (stway && !stway->up && stway->isladder);
set_move_cmd(DIR_DOWN, 0);
if (u_rooted()) if (u_rooted())
return ECMD_TIME; return ECMD_TIME;
@@ -1051,7 +1053,7 @@ dodown(void)
dotrap(trap, TOOKPLUNGE); dotrap(trap, TOOKPLUNGE);
} }
} }
return ECMD_TIME; /* came out of hiding; might need '>' again to go down */ return ECMD_TIME; /* came out of hiding; need '>' again to go down */
} }
if (u.ustuck) { if (u.ustuck) {
@@ -1070,7 +1072,6 @@ dodown(void)
} else if (!trap || !is_hole(trap->ttyp) } else if (!trap || !is_hole(trap->ttyp)
|| !Can_fall_thru(&u.uz) || !trap->tseen) { || !Can_fall_thru(&u.uz) || !trap->tseen) {
if (flags.autodig && !g.context.nopick && uwep && is_pick(uwep)) { if (flags.autodig && !g.context.nopick && uwep && is_pick(uwep)) {
u.dz = 1; /* the #down command doesn't call set_move_cmd() */
return use_pick_axe2(uwep); return use_pick_axe2(uwep);
} else { } else {
You_cant("go down here."); You_cant("go down here.");
@@ -1121,8 +1122,6 @@ dodown(void)
if (trap && Is_stronghold(&u.uz)) { if (trap && Is_stronghold(&u.uz)) {
goto_hell(FALSE, TRUE); goto_hell(FALSE, TRUE);
} else { } else {
if (!trap)
u.dz = 1;
g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER);
next_level(!trap); next_level(!trap);
g.at_ladder = FALSE; g.at_ladder = FALSE;
@@ -1136,6 +1135,8 @@ doup(void)
{ {
stairway *stway = stairway_at(u.ux,u.uy); stairway *stway = stairway_at(u.ux,u.uy);
set_move_cmd(DIR_UP, 0);
if (u_rooted()) if (u_rooted())
return ECMD_TIME; return ECMD_TIME;
@@ -1176,7 +1177,6 @@ doup(void)
return ECMD_OK; return ECMD_OK;
} }
g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER);
u.dz = -1;
prev_level(TRUE); prev_level(TRUE);
g.at_ladder = FALSE; g.at_ladder = FALSE;
return ECMD_TIME; return ECMD_TIME;