Changeset - r17657:64bea15c6ec5
[Not reviewed]
master
0 1 0
frosch - 13 years ago 2011-05-08 18:20:21
frosch@openttd.org
(svn r22439) -Fix (r22291, r22426): Drawing lines of length zero failed.
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/blitter/base.cpp
Show inline comments
 
@@ -33,12 +33,18 @@ void Blitter::DrawLine(void *video, int 
 
		dx = -dx;
 
		stepx = -1;
 
	} else {
 
		stepx = 1;
 
	}
 

	
 
	if (dx == 0 && dy == 0) {
 
		/* The algorithm below cannot handle this special case; make it work at least for line width 1 */
 
		if (x >= 0 && x < screen_width && y >= 0 && y < screen_height) this->SetPixel(video, x, y, colour);
 
		return;
 
	}
 

	
 
	int frac_diff = width * max(dx, dy);
 
	if (width > 1) {
 
		/* compute frac_diff = width * sqrt(dx*dx + dy*dy)
 
		 * Start interval:
 
		 *    max(dx, dy) <= sqrt(dx*dx + dy*dy) <= sqrt(2) * max(dx, dy) <= 3/2 * max(dx, dy) */
 
		int frac_sq = width * width * (dx * dx + dy * dy);
0 comments (0 inline, 0 general)