--- nh343off/src/invent.c 2003-12-08 01:39:13.000000000 +0200 +++ nh343adjsplit/src/invent.c 2004-02-05 16:56:05.000000000 +0200 @@ -2650,13 +2650,23 @@ register char let; char alphabet[52+1], buf[52+1]; char qbuf[QBUFSZ]; +#ifdef ADJSPLIT + char allowallcnt[3]; +#else char allowall[2]; +#endif const char *adj_type; if (!flags.invlet_constant) reassign(); /* get a pointer to the object the user wants to organize */ +#ifdef ADJSPLIT + allowallcnt[0] = ALLOW_COUNT; allowallcnt[1] = ALL_CLASSES; + allowallcnt[2] = '\0'; + if (!(obj = getobj(allowallcnt,"adjust"))) return(0); +#else allowall[0] = ALL_CLASSES; allowall[1] = '\0'; if (!(obj = getobj(allowall,"adjust"))) return(0); +#endif /* initialize the list with all upper and lower case letters */ for (let = 'a', ix = 0; let <= 'z';) alphabet[ix++] = let++; @@ -2685,7 +2695,11 @@ let = yn_function(qbuf, (char *)0, '\0'); if(index(quitchars,let)) { pline(Never_mind); +#ifdef ADJSPLIT + goto cleansplit; +#else return(0); +#endif } if (let == '@' || !letter(let)) pline("Select an inventory slot letter."); @@ -2694,7 +2708,9 @@ } /* change the inventory and print the resulting item */ +#ifndef ADJSPLIT adj_type = "Moving:"; +#endif /* * don't use freeinv/addinv to avoid double-touching artifacts, @@ -2702,19 +2718,56 @@ */ extract_nobj(obj, &invent); +#ifdef ADJSPLIT + for (otmp = invent; otmp && otmp->invlet != let;) + otmp = otmp->nobj; + if (!otmp) + adj_type = "Moving:"; + else if (merged(&otmp,&obj)) { +#else for (otmp = invent; otmp;) if (merged(&otmp,&obj)) { +#endif adj_type = "Merging:"; obj = otmp; +#ifndef ADJSPLIT otmp = otmp->nobj; +#endif extract_nobj(obj, &invent); } else { +#ifdef ADJSPLIT + struct obj *otmp2; + for (otmp2 = invent; otmp2 + && otmp2->invlet != obj->invlet;) + otmp2 = otmp2->nobj; + + if (otmp2) { + char oldlet = obj->invlet; + + adj_type = "Displacing:"; + + /* Here be a nasty hack; solutions that don't + * require duplication of assigninvlet's code + * here are welcome. + */ + assigninvlet(obj); + + if (obj->invlet == NOINVSYM) { + pline("There's nowhere to put that."); + obj->invlet = oldlet; + goto cleansplit; + } + } else +#else if (otmp->invlet == let) { +#endif adj_type = "Swapping:"; otmp->invlet = obj->invlet; } +#ifndef ADJSPLIT otmp = otmp->nobj; } +#endif /* inline addinv (assuming flags.invlet_constant and !merged) */ obj->invlet = let; @@ -2726,6 +2779,14 @@ prinv(adj_type, obj, 0L); update_inventory(); return(0); +#ifdef ADJSPLIT +cleansplit: + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp != obj && otmp->invlet == obj->invlet) + merged( &otmp, &obj ); + + return 0; +#endif } /* common to display_minventory and display_cinventory */