1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-25 15:39:09 +00:00

(svn r22290) -Codechange: Somewhat deduplicate one line of code.

This commit is contained in:
frosch
2011-04-02 15:07:58 +00:00
parent 43323e38b5
commit 7659575cfa

View File

@@ -47,28 +47,29 @@ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_wid
stepx = 1;
}
if (x >= 0 && y >= 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, colour);
if (dx > dy) {
frac = dy - (dx / 2);
x2 += stepx; // Make x2 the first column to not draw to
while (x != x2) {
if (x >= 0 && y >= 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, colour);
if (frac >= 0) {
y += stepy;
frac -= dx;
}
x += stepx;
frac += dy;
if (x >= 0 && y >= 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, colour);
}
} else {
frac = dx - (dy / 2);
y2 += stepy; // Make y2 the first row to not draw to
while (y != y2) {
if (x >= 0 && y >= 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, colour);
if (frac >= 0) {
x += stepx;
frac -= dy;
}
y += stepy;
frac += dx;
if (x >= 0 && y >= 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, colour);
}
}
}