]> granicus.if.org Git - nethack/commit
fix mdig_tunnel impossibility
authorPatR <rankin@nethack.org>
Thu, 14 May 2015 00:54:26 +0000 (17:54 -0700)
committerPatR <rankin@nethack.org>
Thu, 14 May 2015 00:54:26 +0000 (17:54 -0700)
commitdd62a6831f159d951120c7b35d34e86ad3d84ed3
tree5686b454e598495be18332b41a82ac80a760d1a2
parentbeaab1b9740600923dbcd247e010a33bbcc0dc8a
fix mdig_tunnel impossibility

Reported by the keymasher:  "stone at (48,8) is undiggable".  Bigroom 4
has a tree at that spot and the whole level is flagged as undiggable.
Undiggable trees were supported on arboreal levels (where their terrain
type is STONE rather than TREE), but not elsewhere.  Monster movement
uses IS_ROCK(), which is true for TREEs, but may_dig() uses IS_STWALL(),
which is false for TREEs so doesn't consider the location as being of
interest and fails to disallow digging.  But mdig_tunnel() bypasses
may_dig() and tests the NONDIGGABLE bit directly, disallowing digging.
(If this sounds confusing, it's a stroll in the park compared to the
code itself.  Apologies for the mixed metaphore.)

Digging away a secret corridor could leave rocks, which doesn't make
a whole lot of sense.  Now a monster's dig attempt will reveal the
location as a corridor instead.

This also moves an assignment out of a macro invocation where it was
inviting trouble if that macro gets modified.  And reorganizes an 'if'
to put cheaper tests sooner.
src/dig.c
src/hack.c
src/mon.c
src/monmove.c