| 5065 | } |
| 5066 | |
| 5067 | staticfn int |
| 5068 | doorganize_core(struct obj *obj) |
| 5069 | { |
| 5070 | struct obj *otmp, *splitting, *bumped; |
| 5071 | int ix, cur, trycnt; |
| 5072 | char let; |
| 5073 | #define GOLD_INDX 0 |
| 5074 | #define GOLD_OFFSET 1 |
| 5075 | #define OVRFLW_INDX (GOLD_OFFSET + invlet_basic) /* past gold+2*26 letters */ |
| 5076 | char lets[1 + invlet_basic + 1 + 1]; /* room for '$a-zA-Z#\0' */ |
| 5077 | char qbuf[QBUFSZ]; |
| 5078 | char *objname, *otmpname; |
| 5079 | const char *adj_type; |
| 5080 | boolean ever_mind = FALSE, collect, isgold; |
| 5081 | |
| 5082 | if (!obj) |
| 5083 | return ECMD_CANCEL; |
| 5084 | |
| 5085 | /* can only be gold if check_invent_gold() found a problem: multiple '$' |
| 5086 | stacks and/or gold in some other slot, otherwise (*adjust_filter)() |
| 5087 | won't allow gold to be picked; if player has picked any stack of gold |
| 5088 | as #adjust 'from' slot, we'll force the 'to' slot to be '$' below */ |
| 5089 | isgold = (obj->oclass == COIN_CLASS); |
| 5090 | |
| 5091 | /* figure out whether user gave a split count to getobj() */ |
| 5092 | splitting = bumped = 0; |
| 5093 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) |
| 5094 | if (otmp->nobj == obj) { /* knowledge of splitobj() operation */ |
| 5095 | if (otmp->invlet == obj->invlet) |
| 5096 | splitting = otmp; |
| 5097 | break; |
| 5098 | } |
| 5099 | |
| 5100 | /* initialize the list with all lower and upper case letters */ |
| 5101 | lets[GOLD_INDX] = (obj->oclass == COIN_CLASS) ? GOLD_SYM : ' '; |
| 5102 | for (ix = GOLD_OFFSET, let = 'a'; let <= 'z';) |
| 5103 | lets[ix++] = let++; |
| 5104 | for (let = 'A'; let <= 'Z';) |
| 5105 | lets[ix++] = let++; |
| 5106 | lets[OVRFLW_INDX] = ' '; |
| 5107 | lets[sizeof lets - 1] = '\0'; |
| 5108 | /* for floating inv letters, truncate list after the first open slot */ |
| 5109 | if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < invlet_basic) |
| 5110 | lets[ix + (splitting ? 1 : 2)] = '\0'; |
| 5111 | |
| 5112 | /* blank out all the letters currently in use in the inventory |
| 5113 | except those that will be merged with the selected object */ |
| 5114 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) |
| 5115 | if (otmp != obj && !mergable(otmp, obj)) { |
| 5116 | let = otmp->invlet; |
| 5117 | if (let >= 'a' && let <= 'z') |
| 5118 | lets[GOLD_OFFSET + let - 'a'] = ' '; |
| 5119 | else if (let >= 'A' && let <= 'Z') |
| 5120 | lets[GOLD_OFFSET + let - 'A' + 26] = ' '; |
| 5121 | /* overflow defaults to off, but it we find a stack using that |
| 5122 | slot, switch to on -- the opposite of normal invlet handling */ |
| 5123 | else if (let == NOINVSYM) |
| 5124 | lets[OVRFLW_INDX] = NOINVSYM; |
no test coverage detected