If you used ^A to repeat a command which had taken no time, the
repeat execution would take time.  This fixes that.  Also, give some
feedback when trying to repeat an invalid command.

Internals bit: don't use 'X == cmd_from_func(do_repeat)' to decide
whether key X is the key for #repeat.  Both X and Y might be bound to
that action and cmd_from_func() could return Y rather than X.

There is another ^A bug that I haven't figured out how to fix:
 t ESC   start to throw but don't finish
 ^A      nothing seems to happen
 ^A      "You don't have that object."
The first ^A repeats 't', doesn't display a prompt for what to throw,
but does request input for it.  The second ^A fulfills that input and
doesn't match any inventory item.  Either 't' shouldn't have been put
into the do-again buffer or do-again handling should have ceased when
it was taken out and there was no further remembered input, so that
normal prompting would resume.  My tentative attempts for both those
approaches didn't work.
This commit is contained in:
PatR
2022-04-15 11:45:50 -07:00
parent ad46090732
commit 12a63216a7

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 cmd.c $NHDT-Date: 1649272000 2022/04/06 19:06:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.539 $ */
/* NetHack 3.7 cmd.c $NHDT-Date: 1650048286 2022/04/15 18:44:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.553 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2199,15 +2199,26 @@ do_fight(void)
int
do_repeat(void)
{
if (!g.in_doagain && g.saveq[0]) {
int res = ECMD_OK;
if (!g.in_doagain) {
char c = g.saveq[0];
if (!c || !g.Cmd.commands[c & 0xff]) {
Norep("There is no command available to repeat.");
if (c)
savech(0);
return ECMD_FAIL;
}
g.in_doagain = TRUE;
g.stail = 0;
rhack((char *) 0); /* read and execute command */
g.in_doagain = FALSE;
iflags.menu_requested = FALSE;
return ECMD_TIME;
if (g.context.move)
res = ECMD_TIME;
}
return ECMD_OK;
return res;
}
/* extcmdlist: full command list, ordered by command name;
@@ -5158,7 +5169,8 @@ parse(void)
g.last_command_count = 0;
} else if (g.in_doagain) {
g.command_count = g.last_command_count;
} else if (foo && foo == cmd_from_func(do_repeat)) {
} else if (foo && g.Cmd.commands[foo & 0xff]
&& g.Cmd.commands[foo & 0xff]->ef_funct == do_repeat) {
/* g.command_count will be set again when we
re-enter with g.in_doagain set true */
g.command_count = g.last_command_count;
@@ -5247,8 +5259,10 @@ readchar_core(int *x, int *y, int *mod)
return randomkey();
if (*readchar_queue)
sym = *readchar_queue++;
else if (g.in_doagain)
sym = pgetchar();
else
sym = g.in_doagain ? pgetchar() : nh_poskey(x, y, mod);
sym = nh_poskey(x, y, mod);
#ifdef NR_OF_EOFS
if (sym == EOF) {