bridgefall: Fix harmless coordinate normalization bug

bridgefall() wants to do this:

    for all possible pairs of directions (i, j)
        if i and j cancel out
	    continue
	do stuff

It does it by adding direction offsets to start coordinates, and
comparing the resulting coordinates to the start coordinates.  Fine,
except it neglects to normalize the resulting coordinates.

Harmless in practice, because you can get an incorrect result only
when the path goes around the world, which it can do only in a 4x2
world.

Fix it anyway, by testing "directions cancel out" directly.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-17 19:28:03 +01:00
parent 296f3272e2
commit f5244d4702

View file

@ -28,7 +28,7 @@
*
* Known contributors to this file:
* Steve McClure, 1998
* Markus Armbruster, 2004-2010
* Markus Armbruster, 2004-2014
*/
#include <config.h>
@ -92,10 +92,10 @@ bridgefall(struct sctstr *sp)
if (sect.sct_type != SCT_BSPAN)
continue;
for (j = 1; j <= 6; j++) {
if (j == DIR_BACK(i))
continue;
nnx = nx + diroff[j][0];
nny = ny + diroff[j][1];
if (nnx == sp->sct_x && nny == sp->sct_y)
continue;
getsect(nnx, nny, &bh_sect);
if (bh_sect.sct_type == SCT_BHEAD &&
bh_sect.sct_newtype == SCT_BHEAD)