mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-19 12:39:11 +00:00
Fix: Off-by-one in Blitter::DrawLineGeneric
This commit is contained in:
@@ -90,13 +90,14 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
|
||||
if (x1 < 0) {
|
||||
dash_count = (-x1) % (dash + gap);
|
||||
auto adjust_frac = [&](int64_t frac, int &y_bound) -> int {
|
||||
frac -= ((int64_t) dy) * ((int64_t) x1);
|
||||
frac -= ((int64_t) dy) * ((int64_t) (x1 + 1));
|
||||
if (frac >= 0) {
|
||||
int quotient = frac / dx;
|
||||
int remainder = frac % dx;
|
||||
y_bound += (1 + quotient) * stepy;
|
||||
frac = remainder - dx;
|
||||
}
|
||||
frac += dy;
|
||||
return frac;
|
||||
};
|
||||
frac_low = adjust_frac(frac_low, y_low);
|
||||
@@ -152,13 +153,14 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
|
||||
if (y1 < 0) {
|
||||
dash_count = (-y1) % (dash + gap);
|
||||
auto adjust_frac = [&](int64_t frac, int &x_bound) -> int {
|
||||
frac -= ((int64_t) dx) * ((int64_t) y1);
|
||||
frac -= ((int64_t) dx) * ((int64_t) (y1 + 1));
|
||||
if (frac >= 0) {
|
||||
int quotient = frac / dy;
|
||||
int remainder = frac % dy;
|
||||
x_bound += (1 + quotient) * stepx;
|
||||
frac = remainder - dy;
|
||||
}
|
||||
frac += dx;
|
||||
return frac;
|
||||
};
|
||||
frac_low = adjust_frac(frac_low, x_low);
|
||||
|
Reference in New Issue
Block a user