* For menustyle:Traditional and menustyle:Combination. * * Suppose some '?' and '!' objects are present, but '/' objects aren't: * "a" picks all items without further prompting; * "A" steps through all items, asking one by one; * "?" steps through '?' items, asking, and ignores '!' ones; * "/" becomes 'A', since no '/' present; * "?a" or "a?" picks all '?' without f
| 138 | * some players complain that it is too easy to choose accidentally). |
| 139 | */ |
| 140 | staticfn boolean |
| 141 | query_classes( |
| 142 | char oclasses[], /* selected classes */ |
| 143 | boolean *one_at_a_time, /* to tell caller that user picked 'A' */ |
| 144 | boolean *everything, /* to tell caller that user picked 'a' */ |
| 145 | const char *action, /* verb for what activity needs objects */ |
| 146 | struct obj *objs, /* invent or container->cobj or level.objects[x][y] */ |
| 147 | boolean here, /* True: traverse by obj->nexthere; False: by obj->nobj */ |
| 148 | int *menu_on_demand) /* to tell caller that user picked 'm' */ |
| 149 | { |
| 150 | char ilets[36], inbuf[BUFSZ] = DUMMY; /* FIXME: hardcoded ilets[] length */ |
| 151 | int iletct, oclassct; |
| 152 | boolean not_everything, filtered; |
| 153 | char qbuf[QBUFSZ]; |
| 154 | boolean m_seen; |
| 155 | int itemcount, bcnt, ucnt, ccnt, xcnt, ocnt, jcnt; |
| 156 | |
| 157 | oclasses[oclassct = 0] = '\0'; |
| 158 | *one_at_a_time = *everything = m_seen = FALSE; |
| 159 | if (menu_on_demand) |
| 160 | *menu_on_demand = 0; |
| 161 | iletct = collect_obj_classes(ilets, objs, here, |
| 162 | (boolean (*)(OBJ_P)) 0, &itemcount); |
| 163 | if (iletct == 0) |
| 164 | return FALSE; |
| 165 | |
| 166 | if (iletct == 1) { |
| 167 | oclasses[0] = def_char_to_objclass(ilets[0]); |
| 168 | oclasses[1] = '\0'; |
| 169 | } else { /* more than one choice available */ |
| 170 | /* additional choices */ |
| 171 | ilets[iletct++] = ' '; |
| 172 | ilets[iletct++] = 'a'; |
| 173 | ilets[iletct++] = 'A'; |
| 174 | ilets[iletct++] = (objs == gi.invent ? 'i' : ':'); |
| 175 | } |
| 176 | if (itemcount && menu_on_demand) |
| 177 | ilets[iletct++] = 'm'; |
| 178 | if (count_unpaid(objs)) |
| 179 | ilets[iletct++] = 'u'; |
| 180 | |
| 181 | tally_BUCX(objs, here, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt, &jcnt); |
| 182 | if (bcnt) |
| 183 | ilets[iletct++] = 'B'; |
| 184 | if (ucnt) |
| 185 | ilets[iletct++] = 'U'; |
| 186 | if (ccnt) |
| 187 | ilets[iletct++] = 'C'; |
| 188 | if (xcnt) |
| 189 | ilets[iletct++] = 'X'; |
| 190 | if (jcnt) |
| 191 | ilets[iletct++] = 'P'; |
| 192 | ilets[iletct] = '\0'; |
| 193 | |
| 194 | if (iletct > 1) { |
| 195 | const char *where = 0; |
| 196 | char sym, oc_of_sym, *p; |
| 197 |
no test coverage detected