From 20779fba758c4425647e754abd1d04f934fc5252 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Sun, 24 Mar 2002 23:53:28 +0000 Subject: [PATCH] #R675: bug in win32 GUI (division by zero) (from ) >The tile size is actually set just once in mhmap.c so validation can be done >in one place. The patch is attached. > > on Sunday, March 24, 2002 at 16:15:50 --------------------------------------------------------------------------- mailversion: 1.10 nhversion: 3.4.0 nhfrom: 3.4.0 Official binary release for Windows 95/98/NT/2000/Me/XP (nh340win.zip) hardware: 1 Ghz AMD Athlon, 512 MB RAM etc. etc. I don't think that the hardware is related to the problem because I found it. software: I used Win 98 (1st edition) and MS VC++ 6.0 to find/fix the bug in Nethack 3.4.0. comments: steps to crash: start nethackw.exe - start a game - select "fit to sreen" in the map menue - rezize the map until it is very very small -> crash --- win/win32/mhmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 08189a348..fd7596cfc 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -92,8 +92,10 @@ void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw) /* set new screen tile size */ data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA); - data->xScrTile = (data->bFitToScreenMode? wnd_size.cx : lpsz->cx) / COLNO; - data->yScrTile = (data->bFitToScreenMode? wnd_size.cy : lpsz->cy) / ROWNO; + data->xScrTile = + max(1, (data->bFitToScreenMode? wnd_size.cx : lpsz->cx) / COLNO); + data->yScrTile = + max(1, (data->bFitToScreenMode? wnd_size.cy : lpsz->cy) / ROWNO); /* set map origin point */ data->map_orig.x = max(0, client_rt.left + (wnd_size.cx - data->xScrTile*COLNO)/2 );