Skip to content

Commit

Permalink
Fix out-of-bounds mini-map pentagram
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Feb 17, 2024
1 parent 55a5337 commit c171481
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/engine/render/automap_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ void DrawMapLineSteepSW(const Surface &out, Point from, int width, std::uint8_t
*/
void DrawMapFreeLine(const Surface &out, Point from, Point to, uint8_t colorIndex)
{
int dx = std::abs(to.x - from.x);
int dy = std::abs(to.y - from.y);
int sx = from.x < to.x ? 1 : -1;
int sy = from.y < to.y ? 1 : -1;
const int dx = std::abs(to.x - from.x);
const int dy = std::abs(to.y - from.y);
const int sx = from.x < to.x ? 1 : -1;
const int sy = from.y < to.y ? 1 : -1;
int err = dx - dy;

while (true) {
out.SetPixel(from, colorIndex);
SetMapPixel(out, from, colorIndex);

if (from.x == to.x && from.y == to.y) {
break;
}

int e2 = 2 * err;
const int e2 = 2 * err;
if (e2 > -dy) {
err -= dy;
from.x += sx;
Expand Down

0 comments on commit c171481

Please sign in to comment.