]> granicus.if.org Git - nethack/commit
fix #H30 - rn2(0) from off by 1 bug in special level door creation
authornethack.rankin <nethack.rankin>
Sun, 29 Jan 2006 04:32:04 +0000 (04:32 +0000)
committernethack.rankin <nethack.rankin>
Sun, 29 Jan 2006 04:32:04 +0000 (04:32 +0000)
commite2dd0a12ae0ac734a5776324d0e0eec1fbbb5542
tree4df8eeb8995360cdfa5c85b7399e34a4701ec009
parent0a52d1879f4077d88fb03fb3360b9de664a6b58f
fix #H30 - rn2(0) from off by 1 bug in special level door creation

     From a bug report, the placement
of random doors by the code that loads special levels would attempt to
evaluate rn2(0) and either get a divide by zero crash (normal build) or an
impossible warning (DEBUG enabled when compiing rnd.c, done automatically
when BETA is defined).  The problem was only noticable for random door in
a 1x1 room; none of our distributed levels specify such a thing so regular
users won't have encountered this bug.  It's a one line fix.

     Altar placement in temples also had a quirk of a similar nature.  It
wouldn't trigger rn2(0) problems but would always place the altar to left
of mid-point in rooms with even width and above the center point in ones
with even height.  Now the placement is randomized so that sometimes it'll
be to the right and/or below mid-point in such cases.

     This also simplifies a couple other instances of similar expressions
that I spotted.
doc/fixes34.4
src/mklev.c
src/mkroom.c
src/sp_lev.c