]> granicus.if.org Git - nethack/commitdiff
Ensure front tile size is non-zero to avoid divide by zero exceptions.
authorBart House <bart@barthouse.com>
Sat, 21 Dec 2019 21:14:14 +0000 (13:14 -0800)
committerBart House <bart@barthouse.com>
Sat, 21 Dec 2019 21:14:14 +0000 (13:14 -0800)
win/win32/mhmap.c

index fdd7b3a33f53a441c192b1fba7ebe84282669f8a..bff7baa8682d7960aeb24f34d8362d290ab4e321 100644 (file)
@@ -305,9 +305,14 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
 
     }
 
+    /* TODO: Should we round instead of clamping? */
     data->xFrontTile = (int) ((double) data->xBackTile * data->frontScale);
     data->yFrontTile = (int) ((double) data->yBackTile * data->frontScale);
 
+    /* ensure tile is at least one pixel in size */
+    if (data->xFrontTile < 1) data->xFrontTile = 1;
+    if (data->yFrontTile < 1) data->yFrontTile = 1;
+
     /* calcuate ASCII cursor height */
     data->yBlinkCursor = (int) ((double) CURSOR_HEIGHT * data->backScale);
     data->yNoBlinkCursor = data->yBackTile;