From 3d23f959b456ccaa59d2a5eaa0080dfc7c3fbfa0 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 16 Aug 2010 04:09:21 +0200 Subject: [PATCH] fixed that Collision::IntersectLine gets stuck in a loop forever. Closes #6 --- src/game/collision.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 40d79d00a..320b55d08 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -249,6 +249,7 @@ void ThroughOffset(vec2 Pos0, vec2 Pos1, int *Ox, int *Oy) int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough) { float d = distance(Pos0, Pos1); + int End(d+1); vec2 Last = Pos0; int ix, iy; // Temporary position for checking collision int dx, dy; // Offset for checking the "through" tile @@ -256,9 +257,9 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p { ThroughOffset(Pos0, Pos1, &dx, &dy); } - for(float f = 0; f < d; f++) + for(int i = 0; i < End; i++) { - float a = f/d; + float a = i/d; vec2 Pos = mix(Pos0, Pos1, a); ix = round(Pos.x); iy = round(Pos.y);