]> granicus.if.org Git - nethack/commitdiff
Fix stairs on oracle level bones
authorPasi Kallinen <paxed@alt.org>
Thu, 3 Dec 2020 14:38:17 +0000 (16:38 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 3 Dec 2020 14:38:20 +0000 (16:38 +0200)
Recent change to the stairs structure now lets each stair keep
the destination level number and dungeon where the stairs go to.

When a level that can be on different depth (such as the Oracle)
became a bones level, and it was loaded in another game at different
depth, the stairs were still pointing to the old level number.

Save it as relative to the current level instead of absolute.

src/restore.c
src/save.c

index 3622c02ab6acc14954b53f990609ad0ec28ee30e..e28648769f9179da1a1ba17395d259f6633f6722 100644 (file)
@@ -926,6 +926,10 @@ NHFILE *nhfp;
         if (nhfp->structlevel) {
             len += (int) sizeof (stairway);
             mread(nhfp->fd, (genericptr_t) &stway, sizeof (stairway));
+            if (stway.tolev.dnum == u.uz.dnum) {
+                /* stairway dlevel is relative, make it absolute */
+                stway.tolev.dlevel += u.uz.dlevel;
+            }
         }
 
         stairway_add(stway.sx, stway.sy, stway.up, stway.isladder,
index d1dcf15fd50132aabe2b669f97e86c0c8a00f148..bc8def125f970d7f32e488037c151e5768e48f5c 100644 (file)
@@ -669,8 +669,16 @@ NHFILE *nhfp;
     while (stway) {
         if (perform_bwrite(nhfp)) {
             if (nhfp->structlevel) {
+                if (stway->tolev.dnum == u.uz.dnum) {
+                    /* make dlevel relative to current level */
+                    stway->tolev.dlevel -= u.uz.dlevel;
+                }
                 bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
                 bwrite(nhfp->fd, (genericptr_t) stway, sizeof *stway);
+                if (stway->tolev.dnum == u.uz.dnum) {
+                    /* reset staiway dlevel back to absolute */
+                    stway->tolev.dlevel += u.uz.dlevel;
+                }
             }
         }
         stway = stway->next;