]> granicus.if.org Git - nethack/commitdiff
fix B14021 - inconsistent menu styles
authornethack.rankin <nethack.rankin>
Sat, 14 Dec 2002 11:53:22 +0000 (11:53 +0000)
committernethack.rankin <nethack.rankin>
Sat, 14 Dec 2002 11:53:22 +0000 (11:53 +0000)
     Menu styles `partial' and `full' will let you remove any type of
item from the three weapon slots via the 'A' command, but `traditional'
and `combination' would only do that for the primary weapon slot.  For
the alternate weapon and quiver slots, the item in question had to be
one which can normally be wielded or worn, otherwise when choosing the
object class letter you'd be told that it was "Not applicable."  And
for wearable items, you needed to be really wearing one of that class
(besides the quivered one) or else you'd get "not wearing any amulet"
or similar.

doc/fixes34.1
include/extern.h
src/hacklib.c
src/invent.c

index 12db520d0abac1f7a8608ea1d59943f344b2de27..48fcd36ee75d5ba01fac7a15525452a720224190 100644 (file)
@@ -327,6 +327,8 @@ tengu is singular and plural, some rumors were incorrect
 don't let leader or nemesis be renamed
 non-moving monster are not affected by liquid
 'A' command wouldn't remove cursed item from quiver or alternate weapon slot
+'A' command behaved differently depending on menustyle when non-weapons were
+       present in the quiver or alternate weapon inventory slots
 
 
 Platform- and/or Interface-Specific Fixes
index f1558d659e63e784a363e5cf9c760f985a91a997..3702eefce7b08328d51b9abb1fe89abddcd63b24 100644 (file)
@@ -711,6 +711,7 @@ E char *FDECL(lcase, (char *));
 E char *FDECL(upstart, (char *));
 E char *FDECL(mungspaces, (char *));
 E char *FDECL(eos, (char *));
+E char *FDECL(strkitten, (char *,CHAR_P));
 E char *FDECL(s_suffix, (const char *));
 E char *FDECL(xcrypt, (const char *,char *));
 E boolean FDECL(onlyspace, (const char *));
index 1e8aed692546651ef87e688db5c9a1a962ebfefb..2cd0734eb67447697d1e80a27bc6fbca9041d81d 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)hacklib.c  3.4     1999/04/10      */
+/*     SCCS Id: @(#)hacklib.c  3.4     2002/12/13      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* Copyright (c) Robert Patrick Rankin, 1991             */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -18,6 +18,7 @@ NetHack, except that rounddiv may call panic().
        char *          upstart         (char *)
        char *          mungspaces      (char *)
        char *          eos             (char *)
+       char *          strkitten       (char *,char)
        char *          s_suffix        (const char *)
        char *          xcrypt          (const char *, char *)
        boolean         onlyspace       (const char *)
@@ -130,6 +131,19 @@ eos(s)                     /* return the end of a string (pointing at '\0') */
     return s;
 }
 
+/* strcat(s, {c,'\0'}); */
+char *
+strkitten(s, c)                /* append a character to a string (in place) */
+    char *s;
+    char c;
+{
+    char *p = eos(s);
+
+    *p++ = c;
+    *p = '\0';
+    return s;
+}
+
 char *
 s_suffix(s)            /* return a name converted to possessive */
     const char *s;
index 9e036119beac7a3e6a0a7fd72900cfa3c56c4e03..a762d1da786baa54119c8dcf98beecf9fb79cdbf 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)invent.c   3.4     2002/10/07      */
+/*     SCCS Id: @(#)invent.c   3.4     2002/12/13      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1142,6 +1142,7 @@ unsigned *resultflags;
        int oletct, iletct, unpaid, oc_of_sym;
 #endif
        char sym, *ip, olets[MAXOCLASSES+5], ilets[MAXOCLASSES+5];
+       char extra_removeables[3+1];    /* uwep,uswapwep,uquiver */
        char buf[BUFSZ], qbuf[QBUFSZ];
 
        if (resultflags) *resultflags = 0;
@@ -1203,20 +1204,31 @@ unsigned *resultflags;
                break;
        }
 
+       extra_removeables[0] = '\0';
+       if (takeoff) {
+           /* arbitrary types of items can be placed in the weapon slots
+              [any duplicate entries in extra_removeables[] won't matter] */
+           if (uwep) (void)strkitten(extra_removeables, uwep->oclass);
+           if (uswapwep) (void)strkitten(extra_removeables, uswapwep->oclass);
+           if (uquiver) (void)strkitten(extra_removeables, uquiver->oclass);
+       }
+
        ip = buf;
        olets[oletct = 0] = '\0';
        while ((sym = *ip++) != '\0') {
            if (sym == ' ') continue;
            oc_of_sym = def_char_to_objclass(sym);
-           if (takeoff && !(uwep && oc_of_sym == uwep->oclass) &&
-                   (oc_of_sym != MAXOCLASSES)) {
-               if (!index(removeables, oc_of_sym)) {
+           if (takeoff && oc_of_sym != MAXOCLASSES) {
+               if (index(extra_removeables, oc_of_sym)) {
+                   ;   /* skip rest of takeoff checks */
+               } else if (!index(removeables, oc_of_sym)) {
                    pline("Not applicable.");
                    return 0;
                } else if (oc_of_sym == ARMOR_CLASS && !wearing_armor()) {
                    You("are not wearing any armor.");
                    return 0;
-               } else if (oc_of_sym == WEAPON_CLASS && !uwep && !uswapwep && !uquiver) {
+               } else if (oc_of_sym == WEAPON_CLASS &&
+                       !uwep && !uswapwep && !uquiver) {
                    You("are not wielding anything.");
                    return 0;
                } else if (oc_of_sym == RING_CLASS && !uright && !uleft) {