]> granicus.if.org Git - nethack/commitdiff
nethack -X vs normal game (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 17 Feb 2007 05:43:18 +0000 (05:43 +0000)
committernethack.rankin <nethack.rankin>
Sat, 17 Feb 2007 05:43:18 +0000 (05:43 +0000)
     Reported to the beta-testers list by <Someone> last April:
restoring a normal game save file in explore mode let you keep the file,
then after exploring and quitting without saving, you could restore it
again in normal mode and take advantage of whatever information you'd
gained.  This makes nethack -X (or playmode:explore) defer the switch to
explore mode when used while restoring a normal mode save file.  It now
performs a normal restore (with save file deletion) and then acts as if
the user had given the 'X' command interactively, requiring confirmation
to actually switch into explore mode.

doc/fixes35.0
include/extern.h
include/flag.h
src/allmain.c
src/cmd.c
src/options.c
src/restore.c

index 766c64376045e13f5186107cf8548950957ea3cd..50bac50395d4b3ffc500937fec167bd8a40c6c7e 100644 (file)
@@ -188,6 +188,9 @@ can't drop part of a stack of N weapons welded to hero's hand
 pickup still accepts m as command prefix, but now rejects F,g,G,M,numpad 5
 scatter piles of kicked gold rather than move the entire pile at once
 #jump attempt fails if mounted on sleeping steed; jumping spell still works
+if normal game save file is restored via `nethack -X', restore in normal
+       mode--with save file deletion--and require confirmation ala 'X'
+       command to make deferred switch into explore mode
 
 
 Platform- and/or Interface-Specific Fixes
index a878d569c3a80486984591e9bd8086047fa6677a..9e758b5f55e5b033174e5d32be55669cb2981840 100644 (file)
@@ -162,7 +162,6 @@ E int NDECL(domonability);
 E int NDECL(doprev_message);
 E int NDECL(timed_occupation);
 E int NDECL(doattributes);
-E int NDECL(enter_explore_mode);
 # ifdef WIZARD
 E int NDECL(wiz_detect);
 E int NDECL(wiz_genesis);
@@ -187,6 +186,7 @@ E void FDECL(reset_commands, (BOOLEAN_P));
 E void FDECL(rhack, (char *));
 E int NDECL(doextlist);
 E int NDECL(extcmd_via_menu);
+E int NDECL(enter_explore_mode);
 E void FDECL(enlightenment, (int));
 E void FDECL(show_conduct, (int));
 E int FDECL(xytod, (SCHAR_P,SCHAR_P));
index ae8fbd7e29241e0757b959a5d0f19aea05412514..76fc0c5ce4f1af15543c10940265cddeb0558b87 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)flag.h     3.5     2005/11/19      */
+/*     SCCS Id: @(#)flag.h     3.5     2007/02/16      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -174,6 +174,7 @@ struct instance_flags {
        int *opt_booldup;       /* for duplication of boolean opts in config file */
        int *opt_compdup;       /* for duplication of compound opts in config file */
        boolean  cbreak;        /* in cbreak mode, rogue format */
+       boolean  deferred_X;    /* deferred entry into explore mode */
        boolean  num_pad;       /* use numbers for movement commands */
        boolean  news;          /* print news */
        boolean  menu_tab_sep;  /* Use tabs to separate option menu fields */
index de890cac6c2b32016abdfcdec6882e8fe65e6295..356dbc289901e700599c5b7b20ec1b7dd31c4c3f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)allmain.c  3.5     2007/01/12      */
+/*     SCCS Id: @(#)allmain.c  3.5     2007/02/16      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -37,6 +37,11 @@ boolean resuming;
     if (wizard) add_debug_extended_commands();
 #endif
 
+    /* if a save file created in normal mode is now being restored in
+       explore mode, treat it as normal restore followed by 'X' command
+       to use up the save file and require confirmation for explore mode */
+    if (resuming && iflags.deferred_X) (void)enter_explore_mode();
+
     /* side-effects from the real world */
     flags.moonphase = phase_of_the_moon();
     if(flags.moonphase == FULL_MOON) {
index 2e76f1c4dd61e5608d8d302ec14af278670a2960..cbe4551e254b542027e4c7d94ca2c1b1cf62e73b 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -37,6 +37,7 @@ extern int NDECL(doapply); /**/
 extern int NDECL(dorub); /**/
 extern int NDECL(dojump); /**/
 extern int NDECL(doextlist); /**/
+extern int NDECL(enter_explore_mode); /**/
 extern int NDECL(dodrop); /**/
 extern int NDECL(doddrop); /**/
 extern int NDECL(dodown); /**/
@@ -155,7 +156,6 @@ STATIC_DCL int NDECL(wiz_port_debug);
 STATIC_PTR int NDECL(wiz_rumor_check);
 STATIC_DCL char FDECL(cmd_from_func, (int NDECL((*))));
 # endif /* WIZARD */
-STATIC_PTR int NDECL(enter_explore_mode);
 STATIC_PTR int NDECL(doattributes);
 STATIC_PTR int NDECL(doconduct); /**/
 STATIC_PTR boolean NDECL(minimal_enlightenment);
@@ -489,7 +489,7 @@ domonability(VOID_ARGS)
        return 0;
 }
 
-STATIC_PTR int
+int
 enter_explore_mode(VOID_ARGS)
 {
        if(!discover && !wizard) {
index ed39ac0e7ec5a7731b4784941d6f7e550fe162d2..2959a01fcc49c545b95f27a1778a618431877947 100644 (file)
@@ -4501,6 +4501,7 @@ set_playmode()
            wizard = FALSE;     /* not allowed or not available */
        /* force explore mode if we didn't make it into wizard mode */
        discover = !wizard;
+       iflags.deferred_X = FALSE;
     }
     /* don't need to do anything special for explore mode or normal play */
 }
index ed50634e18d600b4768125ba5840e0360867684d..bc946a4be1bcb46c3c0b78a6d58b4bfb577a5883 100644 (file)
@@ -544,11 +544,13 @@ unsigned int *stuckid, *steedid;  /* STEED */
        newgameflags = flags;
        mread(fd, (genericptr_t) &flags, sizeof(struct flag));
        /* wizard and discover are actually flags.debug and flags.explore;
-          player might be overriding the save file values for them */
-       if (newgameflags.explore) discover = TRUE;
+          player might be overriding the save file values for them;
+          in the discover case, we don't want to set that for a normal
+          game until after the save file has been removed */
+       iflags.deferred_X = (newgameflags.explore && !discover);
        if (newgameflags.debug) {
            /* authorized by startup code; wizard mode exists and is allowed */
-           wizard = TRUE, discover = FALSE;
+           wizard = TRUE, discover = iflags.deferred_X = FALSE;
        } else if (wizard) {
            /* specified by save file; check authorization now */
            set_playmode();
@@ -577,6 +579,7 @@ unsigned int *stuckid, *steedid;    /* STEED */
            u.uz.dnum = 0;
            u.uz.dlevel = 1;
            /* revert to pre-restore option settings */
+           iflags.deferred_X = FALSE;
            flags = newgameflags;
 #ifdef SYSFLAGS
            sysflags = newgamesysflags;