summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2006-05-03 19:23:54 +0000
committerSimon Howard2006-05-03 19:23:54 +0000
commitcbd744280545a38e62ecc0290a1312b3aeff9ae0 (patch)
tree7ac58e309b23e8ee7d551603572321c8037e75a8 /src
parenta9684aecd9e8f292ac90a404b3f854df03dfd119 (diff)
downloadchocolate-doom-cbd744280545a38e62ecc0290a1312b3aeff9ae0.tar.gz
chocolate-doom-cbd744280545a38e62ecc0290a1312b3aeff9ae0.tar.bz2
chocolate-doom-cbd744280545a38e62ecc0290a1312b3aeff9ae0.zip
Handle divide by zero in R_PointToDist: fixes crash in udm1.wad
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 474
Diffstat (limited to 'src')
-rw-r--r--src/r_main.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/r_main.c b/src/r_main.c
index 3b710a14..bde0f596 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: r_main.c 445 2006-03-27 22:56:14Z fraggle $
+// $Id: r_main.c 474 2006-05-03 19:23:54Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -49,7 +49,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: r_main.c 445 2006-03-27 22:56:14Z fraggle $";
+static const char rcsid[] = "$Id: r_main.c 474 2006-05-03 19:23:54Z fraggle $";
@@ -423,6 +423,7 @@ R_PointToDist
fixed_t dy;
fixed_t temp;
fixed_t dist;
+ fixed_t frac;
dx = abs(x - viewx);
dy = abs(y - viewy);
@@ -433,8 +434,19 @@ R_PointToDist
dx = dy;
dy = temp;
}
+
+ // Fix crashes in udm1.wad
+
+ if (dx != 0)
+ {
+ frac = FixedDiv(dy, dx);
+ }
+ else
+ {
+ frac = 0;
+ }
- angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT;
+ angle = (tantoangle[frac>>DBITS]+ANG90) >> ANGLETOFINESHIFT;
// use as cosine
dist = FixedDiv (dx, finesine[angle] );