| 1809 | } |
| 1810 | |
| 1811 | staticfn void |
| 1812 | setup_waterlevel(void) |
| 1813 | { |
| 1814 | int typ, glyph; |
| 1815 | coordxy x, y, xskip, yskip; |
| 1816 | |
| 1817 | if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz)) |
| 1818 | panic("setup_waterlevel(): [%d:%d] neither 'Water' nor 'Air'", |
| 1819 | (int) u.uz.dnum, (int) u.uz.dlevel); |
| 1820 | |
| 1821 | /* ouch, hardcoded... (file scope statics and used in bxmin,bymax,&c) */ |
| 1822 | svx.xmin = 3; |
| 1823 | svy.ymin = 1; |
| 1824 | /* use separate statements so that compiler won't complain about min() |
| 1825 | comparing two constants; the alternative is to do this in the |
| 1826 | preprocessor: #if (20 > ROWNO-1) ymax=ROWNO-1 #else ymax=20 #endif */ |
| 1827 | svx.xmax = 78; |
| 1828 | svx.xmax = min(svx.xmax, (COLNO - 1) - 1); |
| 1829 | svy.ymax = 20; |
| 1830 | svy.ymax = min(svy.ymax, (ROWNO - 1)); |
| 1831 | |
| 1832 | /* entire level is remembered as one glyph and any unspecified portion |
| 1833 | should default to level's base element rather than to usual stone */ |
| 1834 | glyph = cmap_to_glyph(Is_waterlevel(&u.uz) ? S_water : S_air); |
| 1835 | typ = Is_waterlevel(&u.uz) ? WATER : AIR; |
| 1836 | |
| 1837 | /* set unspecified terrain (stone) and hero's memory to water or air */ |
| 1838 | for (x = 1; x <= COLNO - 1; x++) |
| 1839 | for (y = 0; y <= ROWNO - 1; y++) { |
| 1840 | levl[x][y].glyph = glyph; |
| 1841 | if (levl[x][y].typ == STONE) |
| 1842 | levl[x][y].typ = typ; |
| 1843 | } |
| 1844 | |
| 1845 | /* make bubbles */ |
| 1846 | if (Is_waterlevel(&u.uz)) { |
| 1847 | xskip = 10 + rn2(10); |
| 1848 | yskip = 4 + rn2(4); |
| 1849 | } else { |
| 1850 | xskip = 6 + rn2(4); |
| 1851 | yskip = 3 + rn2(3); |
| 1852 | } |
| 1853 | |
| 1854 | for (x = gbxmin; x <= gbxmax; x += xskip) |
| 1855 | for (y = gbymin; y <= gbymax; y += yskip) |
| 1856 | mk_bubble(x, y, rn2(7)); |
| 1857 | } |
| 1858 | |
| 1859 | staticfn void |
| 1860 | unsetup_waterlevel(void) |
no test coverage detected