From 8c710e6da9c6e83047da059168753841c665393b Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sun, 30 Aug 2009 12:10:24 +0000 Subject: [PATCH] Patch by Matt McCutchen to prevent division by zero when Tux spawns exactly at a willowisp. (Bug 490) SVN-Revision: 5910 --- src/badguy/willowisp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 0e55486f1..db467e7f9 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -106,11 +106,14 @@ WillOWisp::active_update(float elapsed_time) break; case STATE_TRACKING: - if (dist.norm() <= vanish_range) { + if (dist.norm() > vanish_range) { + vanish(); + } else if (dist.norm() >= 1) { Vector dir = dist.unit(); movement = dir * elapsed_time * flyspeed; } else { - vanish(); + /* We somehow landed right on top of the player without colliding. + * Sit tight and avoid a division by zero. */ } sound_source->set_position(get_pos()); break; -- 2.11.0