From 16ad440adb837a18bf50aeddf2c6d71bab7df613 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Mar 2015 09:51:57 +0100 Subject: [PATCH] - fixed: The distance check in A_RadiusGive could overflow for large distances. --- src/thingdef/thingdef_codeptr.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 0e5d44814b..fc577afcdc 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5068,9 +5068,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) if (flags & RGF_CUBE) { // check if inside a cube - if (abs(thing->x - self->x) > distance || - abs(thing->y - self->y) > distance || - abs((thing->z + thing->height/2) - (self->z + self->height/2)) > distance) + if (fabs((double)thing->x - self->x) > (double)distance || + fabs((double)thing->y - self->y) > (double)distance || + fabs((double)(thing->z + thing->height/2) - (self->z + self->height/2)) > (double)distance) { continue; } @@ -5084,7 +5084,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) continue; } } - fixed_t dz = abs ((thing->z + thing->height/2) - (self->z + self->height/2)); if ((flags & RGF_NOSIGHT) || P_CheckSight (thing, self, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) { // OK to give; target is in direct path, or the monster doesn't care about it being in line of sight.