]> granicus.if.org Git - nethack/commitdiff
paranoid_confirmation [expanded user patch] (trunk only; 2 of 2)
authornethack.rankin <nethack.rankin>
Sat, 5 Mar 2011 10:09:48 +0000 (10:09 +0000)
committernethack.rankin <nethack.rankin>
Sat, 5 Mar 2011 10:09:48 +0000 (10:09 +0000)
[Short writeup; see 'cvs log' of flag.h or options.c for the long one.]

     This is a reworking of user contributed patch known as Paranoid_Quit.

     Add a new compound option, paranoid_confirmation, accepting a space
separated list of values "quit die attack pray Remove"; default is "pray".
paranoid:quit   - yes vs y for "really quit?" and "enter explore mode?"
paranoid:die    - yes vs y for "die?" in explore mode or wizard mode
paranoid:attack - yes vs y for "really attack <peacful monster>?"
paranoid:pray   - y to pray; supersedes prayconfirm boolean; on by default
paranoid:Remove - always issue an inventory prompt for 'R' an 'T', even
  when only one applicable item is currently worn.

dat/opthelp
doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes35.0
include/extern.h
include/patchlevel.h
src/cmd.c
src/do_wear.c
src/end.c
src/pray.c
src/uhitm.c

index 62ff37bed533e90244a37845fc691e72a4b1efbe..e1a29051788e929e327ba9d9786553c879929640 100644 (file)
@@ -25,7 +25,6 @@ null           allow nulls to be sent to your terminal            [TRUE]
                delay code) if moving objects seem to teleport across rooms
 perm_invent    keep inventory in a permanent window               [FALSE]
 pickup_thrown  override pickup_types for thrown objects           [TRUE]
-prayconfirm    use confirmation prompt when #pray command issued  [TRUE]
 pushweapon     when wielding a new weapon, put your previously
                wielded weapon into the secondary weapon slot      [FALSE]
 rawio          allow the use of raw I/O                           [FALSE]
@@ -113,6 +112,14 @@ packorder     a list of default symbols for kinds of objects that gives the
               order in which your pack will be displayed  [")[%?+!=/(*`0_]
               (If you specify only some kinds of items, the others from the
               default order will be appended to the end.)
+paranoid_confirmation  space separated list of situations where alternate
+              prompting is desired  [paranoid_confirmation:pray]
+              quit   -- yes vs y to confirm quitting or to enter explore mode
+              die    -- yes vs y to confirm dying (for explore or debug mode)
+              attack -- yes vs y to confirm attacking a peaceful monster
+              pray   -- y to confirm an attempt to pray; on by default
+              Remove -- always pick from inventory for 'R' and 'T' even when
+              wearing just one applicable item to remove or take off
 pickup_burden when you pick up an item that exceeds this encumberance
               level (Unencumbered, Burdened, streSsed, straiNed, overTaxed,
               or overLoaded), you will be asked if you want to continue. [S]
index 43d1e1dc22ec72e079c3ee6bd05b87ebe0733a88..499374419fe1f8214926fae716def5d8687e7cb5 100644 (file)
@@ -1973,6 +1973,28 @@ Specify the order to list object types in (default ``")[%?+!=/(*`0_'').
 The value of this option should be a string containing the
 symbols for the various object types.  Any omitted types are filled in
 at the end from the previous order.
+.lp paranoid_confirmation
+A space separated list of specific situations where alternate
+prompting is desired.  The default is paranoid_confirmation:pray.
+.sd
+.si
+quit   - require "yes" rather than 'y' to confirm quitting
+         the game or switching into non-scoring explore mode;
+die    - require "yes" rather than 'y' to confirm dying (not
+         useful in normal play; applies to explore mode);
+attack - require "yes" rather than 'y' to confirm attacking
+         a peaceful monster;
+pray   - require 'y' to confirm an attempt to pray rather
+         than immediately praying; on by default;
+Remove - require selection from inventory for 'R' and 'T'
+         commands even when wearing just one applicable item.
+.ei
+.ed
+By default, the pray choice is enabled, the others disabled.
+To disable it without setting
+any of the other choices, use ``paranoid_confirmation:none''.  To keep
+it enabled while setting any of the others, include it in the list,
+such as ``paranoid_confirmation:attack pray Remove''.
 .lp perm_invent
 If true, always display your current inventory in a window.  This only
 makes sense for windowing system interfaces that implement this feature.
@@ -2021,8 +2043,6 @@ user name (on multi-user systems) or specifying a particular character
 name (on single-user systems) or it might be disabled entirely.  Requesting
 it when not allowed or not possible results in explore mode instead.
 Default is normal play.
-.lp prayconfirm
-Prompt for confirmation before praying (default on).
 .lp pushweapon
 Using the `w' (wield) command when already wielding
 something pushes the old item into your alternate weapon slot (default off).
index e12e8a9a294f6ee91aa38da48f9d4909f1dd5f12..37fb8f232a113b33e089d2cd620440ec28d3e21e 100644 (file)
@@ -33,7 +33,7 @@
 \begin{document}
 %
 % input file: guidebook.mn
-% $Revision: 1.109 $ $Date: 2009/10/18 23:52:34 $
+% $Revision: 1.110 $ $Date: 2009/10/20 22:48:30 $
 %
 %.ds h0 "
 %.ds h1 %.ds h2 \%
@@ -2454,6 +2454,37 @@ Specify the order to list object types in (default
 containing the symbols for the various object types.  Any omitted types
 are filled in at the end from the previous order.
 %.lp
+\item[\ib{paranoid_confirmation}]
+A space separated list of specific situations where alternate
+prompting is desired.  The default is ``{\tt paranoid_confirmation:pray}''.
+%.sd
+%.si
+\blist{}       % this might look better as a table
+\item[{\tt quit}]
+require ``{\tt yes}'' rather than `{\tt y}' to confirm quitting
+the game or switching into non-scoring explore mode;
+\item[{\tt die}]
+require ``{\tt yes}'' rather than '{\tt y}' to confirm dying (not
+useful in normal play; applies to explore mode);
+\item[{\tt attack}]
+require ``{\tt yes}'' rather than '{\tt y}' to confirm attacking
+a peaceful monster;
+\item[{\tt pray}]
+require `{\tt y}' to confirm an attempt to pray rather
+than immediately praying; on by default;
+\item[{\tt Remove}] require selection from inventory for `{\tt R}' and `{\tt T}'
+commands even when wearing just one applicable item.
+\elist
+%.ei
+%.ed
+{\relax
+By default, the pray choice is enabled, the others disabled.
+To disable it without setting
+any of the other choices, use ``{\tt paranoid_confirmation:none}''.  To keep
+it enabled while setting others, include it in the list,
+such as ``{\tt paranoid_con\-fir\-ma\-tion:\-attack~pray~Remove}''.
+}%relax
+%.lp
 \item[\ib{perm\_invent}]
 If true, always display your current inventory in a window.  This only
 makes sense for windowing system interfaces that implement this feature.
@@ -2467,7 +2498,7 @@ If the choice is not allowed for the role you are currently playing,
 it will be silently ignored.  For example, ``{\tt horse}'' will only be
 honored when playing a knight.
 Cannot be set with the `{\tt O}' command.
-%.Ip
+%.lp
 \item[\ib{pickup\_burden}]
 When you pick up an item that would exceed this encumbrance
 level (Unencumbered, Burdened, streSsed, straiNed, overTaxed,
@@ -2504,9 +2535,6 @@ name (on single-user systems) or it might be disabled entirely.  Requesting
 it when not allowed or not possible results in explore mode instead.
 Default is normal play.
 %.lp
-\item[\ib{prayconfirm}]
-Prompt for confirmation before praying (default on).
-%.lp
 \item[\ib{pushweapon}]
 Using the `w' (wield) command when already wielding
 something pushes the old item into your alternate weapon slot (default off).
index 8ca9c4fc4d2e6e01d02965ff18ddadbe6a49b119..f28312985e0f21dbeda5677ed4356303169c5f0e 100644 (file)
@@ -477,6 +477,12 @@ chatting to a gecko or shopkeeper while hallucinating gives alternate message
 mimic posing as door might steal hero's key when [un]locking is attempted
 polymorphing into a dragon while wearing dragon scale mail will cause that
        mail to revert to dragon scales
+adopt/adapt/improve the Paranoid_Quit patch; default is paranoid_confirm:pray
+       paranoid_confirm:quit   yes vs y to quit or to enter explore mode
+       paranoid_confirm:die    yes vs y to die in explore or wizard mode
+       paranoid_confirm:attack yes vs y to attack a peaceful monster
+       paranoid_confirm:pray   y to confirm #pray; supersedes prayconfirm
+       paranoid_confirm:Remove always pick from inventory for 'R' and 'T'
 
 
 Platform- and/or Interface-Specific New Features
index 4b36a5a6e9b22daeb7e2f9d20ef46873eb55d51b..780876469d61e176172c8683772ad478255a9443 100644 (file)
@@ -216,6 +216,7 @@ E char NDECL(readchar);
 E void NDECL(sanity_check);
 #endif
 E char FDECL(yn_function, (const char *, const char *, CHAR_P));
+E boolean FDECL(paranoid_query, (BOOLEAN_P,const char *));
 
 /* ### dbridge.c ### */
 
index 938ec5b4b0c40ed9a4440e6aec2c00ea95272919..42c534229cdd8e57641c5bf3f25f24e4290d04ae 100644 (file)
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      44
+#define EDITLEVEL      45
 
 #define COPYRIGHT_BANNER_A \
-"NetHack, Copyright 1985-2009"
+"NetHack, Copyright 1985-2011"
 
 #define COPYRIGHT_BANNER_B \
 "         By Stichting Mathematisch Centrum and M. Stephenson."
index 8ebeb8bcd4da219965e7f322d3601bbc5026cd27..df7c9e0dc6d98c710f3aaf0fd1cfd19191bee650 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -503,19 +503,26 @@ domonability(VOID_ARGS)
 int
 enter_explore_mode(VOID_ARGS)
 {
-       if(!discover && !wizard) {
-               pline("Beware!  From explore mode there will be no return to normal game.");
-               if (yn("Do you want to enter explore mode?") == 'y') {
-                       clear_nhwindow(WIN_MESSAGE);
-                       You("are now in non-scoring explore mode.");
-                       discover = TRUE;
-               }
-               else {
-                       clear_nhwindow(WIN_MESSAGE);
-                       pline("Resuming normal game.");
-               }
+    if (wizard) {
+#ifdef WIZARD
+       You("are in debug mode.");
+#endif
+    } else if (discover) {
+       You("are already in explore mode.");
+    } else {
+       pline(
+        "Beware!  From explore mode there will be no return to normal game.");
+       if (paranoid_query(ParanoidQuit,
+                          "Do you want to enter explore mode?")) {
+           clear_nhwindow(WIN_MESSAGE);
+           You("are now in non-scoring explore mode.");
+           discover = TRUE;
+       } else {
+           clear_nhwindow(WIN_MESSAGE);
+           pline("Resuming normal game.");
        }
-       return 0;
+    }
+    return 0;
 }
 
 #ifdef DUNGEON_OVERVIEW
@@ -3616,6 +3623,28 @@ char def;
        return (*windowprocs.win_yn_function)(qbuf, resp, def);
 }
 
+/* for paranoid_confirm:quit,die,attack prompting */
+boolean
+paranoid_query(be_paranoid, prompt)
+boolean be_paranoid;
+const char *prompt;
+{
+       char qbuf[QBUFSZ], ans[BUFSZ];
+       boolean confirmed_ok;
+
+       /* when paranoid, player must respond with "yes" rather than just 'y'
+          to give the go-ahead for this query; default is "no", obviously */
+       if (be_paranoid) {
+           Sprintf(qbuf, "%s (yes) [no]", prompt);
+           getlin(qbuf, ans);
+           (void) mungspaces(ans);
+           confirmed_ok = !strcmpi(ans, "yes");
+       } else
+           confirmed_ok = (yn(prompt) == 'y');
+
+       return confirmed_ok;
+}
+
 int
 dosuspend_core(){
 #ifdef SUSPEND
index 650e93fdd1c4d08ff4ee5d5d88b1073daad19b60..bd6ea1b1328d55c95012f1de2a89974d60078180 100644 (file)
@@ -1232,12 +1232,12 @@ dotakeoff()
                          "  Use 'R' command to remove accessories." : "");
                return 0;
        }
-       if (armorpieces > 1)
+       if (armorpieces > 1 || ParanoidRemove)
                otmp = getobj(clothes, "take off");
-       if (otmp == 0) return(0);
+       if (!otmp) return 0;
        if (!(otmp->owornmask & W_ARMOR)) {
                You("are not wearing that.");
-               return(0);
+               return 0;
        }
        /* note: the `uskin' case shouldn't be able to happen here; dragons
           can't wear any armor so will end up with `armorpieces == 0' above */
@@ -1295,11 +1295,12 @@ doremring()
                      "  Use 'T' command to take off armor." : "");
                return(0);
        }
-       if (Accessories != 1) otmp = getobj(accessories, "remove");
-       if(!otmp) return(0);
-       if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
+       if (Accessories > 1 || ParanoidRemove)
+               otmp = getobj(accessories, "remove");
+       if (!otmp) return 0;
+       if (!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
                You("are not wearing that.");
-               return(0);
+               return 0;
        }
 
        reset_remarm();         /* clear context.takeoff.mask and context.takeoff.what */
index 8b51e9e4c56f5146384439306c0c55e354300386..fd24aff29023c62294e9143355f31bc7d861c8eb 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -298,7 +298,7 @@ int sig_unused;
 int
 done2()
 {
-       if(yn("Really quit?") == 'n') {
+       if (!paranoid_query(ParanoidQuit, "Really quit?")) {
 #ifndef NO_SIGNAL
                (void) signal(SIGINT, (SIG_RET_TYPE) done1);
 #endif
@@ -865,7 +865,7 @@ int how;
                        wizard ||
 #endif
                        discover) && (how <= GENOCIDED)) {
-               if(yn("Die?") == 'y') goto die;
+               if (paranoid_query(ParanoidDie, "Die?")) goto die;
                pline("OK, so you don't %s.",
                        (how == CHOKING) ? "choke" : "die");
                savelife(how);
index 61aec031734cb7036ebcd852f7ae2b099d746af4..923d39c22981951d4c7f02e6e77cc2198a59d182 100644 (file)
@@ -1648,9 +1648,8 @@ int
 dopray()
 {
     /* Confirm accidental slips of Alt-P */
-    if (flags.prayconfirm)
-       if (yn("Are you sure you want to pray?") == 'n')
-           return 0;
+    if (ParanoidPray && yn("Are you sure you want to pray?") != 'y')
+       return 0;
 
     u.uconduct.gnostic++;
 
index c5aa4e2920118d75dfe38f96b00a49e7e21703f3..f9434e474eadc14b51b8f7a4a802b8fd6530293f 100644 (file)
@@ -205,7 +205,7 @@ struct obj *wep;    /* uwep for attack(), null for kick_monster() */
                }
                if (canspotmon(mtmp)) {
                        Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
-                       if (yn(qbuf) != 'y') {
+                       if (!paranoid_query(ParanoidHit, qbuf)) {
                                context.move = 0;
                                return(TRUE);
                        }