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

Function setup_waterlevel

src/mkmaze.c:1811–1857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1809}
1810
1811staticfn void
1812setup_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
1859staticfn void
1860unsetup_waterlevel(void)

Callers 1

fixup_specialFunction · 0.85

Calls 3

rn2Function · 0.85
mk_bubbleFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected