]> granicus.if.org Git - nethack/commitdiff
address #H6552 - #adjust behavior
authorPatR <rankin@nethack.org>
Fri, 1 Dec 2017 03:15:45 +0000 (19:15 -0800)
committerPatR <rankin@nethack.org>
Fri, 1 Dec 2017 03:15:45 +0000 (19:15 -0800)
The report stated that '#adjust a c' after '#adjust 1a b' moved all
the original 'a' to 'c' instead of leaving the one in 'b' alone.
That's true, but it is also the intended behavior.  Splitting off
with a count explicitly avoids gathering compatible stacks (but
does merge into the destination if compatible, instead of swapping).
Moving a whole stack gathers compatible ones and puts the whole
merged group into the destination.

But that leaves a gap in functionality:  there's no way to get the
don't-collect-other-stacks without splitting; there ought to be.
So, allow the player to specify full count to move a stack from one
slot to another without collecting compatible stacks (the behavior
when no count is given) or splitting (the behavior when count is
less than full amount).  In the example above, if 'a' started with
5 doodads and had 4 left after splitting one to 'b', '#adjust 4a c'
will move those 4 (all of 'a') to 'c' without merging 'b' into them.
The method is a bit obscure but it's also something which doesn't
come up very often.

doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes36.1
src/invent.c

index 94086df1aadca948a108ae9bd1687c1781f343c2..16199ef814d830ca4d6345739cf33e79a5e48d06 100644 (file)
@@ -1,4 +1,4 @@
-.\" $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.233 $ $NHDT-Date: 1505214878 2017/09/12 11:14:38 $
+.\" $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.240 $ $NHDT-Date: 1512098127 2017/12/01 03:15:27 $
 .ds h0 "NetHack Guidebook
 .ds h1
 .ds h2 %
@@ -924,8 +924,17 @@ This command allows you to move an item from one particular inventory
 slot to another so that it has a letter which is more meaningful for you
 or that it will appear in a particular location when inventory listings
 are displayed.
+You can move to a currently empty slot, or if the destination is
+occupied--and won't merge--the item there will swap slots with the one
+being moved.
 ``#adjust'' can also be used to split a stack of objects; when
 choosing the item to adjust, enter a count prior to its letter.
+.lp ""
+When no count is given, other compatible stacks are merged with the source
+stack as it's moved to the destination.  When a split count is given, the
+only stack that might be merged is the one already in the destination.
+To move a whole stack without having other compatible ones merge with it,
+specify a ``split'' count which matches the full stack size.
 .lp #annotate
 Allows you to specify one line of text to associate with the current
 dungeon level.  All levels with annotations are displayed by the
index b67342c7458a8e60552bcb335cca638668c60c88..e776b02d0ef6a5f8e5bb3d0395e419e52f489dd0 100644 (file)
@@ -1104,8 +1104,17 @@ This command allows you to move an item from one particular inventory
 slot to another so that it has a letter which is more meaningful for you
 or that it will appear in a particular location when inventory listings
 are displayed.
+You can move to a currently empty slot, or if the destination is
+occupied--and won't merge--the item there will swap slots with the one
+being moved.
 ``{\tt \#adjust}'' can also be used to split a stack of objects; when
-choosing the item to adjust, enter a count prior to its letter.
+choosing the item to adjust, enter a count prior to its letter.\\
+%.lp ""
+When no count is given, other compatible stacks are merged with the source
+stack as it's moved to the destination.  When a split count is given, the
+only stack that might be merged is the one already in the destination.
+To move a whole stack without having other compatible ones merge with it,
+specify a ``split'' count which matches the full stack size.
 %.lp
 \item[\tb{\#annotate}]
 Allows you to specify one line of text to associate with the current
index 4039409166bde3804bbc614123192a2b51d642fd..4e1d79c763fed5ccc8a98ef9b859e2c4ddcacb2b 100644 (file)
@@ -720,6 +720,9 @@ Master Key of Thievery always finds door and chest traps if used to lock or
 "Elbereth" now erodes based on attacks by the player, not monsters scared
 option herecmd_menu to make a mouse click on your character pop up
        a context menu, and extended command #herecmdmenu to do the same
+for #adjust, specifying a split count which matches an inventory slot's full
+       size will move or swap that stack without combining other compatible
+       stacks (except for the one in the destination slot, if applicable)
 
 
 Platform- and/or Interface-Specific New Features
index edacfc5479f369c06477e40ab273218140a4cd2a..4a8a68815b8f42118c475a505ceeadb157418176 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1508827592 2017/10/24 06:46:32 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.220 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1512096431 2017/12/01 02:47:11 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.222 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -617,8 +617,7 @@ void
 carry_obj_effects(obj)
 struct obj *obj;
 {
-    /* Cursed figurines can spontaneously transform
-       when carried. */
+    /* Cursed figurines can spontaneously transform when carried. */
     if (obj->otyp == FIGURINE) {
         if (obj->cursed && obj->corpsenm != NON_PM
             && !dead_species(obj->corpsenm, TRUE)) {
@@ -1473,6 +1472,9 @@ redo_menu:
             else if (otmp->otyp == LOADSTONE && otmp->cursed)
                 /* kludge for canletgo()'s can't-drop-this message */
                 otmp->corpsenm = (int) cnt;
+        } else if (!strcmp(word, "adjust")) {
+            /* specifying stack's full count means something to #adjust */
+            otmp->nomerge = 1;
         }
     }
     return otmp;
@@ -3568,7 +3570,7 @@ doorganize() /* inventory organizer by Del Lamb */
     char qbuf[QBUFSZ];
     char allowall[4]; /* { ALLOW_COUNT, ALL_CLASSES, 0, 0 } */
     const char *adj_type;
-    boolean ever_mind = FALSE;
+    boolean ever_mind = FALSE, dont_collect = FALSE;
 
     if (!invent) {
         You("aren't carrying anything to adjust.");
@@ -3600,12 +3602,19 @@ doorganize() /* inventory organizer by Del Lamb */
 
     /* figure out whether user gave a split count to getobj() */
     splitting = bumped = 0;
-    for (otmp = invent; otmp; otmp = otmp->nobj)
-        if (otmp->nobj == obj) { /* knowledge of splitobj() operation */
-            if (otmp->invlet == obj->invlet)
-                splitting = otmp;
-            break;
-        }
+    if (obj->nomerge) {
+        /* player specified full count; no split occurred and we'll
+           avoid collecting compatible stacks when moving this one */
+        obj->nomerge = 0;
+        dont_collect = TRUE;
+    } else {
+        for (otmp = invent; otmp; otmp = otmp->nobj)
+            if (otmp->nobj == obj) { /* knowledge of splitobj() operation */
+                if (otmp->invlet == obj->invlet)
+                    splitting = otmp;
+                break;
+            }
+    }
 
     /* initialize the list with all lower and upper case letters */
     lets[GOLD_INDX] = (obj->oclass == COIN_CLASS) ? GOLD_SYM : ' ';
@@ -3659,7 +3668,7 @@ doorganize() /* inventory organizer by Del Lamb */
             /* adjusting to same slot is meaningful since all
                compatible stacks get collected along the way,
                but splitting to same slot is not */
-            || (splitting && let == obj->invlet)) {
+            || ((splitting || dont_collect) && let == obj->invlet)) {
         noadjust:
             if (splitting)
                 (void) merged(&splitting, &obj);
@@ -3692,7 +3701,7 @@ doorganize() /* inventory organizer by Del Lamb */
     extract_nobj(obj, &invent);
 
     for (otmp = invent; otmp;) {
-        if (!splitting) {
+        if (!splitting && !dont_collect) {
             if (merged(&otmp, &obj)) {
                 adj_type = "Merging:";
                 obj = otmp;
@@ -3730,7 +3739,7 @@ doorganize() /* inventory organizer by Del Lamb */
                 if (merged(&otmp, &obj)) {
                     obj = otmp;
                     extract_nobj(obj, &invent);
-                } else if (inv_cnt(FALSE) >= 52) {
+                } else if (inv_cnt(FALSE) >= 52 && !dont_collect) {
                     (void) merged(&splitting, &obj); /* undo split */
                     /* "knapsack cannot accommodate any more items" */
                     Your("pack is too full.");