]> granicus.if.org Git - nethack/commitdiff
BUC patch
authorarromdee <arromdee>
Wed, 16 Jan 2002 03:19:45 +0000 (03:19 +0000)
committerarromdee <arromdee>
Wed, 16 Jan 2002 03:19:45 +0000 (03:19 +0000)
This adds the BUC-patch, except that it includes four separate choices for
blessed/cursed/uncursed/unknown.  The patch only applies to full menu styles.

--Ken A

(Incidentally, I have a suggestion: when deciding what's the first line for
purposes of mailing out messages, use the first nonblank line...)

doc/fixes33.2
include/extern.h
include/hack.h
src/do.c
src/invent.c
src/pickup.c

index c837903e6dda8108b827af3c2a1cbbfcbc43d490..3ba2047085b2b1e248952bd1ecfc863b01a0e520 100644 (file)
@@ -475,6 +475,7 @@ msg_window option for ^P in TTY mode (Jay Tilton)
 ninjas should get multishot bonus with yumi and ya (Dylan O'Donnell)
 put prisoners in the Dark One's dungeon (Dylan O'Donnell)
 add leather cloak so soldiers don't have elven cloaks
+add Tom Friedetzky's BUC-patch (applies to full menustyle only)
 
 
 Platform- and/or Interface-Specific New Features
index 9f9b8fab0fbce940608ed9864a7d3246d9976c68..4a8970108d12cddc576ab46a08ad8d165fd62ac5 100644 (file)
@@ -780,6 +780,7 @@ E void NDECL(free_invbuf);
 E void NDECL(reassign);
 E int NDECL(doorganize);
 E int FDECL(count_unpaid, (struct obj *));
+E int FDECL(count_buc, (struct obj *,int));
 E void FDECL(carry_obj_effects, (struct obj *));
 
 /* ### ioctl.c ### */
index 2142d26265fb2affd37c80216d9e6881fac35e76..8fd8ed5303c89f271f184a0e5ccdd43f50bcc0ae 100644 (file)
@@ -158,6 +158,10 @@ NEARDATA extern coord bhitpos;     /* place where throw or zap hits or stops */
 #define ALL_TYPES    0x10
 #define BILLED_TYPES 0x20
 #define CHOOSE_ALL   0x40
+#define BUC_BLESSED  0x80
+#define BUC_CURSED   0x100
+#define BUC_UNCURSED 0x200
+#define BUC_UNKNOWN  0x400
 #define ALL_TYPES_SELECTED -2
 
 /* Flags to control find_mid() */
index 821560bd6c16de6a189a6851c71694213e4455c1..fdc2b6d4a9f10d2b71dbb159b046b2f375553876 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -608,6 +608,10 @@ int retry;
     menu_item *pick_list;
     boolean all_categories = TRUE;
     boolean drop_everything = FALSE;
+    boolean drop_blessed = FALSE;
+    boolean drop_cursed = FALSE;
+    boolean drop_uncursed = FALSE;
+    boolean drop_buc_unknown = FALSE;
 
 #ifndef GOLDOBJ
     if (u.ugold) {
@@ -626,7 +630,8 @@ int retry;
        all_categories = FALSE;
        n = query_category("Drop what type of items?",
                        invent,
-                       UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL,
+                       UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL |
+                       BUC_BLESSED | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN,
                        &pick_list, PICK_ANY);
        if (!n) goto drop_done;
        for (i = 0; i < n; i++) {
@@ -634,6 +639,14 @@ int retry;
                all_categories = TRUE;
            else if (pick_list[i].item.a_int == 'A')
                drop_everything = TRUE;
+           else if (pick_list[i].item.a_int == 'B')
+               drop_blessed = TRUE;
+           else if (pick_list[i].item.a_int == 'C')
+               drop_cursed = TRUE;
+           else if (pick_list[i].item.a_int == 'U')
+               drop_uncursed = TRUE;
+           else if (pick_list[i].item.a_int == 'X')
+               drop_buc_unknown = TRUE;
            else
                add_valid_menu_class(pick_list[i].item.a_int);
        }
@@ -653,6 +666,35 @@ int retry;
            otmp2 = otmp->nobj;
            n_dropped += drop(otmp);
        }
+    } else if (drop_blessed) {
+       for(otmp = invent; otmp; otmp = otmp2) {
+           /* zw, gold is never blessed or cursed */
+           otmp2 = otmp->nobj;
+           if (otmp->oclass != GOLD_CLASS && otmp->bknown && otmp->blessed)
+               n_dropped += drop(otmp);
+       }
+    } else if (drop_cursed) {
+       for(otmp = invent; otmp; otmp = otmp2) {
+           /* zw, gold is never blessed or cursed */
+           otmp2 = otmp->nobj;
+           if (otmp->oclass != GOLD_CLASS && otmp->bknown && otmp->cursed)
+               n_dropped += drop(otmp);
+       }
+    } else if (drop_uncursed) {
+       for(otmp = invent; otmp; otmp = otmp2) {
+           /* zw, gold is never blessed or cursed */
+           otmp2 = otmp->nobj;
+           if (otmp->oclass != GOLD_CLASS &&
+                   otmp->bknown && !otmp->blessed && !otmp->cursed)
+               n_dropped += drop(otmp);
+       }
+    } else if (drop_buc_unknown) {
+       for(otmp = invent; otmp; otmp = otmp2) {
+           /* zw, gold is never blessed or cursed */
+           otmp2 = otmp->nobj;
+           if (otmp->oclass != GOLD_CLASS && !otmp->bknown)
+               n_dropped += drop(otmp);
+       }
     } else {
        /* should coordinate with perm invent, maybe not show worn items */
        n = query_objlist("What would you like to drop?", invent,
index de29ca9a7dd13a0807f8a3ea6086a2828a4bcd65..816b877053aad88e33645220e048c5ad7fec85a8 100644 (file)
@@ -1631,6 +1631,45 @@ count_unpaid(list)
     return count;
 }
 
+/*
+ * Returns the number of items with b/u/c/unknown within the given list.  
+ * This does NOT include contained objects.
+ */
+int
+count_buc(list, type)
+    struct obj *list;
+    int type;
+{
+    int count = 0;
+
+    while (list) {
+       switch(type) {
+           case BUC_BLESSED:
+               if (list->oclass != GOLD_CLASS && list->bknown && list->blessed)
+                   count++;
+               break;
+           case BUC_CURSED:
+               if (list->oclass != GOLD_CLASS && list->bknown && list->cursed)
+                   count++;
+               break;
+           case BUC_UNCURSED:
+               if (list->oclass != GOLD_CLASS &&
+                       list->bknown && !list->blessed && !list->cursed)
+                   count++;
+               break;
+           case BUC_UNKNOWN:
+               if (list->oclass != GOLD_CLASS && !list->bknown)
+                   count++;
+               break;
+           default:
+               impossible("need count of curse status %d?", type);
+               return 0;
+       }
+       list = list->nobj;
+    }
+    return count;
+}
+
 STATIC_OVL void
 dounpaid()
 {
index 92b84c47ca656801c55660368d7d0248cf1e9095..9d51ce6c96e1c931b947a121004d20dc3cb6e589 100644 (file)
@@ -716,14 +716,33 @@ int how;                  /* type of query */
        char invlet;
        int ccount;
        boolean do_unpaid = FALSE;
+       boolean do_blessed = FALSE, do_cursed = FALSE, do_uncursed = FALSE,
+           do_buc_unknown = FALSE;
+       int num_buc_types = 0;
 
        *pick_list = (menu_item *) 0;
        if (!olist) return 0;
        if ((qflags & UNPAID_TYPES) && count_unpaid(olist)) do_unpaid = TRUE;
+       if ((qflags & BUC_BLESSED) && count_buc(olist, BUC_BLESSED)) {
+           do_blessed = TRUE;
+           num_buc_types++;
+       }
+       if ((qflags & BUC_CURSED) && count_buc(olist, BUC_CURSED)) {
+           do_cursed = TRUE;
+           num_buc_types++;
+       }
+       if ((qflags & BUC_UNCURSED) && count_buc(olist, BUC_UNCURSED)) {
+           do_uncursed = TRUE;
+           num_buc_types++;
+       }
+       if ((qflags & BUC_UNKNOWN) && count_buc(olist, BUC_UNKNOWN)) {
+           do_buc_unknown = TRUE;
+           num_buc_types++;
+       }
 
        ccount = count_categories(olist, qflags);
        /* no point in actually showing a menu for a single category */
-       if (ccount == 1 && !do_unpaid && !(qflags & BILLED_TYPES)) {
+       if (ccount == 1 && !do_unpaid && num_buc_types <= 1 && !(qflags & BILLED_TYPES)) {
            for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
                if ((qflags & WORN_TYPES) &&
                    !(curr->owornmask & (W_ARMOR|W_RING|W_AMUL|W_TOOL|W_WEP|W_SWAPWEP|W_QUIVER)))
@@ -805,6 +824,35 @@ int how;                   /* type of query */
                        "Auto-select every item being worn" :
                        "Auto-select every item", MENU_UNSELECTED);
        }
+       /* items with b/u/c/unknown if there are any */
+       if (do_blessed) {
+               invlet = 'B';
+               any.a_void = 0;
+               any.a_int = 'B';
+               add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
+                       "Auto-select blessed items", MENU_UNSELECTED);
+       }
+       if (do_cursed) {
+               invlet = 'C';
+               any.a_void = 0;
+               any.a_int = 'C';
+               add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
+                       "Auto-select cursed items", MENU_UNSELECTED);
+       }
+       if (do_uncursed) {
+               invlet = 'U';
+               any.a_void = 0;
+               any.a_int = 'U';
+               add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
+                       "Auto-select known uncursed items", MENU_UNSELECTED);
+       }
+       if (do_buc_unknown) {
+               invlet = 'X';
+               any.a_void = 0;
+               any.a_int = 'X';
+               add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
+                       "Auto-select un-b/u/c known items", MENU_UNSELECTED);
+       }
        end_menu(win, qstr);
        n = select_menu(win, how, pick_list);
        destroy_nhwindow(win);