]> granicus.if.org Git - nethack/commitdiff
fix B18002 and B18003 - #rub worn blindfold and wield_tool() feedback
authornethack.rankin <nethack.rankin>
Thu, 30 Jan 2003 11:31:12 +0000 (11:31 +0000)
committernethack.rankin <nethack.rankin>
Thu, 30 Jan 2003 11:31:12 +0000 (11:31 +0000)
     Prevent #rub from wielding an item that is already being worn
(which should narrow things down to the various types of eyewear;
other tools and weapons that go through wield_tool() can't be worn).
Fix up the wield_tool message spacing in the process.

     This moves wield_tool() from apply.c to wield.c.  Some plural
handling for messages is included; it is feasible to try to #rub a
"pair of lenses" or a stack of N candles.

doc/fixes34.1
include/extern.h
src/apply.c
src/dig.c
src/wield.c

index 96feacdbd07523ed09aa7cdbea5e1d01bcd78ad1..79edb4e0cf6d1bc6c03723d71b590aa4144982d4 100644 (file)
@@ -367,6 +367,7 @@ when adding an object to inventory, it is possible for it to becomed both
 include rocks as likely candidates for quivering if alternate weapon is a sling
 Asmodeus fails an is_armed() check, so code in m_initweap() to give him wands 
        of fire and cold never got called; move the code to m_initinv()
+#rub would wield the target tool even when already being worn as eyewear
 
 
 Platform- and/or Interface-Specific Fixes
index c5dcad1d77ebac9b760d0661e0ccac2f8d46486f..232375adb08d6d8e50f93931901715d8ded21ebe 100644 (file)
@@ -39,7 +39,6 @@ E void NDECL(unleash_all);
 E boolean NDECL(next_to_u);
 E struct obj *FDECL(get_mleash, (struct monst *));
 E void FDECL(check_leash, (XCHAR_P,XCHAR_P));
-E boolean FDECL(wield_tool, (struct obj *));
 E boolean FDECL(um_dist, (XCHAR_P,XCHAR_P,XCHAR_P));
 E boolean FDECL(snuff_candle, (struct obj *));
 E boolean FDECL(snuff_lit, (struct obj *));
@@ -2226,18 +2225,19 @@ E void FDECL(setuswapwep, (struct obj *));
 E int NDECL(dowield);
 E int NDECL(doswapweapon);
 E int NDECL(dowieldquiver);
-E int NDECL(dotwoweapon);
+E boolean FDECL(wield_tool, (struct obj *,const char *));
 E int NDECL(can_twoweapon);
-E void NDECL(untwoweapon);
+E void NDECL(drop_uswapwep);
+E int NDECL(dotwoweapon);
 E void NDECL(uwepgone);
 E void NDECL(uswapwepgone);
 E void NDECL(uqwepgone);
+E void NDECL(untwoweapon);
 E void FDECL(erode_obj, (struct obj *,BOOLEAN_P,BOOLEAN_P));
 E int FDECL(chwepon, (struct obj *,int));
 E int FDECL(welded, (struct obj *));
 E void FDECL(weldmsg, (struct obj *));
 E void FDECL(setmnotwielded, (struct monst *,struct obj *));
-E void NDECL(drop_uswapwep);
 
 /* ### windows.c ### */
 
index 44e274b5aa3b087fcc5c2d71c836befb261219eb..3459bc2ff0bacadb334dd4556aaa10ab8f8247db 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)apply.c    3.4     2003/01/08      */
+/*     SCCS Id: @(#)apply.c    3.4     2003/01/29      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -570,48 +570,6 @@ register xchar x, y;
 #endif /* OVL0 */
 #ifdef OVLB
 
-boolean
-wield_tool(obj)
-struct obj *obj;
-{
-       if(welded(uwep)) {
-               /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */
-               if(flags.verbose) {
-                       pline("Since your weapon is welded to your %s,",
-                               bimanual(uwep) ?
-                               (const char *)makeplural(body_part(HAND))
-                               : body_part(HAND));
-                       pline("you cannot wield that %s.", xname(obj));
-               }
-               return(FALSE);
-       }
-       if (cantwield(youmonst.data)) {
-               You_cant("hold it strongly enough.");
-               return(FALSE);
-       }
-       /* Check shield */
-       if (uarms && bimanual(obj)) {
-               You("cannot wield a two-handed tool while wearing a shield.");
-               return(FALSE);
-       }
-       if(uquiver == obj) setuqwep((struct obj *)0);
-       if(uswapwep == obj) {
-           (void) doswapweapon();
-           /* If doswapweapon failed... */
-           if(uswapwep == obj) return (FALSE);
-       } else {
-           You("now wield %s.", doname(obj));
-           setuwep(obj);
-       }
-       if (uwep != obj) return(FALSE); /* rewielded old object after dying */
-       /* applying weapon or tool that gets wielded ends two-weapon combat */
-       if (u.twoweap)
-               untwoweapon();
-       if (obj->oclass != WEAPON_CLASS)
-               unweapon = TRUE;
-       return(TRUE);
-}
-
 #define WEAK   3       /* from eat.c */
 
 static const char look_str[] = "look %s.";
@@ -1188,7 +1146,7 @@ dorub()
            }
        }
 
-       if(!obj || (obj != uwep && !wield_tool(obj))) return 0;
+       if (!obj || !wield_tool(obj, "rub")) return 0;
 
        /* now uwep is obj */
        if (uwep->otyp == MAGIC_LAMP) {
@@ -2090,10 +2048,8 @@ struct obj *obj;
     const char *msg_snap = "Snap!";
 
     if (obj != uwep) {
-       if (!wield_tool(obj)) return 0;
+       if (!wield_tool(obj, "lash")) return 0;
        else res = 1;
-       /* prevent bashing msg */
-       unweapon = FALSE;
     }
     if (!getdir((char *)0)) return res;
 
@@ -2351,7 +2307,7 @@ use_pole (obj)
            return (0);
        }
        if (obj != uwep) {
-           if (!wield_tool(obj)) return(0);
+           if (!wield_tool(obj, "swing")) return(0);
            else res = 1;
        }
      /* assert(obj == uwep); */
@@ -2452,7 +2408,7 @@ use_grapple (obj)
            return (0);
        }
        if (obj != uwep) {
-           if (!wield_tool(obj)) return(0);
+           if (!wield_tool(obj, "cast")) return(0);
            else res = 1;
        }
      /* assert(obj == uwep); */
index e6b69b31920d763100eb718ea876dbe359fa99d7..a484f2c392981d2ff5be2715c536d14f9576cbcc 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dig.c      3.4     2003/01/08      */
+/*     SCCS Id: @(#)dig.c      3.4     2003/01/29      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -820,7 +820,7 @@ struct obj *obj;
 
        /* Check tool */
        if (obj != uwep) {
-           if (!wield_tool(obj)) return(0);
+           if (!wield_tool(obj, "swing")) return 0;
            else res = 1;
        }
        ispick = is_pick(obj);
index 92e84cf91cf98ae2df5cd120d5c0e57c8bc29a41..04231166a6e4cef62e775da41f0f1b21cbc6ddb3 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)wield.c    3.4     2002/08/03      */
+/*     SCCS Id: @(#)wield.c    3.4     2003/01/29      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -397,6 +397,74 @@ dowieldquiver()
        return (0);
 }
 
+/* used for #rub and for applying pick-axe, whip, grappling hook, or polearm */
+/* (moved from apply.c) */
+boolean
+wield_tool(obj, verb)
+struct obj *obj;
+const char *verb;      /* "rub",&c */
+{
+    const char *what;
+    boolean more_than_1;
+
+    if (obj == uwep) return TRUE;   /* nothing to do if already wielding it */
+
+    if (!verb) verb = "wield";
+    what = xname(obj);
+    more_than_1 = (obj->quan > 1L ||
+                  strstri(what, "pair of ") != 0 ||
+                  strstri(what, "s of ") != 0);
+
+    if (obj->owornmask & (W_ARMOR|W_RING|W_AMUL|W_TOOL)) {
+       char yourbuf[BUFSZ];
+
+       You_cant("%s %s %s while wearing %s.",
+                verb, shk_your(yourbuf, obj), what,
+                more_than_1 ? "them" : "it");
+       return FALSE;
+    }
+    if (welded(uwep)) {
+       if (flags.verbose) {
+           const char *hand = body_part(HAND);
+
+           if (bimanual(uwep)) hand = makeplural(hand);
+           if (strstri(what, "pair of ") != 0) more_than_1 = FALSE;
+           pline(
+            "Since your weapon is welded to your %s, you cannot %s %s %s.",
+                 hand, verb, more_than_1 ? "those" : "that", xname(obj));
+       } else {
+           You_cant("do that.");
+       }
+       return FALSE;
+    }
+    if (cantwield(youmonst.data)) {
+       You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it");
+       return FALSE;
+    }
+    /* check shield */
+    if (uarms && bimanual(obj)) {
+       You("cannot %s a two-handed %s while wearing a shield.",
+           verb, (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool");
+       return FALSE;
+    }
+    if (uquiver == obj) setuqwep((struct obj *)0);
+    if (uswapwep == obj) {
+       (void) doswapweapon();
+       /* doswapweapon might fail */
+       if (uswapwep == obj) return FALSE;
+    } else {
+       You("now wield %s.", doname(obj));
+       setuwep(obj);
+    }
+    if (uwep != obj) return FALSE;     /* rewielded old object after dying */
+    /* applying weapon or tool that gets wielded ends two-weapon combat */
+    if (u.twoweap)
+       untwoweapon();
+    if (obj->oclass != WEAPON_CLASS)
+       unweapon = TRUE;
+    return TRUE;
+}
+
 int
 can_twoweapon()
 {