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.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mklev.c 3.5 2001/11/29 */
|
||||
/* SCCS Id: @(#)mklev.c 3.5 2006/01/28 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -83,8 +83,8 @@ xchar xl,yl,xh,yh;
|
||||
{
|
||||
register xchar x, y;
|
||||
|
||||
x = (xl == xh) ? xl : (xl + rn2(xh-xl+1));
|
||||
y = (yl == yh) ? yl : (yl + rn2(yh-yl+1));
|
||||
x = rn1(xh - xl + 1, xl);
|
||||
y = rn1(yh - yl + 1, yl);
|
||||
if(okdoor(x, y))
|
||||
goto gotit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user