]> granicus.if.org Git - nethack/commitdiff
Improve the tin opener
authorPasi Kallinen <paxed@alt.org>
Sat, 19 Dec 2015 12:44:39 +0000 (14:44 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 19 Dec 2015 12:44:39 +0000 (14:44 +0200)
doc/fixes36.1
include/extern.h
src/apply.c
src/eat.c
src/invent.c

index 5dc93f056adcd47239aca8c9dd3e577824a4f54d..465be7241557dcfcd0f5ba4052b38c8c4b35a8e3 100644 (file)
@@ -76,6 +76,7 @@ Platform- and/or Interface-Specific New Features
 
 NetHack Community Patches (or Variation) Included
 -------------------------------------------------
+Malcolm Ryan's improved tin opener
 
 
 Code Cleanup and Reorganization
index 564d863fd96f0a09802c2f7a2ea4c3b94492ae0c..2591f9ec5bb2210927ea8ef28af983791041defc 100644 (file)
@@ -604,6 +604,7 @@ E void NDECL(init_uhunger);
 E int NDECL(Hear_again);
 E void NDECL(reset_eat);
 E int NDECL(doeat);
+E int FDECL(use_tin_opener, (struct obj *));
 E void NDECL(gethungry);
 E void FDECL(morehungry, (int));
 E void FDECL(lesshungry, (int));
index 96c77386cae57fc53dc66cca740e88f9457c91a1..66e2919465a4eabb70cca2adec6906496cce081f 100644 (file)
@@ -3494,18 +3494,8 @@ doapply()
         res = dowrite(obj);
         break;
     case TIN_OPENER:
-        if (!carrying(TIN)) {
-            You("have no tin to open.");
-            goto xit;
-        }
-        You("cannot open a tin without eating or discarding its contents.");
-        if (flags.verbose)
-            pline("In order to eat, use the 'e' command.");
-        if (obj != uwep)
-            pline(
-          "Opening the tin will be much easier if you wield the tin opener.");
-        goto xit;
-
+        res = use_tin_opener(obj);
+        break;
     case FIGURINE:
         use_figurine(&obj);
         break;
index fe3e4e0715414c7215bf03905ddae9fdb2f14c48..2fb798b250233e19dce6a74ffc850ad6d613ffb7 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -2579,6 +2579,34 @@ doeat()
     return 1;
 }
 
+int
+use_tin_opener(obj)
+register struct obj *obj;
+{
+    register struct obj *otmp;
+    int res = 0;
+
+    if (!carrying(TIN)) {
+        You("have no tin to open.");
+        return 0;
+    }
+
+    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 (!wield_tool(obj, "use")) return 0;
+       else res = 1;
+    }
+
+    otmp = getobj((const char *)comestibles, "open");
+    if (!otmp) return 0;
+    start_tin(otmp);
+    return(1);
+}
+
 /* Take a single bite from a piece of food, checking for choking and
  * modifying usedtime.  Returns 1 if they choked and survived, 0 otherwise.
  */
index 6c3a221076d721cbac3afc871a088acd487c068e..3f0c15b8599d75033e66f2bd6c89eddd81c49934 100644 (file)
@@ -1099,6 +1099,7 @@ register const char *let, *word;
                  && (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown
                      || !objects[HORN_OF_PLENTY].oc_name_known))
              || (!strcmp(word, "charge") && !is_chargeable(otmp))
+             || (!strcmp(word, "open") && otyp != TIN)
              || (!strcmp(word, "call") && !objtyp_is_callable(otyp))
              ) {
                 foo--;