Skip to content

Commit

Permalink
#adjust tweaks (trunk only)
Browse files Browse the repository at this point in the history
     Allow '#' as a destination slot if you've given '#' as the source
and there aren't any available inventory letters, making it possible to
use doorganize()'s feature of merging compatible items into one slot even
when that slot is #.  ('#' won't work as a destination when the source is
from a regular letter.  If the player wants to swap something in letter
slot x with whatever is in the # slot, he'll have to use # -> x rather
than x -> #.)

     Also, a post-3.4.3 change made it possible to produce an inventory
that used duplicate letters.  Giving a count while specifying the source
slot splits the source object.  But the extra '?' choice added to show
inventory letters in use didn't undo the split if player hit ESC to quit
early instead of specifying a destination slot.

     Lastly, don't prompt forever if the user doesn't give a valid
destination letter; give up after 5 attempts.
  • Loading branch information
nethack.rankin committed Nov 3, 2006
1 parent 672c14c commit 86249ed
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/invent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2790,8 +2790,8 @@ int
doorganize() /* inventory organizer by Del Lamb */
{
struct obj *obj, *otmp, *splitting, *bumped;
register int ix, cur;
register char let;
int ix, cur, trycnt;
char let;
char alphabet[52+1], buf[52+1];
char qbuf[QBUFSZ];
char allowall[3]; /* { ALLOW_COUNT, ALL_CLASSES, 0 } */
Expand Down Expand Up @@ -2838,34 +2838,34 @@ doorganize() /* inventory organizer by Del Lamb */
/* compact the list by removing all the blanks */
for (ix = cur = 0; alphabet[ix]; ix++)
if (alphabet[ix] != ' ') buf[cur++] = alphabet[ix];
if (!cur && obj->invlet == NOINVSYM) buf[cur++] = NOINVSYM;
buf[cur] = '\0';
/* and by dashing runs of letters */
if(cur > 5) compactify(buf);

/* get 'to' slot to use as destination */
Sprintf(qbuf, "Adjust letter to what [%s]%s?", buf,
invent ? " (? see used letters)" : "");
for (;;) {
for (trycnt = 1; ; ++trycnt) {
let = yn_function(qbuf, (char *)0, '\0');
if(let == '?' || let == '*') {
char ilet = display_used_invlets(splitting ? obj->invlet : 0);
if(!ilet) continue;
if(ilet == '\033') {
pline(Never_mind);
return 0;
}
let = ilet;
let = display_used_invlets(splitting ? obj->invlet : 0);
if (!let) continue;
if (let == '\033') goto noadjust;
}
if (index(quitchars, let) ||
/* 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)) {
noadjust:
if (splitting) (void) merged(&splitting, &obj);
pline(Never_mind);
return 0;
}
if (letter(let) && let != '@') break; /* got one */
if ((letter(let) && let != '@') || index(buf, let))
break; /* got one */
if (trycnt == 5) goto noadjust;
pline("Select an inventory slot letter."); /* else try again */
}

Expand Down

0 comments on commit 86249ed

Please sign in to comment.