]> granicus.if.org Git - nethack/commitdiff
tin opener fix
authorPatR <rankin@nethack.org>
Sun, 20 Dec 2015 01:11:33 +0000 (17:11 -0800)
committerPatR <rankin@nethack.org>
Sun, 20 Dec 2015 01:11:33 +0000 (17:11 -0800)
Applying a non-wielded tin opener and then declining to pick a tin to
open would wield the opener without having any time elapse.

Reformat the new tin opener code.

Remove a no-longer-used label in doapply() in order to avoid a warning
from gcc.

src/apply.c
src/eat.c

index 66e2919465a4eabb70cca2adec6906496cce081f..12d6812bfdaeeb953fdcc2a9c24c022cadf9dadc 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 apply.c $NHDT-Date: 1450481050 2015/12/18 23:24:10 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.214 $ */
+/* NetHack 3.6 apply.c $NHDT-Date: 1450573880 2015/12/20 01:11:20 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.216 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3537,7 +3537,6 @@ doapply()
             break;
         }
         pline("Sorry, I don't know how to use that.");
-    xit:
         nomul(0);
         return 0;
     }
index 2fb798b250233e19dce6a74ffc850ad6d613ffb7..4e97a58184ded722606f29cada1c5ef2eb9bd055 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 eat.c   $NHDT-Date: 1449269916 2015/12/04 22:58:36 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.154 $ */
+/* NetHack 3.6 eat.c   $NHDT-Date: 1450573885 2015/12/20 01:11:25 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.156 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2581,9 +2581,9 @@ doeat()
 
 int
 use_tin_opener(obj)
-register struct obj *obj;
+struct obj *obj;
 {
-    register struct obj *otmp;
+    struct obj *otmp;
     int res = 0;
 
     if (!carrying(TIN)) {
@@ -2594,17 +2594,22 @@ register struct obj *obj;
     if (obj != uwep) {
         if (obj->cursed && obj->bknown) {
             char qbuf[QBUFSZ];
-            (void) safe_qbuf(qbuf, "Really wield ", "?", obj, doname, ansimpleoname, "that");
-            if (ynq(qbuf) != 'y') return 0;
+
+            if (ynq(safe_qbuf(qbuf, "Really wield ", "?",
+                              obj, doname, thesimpleoname, "that")) != 'y')
+                return 0;
         }
-       if (!wield_tool(obj, "use")) return 0;
-       else res = 1;
+       if (!wield_tool(obj, "use"))
+            return 0;
+        res = 1;
     }
 
-    otmp = getobj((const char *)comestibles, "open");
-    if (!otmp) return 0;
+    otmp = getobj(comestibles, "open");
+    if (!otmp)
+        return res;
+
     start_tin(otmp);
-    return(1);
+    return 1;
 }
 
 /* Take a single bite from a piece of food, checking for choking and