From: wolfgangb Date: Sun, 30 Aug 2009 12:10:24 +0000 (+0000) Subject: Patch by Matt McCutchen to prevent division by zero when Tux spawns exactly at a... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e9ffce0200246e9bd1d31ed140bc8b62ee39270f;p=supertux.git Patch by Matt McCutchen to prevent division by zero when Tux spawns exactly at a willowisp. (Bug 490) git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@5910 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- 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;