From 67d7655544d820c10cb6d3f33e341248a92cab0b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 22 Feb 2020 17:23:50 +0100 Subject: [PATCH] Fix world_draw_black_tile not taking buffer borders in to account Thanks to @imperialsecond for providing a test case for world_draw_black_tile --- Source/render.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/render.cpp b/Source/render.cpp index 49762c4a2..0580e9cf0 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -255,14 +255,18 @@ void RenderTile(BYTE *pBuff) /** * @brief Render a black tile - * @param pBuff pointer where to render the tile + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ void world_draw_black_tile(int sx, int sy) { int i, j, k; BYTE *dst; - if (sx >= SCREEN_WIDTH - 64 || sy >= SCREEN_HEIGHT - 32) + if (sx >= SCREEN_X + SCREEN_WIDTH || sy >= SCREEN_Y + VIEWPORT_HEIGHT + 32) + return; + + if (sx < SCREEN_X - 60 || sy < SCREEN_Y) return; dst = &gpBuffer[sx + BUFFER_WIDTH * sy] + 30;