diff -pruN slashem-0.0.7E7F1-official-release/src/pickup.c slashem-0.0.7E7F1-menuloot/src/pickup.c --- slashem-0.0.7E7F1-official-release/src/pickup.c 2005-07-02 09:24:44.000000000 +0200 +++ slashem-0.0.7E7F1-menuloot/src/pickup.c 2005-10-26 00:49:57.000000000 +0200 @@ -1518,6 +1518,35 @@ int x, y; } int +#ifdef MENULOOTING +do_loot_cont(cobj, noit) +struct obj *cobj; +boolean noit; +{ + if (!cobj) return 0; + + if (cobj->olocked) { + pline("Hmmm, %s seems to be locked.", noit ? the(xname(cobj)) : "it"); + return 0; + } + if (cobj->otyp == BAG_OF_TRICKS) { + int tmp; + You("carefully open the bag..."); + pline("It develops a huge set of teeth and bites you!"); + tmp = rnd(10); + if (Half_physical_damage) tmp = (tmp+1) / 2; + losehp(tmp, "carnivorous bag", KILLED_BY_AN); + makeknown(BAG_OF_TRICKS); + return 1; + } + + You("carefully open %s...", the(xname(cobj))); + return use_container(cobj, 0); +} + + +int +#endif doloot() /* loot a container on the floor or loot saddle from mon. */ { struct obj *cobj, *nobj; @@ -1530,6 +1559,9 @@ doloot() /* loot a container on the floo char qbuf[BUFSZ]; int prev_inquiry = 0; boolean prev_loot = FALSE; +#ifdef MENULOOTING + int num_cont = 0; +#endif if (check_capacity((char *)0)) { /* "Can't do that while carrying so much stuff." */ @@ -1544,13 +1576,38 @@ doloot() /* loot a container on the floo lootcont: if (container_at(cc.x, cc.y, FALSE)) { +#ifndef MENULOOTING boolean any = FALSE; +#else + winid win; + anything any; + menu_item *pick_list; +#endif if (!able_to_loot(cc.x, cc.y)) return 0; for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) { +#ifdef MENULOOTING + if (Is_container(cobj)) num_cont++; +#endif nobj = cobj->nexthere; +#ifdef MENULOOTING + } + + timepassed = 0; +#endif +#ifdef MENULOOTING + if (num_cont > 1) { + /* use a menu to loot many containers */ + int n, i; + any.a_void = 0; + win = create_nhwindow(NHW_MENU); + start_menu(win); + + for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) { +#endif if (Is_container(cobj)) { +#ifndef MENULOOTING Sprintf(qbuf, "There is %s here, loot it?", safe_qbuf("", sizeof("There is here, loot it?"), doname(cobj), an(simple_typename(cobj->otyp)), @@ -1559,11 +1616,19 @@ lootcont: if (c == 'q') return (timepassed); if (c == 'n') continue; any = TRUE; +#else + any.a_obj = cobj; + add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, doname(cobj), + MENU_UNSELECTED); +#endif +#ifndef MENULOOTING if (cobj->olocked) { pline("Hmmm, it seems to be locked."); continue; +#endif } +#ifndef MENULOOTING if (cobj->otyp == BAG_OF_TRICKS) { int tmp; You("carefully open the bag..."); @@ -1574,15 +1639,58 @@ lootcont: makeknown(BAG_OF_TRICKS); timepassed = 1; continue; +#else + nobj = cobj->nexthere; +#endif } - +#ifdef MENULOOTING + end_menu(win, "Loot which containers?"); + n = select_menu(win, PICK_ANY, &pick_list); + destroy_nhwindow(win); +#endif + +#ifndef MENULOOTING You("carefully open %s...", the(xname(cobj))); timepassed |= use_container(&cobj, 0); +#else + if (n > 0) + for (i = 0; i < n; i++) { + timepassed |= do_loot_cont(pick_list[i].item.a_obj, TRUE); + if (multi < 0) { /* chest trap, stop looting */ + free((genericptr_t) pick_list); + return 1; + } + } + + free((genericptr_t) pick_list); + + /* don't ask for looting in a direction, if the menu was + cancelled, or if we did open any containers. */ + if (n != 0) return timepassed; + } else { + /* use the old style looting: ask y/n for each container */ + boolean didany = FALSE; + for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) { + nobj = cobj->nexthere; + if (Is_container(cobj)) { + Sprintf(qbuf, "There is %s here, loot it?", doname(cobj)); + c = ynq(qbuf); + + if (c == 'q') return 0; + if (c == 'n') continue; + didany = TRUE; + timepassed |= do_loot_cont(cobj, FALSE); +#endif /* might have triggered chest trap or magic bag explosion */ if (multi < 0 || !cobj) return 1; } } - if (any) c = 'y'; +#ifndef MENULOOTING + if (any) c = 'y'; +#else + if (didany) c = 'y'; + } +#endif } else if (Confusion) { #ifndef GOLDOBJ if (u.ugold){