#R675: bug in win32 GUI (division by zero)

(from <Someone>)

>The tile size is actually set just once in mhmap.c so validation can be done
>in one place. The patch is attached.
>
><email deleted>
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
This commit is contained in:
nethack.allison
2002-03-24 23:53:28 +00:00
parent e3028a84c0
commit 20779fba75

View File

@@ -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 );