From 459aa0d20caa0031890e2c81528e4fa52fb05057 Mon Sep 17 00:00:00 2001 From: KPhoenix Date: Tue, 16 Apr 2024 23:33:25 -0400 Subject: [PATCH] Clean up: DrawView() --- Source/engine/render/scrollrt.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 7061a0c5f..ddd0042f7 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -1165,23 +1165,23 @@ void DrawView(const Surface &out, Point startPosition) { .flags = UiFlags::ColorRed | UiFlags::AlignCenter | UiFlags::VerticalCenter }); } if (DebugGrid) { - auto DrawDebugSquare = [&out](Point center, Displacement hor, Displacement ver, uint8_t col) { - auto DrawLine = [&out](Point from, Point to, uint8_t col) { + auto drawDebugSquare = [&out](Point center, Displacement hor, Displacement ver, uint8_t col) { + auto drawLine = [&out](Point from, Point to, uint8_t col) { int dx = to.x - from.x; int dy = to.y - from.y; int steps = std::abs(dx) > std::abs(dy) ? std::abs(dx) : std::abs(dy); - float ix = dx / (float)steps; - float iy = dy / (float)steps; - float sx = static_cast(from.x); - float sy = static_cast(from.y); + auto ix = static_cast(dx) / static_cast(steps); + auto iy = static_cast(dy) / static_cast(steps); + auto sx = static_cast(from.x); + auto sy = static_cast(from.y); for (int i = 0; i <= steps; i++, sx += ix, sy += iy) - out.SetPixel({ (int)sx, (int)sy }, col); + out.SetPixel({ static_cast(sx), static_cast(sy) }, col); }; - DrawLine(center - hor, center + ver, col); - DrawLine(center + hor, center + ver, col); - DrawLine(center - hor, center - ver, col); - DrawLine(center + hor, center - ver, col); + drawLine(center - hor, center + ver, col); + drawLine(center + hor, center + ver, col); + drawLine(center - hor, center - ver, col); + drawLine(center + hor, center - ver, col); }; Displacement hor = { TILE_WIDTH / 2, 0 }; @@ -1199,7 +1199,7 @@ void DrawView(const Surface &out, Point startPosition) uint8_t col = PAL16_BEIGE; - DrawDebugSquare(center, hor, ver, col); + drawDebugSquare(center, hor, ver, col); } } }