]> granicus.if.org Git - nethack/commit
fix getpos() m,M to move to next monster
authorPatR <rankin@nethack.org>
Wed, 6 Jan 2016 07:19:14 +0000 (23:19 -0800)
committerPatR <rankin@nethack.org>
Wed, 6 Jan 2016 07:19:14 +0000 (23:19 -0800)
commitcb4bb726314eedfd65d011516f714da9ec777046
tree9e65d1721f23d4138eb6e5c79017098c2857360f
parent4aeb2913cf58848ee4e3dadee59fffb737358f5f
fix getpos() m,M to move to next monster

Fixing a couple of warnings led to discovery of a couple of real bugs.
Warnings:
1) -Wshadow warning for 'dist2' variable blocking access to dist2()
   function.
2) Declaration not at top of block not allowed for C89/C90 (let alone
   for pre-ANSI).
Bugs:
3) there might be 0 visible monsters, in which case the code prior to
   qsort will call alloc(0).  I think ANSI requires malloc(0) to return
   a unique pointer which can be freed, but pre-ANSI malloc might
   return Null to satisfy it, leading to panic from nethack's alloc().
4) visible monsters in direct line with hero horizontally or vertically
   were unintentionally skipped when collecting monster locations.

I think looking at monsters is the wrong way to implement this.  It
should be scanning the map for monster glyphs instead.  (Coin toss as
to whether it should also treat statues-shown-as-monsters as if they
were monsters while doing this.  I'm leaning towards yes.  And what
about warning glyphs and instances of the remembered-invisible monster
glyph?  They aren't interesting to look at but they might provide a
shortcut to positioning the cursor near something else.)

Using '^' to move to next trap moves from hero's position to end of
hero's line, then columns 1 to N of next line, and so on to bottom
right, then top left columns 1 to N, second line 1 to N, on down to
hero's line.  Having 'm' traverse monsters from nearest to farthest
feels like a noticeable inconsistency between the two.  Especially if
you move the cursor with direction or topology keystrokes prior to 'm'.
src/do_name.c