MCPcopy Create free account
hub / github.com/NetHack/NetHack / initMapTiles

Function initMapTiles

outdated/sys/wince/mswproc.c:1705–1760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1703}
1704
1705BOOL
1706initMapTiles(void)
1707{
1708 HBITMAP hBmp;
1709 BITMAP bm;
1710 TCHAR wbuf[MAX_PATH];
1711 int tl_num;
1712 SIZE map_size;
1713 extern int total_tiles_used;
1714
1715 /* no file - no tile */
1716 if (!(iflags.wc_tile_file && *iflags.wc_tile_file))
1717 return TRUE;
1718
1719 /* load bitmap */
1720 hBmp = SHLoadDIBitmap(NH_A2W(iflags.wc_tile_file, wbuf, MAX_PATH));
1721 if (hBmp == NULL) {
1722 raw_print(
1723 "Cannot load tiles from the file. Reverting back to default.");
1724 return FALSE;
1725 }
1726
1727 /* calculate tile dimensions */
1728 GetObject(hBmp, sizeof(BITMAP), (LPVOID) &bm);
1729 if (bm.bmWidth % iflags.wc_tile_width
1730 || bm.bmHeight % iflags.wc_tile_height) {
1731 DeleteObject(hBmp);
1732 raw_print("Tiles bitmap does not match tile_width and tile_height "
1733 "options. Reverting back to default.");
1734 return FALSE;
1735 }
1736
1737 tl_num = (bm.bmWidth / iflags.wc_tile_width)
1738 * (bm.bmHeight / iflags.wc_tile_height);
1739 if (tl_num < total_tiles_used) {
1740 DeleteObject(hBmp);
1741 raw_print("Number of tiles in the bitmap is less than required by "
1742 "the game. Reverting back to default.");
1743 return FALSE;
1744 }
1745
1746 /* set the tile information */
1747 if (GetNHApp()->bmpMapTiles != GetNHApp()->bmpTiles) {
1748 DeleteObject(GetNHApp()->bmpMapTiles);
1749 }
1750
1751 GetNHApp()->bmpMapTiles = hBmp;
1752 GetNHApp()->mapTile_X = iflags.wc_tile_width;
1753 GetNHApp()->mapTile_Y = iflags.wc_tile_height;
1754 GetNHApp()->mapTilesPerLine = bm.bmWidth / iflags.wc_tile_width;
1755
1756 map_size.cx = GetNHApp()->mapTile_X * COLNO;
1757 map_size.cy = GetNHApp()->mapTile_Y * ROWNO;
1758 mswin_map_stretch(mswin_hwnd_from_winid(WIN_MAP), &map_size, TRUE);
1759 return TRUE;
1760}
1761
1762void

Callers 1

mswin_init_nhwindowsFunction · 0.70

Calls 4

raw_printFunction · 0.85
mswin_map_stretchFunction · 0.85
GetNHAppFunction · 0.70
mswin_hwnd_from_winidFunction · 0.70

Tested by

no test coverage detected