]> granicus.if.org Git - nethack/commitdiff
hangup vs u.uinwater again (trunk only)
authornethack.rankin <nethack.rankin>
Wed, 30 Nov 2011 18:52:28 +0000 (18:52 +0000)
committernethack.rankin <nethack.rankin>
Wed, 30 Nov 2011 18:52:28 +0000 (18:52 +0000)
     Redo the fix that prevents hangup from putting hero on top of water
if it occurs during magic mapping or object/gold/trap detection.  Instead
of copying u.uinwater into another field in struct u so that it can be
reset during restore, copy it into a new field in struct iflags and reset
it during save so that no fixup upon restore is needed.

include/flag.h
include/you.h
src/detect.c
src/restore.c
src/save.c

index 25e2bac84015bbf75c403390ac59da130555306f..a4e53408d0e769ba010713c9035a7307f871c0c4 100644 (file)
@@ -306,6 +306,11 @@ struct instance_flags {
 #define MAX_ALTKEYHANDLER 25
        char     altkeyhandler[MAX_ALTKEYHANDLER];
 #endif
+       /* copies of values in struct u, used during detection when the
+          originals are temporarily cleared; kept here rather than
+          locally so that they can be restored during a hangup save */
+       Bitfield(save_uinwater,1);
+       Bitfield(save_uburied,1);
 };
 
 /*
index 9b3e0743d13d1f76ee4c333cae04dab9006e4290..55f0864a6f177522d5abbdbe9a421913b92e691d 100644 (file)
@@ -227,14 +227,6 @@ struct Align {
 
 extern const struct Align aligns[];    /* table of available alignments */
 
-/* hangup handling; sometimes u.uinwater is overridden, and we need to
-   be able to reset it in the event of restoring from a hangup save;
-   save/override/restore takes place during normal execution, so this
-   isn't dependent upon current port's signal handling capability */
-struct huphack {
-       Bitfield(hup_uinwater,1);
-       Bitfield(hup_uburied,1);
-};
 
 /*** Information about the player ***/
 struct you {
@@ -368,7 +360,6 @@ struct you {
        xchar   skill_record[P_SKILL_LIMIT];    /* skill advancements */
        struct skills weapon_skills[P_NUM_SKILLS];
        boolean twoweap;                /* KMH -- Using two-weapon combat */
-       struct huphack save;    /* hup_{uinwater,uburied} */
 
 };     /* end of `struct you' */
 
index a06a62e7e4219eb957b0db2808650efbbd688286..824105207bbce44bd43659421630eb114cdfe705 100644 (file)
@@ -233,7 +233,7 @@ register struct obj *sobj;
 outgoldmap:
     cls();
 
-    u.save.hup_uinwater = u.uinwater, u.save.hup_uburied = u.uburied;
+    iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
     u.uinwater = u.uburied = 0;
     /* Discover gold locations. */
     for (obj = fobj; obj; obj = obj->nobj) {
@@ -278,7 +278,7 @@ outgoldmap:
            }
     }
     newsym(u.ux,u.uy);
-    u.uinwater = u.save.hup_uinwater, u.uburied = u.save.hup_uburied;
+    u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
     You_feel("very greedy, and sense gold!");
     exercise(A_WIS, TRUE);
     display_nhwindow(WIN_MAP, TRUE);
@@ -351,7 +351,7 @@ register struct obj *sobj;
        struct obj *temp;
        known = TRUE;
        cls();
-       u.save.hup_uinwater = u.uinwater, u.save.hup_uburied = u.uburied;
+       iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
        u.uinwater = u.uburied = 0;
        for (obj = fobj; obj; obj = obj->nobj)
            if ((temp = o_in(obj, oclass)) != 0) {
@@ -371,7 +371,7 @@ register struct obj *sobj;
                    break;      /* skip rest of this monster's inventory */
                }
        newsym(u.ux,u.uy);
-       u.uinwater = u.save.hup_uinwater, u.uburied = u.save.hup_uburied;
+       u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
        if (sobj) {
            if (sobj->blessed) {
                Your("%s %s to tingle and you smell %s.", body_part(NOSE),
@@ -482,7 +482,7 @@ int         class;          /* an object class, 0 for all */
 
     cls();
 
-    u.save.hup_uinwater = u.uinwater, u.save.hup_uburied = u.uburied;
+    iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
     u.uinwater = u.uburied = 0;
 /*
  *     Map all buried objects first.
@@ -560,7 +560,7 @@ int         class;          /* an object class, 0 for all */
     }
 
     newsym(u.ux,u.uy);
-    u.uinwater = u.save.hup_uinwater, u.uburied = u.save.hup_uburied;
+    u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
     You("detect the %s of %s.", ct ? "presence" : "absence", stuff);
     display_nhwindow(WIN_MAP, TRUE);
     /*
@@ -766,7 +766,7 @@ register struct obj *sobj;
 outtrapmap:
     cls();
 
-    u.save.hup_uinwater = u.uinwater, u.save.hup_uburied = u.uburied;
+    iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
     u.uinwater = u.uburied = 0;
 
     /* show chest traps first, so that subsequent floor trap display
@@ -792,7 +792,7 @@ outtrapmap:
     glyph = glyph_at(u.ux, u.uy);
     if (!(glyph_is_trap(glyph) || glyph_is_object(glyph)))
        newsym(u.ux, u.uy);
-    u.uinwater = u.save.hup_uinwater, u.uburied = u.save.hup_uburied;
+    u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
 
     You_feel("%s.", cursed_src ? "very greedy" : "entrapped");
     /* wait for user to respond, then reset map display to normal */
@@ -1005,12 +1005,12 @@ do_mapping()
 {
     register int zx, zy;
 
-    u.save.hup_uinwater = u.uinwater, u.save.hup_uburied = u.uburied;
+    iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
     u.uinwater = u.uburied = 0;
     for (zx = 1; zx < COLNO; zx++)
        for (zy = 0; zy < ROWNO; zy++)
            show_map_spot(zx, zy);
-    u.uinwater = u.save.hup_uinwater, u.uburied = u.save.hup_uburied;
+    u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
     if (!level.flags.hero_memory || Underwater) {
        flush_screen(1);                        /* flush temp screen */
        display_nhwindow(WIN_MAP, TRUE);        /* wait */
index 9e2def56d7a92db575e24d160af565b6c9d158a2..4d5136f7a1d92a074bf02429e12f18de8fce9fb1 100644 (file)
@@ -857,11 +857,6 @@ register int fd;
         */
        reset_restpref();
 
-       /* some fixups in case this was a hangup save */
-       u.uinvulnerable = 0;
-       if (u.save.hup_uinwater) u.uinwater = 1, u.save.hup_uinwater = 0;
-       if (u.save.hup_uburied) u.uburied = 1, u.save.hup_uburied = 0;
-
        restlevelstate(stuckid, steedid);
        program_state.something_worth_saving = 1; /* useful data now exists */
 
index ecf8d305f9ffca523154fd058f9decd526449ba0..2e743037f961d82b73528d110dbe691d755f71cb 100644 (file)
@@ -139,6 +139,13 @@ dosave0()
        d_level uz_save;
        char whynot[BUFSZ];
 
+       /* we may get here via hangup signal, in which case we want to fix up
+          a few of things before saving so that they won't be restored in
+          an improper state; these will be no-ops for normal save sequence */
+       u.uinvulnerable = 0;
+       if (iflags.save_uinwater) u.uinwater = 1, iflags.save_uinwater = 0;
+       if (iflags.save_uburied) u.uburied = 1, iflags.save_uburied = 0;
+
        if (!program_state.something_worth_saving || !SAVEF[0])
                return 0;
        fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */