]> granicus.if.org Git - nethack/commitdiff
Merge branch 'NetHack-3.6'
authornhmall <nhmall@nethack.org>
Fri, 31 May 2019 21:59:11 +0000 (17:59 -0400)
committernhmall <nhmall@nethack.org>
Fri, 31 May 2019 21:59:11 +0000 (17:59 -0400)
1  2 
src/do.c
src/hack.c
src/mkmaze.c
win/curses/cursdial.c
win/curses/cursmain.c

diff --cc src/do.c
index 6d6953f9da600e3d00266cabc900f7cb58dfc1ed,c899676ef97169bd954d3fcbe44766a4038516b6..dbf41fc8e7e2f7f9548ea0e6147181a0cae6db34
+++ b/src/do.c
@@@ -1426,7 -1433,12 +1426,12 @@@ boolean at_stairs, falling, portal
          reseed_random(rn2);
          reseed_random(rn2_on_display_rng);
          minit(); /* ZEROCOMP */
 -        getlev(fd, hackpid, new_ledger, FALSE);
 +        getlev(fd, g.hackpid, new_ledger, FALSE);
+         /* when in wizard mode, it is possible to leave from and return to
+            any level in the endgame; above, we discarded bubble/cloud info
+            when leaving Plane of Water or Air so recreate some now */
+         if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
+             restore_waterlevel(-1);
          (void) nhclose(fd);
          oinit(); /* reassign level dependent obj probabilities */
      }
diff --cc src/hack.c
index 399457e2cee345600249d795ec51ba6dee5de629,7c80a8c1e5dde32af030b24986868a68d7c90f7c..1bbaf44d9a7a792727ddd50dfc0c2dc79330ebf8
@@@ -1155,10 -1157,11 +1155,11 @@@ int x,y
      int tx = u.tx;
      int ty = u.ty;
      boolean ret;
 -    int g = glyph_at(x,y);
 +    int glyph = glyph_at(x,y);
      if (x == u.ux && y == u.uy)
          return TRUE;
 -    if (isok(x,y) && glyph_is_cmap(g) && S_stone == glyph_to_cmap(g)
 +    if (isok(x,y) && glyph_is_cmap(glyph) && S_stone == glyph_to_cmap(glyph)
          && !levl[x][y].seenv)
          return FALSE;
      u.tx = x;
diff --cc src/mkmaze.c
index fc9c24b47b640b4da97b17d6857eb9272e64cd1b,bdab684ef39fed12ba4a606d554e1fcc315938d0..bdbc8c9da890064315d5968aca3ba78c2d4969b3
@@@ -1483,10 -1493,22 +1483,22 @@@ movebubbles(
                      }
          }
      } else if (Is_airlevel(&u.uz)) {
-         for (x = 0; x < COLNO; x++)
-             for (y = 0; y < ROWNO; y++) {
+         boolean xedge, yedge;
+         for (x = 1; x <= (COLNO - 1); x++)
+             for (y = 0; y <= (ROWNO - 1); y++) {
                  levl[x][y] = air_pos;
                  unblock_point(x, y);
 -                xedge = (boolean) (x < bxmin || x > bxmax);
 -                yedge = (boolean) (y < bymin || y > bymax);
+                 /* all air or all cloud around the perimeter of the Air
+                    level tends to look strange; break up the pattern */
++                xedge = (boolean) (x < gbxmin || x > gbxmax);
++                yedge = (boolean) (y < gbymin || y > gbymax);
+                 if (xedge || yedge) {
+                     if (!rn2(xedge ? 3 : 5)) {
+                         levl[x][y].typ = CLOUD;
+                         block_point(x, y);
+                     }
+                 }
              }
      }
  
@@@ -1579,12 -1601,20 +1591,20 @@@ int fd
      if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz))
          return;
  
+     if (fd == -1) { /* special handling for restore in goto_level() */
+         if (!wizard)
+             impossible("restore_waterlevel: returning to %s?",
+                        Is_waterlevel(&u.uz) ? "Water" : "Air");
+         setup_waterlevel();
+         return;
+     }
      set_wportal();
      mread(fd, (genericptr_t) &n, sizeof n);
 -    mread(fd, (genericptr_t) &xmin, sizeof xmin);
 -    mread(fd, (genericptr_t) &ymin, sizeof ymin);
 -    mread(fd, (genericptr_t) &xmax, sizeof xmax);
 -    mread(fd, (genericptr_t) &ymax, sizeof ymax);
 +    mread(fd, (genericptr_t) &g.xmin, sizeof g.xmin);
 +    mread(fd, (genericptr_t) &g.ymin, sizeof g.ymin);
 +    mread(fd, (genericptr_t) &g.xmax, sizeof g.xmax);
 +    mread(fd, (genericptr_t) &g.ymax, sizeof g.ymax);
      for (i = 0; i < n; i++) {
          btmp = b;
          b = (struct bubble *) alloc(sizeof *b);
@@@ -1645,26 -1675,37 +1665,37 @@@ set_wportal(
  STATIC_OVL void
  setup_waterlevel()
  {
-     int x, y;
-     int xskip, yskip;
-     int water_glyph = cmap_to_glyph(S_water),
-         air_glyph = cmap_to_glyph(S_air);
+     int x, y, xskip, yskip, typ, glyph;
  
-     /* ouch, hardcoded... */
+     if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz))
+         panic("setup_waterlevel(): [%d:%d] neither 'Water' nor 'Air'",
+               (int) u.uz.dnum, (int) u.uz.dlevel);
  
 -    xmin = 3;
 -    ymin = 1;
+     /* ouch, hardcoded... (file scope statics and used in bxmin,bymax,&c) */
 -       preprocessor: #if (20 > ROWNO-1) ymax=ROWNO-1 #else ymax=20 #endif */
 -    xmax = 78;
 -    xmax = min(xmax, (COLNO - 1) - 1);
 -    ymax = 20;
 -    ymax = min(ymax, (ROWNO - 1));
 +    g.xmin = 3;
 +    g.ymin = 1;
+     /* use separate statements so that compiler won't complain about min()
+        comparing two constants; the alternative is to do this in the
-     /* set hero's memory to water */
-     for (x = g.xmin; x <= g.xmax; x++)
-         for (y = g.ymin; y <= g.ymax; y++)
-             levl[x][y].glyph = Is_waterlevel(&u.uz) ? water_glyph : air_glyph;
++       preprocessor: #if (20 > ROWNO-1) g.ymax=ROWNO-1 #else g.ymax=20 #endif */
 +    g.xmax = 78;
++    g.xmax = min(g.xmax, (COLNO - 1) - 1);
 +    g.ymax = 20;
++    g.ymax = min(g.ymax, (ROWNO - 1));
+     /* entire level is remembered as one glyph and any unspecified portion
+        should default to level's base element rather than to usual stone */
+     glyph = cmap_to_glyph(Is_waterlevel(&u.uz) ? S_water : S_air);
+     typ = Is_waterlevel(&u.uz) ? WATER : AIR;
+     /* set unspecified terrain (stone) and hero's memory to water or air */
+     for (x = 1; x <= COLNO - 1; x++)
+         for (y = 0; y <= ROWNO - 1; y++) {
+             levl[x][y].glyph = glyph;
+             if (levl[x][y].typ == STONE)
+                 levl[x][y].typ = typ;
+         }
  
      /* make bubbles */
      if (Is_waterlevel(&u.uz)) {
          xskip = 10 + rn2(10);
          yskip = 4 + rn2(4);
@@@ -1684,8 -1725,7 +1715,7 @@@ unsetup_waterlevel(
      struct bubble *b, *bb;
  
      /* free bubbles */
 -    for (b = bbubbles; b; b = bb) {
 +    for (b = g.bbubbles; b; b = bb) {
          bb = b->next;
          free((genericptr_t) b);
      }
@@@ -1703,17 -1743,18 +1733,18 @@@ int x, y, n
       * in situ, either.  The first two elements tell the dimensions of
       * the bubble's bounding box.
       */
-     static uchar bm2[] = { 2, 1, 0x3 },
-                  bm3[] = { 3, 2, 0x7, 0x7 },
-                  bm4[] = { 4, 3, 0x6, 0xf, 0x6 },
-                  bm5[] = { 5, 3, 0xe, 0x1f, 0xe },
-                  bm6[] = { 6, 4, 0x1e, 0x3f, 0x3f, 0x1e },
-                  bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e },
-                  bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e },
-                  *bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 };
+     static const uchar
+         bm2[] = { 2, 1, 0x3 },
+         bm3[] = { 3, 2, 0x7, 0x7 },
+         bm4[] = { 4, 3, 0x6, 0xf, 0x6 },
+         bm5[] = { 5, 3, 0xe, 0x1f, 0xe },
+         bm6[] = { 6, 4, 0x1e, 0x3f, 0x3f, 0x1e },
+         bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e },
+         bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e },
+         *const bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 };
      struct bubble *b;
  
 -    if (x >= bxmax || y >= bymax)
 +    if (x >= gbxmax || y >= gbymax)
          return;
      if (n >= SIZE(bmask)) {
          impossible("n too large (mk_bubble)");
Simple merge
index f187feb924d59e0ac14c56cd3608e56049664ad5,931de9569eafa2856ca5a271ec6ed41e50f29050..24eaa3548846a80e3d306fbd1c8ef0ca3f25ba14
@@@ -202,7 -202,8 +202,8 @@@ curses_player_selection(
  void
  curses_askname()
  {
 -    plname[0] = '\0';
 -    curses_line_input_dialog("Who are you?", plname, PL_NSIZ);
++    g.plname[0] = '\0';
 +    curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ);
  }