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

Function restore_waterlevel

src/mkmaze.c:1749–1798  ·  view source on GitHub ↗

restoring air bubbles on Plane of Water or clouds on Plane of Air */

Source from the content-addressed store, hash-verified

1747
1748/* restoring air bubbles on Plane of Water or clouds on Plane of Air */
1749void
1750restore_waterlevel(NHFILE *nhfp)
1751{
1752 struct bubble *b = (struct bubble *) 0, *btmp;
1753 int i, n = 0;
1754
1755#ifdef SFCTOOL
1756 svb.bbubbles = (struct bubble *) 0;
1757 /* set_wportal(); */
1758#endif
1759
1760 Sfi_int(nhfp, &n, "waterlevel-bubble_count");
1761 Sfi_int(nhfp, &svx.xmin, "waterlevel-xmin");
1762 Sfi_int(nhfp, &svy.ymin, "waterlevel-ymin");
1763 Sfi_int(nhfp, &svx.xmax, "waterlevel-xmax");
1764 Sfi_int(nhfp, &svy.ymax, "waterlevel-ymax");
1765 for (i = 0; i < n; i++) {
1766 btmp = b;
1767 b = (struct bubble *) alloc((unsigned) sizeof *b);
1768 Sfi_bubble(nhfp, b, "waterlevel-bubble");
1769 if (btmp) {
1770 btmp->next = b;
1771 b->prev = btmp;
1772 } else {
1773 svb.bbubbles = b;
1774 b->prev = (struct bubble *) 0;
1775 }
1776#ifndef SFCTOOL
1777 mv_bubble(b, 0, 0, TRUE);
1778#endif
1779 }
1780#ifndef SFCTOOL
1781 ge.ebubbles = b;
1782 if (b) {
1783 b->next = (struct bubble *) 0;
1784 } else {
1785 /* avoid "saving and reloading may fix this" */
1786 program_state.something_worth_saving = 0;
1787 /* during restore, information about what level this is might not
1788 be available so we're wishy-washy about what we describe */
1789 impossible("No %s to restore?",
1790 (Is_waterlevel(&u.uz) || Is_waterlevel(&gu.uz_save))
1791 ? "air bubbles"
1792 : (Is_airlevel(&u.uz) || Is_airlevel(&gu.uz_save))
1793 ? "clouds"
1794 : "air bubbles or clouds");
1795 program_state.something_worth_saving = 1;
1796 }
1797#endif
1798}
1799
1800#ifndef SFCTOOL
1801staticfn void

Callers 1

rest_bubblesFunction · 0.85

Calls 3

mv_bubbleFunction · 0.85
allocFunction · 0.70
impossibleFunction · 0.70

Tested by

no test coverage detected