From e966cdb334356ad96aeccb19481a85f46f6a4b55 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 16 Aug 2010 04:09:21 +0200 Subject: fixed that Collision::IntersectLine gets stuck in a loop forever. Closes #6 --- src/game/collision.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 0dee57c8..f114fd06 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -67,11 +67,12 @@ bool CCollision::IsTileSolid(int x, int y) int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision) { float d = distance(Pos0, Pos1); + int End(d+1); vec2 Last = Pos0; - 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); if(CheckPoint(Pos.x, Pos.y)) { -- cgit 1.4.1