NetHack / NetHack

Official NetHack Git Repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeating #sit caused a sitting loop

ars3niy opened this issue · comments

I do not know what this was, was never able to reproduce managed to reproduce - see later comment, this is related to #1229

attached ttyrec from hardfought.

On turn 29377 I sit on a throne, get electric shock. Turn number is still the same after this because I'm wearing speed boots.
sit1

I press Ctrl+A to sit again, and this happens:
sit2

The electric shock message at the top seems to be from the previous turn: that's how it works when repeating, output from the last two (identical) actions is highlighted in bright/bold. But then, I kept sitting without getting an action, with all messages getting highlighted and turn counter running, similar to what would happen if I typed n(some number)Ctrl+A except there is no sign of me mistyping something like that. After sitting 13 times, which took 8 turns, I got interrupted by a thrown projectile.

2024-05-09.12 33 48 T29377.ttyrec.gz

To reproduce:

  • wait with repeat-N-times prefix
  • sit on a throne, get electric shock or teleportation - this is needed because otherwise you would auto-enter extended command prompt after sitting and would not be able to do the following step
  • Ctrl+A

Expected result: you sit once.
Actual result: you sit N times.

Strange, I can reproduce it easier than ever with throne and #sit. But actually, with keyboard shortcuts or simple keyboard commands I don't even need a throne. Regardless of whether my initial repeat-wait got interrupted, I end up repeating the target action however many times I had typed to wait:

n10s Alt+S Ctrl+A (sits, then sits 10 more times)
or
n10s Alt+W Ctrl+A (wipes, then wipes 10 times)
or even
n10s 2 Ctrl+A (steps 1 south, then 10 south or until you hit a wall)
n10s s Ctrl+A (waits 21 times total)

Finally, # also seems to work a bit like a command, and that's #1229 .

Looking at the code, it seems related to gl.last_command_count and what parse() does with it