From: PatR Date: Mon, 7 Feb 2022 01:46:31 +0000 (-0800) Subject: fix movement prefixes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3c5d683996028d00a7ca91f72638fb1a0d07347;p=nethack 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. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2e7d69193..cac6d33c6 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1002,6 +1002,9 @@ cursed scroll of light had special message when wielding Sunsword that didn't work for wearing gold dragon scales/mail giving a prefix keystroke other than 'm' prior to a command that doesn't use 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 also included tty support diff --git a/include/extern.h b/include/extern.h index dea9bedbc..a2bf6ca7e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -199,6 +199,7 @@ extern boolean status_hilite_menu(void); /* ### cmd.c ### */ +extern void set_move_cmd(int, int); extern int do_move_west(void); extern int do_move_northwest(void); extern int do_move_north(void); diff --git a/src/cmd.c b/src/cmd.c index 1d5daaca0..c7d0e5ca7 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -105,7 +105,6 @@ static int dotravel(void); static int dotravel_target(void); static int doclicklook(void); static int doterrain(void); -static void set_move_cmd(int, int); static int wiz_wish(void); static int wiz_identify(void); static int wiz_map(void); @@ -1844,20 +1843,20 @@ doterrain(void) return ECMD_OK; /* no time elapses */ } -static void +void 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 */ if (iflags.menu_requested) g.context.nopick = 1; g.context.travel = g.context.travel1 = 0; - if (!g.domove_attempting) { + if (!g.domove_attempting && !u.dz) { g.context.run = run; g.domove_attempting |= (!run ? DOMOVE_WALK : DOMOVE_RUSH); } - u.dz = zdir[dir]; - u.dx = xdir[dir]; - u.dy = ydir[dir]; } /* move or attack */ @@ -2036,7 +2035,8 @@ int do_reqmenu(void) { 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; return ECMD_CANCEL; } @@ -2135,7 +2135,7 @@ struct ext_func_tab extcmdlist[] = { { M('d'), "dip", "dip an object into something", dodip, AUTOCOMPLETE, NULL }, { '>', "down", "go down a staircase", - dodown, 0, NULL }, + dodown, MOVEMENTCMD, NULL }, { 'd', "drop", "drop an item", dodrop, 0, NULL }, { 'D', "droptype", "drop specific item types", @@ -2320,7 +2320,7 @@ struct ext_func_tab extcmdlist[] = { { M('u'), "untrap", "untrap something", dountrap, AUTOCOMPLETE, NULL }, { '<', "up", "go up a staircase", - doup, 0, NULL }, + doup, MOVEMENTCMD, NULL }, { '\0', "vanquished", "list vanquished monsters", dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { M('v'), "version", @@ -2386,55 +2386,55 @@ struct ext_func_tab extcmdlist[] = { /* movement commands will be bound by reset_commands() */ /* move or attack */ { '\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)", - do_move_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_move_northwest, MOVEMENTCMD, NULL }, { '\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)", - do_move_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_move_northeast, MOVEMENTCMD, NULL }, { '\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)", - do_move_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_move_southeast, MOVEMENTCMD, NULL }, { '\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)", - do_move_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_move_southwest, MOVEMENTCMD, NULL }, /* rush */ { '\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)", - do_rush_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_rush_northwest, MOVEMENTCMD, NULL }, { '\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)", - do_rush_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_rush_northeast, MOVEMENTCMD, NULL }, { '\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)", - do_rush_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_rush_southeast, MOVEMENTCMD, NULL }, { '\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)", - do_rush_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_rush_southwest, MOVEMENTCMD, NULL }, /* run */ { '\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)", - do_run_northwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_run_northwest, MOVEMENTCMD, NULL }, { '\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)", - do_run_northeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_run_northeast, MOVEMENTCMD, NULL }, { '\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)", - do_run_southeast, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_run_southeast, MOVEMENTCMD, NULL }, { '\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)", - do_run_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL }, + do_run_southwest, MOVEMENTCMD, NULL }, /* internal commands: only used by game core, not available for user */ { '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL }, @@ -3844,13 +3844,14 @@ rhack(char *cmd) /* can_do_extcmd() already gave a message */ reset_cmd_vars(); 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))) { const char *which; /* got prefix previously but this command doesn't accept one */ which = (prefix_seen->ef_funct == do_reqmenu) - ? "move or request menu" + ? "move-no-pickup or request-menu" : prefix_seen->ef_txt; pline("The %s command does not accept %s prefix.", tlist->ef_txt, which); diff --git a/src/do.c b/src/do.c index b6e86c4f1..3f881e3b7 100644 --- a/src/do.c +++ b/src/do.c @@ -981,6 +981,8 @@ dodown(void) boolean stairs_down = (stway && !stway->up && !stway->isladder), ladder_down = (stway && !stway->up && stway->isladder); + set_move_cmd(DIR_DOWN, 0); + if (u_rooted()) return ECMD_TIME; @@ -1051,7 +1053,7 @@ dodown(void) 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) { @@ -1070,7 +1072,6 @@ dodown(void) } else if (!trap || !is_hole(trap->ttyp) || !Can_fall_thru(&u.uz) || !trap->tseen) { 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); } else { You_cant("go down here."); @@ -1121,8 +1122,6 @@ dodown(void) if (trap && Is_stronghold(&u.uz)) { goto_hell(FALSE, TRUE); } else { - if (!trap) - u.dz = 1; g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); next_level(!trap); g.at_ladder = FALSE; @@ -1136,6 +1135,8 @@ doup(void) { stairway *stway = stairway_at(u.ux,u.uy); + set_move_cmd(DIR_UP, 0); + if (u_rooted()) return ECMD_TIME; @@ -1176,7 +1177,6 @@ doup(void) return ECMD_OK; } g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); - u.dz = -1; prev_level(TRUE); g.at_ladder = FALSE; return ECMD_TIME;