Source:NetHack 3.4.3/src/invent.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to src/invent.c from NetHack 3.4.3. To link to a particular line, write [[invent.c#line123]], for example.

Top of file[edit]

  1. /*	SCCS Id: @(#)invent.c	3.4	2003/12/02	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #include "hack.h"
  2.  
  3. #define NOINVSYM	'#'
  4. #define CONTAINED_SYM	'>'	/* designator for inside a container */
  5.  
  6. #ifdef OVL1
  7. STATIC_DCL void NDECL(reorder_invent);
  8. STATIC_DCL boolean FDECL(mergable,(struct obj *,struct obj *));
  9. STATIC_DCL void FDECL(invdisp_nothing, (const char *,const char *));
  10. STATIC_DCL boolean FDECL(worn_wield_only, (struct obj *));
  11. STATIC_DCL boolean FDECL(only_here, (struct obj *));
  12. #endif /* OVL1 */
  13. STATIC_DCL void FDECL(compactify,(char *));
  14. STATIC_DCL boolean FDECL(taking_off, (const char *));
  15. STATIC_DCL boolean FDECL(putting_on, (const char *));
  16. STATIC_PTR int FDECL(ckunpaid,(struct obj *));
  17. STATIC_PTR int FDECL(ckvalidcat,(struct obj *));
  18. static char FDECL(display_pickinv, (const char *,BOOLEAN_P, long *));
  19. #ifdef OVLB
  20. STATIC_DCL boolean FDECL(this_type_only, (struct obj *));
  21. STATIC_DCL void NDECL(dounpaid);
  22. STATIC_DCL struct obj *FDECL(find_unpaid,(struct obj *,struct obj **));
  23. STATIC_DCL void FDECL(menu_identify, (int));
  24. STATIC_DCL boolean FDECL(tool_in_use, (struct obj *));
  25. #endif /* OVLB */
  26. STATIC_DCL char FDECL(obj_to_let,(struct obj *));
  27.  
  28. #ifdef OVLB
  29.  
  30. static int lastinvnr = 51;	/* 0 ... 51 (never saved&restored) */
  31.  
  32. #ifdef WIZARD
  33. /* wizards can wish for venom, which will become an invisible inventory
  34. * item without this.  putting it in inv_order would mean venom would
  35. * suddenly become a choice for all the inventory-class commands, which
  36. * would probably cause mass confusion.  the test for inventory venom
  37. * is only WIZARD and not wizard because the wizard can leave venom lying
  38. * around on a bones level for normal players to find.
  39. */
  40. static char venom_inv[] = { VENOM_CLASS, 0 };	/* (constant) */
  41. #endif

assigninvlet[edit]

  1. void
  2. assigninvlet(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	boolean inuse[52];
  6. 	register int i;
  7. 	register struct obj *obj;
  8.  
  9. #ifdef GOLDOBJ
  10. /* There is only one of these in inventory... */        
  11. if (otmp->oclass == COIN_CLASS) {
  12. 	    otmp->invlet = GOLD_SYM;
  13. 	    return;
  14. 	}
  15. #endif
  16.  
  17. 	for(i = 0; i < 52; i++) inuse[i] = FALSE;
  18. 	for(obj = invent; obj; obj = obj->nobj) if(obj != otmp) {
  19. 		i = obj->invlet;
  20. 		if('a' <= i && i <= 'z') inuse[i - 'a'] = TRUE; else
  21. 		if('A' <= i && i <= 'Z') inuse[i - 'A' + 26] = TRUE;
  22. 		if(i == otmp->invlet) otmp->invlet = 0;
  23. 	}
  24. 	if((i = otmp->invlet) &&
  25. 	    (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z')))
  26. 		return;
  27. 	for(i = lastinvnr+1; i != lastinvnr; i++) {
  28. 		if(i == 52) { i = -1; continue; }
  29. 		if(!inuse[i]) break;
  30. 	}
  31. 	otmp->invlet = (inuse[i] ? NOINVSYM :
  32. 			(i < 26) ? ('a'+i) : ('A'+i-26));
  33. 	lastinvnr = i;
  34. }
  35.  
  36. #endif /* OVLB */

reorder_invent[edit]

  1. #ifdef OVL1
  2.  
  3. /* note: assumes ASCII; toggling a bit puts lowercase in front of uppercase */
  4. #define inv_rank(o) ((o)->invlet ^ 040)
  5.  
  6. /* sort the inventory; used by addinv() and doorganize() */
  7. STATIC_OVL void
  8. reorder_invent()
  9. {
  10. 	struct obj *otmp, *prev, *next;
  11. 	boolean need_more_sorting;
  12.  
  13. 	do {
  14. 	    /*
  15. 	     * We expect at most one item to be out of order, so this
  16. 	     * isn't nearly as inefficient as it may first appear.
  17. 	     */
  18. 	    need_more_sorting = FALSE;
  19. 	    for (otmp = invent, prev = 0; otmp; ) {
  20. 		next = otmp->nobj;
  21. 		if (next && inv_rank(next) < inv_rank(otmp)) {
  22. 		    need_more_sorting = TRUE;
  23. 		    if (prev) prev->nobj = next;
  24. 		    else      invent = next;
  25. 		    otmp->nobj = next->nobj;
  26. 		    next->nobj = otmp;
  27. 		    prev = next;
  28. 		} else {
  29. 		    prev = otmp;
  30. 		    otmp = next;
  31. 		}
  32. 	    }
  33. 	} while (need_more_sorting);
  34. }
  35.  
  36. #undef inv_rank

merge_choice[edit]

  1. /* scan a list of objects to see whether another object will merge with
  2. one of them; used in pickup.c when all 52 inventory slots are in use,
  3. to figure out whether another object could still be picked up */
  4. struct obj *
  5. merge_choice(objlist, obj)
  6. struct obj *objlist, *obj;
  7. {
  8. 	struct monst *shkp;
  9. 	int save_nocharge;
  10.  
  11. 	if (obj->otyp == SCR_SCARE_MONSTER)	/* punt on these */
  12. 	    return (struct obj *)0;
  13. 	/* if this is an item on the shop floor, the attributes it will
  14. 	   have when carried are different from what they are now; prevent
  15. 	   that from eliciting an incorrect result from mergable() */
  16. 	save_nocharge = obj->no_charge;
  17. 	if (objlist == invent && obj->where == OBJ_FLOOR &&
  18. 		(shkp = shop_keeper(inside_shop(obj->ox, obj->oy))) != 0) {
  19. 	    if (obj->no_charge) obj->no_charge = 0;
  20. 	    /* A billable object won't have its `unpaid' bit set, so would
  21. 	       erroneously seem to be a candidate to merge with a similar
  22. 	       ordinary object.  That's no good, because once it's really
  23. 	       picked up, it won't merge after all.  It might merge with
  24. 	       another unpaid object, but we can't check that here (depends
  25. 	       too much upon shk's bill) and if it doesn't merge it would
  26. 	       end up in the '#' overflow inventory slot, so reject it now. */
  27. 	    else if (inhishop(shkp)) return (struct obj *)0;
  28. 	}
  29. 	while (objlist) {
  30. 	    if (mergable(objlist, obj)) break;
  31. 	    objlist = objlist->nobj;
  32. 	}
  33. 	obj->no_charge = save_nocharge;
  34. 	return objlist;
  35. }

merged[edit]

  1. /* merge obj with otmp and delete obj if types agree */
  2. int
  3. merged(potmp, pobj)
  4. struct obj **potmp, **pobj;
  5. {
  6. 	register struct obj *otmp = *potmp, *obj = *pobj;
  7.  
  8. 	if(mergable(otmp, obj)) {
  9. 		/* Approximate age: we do it this way because if we were to
  10. 		 * do it "accurately" (merge only when ages are identical)
  11. 		 * we'd wind up never merging any corpses.
  12. 		 * otmp->age = otmp->age*(1-proportion) + obj->age*proportion;
  13. 		 *
  14. 		 * Don't do the age manipulation if lit.  We would need
  15. 		 * to stop the burn on both items, then merge the age,
  16. 		 * then restart the burn.
  17. 		 */
  18. 		if (!obj->lamplit)
  19. 		    otmp->age = ((otmp->age*otmp->quan) + (obj->age*obj->quan))
  20. 			    / (otmp->quan + obj->quan);
  21.  
  22. 		otmp->quan += obj->quan;
  23. #ifdef GOLDOBJ
  24. /* temporary special case for gold objects!!!! */
  25. #endif
  26. 		if (otmp->oclass == COIN_CLASS) otmp->owt = weight(otmp);
  27. 		else otmp->owt += obj->owt;
  28. 		if(!otmp->onamelth && obj->onamelth)
  29. 			otmp = *potmp = oname(otmp, ONAME(obj));
  30. 		obj_extract_self(obj);
  31.  
  32. 		/* really should merge the timeouts */
  33. 		if (obj->lamplit) obj_merge_light_sources(obj, otmp);
  34. 		if (obj->timed) obj_stop_timers(obj);	/* follows lights */
  35.  
  36. 		/* fixup for `#adjust' merging wielded darts, daggers, &c */
  37. 		if (obj->owornmask && carried(otmp)) {
  38. 		    long wmask = otmp->owornmask | obj->owornmask;
  39.  
  40. 		    /* Both the items might be worn in competing slots;
  41. 		       merger preference (regardless of which is which):
  42. 			 primary weapon + alternate weapon -> primary weapon;
  43. 			 primary weapon + quiver -> primary weapon;
  44. 			 alternate weapon + quiver -> alternate weapon.
  45. 		       (Prior to 3.3.0, it was not possible for the two
  46. 		       stacks to be worn in different slots and `obj'
  47. 		       didn't need to be unworn when merging.) */
  48. 		    if (wmask & W_WEP) wmask = W_WEP;
  49. 		    else if (wmask & W_SWAPWEP) wmask = W_SWAPWEP;
  50. 		    else if (wmask & W_QUIVER) wmask = W_QUIVER;
  51. 		    else {
  52. 			impossible("merging strangely worn items (%lx)", wmask);
  53. 			wmask = otmp->owornmask;
  54. 		    }
  55. 		    if ((otmp->owornmask & ~wmask) != 0L) setnotworn(otmp);
  56. 		    setworn(otmp, wmask);
  57. 		    setnotworn(obj);
  58. 		}
  59. #if 0
  60. 		/* (this should not be necessary, since items
  61. 		    already in a monster's inventory don't ever get
  62. 		    merged into other objects [only vice versa]) */
  63. 		else if (obj->owornmask && mcarried(otmp)) {
  64. 		    if (obj == MON_WEP(otmp->ocarry)) {
  65. 			MON_WEP(otmp->ocarry) = otmp;
  66. 			otmp->owornmask = W_WEP;
  67. 		    }
  68. 		}
  69. #endif /*0*/
  70.  
  71. 		obfree(obj,otmp);	/* free(obj), bill->otmp */
  72. 		return(1);
  73. 	}
  74. 	return 0;
  75. }

addinv_core1[edit]

  1. /*
  2. Adjust hero intrinsics as if this object was being added to the hero's
  3. inventory.  Called _before_ the object has been added to the hero's
  4. inventory.
  5.  
  6. This is called when adding objects to the hero's inventory normally (via
  7. addinv) or when an object in the hero's inventory has been polymorphed
  8. in-place.
  9.  
  10. It may be valid to merge this code with with addinv_core2().
  11. */
  12. void
  13. addinv_core1(obj)
  14. struct obj *obj;
  15. {
  16. 	if (obj->oclass == COIN_CLASS) {
  17. #ifndef GOLDOBJ
  18. 		u.ugold += obj->quan;
  19. #else
  20. 		flags.botl = 1;
  21. #endif
  22. 	} else if (obj->otyp == AMULET_OF_YENDOR) {
  23. 		if (u.uhave.amulet) impossible("already have amulet?");
  24. 		u.uhave.amulet = 1;
  25. 	} else if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
  26. 		if (u.uhave.menorah) impossible("already have candelabrum?");
  27. 		u.uhave.menorah = 1;
  28. 	} else if (obj->otyp == BELL_OF_OPENING) {
  29. 		if (u.uhave.bell) impossible("already have silver bell?");
  30. 		u.uhave.bell = 1;
  31. 	} else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
  32. 		if (u.uhave.book) impossible("already have the book?");
  33. 		u.uhave.book = 1;
  34. 	} else if (obj->oartifact) {
  35. 		if (is_quest_artifact(obj)) {
  36. 		    if (u.uhave.questart)
  37. 			impossible("already have quest artifact?");
  38. 		    u.uhave.questart = 1;
  39. 		    artitouch();
  40. 		}
  41. 		set_artifact_intrinsic(obj, 1, W_ART);
  42. 	}
  43. }

addinv_core2[edit]

  1. /*
  2. Adjust hero intrinsics as if this object was being added to the hero's
  3. inventory.  Called _after_ the object has been added to the hero's
  4. inventory.
  5.  
  6. This is called when adding objects to the hero's inventory normally (via
  7. addinv) or when an object in the hero's inventory has been polymorphed
  8. in-place.
  9. */
  10. void
  11. addinv_core2(obj)
  12. struct obj *obj;
  13. {
  14. 	if (confers_luck(obj)) {
  15. 		/* new luckstone must be in inventory by this point
  16. 		 * for correct calculation */
  17. 		set_moreluck();
  18. 	}
  19. }

addinv[edit]

  1. /*
  2. Add obj to the hero's inventory.  Make sure the object is "free".
  3. Adjust hero attributes as necessary.
  4. */
  5. struct obj *
  6. addinv(obj)
  7. struct obj *obj;
  8. {
  9. 	struct obj *otmp, *prev;
  10.  
  11. 	if (obj->where != OBJ_FREE)
  12. 	    panic("addinv: obj not free");
  13. 	obj->no_charge = 0;	/* not meaningful for invent */
  14.  
  15. 	addinv_core1(obj);
  16. #ifndef GOLDOBJ
  17. 	/* if handed gold, we're done */
  18. 	if (obj->oclass == COIN_CLASS)
  19. 	    return obj;
  20. #endif
  21.  
  22. 	/* merge if possible; find end of chain in the process */
  23. 	for (prev = 0, otmp = invent; otmp; prev = otmp, otmp = otmp->nobj)
  24. 	    if (merged(&otmp, &obj)) {
  25. 		obj = otmp;
  26. 		goto added;
  27. 	    }
  28. 	/* didn't merge, so insert into chain */
  29. 	if (flags.invlet_constant || !prev) {
  30. 	    if (flags.invlet_constant) assigninvlet(obj);
  31. 	    obj->nobj = invent;		/* insert at beginning */
  32. 	    invent = obj;
  33. 	    if (flags.invlet_constant) reorder_invent();
  34. 	} else {
  35. 	    prev->nobj = obj;		/* insert at end */
  36. 	    obj->nobj = 0;
  37. 	}
  38. 	obj->where = OBJ_INVENT;
  39.  
  40. added:
  41. 	addinv_core2(obj);
  42. 	carry_obj_effects(obj);		/* carrying affects the obj */
  43. 	update_inventory();
  44. 	return(obj);
  45. }

carry_obj_effects[edit]

  1. /*
  2. * Some objects are affected by being carried.
  3. * Make those adjustments here. Called _after_ the object
  4. * has been added to the hero's or monster's inventory,
  5. * and after hero's intrinsics have been updated.
  6. */

Figurine transforms are unset in invent.c, line 526.

  1. void
  2. carry_obj_effects(obj)
  3. struct obj *obj;
  4. {
  5. 	/* Cursed figurines can spontaneously transform
  6. 	   when carried. */
  7. 	if (obj->otyp == FIGURINE) {
  8. 		if (obj->cursed
  9. 	    	    && obj->corpsenm != NON_PM
  10. 	    	    && !dead_species(obj->corpsenm,TRUE)) {
  11. 			attach_fig_transform_timeout(obj);
  12. 		    }
  13. 	}
  14. }
  15.  
  16. #endif /* OVL1 */

hold_another_object[edit]

  1. #ifdef OVLB
  2.  
  3. /* Add an item to the inventory unless we're fumbling or it refuses to be
  4. * held (via touch_artifact), and give a message.
  5. * If there aren't any free inventory slots, we'll drop it instead.
  6. * If both success and failure messages are NULL, then we're just doing the
  7. * fumbling/slot-limit checking for a silent grab.  In any case,
  8. * touch_artifact will print its own messages if they are warranted.
  9. */
  10. struct obj *
  11. hold_another_object(obj, drop_fmt, drop_arg, hold_msg)
  12. struct obj *obj;
  13. const char *drop_fmt, *drop_arg, *hold_msg;
  14. {
  15. 	char buf[BUFSZ];
  16.  
  17. 	if (!Blind) obj->dknown = 1;	/* maximize mergibility */
  18. 	if (obj->oartifact) {
  19. 	    /* place_object may change these */
  20. 	    boolean crysknife = (obj->otyp == CRYSKNIFE);
  21. 	    int oerode = obj->oerodeproof;
  22. 	    boolean wasUpolyd = Upolyd;
  23.  
  24. 	    /* in case touching this object turns out to be fatal */
  25. 	    place_object(obj, u.ux, u.uy);
  26.  
  27. 	    if (!touch_artifact(obj, &youmonst)) {
  28. 		obj_extract_self(obj);	/* remove it from the floor */
  29. 		dropy(obj);		/* now put it back again :-) */
  30. 		return obj;
  31. 	    } else if (wasUpolyd && !Upolyd) {
  32. 		/* loose your grip if you revert your form */
  33. 		if (drop_fmt) pline(drop_fmt, drop_arg);
  34. 		obj_extract_self(obj);
  35. 		dropy(obj);
  36. 		return obj;
  37. 	    }
  38. 	    obj_extract_self(obj);
  39. 	    if (crysknife) {
  40. 		obj->otyp = CRYSKNIFE;
  41. 		obj->oerodeproof = oerode;
  42. 	    }
  43. 	}
  44. 	if (Fumbling) {
  45. 	    if (drop_fmt) pline(drop_fmt, drop_arg);
  46. 	    dropy(obj);
  47. 	} else {
  48. 	    long oquan = obj->quan;
  49. 	    int prev_encumbr = near_capacity();	/* before addinv() */
  50.  
  51. 	    /* encumbrance only matters if it would now become worse
  52. 	       than max( current_value, stressed ) */
  53. 	    if (prev_encumbr < MOD_ENCUMBER) prev_encumbr = MOD_ENCUMBER;
  54. 	    /* addinv() may redraw the entire inventory, overwriting
  55. 	       drop_arg when it comes from something like doname() */
  56. 	    if (drop_arg) drop_arg = strcpy(buf, drop_arg);
  57.  
  58. 	    obj = addinv(obj);
  59. 	    if (inv_cnt() > 52
  60. 		    || ((obj->otyp != LOADSTONE || !obj->cursed)
  61. 			&& near_capacity() > prev_encumbr)) {
  62. 		if (drop_fmt) pline(drop_fmt, drop_arg);
  63. 		/* undo any merge which took place */
  64. 		if (obj->quan > oquan) obj = splitobj(obj, oquan);
  65. 		dropx(obj);
  66. 	    } else {
  67. 		if (flags.autoquiver && !uquiver && !obj->owornmask &&
  68. 			(is_missile(obj) ||
  69. 			    ammo_and_launcher(obj, uwep) ||
  70. 			    ammo_and_launcher(obj, uswapwep)))
  71. 		    setuqwep(obj);
  72. 		if (hold_msg || drop_fmt) prinv(hold_msg, obj, oquan);
  73. 	    }
  74. 	}
  75. 	return obj;
  76. }

useupall[edit]

  1. /* useup() all of an item regardless of its quantity */
  2. void
  3. useupall(obj)
  4. struct obj *obj;
  5. {
  6. 	setnotworn(obj);
  7. 	freeinv(obj);
  8. 	obfree(obj, (struct obj *)0);	/* deletes contents also */
  9. }

useup[edit]

useup() takes one parameter, an object, and will either remove one from that pile or delete the whole object.

  1. void
  2. useup(obj)
  3. register struct obj *obj;
  4. {
  5. 	/*  Note:  This works correctly for containers because they */
  6. 	/*	   (containers) don't merge.			    */
  7. 	if (obj->quan > 1L) {
  8. 		obj->in_use = FALSE;	/* no longer in use */
  9. 		obj->quan--;
  10. 		obj->owt = weight(obj);
  11. 		update_inventory();
  12. 	} else {
  13. 		useupall(obj);
  14. 	}
  15. }

consume_obj_charge[edit]

  1. /* use one charge from an item and possibly incur shop debt for it */
  2. void
  3. consume_obj_charge(obj, maybe_unpaid)
  4. struct obj *obj;
  5. boolean maybe_unpaid;	/* false if caller handles shop billing */
  6. {
  7. 	if (maybe_unpaid) check_unpaid(obj);
  8. 	obj->spe -= 1;
  9. 	if (obj->known) update_inventory();
  10. }
  11.  
  12. #endif /* OVLB */

freeinv_core[edit]

  1. #ifdef OVL3
  2.  
  3. /*
  4. Adjust hero's attributes as if this object was being removed from the
  5. hero's inventory.  This should only be called from freeinv() and
  6. where we are polymorphing an object already in the hero's inventory.
  7.  
  8. Should think of a better name...
  9. */
  10. void
  11. freeinv_core(obj)
  12. struct obj *obj;
  13. {
  14. 	if (obj->oclass == COIN_CLASS) {
  15. #ifndef GOLDOBJ
  16. 		u.ugold -= obj->quan;
  17. 		obj->in_use = FALSE;
  18. #endif
  19. 		flags.botl = 1;
  20. 		return;
  21. 	} else if (obj->otyp == AMULET_OF_YENDOR) {
  22. 		if (!u.uhave.amulet) impossible("don't have amulet?");
  23. 		u.uhave.amulet = 0;
  24. 	} else if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
  25. 		if (!u.uhave.menorah) impossible("don't have candelabrum?");
  26. 		u.uhave.menorah = 0;
  27. 	} else if (obj->otyp == BELL_OF_OPENING) {
  28. 		if (!u.uhave.bell) impossible("don't have silver bell?");
  29. 		u.uhave.bell = 0;
  30. 	} else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
  31. 		if (!u.uhave.book) impossible("don't have the book?");
  32. 		u.uhave.book = 0;
  33. 	} else if (obj->oartifact) {
  34. 		if (is_quest_artifact(obj)) {
  35. 		    if (!u.uhave.questart)
  36. 			impossible("don't have quest artifact?");
  37. 		    u.uhave.questart = 0;
  38. 		}
  39. 		set_artifact_intrinsic(obj, 0, W_ART);
  40. 	}
  41.  
  42. 	if (obj->otyp == LOADSTONE) {
  43. 		curse(obj);
  44. 	} else if (confers_luck(obj)) {
  45. 		set_moreluck();
  46. 		flags.botl = 1;
  47. 	} else if (obj->otyp == FIGURINE && obj->timed) {
  48. 		(void) stop_timer(FIG_TRANSFORM, (genericptr_t) obj);
  49. 	}
  50. }

freeinv[edit]

  1. /* remove an object from the hero's inventory */
  2. void
  3. freeinv(obj)
  4. register struct obj *obj;
  5. {
  6. 	extract_nobj(obj, &invent);
  7. 	freeinv_core(obj);
  8. 	update_inventory();
  9. }

delallobj[edit]

delallobj() takes two parameters, an x,y coordinate, and removes all objects on the map at that location.

  1. void
  2. delallobj(x, y)
  3. int x, y;
  4. {
  5. 	struct obj *otmp, *otmp2;
  6.  
  7. 	for (otmp = level.objects[x][y]; otmp; otmp = otmp2) {
  8. 		if (otmp == uball)
  9. 			unpunish();
  10. 		/* after unpunish(), or might get deallocated chain */
  11. 		otmp2 = otmp->nexthere;
  12. 		if (otmp == uchain)
  13. 			continue;
  14. 		delobj(otmp);
  15. 	}
  16. }
  17.  
  18. #endif /* OVL3 */

delobj[edit]

  1. #ifdef OVL2
  2.  
  3. /* destroy object in fobj chain (if unpaid, it remains on the bill) */
  4. void
  5. delobj(obj)
  6. register struct obj *obj;
  7. {
  8. 	boolean update_map;
  9.  
  10. 	if (obj->otyp == AMULET_OF_YENDOR ||
  11. 			obj->otyp == CANDELABRUM_OF_INVOCATION ||
  12. 			obj->otyp == BELL_OF_OPENING ||
  13. 			obj->otyp == SPE_BOOK_OF_THE_DEAD) {
  14. 		/* player might be doing something stupid, but we
  15. 		 * can't guarantee that.  assume special artifacts
  16. 		 * are indestructible via drawbridges, and exploding
  17. 		 * chests, and golem creation, and ...
  18. 		 */
  19. 		return;
  20. 	}
  21. 	update_map = (obj->where == OBJ_FLOOR);
  22. 	obj_extract_self(obj);
  23. 	if (update_map) newsym(obj->ox, obj->oy);
  24. 	obfree(obj, (struct obj *) 0);	/* frees contents also */
  25. }
  26.  
  27. #endif /* OVL2 */

sobj_at[edit]

sobj_at() takes three parameters, an object type macro and an x,y coordinate, and returns a pointer to an object of that type at that location, or NULL if none found there.

  1. #ifdef OVL0
  2.  
  3. struct obj *
  4. sobj_at(n,x,y)
  5. register int n, x, y;
  6. {
  7. 	register struct obj *otmp;
  8.  
  9. 	for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
  10. 		if(otmp->otyp == n)
  11. 		    return(otmp);
  12. 	return((struct obj *)0);
  13. }
  14.  
  15. #endif /* OVL0 */

carrying[edit]

carrying() takes one parameter, an object type macro and returns a pointer to an object of that type hero is carrying, or NULL if no such object.

  1. #ifdef OVLB
  2.  
  3. struct obj *
  4. carrying(type)
  5. register int type;
  6. {
  7. 	register struct obj *otmp;
  8.  
  9. 	for(otmp = invent; otmp; otmp = otmp->nobj)
  10. 		if(otmp->otyp == type)
  11. 			return(otmp);
  12. 	return((struct obj *) 0);
  13. }

currency[edit]

  1. const char *
  2. currency(amount)
  3. long amount;
  4. {
  5. 	if (amount == 1L) return "zorkmid";
  6. 	else return "zorkmids";
  7. }

have_lizard[edit]

  1. boolean
  2. have_lizard()
  3. {
  4. 	register struct obj *otmp;
  5.  
  6. 	for(otmp = invent; otmp; otmp = otmp->nobj)
  7. 		if(otmp->otyp == CORPSE && otmp->corpsenm == PM_LIZARD)
  8. 			return(TRUE);
  9. 	return(FALSE);
  10. }

o_on[edit]

  1. struct obj *
  2. o_on(id, objchn)
  3. unsigned int id;
  4. register struct obj *objchn;
  5. {
  6. 	struct obj *temp;
  7.  
  8. 	while(objchn) {
  9. 		if(objchn->o_id == id) return(objchn);
  10. 		if (Has_contents(objchn) && (temp = o_on(id,objchn->cobj)))
  11. 			return temp;
  12. 		objchn = objchn->nobj;
  13. 	}
  14. 	return((struct obj *) 0);
  15. }

obj_here[edit]

  1. boolean
  2. obj_here(obj, x, y)
  3. register struct obj *obj;
  4. int x, y;
  5. {
  6. 	register struct obj *otmp;
  7.  
  8. 	for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
  9. 		if(obj == otmp) return(TRUE);
  10. 	return(FALSE);
  11. }
  12.  
  13. #endif /* OVLB */

g_at[edit]

  1. #ifdef OVL2
  2.  
  3. struct obj *
  4. g_at(x,y)
  5. register int x, y;
  6. {
  7. 	register struct obj *obj = level.objects[x][y];
  8. 	while(obj) {
  9. 	    if (obj->oclass == COIN_CLASS) return obj;
  10. 	    obj = obj->nexthere;
  11. 	}
  12. 	return((struct obj *)0);
  13. }
  14.  
  15. #endif /* OVL2 */

mkgoldobj[edit]

  1. #ifdef OVLB
  2. #ifndef GOLDOBJ
  3. /* Make a gold object from the hero's gold. */
  4. struct obj *
  5. mkgoldobj(q)
  6. register long q;
  7. {
  8. 	register struct obj *otmp;
  9.  
  10. 	otmp = mksobj(GOLD_PIECE, FALSE, FALSE);
  11. 	u.ugold -= q;
  12. 	otmp->quan = q;
  13. 	otmp->owt = weight(otmp);
  14. 	flags.botl = 1;
  15. 	return(otmp);
  16. }
  17. #endif
  18. #endif /* OVLB */

compactify[edit]

  1. #ifdef OVL1
  2.  
  3. STATIC_OVL void
  4. compactify(buf)
  5. register char *buf;
  6. /* compact a string of inventory letters by dashing runs of letters */
  7. {
  8. 	register int i1 = 1, i2 = 1;
  9. 	register char ilet, ilet1, ilet2;
  10.  
  11. 	ilet2 = buf[0];
  12. 	ilet1 = buf[1];
  13. 	buf[++i2] = buf[++i1];
  14. 	ilet = buf[i1];
  15. 	while(ilet) {
  16. 		if(ilet == ilet1+1) {
  17. 			if(ilet1 == ilet2+1)
  18. 				buf[i2 - 1] = ilet1 = '-';
  19. 			else if(ilet2 == '-') {
  20. 				buf[i2 - 1] = ++ilet1;
  21. 				buf[i2] = buf[++i1];
  22. 				ilet = buf[i1];
  23. 				continue;
  24. 			}
  25. 		}
  26. 		ilet2 = ilet1;
  27. 		ilet1 = ilet;
  28. 		buf[++i2] = buf[++i1];
  29. 		ilet = buf[i1];
  30. 	}
  31. }

taking_off[edit]

  1. /* match the prompt for either 'T' or 'R' command */
  2. STATIC_OVL boolean
  3. taking_off(action)
  4. const char *action;
  5. {
  6. return !strcmp(action, "take off") || !strcmp(action, "remove");
  7. }

putting_on[edit]

  1. /* match the prompt for either 'W' or 'P' command */
  2. STATIC_OVL boolean
  3. putting_on(action)
  4. const char *action;
  5. {
  6. return !strcmp(action, "wear") || !strcmp(action, "put on");
  7. }

getobj[edit]

  1. /*
  2. * getobj returns:
  3. *	struct obj *xxx:	object to do something with.
  4. *	(struct obj *) 0	error return: no object.
  5. *	&zeroobj		explicitly no object (as in w-).
  6. #ifdef GOLDOBJ
  7. !!!! test if gold can be used in unusual ways (eaten etc.)
  8. !!!! may be able to remove "usegold"
  9. #endif
  10. */
  11. struct obj *
  12. getobj(let,word)
  13. register const char *let,*word;
  14. {
  15. 	register struct obj *otmp;
  16. 	register char ilet;
  17. 	char buf[BUFSZ], qbuf[QBUFSZ];
  18. 	char lets[BUFSZ], altlets[BUFSZ], *ap;
  19. 	register int foo = 0;
  20. 	register char *bp = buf;
  21. 	xchar allowcnt = 0;	/* 0, 1 or 2 */
  22. #ifndef GOLDOBJ
  23. 	boolean allowgold = FALSE;	/* can't use gold because they don't have any */
  24. #endif
  25. 	boolean usegold = FALSE;	/* can't use gold because its illegal */
  26. 	boolean allowall = FALSE;
  27. 	boolean allownone = FALSE;
  28. 	boolean useboulder = FALSE;
  29. 	xchar foox = 0;
  30. 	long cnt;
  31. 	boolean prezero = FALSE;
  32. 	long dummymask;
  33.  
  34. 	if(*let == ALLOW_COUNT) let++, allowcnt = 1;
  35. #ifndef GOLDOBJ
  36. 	if(*let == COIN_CLASS) let++,
  37. 		usegold = TRUE, allowgold = (u.ugold ? TRUE : FALSE);
  38. #else
  39. 	if(*let == COIN_CLASS) let++, usegold = TRUE;
  40. #endif
  41.  
  42. 	/* Equivalent of an "ugly check" for gold */
  43. 	if (usegold && !strcmp(word, "eat") &&
  44. 	    (!metallivorous(youmonst.data)
  45. 	     || youmonst.data == &mons[PM_RUST_MONSTER]))
  46. #ifndef GOLDOBJ
  47. 		usegold = allowgold = FALSE;
  48. #else
  49. 		usegold = FALSE;
  50. #endif
  51.  
  52. 	if(*let == ALL_CLASSES) let++, allowall = TRUE;
  53. 	if(*let == ALLOW_NONE) let++, allownone = TRUE;
  54. 	/* "ugly check" for reading fortune cookies, part 1 */
  55. 	/* The normal 'ugly check' keeps the object on the inventory list.
  56. 	 * We don't want to do that for shirts/cookies, so the check for
  57. 	 * them is handled a bit differently (and also requires that we set
  58. 	 * allowall in the caller)
  59. 	 */
  60. 	if(allowall && !strcmp(word, "read")) allowall = FALSE;
  61.  
  62. 	/* another ugly check: show boulders (not statues) */
  63. 	if(*let == WEAPON_CLASS &&
  64. 	   !strcmp(word, "throw") && throws_rocks(youmonst.data))
  65. 	    useboulder = TRUE;
  66.  
  67. 	if(allownone) *bp++ = '-';
  68. #ifndef GOLDOBJ
  69. 	if(allowgold) *bp++ = def_oc_syms[COIN_CLASS];
  70. #endif
  71. 	if(bp > buf && bp[-1] == '-') *bp++ = ' ';
  72. 	ap = altlets;
  73.  
  74. 	ilet = 'a';
  75. 	for (otmp = invent; otmp; otmp = otmp->nobj) {
  76. 	    if (!flags.invlet_constant)
  77. #ifdef GOLDOBJ
  78. 		if (otmp->invlet != GOLD_SYM) /* don't reassign this */
  79. #endif
  80. 		otmp->invlet = ilet;	/* reassign() */
  81. 	    if (!*let || index(let, otmp->oclass)
  82. #ifdef GOLDOBJ
  83. 		|| (usegold && otmp->invlet == GOLD_SYM)
  84. #endif
  85. 		|| (useboulder && otmp->otyp == BOULDER)
  86. 		) {
  87. 		register int otyp = otmp->otyp;
  88. 		bp[foo++] = otmp->invlet;
  89.  
  90. 		/* ugly check: remove inappropriate things */
  91. 		if ((taking_off(word) &&
  92. 		    (!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
  93. 		     || (otmp==uarm && uarmc)
  94. #ifdef TOURIST
  95. 		     || (otmp==uarmu && (uarm || uarmc))
  96. #endif
  97. 		    ))
  98. 		|| (putting_on(word) &&
  99. 		     (otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)))
  100. 							/* already worn */
  101. #if 0	/* 3.4.1 -- include currently wielded weapon among the choices */
  102. 		|| (!strcmp(word, "wield") &&
  103. 		    (otmp->owornmask & W_WEP))
  104. #endif
  105. 		|| (!strcmp(word, "ready") &&
  106. 		    (otmp == uwep || (otmp == uswapwep && u.twoweap)))
  107. 		    ) {
  108. 			foo--;
  109. 			foox++;
  110. 		}
  111.  
  112. 		/* Second ugly check; unlike the first it won't trigger an
  113. 		 * "else" in "you don't have anything else to ___".
  114. 		 */
  115. 		else if ((putting_on(word) &&
  116. 		    ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING) ||
  117. 		    (otmp->oclass == TOOL_CLASS &&
  118. 		     otyp != BLINDFOLD && otyp != TOWEL && otyp != LENSES)))
  119. 		|| (!strcmp(word, "wield") &&
  120. 		    (otmp->oclass == TOOL_CLASS && !is_weptool(otmp)))
  121. 		|| (!strcmp(word, "eat") && !is_edible(otmp))
  122. 		|| (!strcmp(word, "sacrifice") &&
  123. 		    (otyp != CORPSE &&
  124. 		     otyp != AMULET_OF_YENDOR && otyp != FAKE_AMULET_OF_YENDOR))
  125. 		|| (!strcmp(word, "write with") &&
  126. 		    (otmp->oclass == TOOL_CLASS &&
  127. 		     otyp != MAGIC_MARKER && otyp != TOWEL))
  128. 		|| (!strcmp(word, "tin") &&
  129. 		    (otyp != CORPSE || !tinnable(otmp)))
  130. 		|| (!strcmp(word, "rub") &&
  131. 		    ((otmp->oclass == TOOL_CLASS &&
  132. 		      otyp != OIL_LAMP && otyp != MAGIC_LAMP &&
  133. 		      otyp != BRASS_LANTERN) ||
  134. 		     (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
  135. 		|| (!strncmp(word, "rub on the stone", 16) &&
  136. 		    *let == GEM_CLASS &&	/* using known touchstone */
  137. 		    otmp->dknown && objects[otyp].oc_name_known)
  138. 		|| ((!strcmp(word, "use or apply") ||
  139. 			!strcmp(word, "untrap with")) &&
  140. 		     /* Picks, axes, pole-weapons, bullwhips */
  141. 		    ((otmp->oclass == WEAPON_CLASS && !is_pick(otmp) &&
  142. 		      !is_axe(otmp) && !is_pole(otmp) && otyp != BULLWHIP) ||
  143. 		     (otmp->oclass == POTION_CLASS &&
  144. 		     /* only applicable potion is oil, and it will only
  145. 			be offered as a choice when already discovered */
  146. 		     (otyp != POT_OIL || !otmp->dknown ||
  147. 		      !objects[POT_OIL].oc_name_known)) ||
  148. 		     (otmp->oclass == FOOD_CLASS &&
  149. 		      otyp != CREAM_PIE && otyp != EUCALYPTUS_LEAF) ||
  150. 		     (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
  151. 		|| (!strcmp(word, "invoke") &&
  152. 		    (!otmp->oartifact && !objects[otyp].oc_unique &&
  153. 		     (otyp != FAKE_AMULET_OF_YENDOR || otmp->known) &&
  154. 		     otyp != CRYSTAL_BALL &&	/* #invoke synonym for apply */
  155. 		   /* note: presenting the possibility of invoking non-artifact
  156. 		      mirrors and/or lamps is a simply a cruel deception... */
  157. 		     otyp != MIRROR && otyp != MAGIC_LAMP &&
  158. 		     (otyp != OIL_LAMP ||	/* don't list known oil lamp */
  159. 		      (otmp->dknown && objects[OIL_LAMP].oc_name_known))))
  160. 		|| (!strcmp(word, "untrap with") &&
  161. 		    (otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE))
  162. 		|| (!strcmp(word, "charge") && !is_chargeable(otmp))
  163. 		    )
  164. 			foo--;
  165. 		/* ugly check for unworn armor that can't be worn */
  166. 		else if (putting_on(word) && *let == ARMOR_CLASS &&
  167. 			 !canwearobj(otmp, &dummymask, FALSE)) {
  168. 			foo--;
  169. 			allowall = TRUE;
  170. 			*ap++ = otmp->invlet;
  171. 		}
  172. 	    } else {
  173.  
  174. 		/* "ugly check" for reading fortune cookies, part 2 */
  175. 		if ((!strcmp(word, "read") &&
  176. 		    (otmp->otyp == FORTUNE_COOKIE
  177. #ifdef TOURIST
  178. 			|| otmp->otyp == T_SHIRT
  179. #endif
  180. 		    )))
  181. 			allowall = TRUE;
  182. 	    }
  183.  
  184. 	    if(ilet == 'z') ilet = 'A'; else ilet++;
  185. 	}
  186. 	bp[foo] = 0;
  187. 	if(foo == 0 && bp > buf && bp[-1] == ' ') *--bp = 0;
  188. 	Strcpy(lets, bp);	/* necessary since we destroy buf */
  189. 	if(foo > 5)			/* compactify string */
  190. 		compactify(bp);
  191. 	*ap = '\0';
  192.  
  193. #ifndef GOLDOBJ
  194. 	if(!foo && !allowall && !allowgold && !allownone) {
  195. #else
  196. 	if(!foo && !allowall && !allownone) {
  197. #endif
  198. 		You("don't have anything %sto %s.",
  199. 			foox ? "else " : "", word);
  200. 		return((struct obj *)0);
  201. 	}
  202. 	for(;;) {
  203. 		cnt = 0;
  204. 		if (allowcnt == 2) allowcnt = 1;  /* abort previous count */
  205. 		if(!buf[0]) {
  206. 			Sprintf(qbuf, "What do you want to %s? [*]", word);
  207. 		} else {
  208. 			Sprintf(qbuf, "What do you want to %s? [%s or ?*]",
  209. 				word, buf);
  210. 		}
  211. #ifdef REDO
  212. 		if (in_doagain)
  213. 		    ilet = readchar();
  214. 		else
  215. #endif
  216. 		    ilet = yn_function(qbuf, (char *)0, '\0');
  217. 		if(ilet == '0') prezero = TRUE;
  218. 		while(digit(ilet) && allowcnt) {
  219. #ifdef REDO
  220. 			if (ilet != '?' && ilet != '*')	savech(ilet);
  221. #endif
  222. 			cnt = 10*cnt + (ilet - '0');
  223. 			allowcnt = 2;	/* signal presence of cnt */
  224. 			ilet = readchar();
  225. 		}
  226. 		if(digit(ilet)) {
  227. 			pline("No count allowed with this command.");
  228. 			continue;
  229. 		}
  230. 		if(index(quitchars,ilet)) {
  231. 		    if(flags.verbose)
  232. 			pline(Never_mind);
  233. 		    return((struct obj *)0);
  234. 		}
  235. 		if(ilet == '-') {
  236. 			return(allownone ? &zeroobj : (struct obj *) 0);
  237. 		}
  238. 		if(ilet == def_oc_syms[COIN_CLASS]) {
  239. 			if (!usegold) {
  240. 			    if (!strncmp(word, "rub on ", 7)) {
  241. 				/* the dangers of building sentences... */
  242. 				You("cannot rub gold%s.", word + 3);
  243. 			    } else {
  244. 				You("cannot %s gold.", word);
  245. 			    }
  246. 			    return(struct obj *)0;
  247. #ifndef GOLDOBJ
  248. 			} else if (!allowgold) {
  249. 				You("are not carrying any gold.");
  250. 				return(struct obj *)0;
  251. #endif
  252. 			} 
  253. 			if(cnt == 0 && prezero) return((struct obj *)0);
  254. 			/* Historic note: early Nethack had a bug which was
  255. 			 * first reported for Larn, where trying to drop 2^32-n
  256. 			 * gold pieces was allowed, and did interesting things
  257. 			 * to your money supply.  The LRS is the tax bureau
  258. 			 * from Larn.
  259. 			 */
  260. 			if(cnt < 0) {
  261. 	pline_The("LRS would be very interested to know you have that much.");
  262. 				return(struct obj *)0;
  263. 			}
  264.  
  265. #ifndef GOLDOBJ
  266. 			if(!(allowcnt == 2 && cnt < u.ugold))
  267. 				cnt = u.ugold;
  268. 			return(mkgoldobj(cnt));
  269. #endif
  270. 		}
  271. 		if(ilet == '?' || ilet == '*') {
  272. 		    char *allowed_choices = (ilet == '?') ? lets : (char *)0;
  273. 		    long ctmp = 0;
  274.  
  275. 		    if (ilet == '?' && !*lets && *altlets)
  276. 			allowed_choices = altlets;
  277. 		    ilet = display_pickinv(allowed_choices, TRUE,
  278. 					   allowcnt ? &ctmp : (long *)0);
  279. 		    if(!ilet) continue;
  280. 		    if (allowcnt && ctmp >= 0) {
  281. 			cnt = ctmp;
  282. 			if (!cnt) prezero = TRUE;
  283. 			allowcnt = 2;
  284. 		    }
  285. 		    if(ilet == '\033') {
  286. 			if(flags.verbose)
  287. 			    pline(Never_mind);
  288. 			return((struct obj *)0);
  289. 		    }
  290. 		    /* they typed a letter (not a space) at the prompt */
  291. 		}
  292. 		if(allowcnt == 2 && !strcmp(word,"throw")) {
  293. 		    /* permit counts for throwing gold, but don't accept
  294. 		     * counts for other things since the throw code will
  295. 		     * split off a single item anyway */
  296. #ifdef GOLDOBJ
  297. 		    if (ilet != def_oc_syms[COIN_CLASS])
  298. #endif
  299. 			allowcnt = 1;
  300. 		    if(cnt == 0 && prezero) return((struct obj *)0);
  301. 		    if(cnt > 1) {
  302. 			You("can only throw one item at a time.");
  303. 			continue;
  304. 		    }
  305. 		}
  306. #ifdef GOLDOBJ
  307. 		flags.botl = 1; /* May have changed the amount of money */
  308. #endif
  309. #ifdef REDO
  310. 		savech(ilet);
  311. #endif
  312. 		for (otmp = invent; otmp; otmp = otmp->nobj)
  313. 			if (otmp->invlet == ilet) break;
  314. 		if(!otmp) {
  315. 			You("don't have that object.");
  316. #ifdef REDO
  317. 			if (in_doagain) return((struct obj *) 0);
  318. #endif
  319. 			continue;
  320. 		} else if (cnt < 0 || otmp->quan < cnt) {
  321. 			You("don't have that many!  You have only %ld.",
  322. 			    otmp->quan);
  323. #ifdef REDO
  324. 			if (in_doagain) return((struct obj *) 0);
  325. #endif
  326. 			continue;
  327. 		}
  328. 		break;
  329. 	}
  330. 	if(!allowall && let && !index(let,otmp->oclass)
  331. #ifdef GOLDOBJ
  332. 	   && !(usegold && otmp->oclass == COIN_CLASS)
  333. #endif
  334. 	   ) {
  335. 		silly_thing(word, otmp);
  336. 		return((struct obj *)0);
  337. 	}
  338. 	if(allowcnt == 2) {	/* cnt given */
  339. 	    if(cnt == 0) return (struct obj *)0;
  340. 	    if(cnt != otmp->quan) {
  341. 		/* don't split a stack of cursed loadstones */
  342. 		if (otmp->otyp == LOADSTONE && otmp->cursed)
  343. 		    /* kludge for canletgo()'s can't-drop-this message */
  344. 		    otmp->corpsenm = (int) cnt;
  345. 		else
  346. 		    otmp = splitobj(otmp, cnt);
  347. 	    }
  348. 	}
  349. 	return(otmp);
  350. }

silly_thing[edit]

  1. void
  2. silly_thing(word, otmp)
  3. const char *word;
  4. struct obj *otmp;
  5. {
  6. 	const char *s1, *s2, *s3, *what;
  7. 	int ocls = otmp->oclass, otyp = otmp->otyp;
  8.  
  9. 	s1 = s2 = s3 = 0;
  10. 	/* check for attempted use of accessory commands ('P','R') on armor
  11. 	   and for corresponding armor commands ('W','T') on accessories */
  12. 	if (ocls == ARMOR_CLASS) {
  13. 	    if (!strcmp(word, "put on"))
  14. 		s1 = "W", s2 = "wear", s3 = "";
  15. 	    else if (!strcmp(word, "remove"))
  16. 		s1 = "T", s2 = "take", s3 = " off";
  17. 	} else if ((ocls == RING_CLASS || otyp == MEAT_RING) ||
  18. 		ocls == AMULET_CLASS ||
  19. 		(otyp == BLINDFOLD || otyp == TOWEL || otyp == LENSES)) {
  20. 	    if (!strcmp(word, "wear"))
  21. 		s1 = "P", s2 = "put", s3 = " on";
  22. 	    else if (!strcmp(word, "take off"))
  23. 		s1 = "R", s2 = "remove", s3 = "";
  24. 	}
  25. 	if (s1) {
  26. 	    what = "that";
  27. 	    /* quantity for armor and accessory objects is always 1,
  28. 	       but some things should be referred to as plural */
  29. 	    if (otyp == LENSES || is_gloves(otmp) || is_boots(otmp))
  30. 		what = "those";
  31. 	    pline("Use the '%s' command to %s %s%s.", s1, s2, what, s3);
  32. 	} else {
  33. 	    pline(silly_thing_to, word);
  34. 	}
  35. }
  36.  
  37. #endif /* OVL1 */

ckvalidcat[edit]

  1. #ifdef OVLB
  2.  
  3. STATIC_PTR int
  4. ckvalidcat(otmp)
  5. register struct obj *otmp;
  6. {
  7. 	/* use allow_category() from pickup.c */
  8. 	return((int)allow_category(otmp));
  9. }

ckunpaid[edit]

  1. STATIC_PTR int
  2. ckunpaid(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	return((int)(otmp->unpaid));
  6. }

wearing_armor[edit]

  1. boolean
  2. wearing_armor()
  3. {
  4. 	return((boolean)(uarm || uarmc || uarmf || uarmg || uarmh || uarms
  5. #ifdef TOURIST
  6. 		|| uarmu
  7. #endif
  8. 		));
  9. }

is_worn[edit]

  1. boolean
  2. is_worn(otmp)
  3. register struct obj *otmp;
  4. {
  5. return((boolean)(!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL |
  6. #ifdef STEED
  7. 			W_SADDLE |
  8. #endif
  9. 			W_WEP | W_SWAPWEP | W_QUIVER))));
  10. }

ggetobj[edit]

  1. static NEARDATA const char removeables[] =
  2. 	{ ARMOR_CLASS, WEAPON_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, 0 };
  3.  
  4. /* interactive version of getobj - used for Drop, Identify and */
  5. /* Takeoff (A). Return the number of times fn was called successfully */
  6. /* If combo is TRUE, we just use this to get a category list */
  7. int
  8. ggetobj(word, fn, mx, combo, resultflags)
  9. const char *word;
  10. int FDECL((*fn),(OBJ_P)), mx;
  11. boolean combo;		/* combination menu flag */
  12. unsigned *resultflags;
  13. {
  14. 	int FDECL((*ckfn),(OBJ_P)) = (int FDECL((*),(OBJ_P))) 0;
  15. 	boolean FDECL((*filter),(OBJ_P)) = (boolean FDECL((*),(OBJ_P))) 0;
  16. 	boolean takeoff, ident, allflag, m_seen;
  17. 	int itemcount;
  18. #ifndef GOLDOBJ
  19. 	int oletct, iletct, allowgold, unpaid, oc_of_sym;
  20. #else
  21. 	int oletct, iletct, unpaid, oc_of_sym;
  22. #endif
  23. 	char sym, *ip, olets[MAXOCLASSES+5], ilets[MAXOCLASSES+5];
  24. 	char extra_removeables[3+1];	/* uwep,uswapwep,uquiver */
  25. 	char buf[BUFSZ], qbuf[QBUFSZ];
  26.  
  27. 	if (resultflags) *resultflags = 0;
  28. #ifndef GOLDOBJ
  29. 	allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0;
  30. #endif
  31. 	takeoff = ident = allflag = m_seen = FALSE;
  32. #ifndef GOLDOBJ
  33. 	if(!invent && !allowgold){
  34. #else
  35. 	if(!invent){
  36. #endif
  37. 		You("have nothing to %s.", word);
  38. 		return(0);
  39. 	}
  40. 	add_valid_menu_class(0);	/* reset */
  41. 	if (taking_off(word)) {
  42. 	    takeoff = TRUE;
  43. 	    filter = is_worn;
  44. 	} else if (!strcmp(word, "identify")) {
  45. 	    ident = TRUE;
  46. 	    filter = not_fully_identified;
  47. 	}
  48.  
  49. 	iletct = collect_obj_classes(ilets, invent,
  50. 				     	FALSE,
  51. #ifndef GOLDOBJ
  52. 					(allowgold != 0),
  53. #endif
  54. 					filter, &itemcount);
  55. 	unpaid = count_unpaid(invent);
  56.  
  57. 	if (ident && !iletct) {
  58. 	    return -1;		/* no further identifications */
  59. 	} else if (!takeoff && (unpaid || invent)) {
  60. 	    ilets[iletct++] = ' ';
  61. 	    if (unpaid) ilets[iletct++] = 'u';
  62. 	    if (count_buc(invent, BUC_BLESSED))  ilets[iletct++] = 'B';
  63. 	    if (count_buc(invent, BUC_UNCURSED)) ilets[iletct++] = 'U';
  64. 	    if (count_buc(invent, BUC_CURSED))   ilets[iletct++] = 'C';
  65. 	    if (count_buc(invent, BUC_UNKNOWN))  ilets[iletct++] = 'X';
  66. 	    if (invent) ilets[iletct++] = 'a';
  67. 	} else if (takeoff && invent) {
  68. 	    ilets[iletct++] = ' ';
  69. 	}
  70. 	ilets[iletct++] = 'i';
  71. 	if (!combo)
  72. 	    ilets[iletct++] = 'm';	/* allow menu presentation on request */
  73. 	ilets[iletct] = '\0';
  74.  
  75. 	for (;;) {
  76. 	    Sprintf(qbuf,"What kinds of thing do you want to %s? [%s]",
  77. 		    word, ilets);
  78. 	    getlin(qbuf, buf);
  79. 	    if (buf[0] == '\033') return(0);
  80. 	    if (index(buf, 'i')) {
  81. 		if (display_inventory((char *)0, TRUE) == '\033') return 0;
  82. 	    } else
  83. 		break;
  84. 	}
  85.  
  86. 	extra_removeables[0] = '\0';
  87. 	if (takeoff) {
  88. 	    /* arbitrary types of items can be placed in the weapon slots
  89. 	       [any duplicate entries in extra_removeables[] won't matter] */
  90. 	    if (uwep) (void)strkitten(extra_removeables, uwep->oclass);
  91. 	    if (uswapwep) (void)strkitten(extra_removeables, uswapwep->oclass);
  92. 	    if (uquiver) (void)strkitten(extra_removeables, uquiver->oclass);
  93. 	}
  94.  
  95. 	ip = buf;
  96. 	olets[oletct = 0] = '\0';
  97. 	while ((sym = *ip++) != '\0') {
  98. 	    if (sym == ' ') continue;
  99. 	    oc_of_sym = def_char_to_objclass(sym);
  100. 	    if (takeoff && oc_of_sym != MAXOCLASSES) {
  101. 		if (index(extra_removeables, oc_of_sym)) {
  102. 		    ;	/* skip rest of takeoff checks */
  103. 		} else if (!index(removeables, oc_of_sym)) {
  104. 		    pline("Not applicable.");
  105. 		    return 0;
  106. 		} else if (oc_of_sym == ARMOR_CLASS && !wearing_armor()) {
  107. 		    You("are not wearing any armor.");
  108. 		    return 0;
  109. 		} else if (oc_of_sym == WEAPON_CLASS &&
  110. 			!uwep && !uswapwep && !uquiver) {
  111. 		    You("are not wielding anything.");
  112. 		    return 0;
  113. 		} else if (oc_of_sym == RING_CLASS && !uright && !uleft) {
  114. 		    You("are not wearing rings.");
  115. 		    return 0;
  116. 		} else if (oc_of_sym == AMULET_CLASS && !uamul) {
  117. 		    You("are not wearing an amulet.");
  118. 		    return 0;
  119. 		} else if (oc_of_sym == TOOL_CLASS && !ublindf) {
  120. 		    You("are not wearing a blindfold.");
  121. 		    return 0;
  122. 		}
  123. 	    }
  124.  
  125. 	    if (oc_of_sym == COIN_CLASS && !combo) {
  126. #ifndef GOLDOBJ
  127. 		if (allowgold == 1)
  128. 		    (*fn)(mkgoldobj(u.ugold));
  129. 		else if (!u.ugold)
  130. 		    You("have no gold.");
  131. 		allowgold = 2;
  132. #else
  133. 		flags.botl = 1;
  134. #endif
  135. 	    } else if (sym == 'a') {
  136. 		allflag = TRUE;
  137. 	    } else if (sym == 'A') {
  138. 		/* same as the default */ ;
  139. 	    } else if (sym == 'u') {
  140. 		add_valid_menu_class('u');
  141. 		ckfn = ckunpaid;
  142. 	    } else if (sym == 'B') {
  143. 	    	add_valid_menu_class('B');
  144. 	    	ckfn = ckvalidcat;
  145. 	    } else if (sym == 'U') {
  146. 	    	add_valid_menu_class('U');
  147. 	    	ckfn = ckvalidcat;
  148. 	    } else if (sym == 'C') {
  149. 	    	add_valid_menu_class('C');
  150. 		ckfn = ckvalidcat;
  151. 	    } else if (sym == 'X') {
  152. 	    	add_valid_menu_class('X');
  153. 		ckfn = ckvalidcat;
  154. 	    } else if (sym == 'm') {
  155. 		m_seen = TRUE;
  156. 	    } else if (oc_of_sym == MAXOCLASSES) {
  157. 		You("don't have any %c's.", sym);
  158. 	    } else if (oc_of_sym != VENOM_CLASS) {	/* suppress venom */
  159. 		if (!index(olets, oc_of_sym)) {
  160. 		    add_valid_menu_class(oc_of_sym);
  161. 		    olets[oletct++] = oc_of_sym;
  162. 		    olets[oletct] = 0;
  163. 		}
  164. 	    }
  165. 	}
  166.  
  167. 	if (m_seen)
  168. 	    return (allflag || (!oletct && ckfn != ckunpaid)) ? -2 : -3;
  169. 	else if (flags.menu_style != MENU_TRADITIONAL && combo && !allflag)
  170. 	    return 0;
  171. #ifndef GOLDOBJ
  172. 	else if (allowgold == 2 && !oletct)
  173. 	    return 1;	/* you dropped gold (or at least tried to) */
  174. 	else {
  175. #else
  176. 	else /*!!!! if (allowgold == 2 && !oletct)
  177. 	    !!!! return 1;	 you dropped gold (or at least tried to) 
  178. !!!! test gold dropping
  179. 	else*/ {
  180. #endif
  181. 	    int cnt = askchain(&invent, olets, allflag, fn, ckfn, mx, word); 
  182. 	    /*
  183. 	     * askchain() has already finished the job in this case
  184. 	     * so set a special flag to convey that back to the caller
  185. 	     * so that it won't continue processing.
  186. 	     * Fix for bug C331-1 reported by Irina Rempt-Drijfhout. 
  187. 	     */
  188. 	    if (combo && allflag && resultflags)
  189. 		*resultflags |= ALL_FINISHED; 
  190. 	    return cnt;
  191. 	}
  192. }

askchain[edit]

  1. /*
  2. * Walk through the chain starting at objchn and ask for all objects
  3. * with olet in olets (if nonNULL) and satisfying ckfn (if nonnull)
  4. * whether the action in question (i.e., fn) has to be performed.
  5. * If allflag then no questions are asked. Max gives the max nr of
  6. * objects to be treated. Return the number of objects treated.
  7. */
  8. int
  9. askchain(objchn, olets, allflag, fn, ckfn, mx, word)
  10. struct obj **objchn;
  11. register int allflag, mx;
  12. register const char *olets, *word;	/* olets is an Obj Class char array */
  13. register int FDECL((*fn),(OBJ_P)), FDECL((*ckfn),(OBJ_P));
  14. {
  15. 	struct obj *otmp, *otmp2, *otmpo;
  16. 	register char sym, ilet;
  17. 	register int cnt = 0, dud = 0, tmp;
  18. 	boolean takeoff, nodot, ident, ininv;
  19. 	char qbuf[QBUFSZ];
  20.  
  21. 	takeoff = taking_off(word);
  22. 	ident = !strcmp(word, "identify");
  23. 	nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") ||
  24. 		 ident || takeoff);
  25. 	ininv = (*objchn == invent);
  26. 	/* Changed so the askchain is interrogated in the order specified.
  27. 	 * For example, if a person specifies =/ then first all rings will be
  28. 	 * asked about followed by all wands -dgk
  29. 	 */
  30. nextclass:
  31. 	ilet = 'a'-1;
  32. 	if (*objchn && (*objchn)->oclass == COIN_CLASS)
  33. 		ilet--;		/* extra iteration */
  34. 	for (otmp = *objchn; otmp; otmp = otmp2) {
  35. 		if(ilet == 'z') ilet = 'A'; else ilet++;
  36. 		otmp2 = otmp->nobj;
  37. 		if (olets && *olets && otmp->oclass != *olets) continue;
  38. 		if (takeoff && !is_worn(otmp)) continue;
  39. 		if (ident && !not_fully_identified(otmp)) continue;
  40. 		if (ckfn && !(*ckfn)(otmp)) continue;
  41. 		if (!allflag) {
  42. 			Strcpy(qbuf, !ininv ? doname(otmp) :
  43. 				xprname(otmp, (char *)0, ilet, !nodot, 0L, 0L));
  44. 			Strcat(qbuf, "?");
  45. 			sym = (takeoff || ident || otmp->quan < 2L) ?
  46. 				nyaq(qbuf) : nyNaq(qbuf);
  47. 		}
  48. 		else	sym = 'y';
  49.  
  50. 		otmpo = otmp;
  51. 		if (sym == '#') {
  52. 		 /* Number was entered; split the object unless it corresponds
  53. 		    to 'none' or 'all'.  2 special cases: cursed loadstones and
  54. 		    welded weapons (eg, multiple daggers) will remain as merged
  55. 		    unit; done to avoid splitting an object that won't be
  56. 		    droppable (even if we're picking up rather than dropping).
  57. 		  */
  58. 		    if (!yn_number)
  59. 			sym = 'n';
  60. 		    else {
  61. 			sym = 'y';
  62. 			if (yn_number < otmp->quan && !welded(otmp) &&
  63. 			    (!otmp->cursed || otmp->otyp != LOADSTONE)) {
  64. 			    otmp = splitobj(otmp, yn_number);
  65. 			}
  66. 		    }
  67. 		}
  68. 		switch(sym){
  69. 		case 'a':
  70. 			allflag = 1;
  71. 		case 'y':
  72. 			tmp = (*fn)(otmp);
  73. 			if(tmp < 0) {
  74. 			    if (otmp != otmpo) {
  75. 				/* split occurred, merge again */
  76. 				(void) merged(&otmpo, &otmp);
  77. 			    }
  78. 			    goto ret;
  79. 			}
  80. 			cnt += tmp;
  81. 			if(--mx == 0) goto ret;
  82. 		case 'n':
  83. 			if(nodot) dud++;
  84. 		default:
  85. 			break;
  86. 		case 'q':
  87. 			/* special case for seffects() */
  88. 			if (ident) cnt = -1;
  89. 			goto ret;
  90. 		}
  91. 	}
  92. 	if (olets && *olets && *++olets)
  93. 		goto nextclass;
  94. 	if(!takeoff && (dud || cnt)) pline("That was all.");
  95. 	else if(!dud && !cnt) pline("No applicable objects.");
  96. ret:
  97. 	return(cnt);
  98. }

fully_identify_obj[edit]

  1. /*
  2. *	Object identification routines:
  3. */
  4.  
  5. /* make an object actually be identified; no display updating */
  6. void
  7. fully_identify_obj(otmp)
  8. struct obj *otmp;
  9. {
  10. makeknown(otmp->otyp);
  11. if (otmp->oartifact) discover_artifact((xchar)otmp->oartifact);
  12. otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1;
  13. if (otmp->otyp == EGG && otmp->corpsenm != NON_PM)
  14. 	learn_egg_type(otmp->corpsenm);
  15. }

identify[edit]

  1. /* ggetobj callback routine; identify an object and give immediate feedback */
  2. int
  3. identify(otmp)
  4. struct obj *otmp;
  5. {
  6. fully_identify_obj(otmp);
  7. prinv((char *)0, otmp, 0L);
  8. return 1;
  9. }

menu_identify[edit]

  1. /* menu of unidentified objects; select and identify up to id_limit of them */
  2. STATIC_OVL void
  3. menu_identify(id_limit)
  4. int id_limit;
  5. {
  6. menu_item *pick_list;
  7. int n, i, first = 1;
  8. char buf[BUFSZ];
  9. /* assumptions:  id_limit > 0 and at least one unID'd item is present */
  10.  
  11. while (id_limit) {
  12. 	Sprintf(buf, "What would you like to identify %s?",
  13. 		first ? "first" : "next");
  14. 	n = query_objlist(buf, invent, SIGNAL_NOMENU|USE_INVLET|INVORDER_SORT,
  15. 		&pick_list, PICK_ANY, not_fully_identified);
  16.  
  17. 	if (n > 0) {
  18. 	    if (n > id_limit) n = id_limit;
  19. 	    for (i = 0; i < n; i++, id_limit--)
  20. 		(void) identify(pick_list[i].item.a_obj);
  21. 	    free((genericptr_t) pick_list);
  22. 	    mark_synch(); /* Before we loop to pop open another menu */
  23. 	} else {
  24. 	    if (n < 0) pline("That was all.");
  25. 	    id_limit = 0; /* Stop now */
  26. 	}
  27. 	first = 0;
  28. }
  29. }

identify_pack[edit]

  1. /* dialog with user to identify a given number of items; 0 means all */
  2. void
  3. identify_pack(id_limit)
  4. int id_limit;
  5. {
  6. struct obj *obj, *the_obj;
  7. int n, unid_cnt;
  8.  
  9. unid_cnt = 0;
  10. the_obj = 0;		/* if unid_cnt ends up 1, this will be it */
  11. for (obj = invent; obj; obj = obj->nobj)
  12. 	if (not_fully_identified(obj)) ++unid_cnt, the_obj = obj;
  13.  
  14. if (!unid_cnt) {
  15. 	You("have already identified all of your possessions.");
  16. } else if (!id_limit) {
  17. 	/* identify everything */
  18. 	if (unid_cnt == 1) {
  19. 	    (void) identify(the_obj);
  20. 	} else {
  21.  
  22. 	    /* TODO:  use fully_identify_obj and cornline/menu/whatever here */
  23. 	    for (obj = invent; obj; obj = obj->nobj)
  24. 		if (not_fully_identified(obj)) (void) identify(obj);
  25.  
  26. 	}
  27. } else {
  28. 	/* identify up to `id_limit' items */
  29. 	n = 0;
  30. 	if (flags.menu_style == MENU_TRADITIONAL)
  31. 	    do {
  32. 		n = ggetobj("identify", identify, id_limit, FALSE, (unsigned *)0);
  33. 		if (n < 0) break; /* quit or no eligible items */
  34. 	    } while ((id_limit -= n) > 0);
  35. 	if (n == 0 || n < -1)
  36. 	    menu_identify(id_limit);
  37. }
  38. update_inventory();
  39. }
  40.  
  41. #endif /* OVLB */

obj_to_let[edit]

  1. #ifdef OVL2
  2.  
  3. STATIC_OVL char
  4. obj_to_let(obj)	/* should of course only be called for things in invent */
  5. register struct obj *obj;
  6. {
  7. #ifndef GOLDOBJ
  8. 	if (obj->oclass == COIN_CLASS)
  9. 		return GOLD_SYM;
  10. #endif
  11. 	if (!flags.invlet_constant) {
  12. 		obj->invlet = NOINVSYM;
  13. 		reassign();
  14. 	}
  15. 	return obj->invlet;
  16. }

prinv[edit]

  1. /*
  2. * Print the indicated quantity of the given object.  If quan == 0L then use
  3. * the current quantity.
  4. */
  5. void
  6. prinv(prefix, obj, quan)
  7. const char *prefix;
  8. register struct obj *obj;
  9. long quan;
  10. {
  11. 	if (!prefix) prefix = "";
  12. 	pline("%s%s%s",
  13. 	      prefix, *prefix ? " " : "",
  14. 	      xprname(obj, (char *)0, obj_to_let(obj), TRUE, 0L, quan));
  15. }
  16.  
  17. #endif /* OVL2 */

xprname[edit]

  1. #ifdef OVL1
  2.  
  3. char *
  4. xprname(obj, txt, let, dot, cost, quan)
  5. struct obj *obj;
  6. const char *txt;	/* text to print instead of obj */
  7. char let;		/* inventory letter */
  8. boolean dot;		/* append period; (dot && cost => Iu) */
  9. long cost;		/* cost (for inventory of unpaid or expended items) */
  10. long quan;		/* if non-0, print this quantity, not obj->quan */
  11. {
  12. #ifdef LINT	/* handle static char li[BUFSZ]; */
  13. char li[BUFSZ];
  14. #else
  15. static char li[BUFSZ];
  16. #endif
  17. boolean use_invlet = flags.invlet_constant && let != CONTAINED_SYM;
  18. long savequan = 0;
  19.  
  20. if (quan && obj) {
  21. 	savequan = obj->quan;
  22. 	obj->quan = quan;
  23. }
  24.  
  25. /*
  26. * If let is:
  27. *	*  Then obj == null and we are printing a total amount.
  28. *	>  Then the object is contained and doesn't have an inventory letter.
  29. */
  30. if (cost != 0 || let == '*') {
  31. 	/* if dot is true, we're doing Iu, otherwise Ix */
  32. 	Sprintf(li, "%c - %-45s %6ld %s",
  33. 		(dot && use_invlet ? obj->invlet : let),
  34. 		(txt ? txt : doname(obj)), cost, currency(cost));
  35. #ifndef GOLDOBJ
  36. } else if (obj && obj->oclass == COIN_CLASS) {
  37. 	Sprintf(li, "%ld gold piece%s%s", obj->quan, plur(obj->quan),
  38. 		(dot ? "." : ""));
  39. #endif
  40. } else {
  41. 	/* ordinary inventory display or pickup message */
  42. 	Sprintf(li, "%c - %s%s",
  43. 		(use_invlet ? obj->invlet : let),
  44. 		(txt ? txt : doname(obj)), (dot ? "." : ""));
  45. }
  46. if (savequan) obj->quan = savequan;
  47.  
  48. return li;
  49. }
  50.  
  51. #endif /* OVL1 */

ddoinv[edit]

  1. #ifdef OVLB
  2.  
  3. /* the 'i' command */
  4. int
  5. ddoinv()
  6. {
  7. 	(void) display_inventory((char *)0, FALSE);
  8. 	return 0;
  9. }

find_unpaid[edit]

  1. /*
  2. * find_unpaid()
  3. *
  4. * Scan the given list of objects.  If last_found is NULL, return the first
  5. * unpaid object found.  If last_found is not NULL, then skip over unpaid
  6. * objects until last_found is reached, then set last_found to NULL so the
  7. * next unpaid object is returned.  This routine recursively follows
  8. * containers.
  9. */
  10. STATIC_OVL struct obj *
  11. find_unpaid(list, last_found)
  12. struct obj *list, **last_found;
  13. {
  14. struct obj *obj;
  15.  
  16. while (list) {
  17. 	if (list->unpaid) {
  18. 	    if (*last_found) {
  19. 		/* still looking for previous unpaid object */
  20. 		if (list == *last_found)
  21. 		    *last_found = (struct obj *) 0;
  22. 	    } else
  23. 		return (*last_found = list);
  24. 	}
  25. 	if (Has_contents(list)) {
  26. 	    if ((obj = find_unpaid(list->cobj, last_found)) != 0)
  27. 		return obj;
  28. 	}
  29. 	list = list->nobj;
  30. }
  31. return (struct obj *) 0;
  32. }

display_pickinv[edit]

  1. /*
  2. * Internal function used by display_inventory and getobj that can display
  3. * inventory and return a count as well as a letter. If out_cnt is not null,
  4. * any count returned from the menu selection is placed here.
  5. */
  6. static char
  7. display_pickinv(lets, want_reply, out_cnt)
  8. register const char *lets;
  9. boolean want_reply;
  10. long* out_cnt;
  11. {
  12. 	struct obj *otmp;
  13. 	char ilet, ret;
  14. 	char *invlet = flags.inv_order;
  15. 	int n, classcount;
  16. 	winid win;				/* windows being used */
  17. 	static winid local_win = WIN_ERR;	/* window for partial menus */
  18. 	anything any;
  19. 	menu_item *selected;
  20.  
  21. 	/* overriden by global flag */
  22. 	if (flags.perm_invent) {
  23. 	    win = (lets && *lets) ? local_win : WIN_INVEN;
  24. 	    /* create the first time used */
  25. 	    if (win == WIN_ERR)
  26. 		win = local_win = create_nhwindow(NHW_MENU);
  27. 	} else
  28. 	    win = WIN_INVEN;
  29.  
  30. 	/*
  31. 	Exit early if no inventory -- but keep going if we are doing
  32. 	a permanent inventory update.  We need to keep going so the
  33. 	permanent inventory window updates itself to remove the last
  34. 	item(s) dropped.  One down side:  the addition of the exception
  35. 	for permanent inventory window updates _can_ pop the window
  36. 	up when it's not displayed -- even if it's empty -- because we
  37. 	don't know at this level if its up or not.  This may not be
  38. 	an issue if empty checks are done before hand and the call
  39. 	to here is short circuited away.
  40. 	*/
  41. 	if (!invent && !(flags.perm_invent && !lets && !want_reply)) {
  42. #ifndef GOLDOBJ
  43. 	    pline("Not carrying anything%s.", u.ugold ? " except gold" : "");
  44. #else
  45. 	    pline("Not carrying anything.");
  46. #endif
  47. 	    return 0;
  48. 	}
  49.  
  50. 	/* oxymoron? temporarily assign permanent inventory letters */
  51. 	if (!flags.invlet_constant) reassign();
  52.  
  53. 	if (lets && strlen(lets) == 1) {
  54. 	    /* when only one item of interest, use pline instead of menus;
  55. 	       we actually use a fake message-line menu in order to allow
  56. 	       the user to perform selection at the --More-- prompt for tty */
  57. 	    ret = '\0';
  58. 	    for (otmp = invent; otmp; otmp = otmp->nobj) {
  59. 		if (otmp->invlet == lets[0]) {
  60. 		    ret = message_menu(lets[0],
  61. 			  want_reply ? PICK_ONE : PICK_NONE,
  62. 			  xprname(otmp, (char *)0, lets[0], TRUE, 0L, 0L));
  63. 		    if (out_cnt) *out_cnt = -1L;	/* select all */
  64. 		    break;
  65. 		}
  66. 	    }
  67. 	    return ret;
  68. 	}
  69.  
  70. 	start_menu(win);
  71. nextclass:
  72. 	classcount = 0;
  73. 	any.a_void = 0;		/* set all bits to zero */
  74. 	for(otmp = invent; otmp; otmp = otmp->nobj) {
  75. 		ilet = otmp->invlet;
  76. 		if(!lets || !*lets || index(lets, ilet)) {
  77. 			if (!flags.sortpack || otmp->oclass == *invlet) {
  78. 			    if (flags.sortpack && !classcount) {
  79. 				any.a_void = 0;		/* zero */
  80. 				add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
  81. 				    let_to_name(*invlet, FALSE), MENU_UNSELECTED);
  82. 				classcount++;
  83. 			    }
  84. 			    any.a_char = ilet;
  85. 			    add_menu(win, obj_to_glyph(otmp),
  86. 					&any, ilet, 0, ATR_NONE, doname(otmp),
  87. 					MENU_UNSELECTED);
  88. 			}
  89. 		}
  90. 	}
  91. 	if (flags.sortpack) {
  92. 		if (*++invlet) goto nextclass;
  93. #ifdef WIZARD
  94. 		if (--invlet != venom_inv) {
  95. 			invlet = venom_inv;
  96. 			goto nextclass;
  97. 		}
  98. #endif
  99. 	}
  100. 	end_menu(win, (char *) 0);
  101.  
  102. 	n = select_menu(win, want_reply ? PICK_ONE : PICK_NONE, &selected);
  103. 	if (n > 0) {
  104. 	    ret = selected[0].item.a_char;
  105. 	    if (out_cnt) *out_cnt = selected[0].count;
  106. 	    free((genericptr_t)selected);
  107. 	} else
  108. 	    ret = !n ? '\0' : '\033';	/* cancelled */
  109.  
  110. 	return ret;
  111. }

display_inventory[edit]

  1. /*
  2. * If lets == NULL or "", list all objects in the inventory.  Otherwise,
  3. * list all objects with object classes that match the order in lets.
  4. *
  5. * Returns the letter identifier of a selected item, or 0 if nothing
  6. * was selected.
  7. */
  8. char
  9. display_inventory(lets, want_reply)
  10. register const char *lets;
  11. boolean want_reply;
  12. {
  13. 	return display_pickinv(lets, want_reply, (long *)0);
  14. }

count_unpaid[edit]

  1. /*
  2. * Returns the number of unpaid items within the given list.  This includes
  3. * contained objects.
  4. */
  5. int
  6. count_unpaid(list)
  7. struct obj *list;
  8. {
  9. int count = 0;
  10.  
  11. while (list) {
  12. 	if (list->unpaid) count++;
  13. 	if (Has_contents(list))
  14. 	    count += count_unpaid(list->cobj);
  15. 	list = list->nobj;
  16. }
  17. return count;
  18. }

count_buc[edit]

  1. /*
  2. * Returns the number of items with b/u/c/unknown within the given list.  
  3. * This does NOT include contained objects.
  4. */
  5. int
  6. count_buc(list, type)
  7. struct obj *list;
  8. int type;
  9. {
  10. int count = 0;
  11.  
  12. while (list) {
  13. 	if (Role_if(PM_PRIEST)) list->bknown = TRUE;
  14. 	switch(type) {
  15. 	    case BUC_BLESSED:
  16. 		if (list->oclass != COIN_CLASS && list->bknown && list->blessed)
  17. 		    count++;
  18. 		break;
  19. 	    case BUC_CURSED:
  20. 		if (list->oclass != COIN_CLASS && list->bknown && list->cursed)
  21. 		    count++;
  22. 		break;
  23. 	    case BUC_UNCURSED:
  24. 		if (list->oclass != COIN_CLASS &&
  25. 			list->bknown && !list->blessed && !list->cursed)
  26. 		    count++;
  27. 		break;
  28. 	    case BUC_UNKNOWN:
  29. 		if (list->oclass != COIN_CLASS && !list->bknown)
  30. 		    count++;
  31. 		break;
  32. 	    default:
  33. 		impossible("need count of curse status %d?", type);
  34. 		return 0;
  35. 	}
  36. 	list = list->nobj;
  37. }
  38. return count;
  39. }

dounpaid[edit]

  1. STATIC_OVL void
  2. dounpaid()
  3. {
  4. winid win;
  5. struct obj *otmp, *marker;
  6. register char ilet;
  7. char *invlet = flags.inv_order;
  8. int classcount, count, num_so_far;
  9. int save_unpaid = 0;	/* lint init */
  10. long cost, totcost;
  11.  
  12. count = count_unpaid(invent);
  13.  
  14. if (count == 1) {
  15. 	marker = (struct obj *) 0;
  16. 	otmp = find_unpaid(invent, &marker);
  17.  
  18. 	/* see if the unpaid item is in the top level inventory */
  19. 	for (marker = invent; marker; marker = marker->nobj)
  20. 	    if (marker == otmp) break;
  21.  
  22. 	pline("%s", xprname(otmp, distant_name(otmp, doname),
  23. 			    marker ? otmp->invlet : CONTAINED_SYM,
  24. 			    TRUE, unpaid_cost(otmp), 0L));
  25. 	return;
  26. }
  27.  
  28. win = create_nhwindow(NHW_MENU);
  29. cost = totcost = 0;
  30. num_so_far = 0;	/* count of # printed so far */
  31. if (!flags.invlet_constant) reassign();
  32.  
  33. do {
  34. 	classcount = 0;
  35. 	for (otmp = invent; otmp; otmp = otmp->nobj) {
  36. 	    ilet = otmp->invlet;
  37. 	    if (otmp->unpaid) {
  38. 		if (!flags.sortpack || otmp->oclass == *invlet) {
  39. 		    if (flags.sortpack && !classcount) {
  40. 			putstr(win, 0, let_to_name(*invlet, TRUE));
  41. 			classcount++;
  42. 		    }
  43.  
  44. 		    totcost += cost = unpaid_cost(otmp);
  45. 		    /* suppress "(unpaid)" suffix */
  46. 		    save_unpaid = otmp->unpaid;
  47. 		    otmp->unpaid = 0;
  48. 		    putstr(win, 0, xprname(otmp, distant_name(otmp, doname),
  49. 					   ilet, TRUE, cost, 0L));
  50. 		    otmp->unpaid = save_unpaid;
  51. 		    num_so_far++;
  52. 		}
  53. 	    }
  54. 	}
  55. } while (flags.sortpack && (*++invlet));
  56.  
  57. if (count > num_so_far) {
  58. 	/* something unpaid is contained */
  59. 	if (flags.sortpack)
  60. 	    putstr(win, 0, let_to_name(CONTAINED_SYM, TRUE));
  61. 	/*
  62. 	 * Search through the container objects in the inventory for
  63. 	 * unpaid items.  The top level inventory items have already
  64. 	 * been listed.
  65. 	 */
  66. 	for (otmp = invent; otmp; otmp = otmp->nobj) {
  67. 	    if (Has_contents(otmp)) {
  68. 		marker = (struct obj *) 0;	/* haven't found any */
  69. 		while (find_unpaid(otmp->cobj, &marker)) {
  70. 		    totcost += cost = unpaid_cost(marker);
  71. 		    save_unpaid = marker->unpaid;
  72. 		    marker->unpaid = 0;    /* suppress "(unpaid)" suffix */
  73. 		    putstr(win, 0,
  74. 			   xprname(marker, distant_name(marker, doname),
  75. 				   CONTAINED_SYM, TRUE, cost, 0L));
  76. 		    marker->unpaid = save_unpaid;
  77. 		}
  78. 	    }
  79. 	}
  80. }
  81.  
  82. putstr(win, 0, "");
  83. putstr(win, 0, xprname((struct obj *)0, "Total:", '*', FALSE, totcost, 0L));
  84. display_nhwindow(win, FALSE);
  85. destroy_nhwindow(win);
  86. }

this_type_only[edit]

  1. /* query objlist callback: return TRUE if obj type matches "this_type" */
  2. static int this_type;
  3.  
  4. STATIC_OVL boolean
  5. this_type_only(obj)
  6. struct obj *obj;
  7. {
  8. return (obj->oclass == this_type);
  9. }

dotypeinv[edit]

  1. /* the 'I' command */
  2. int
  3. dotypeinv()
  4. {
  5. 	char c = '\0';
  6. 	int n, i = 0;
  7. 	char *extra_types, types[BUFSZ];
  8. 	int class_count, oclass, unpaid_count, itemcount;
  9. 	boolean billx = *u.ushops && doinvbill(0);
  10. 	menu_item *pick_list;
  11. 	boolean traditional = TRUE;
  12. 	const char *prompt = "What type of object do you want an inventory of?";
  13.  
  14. #ifndef GOLDOBJ
  15. 	if (!invent && !u.ugold && !billx) {
  16. #else
  17. 	if (!invent && !billx) {
  18. #endif
  19. 	    You("aren't carrying anything.");
  20. 	    return 0;
  21. 	}
  22. 	unpaid_count = count_unpaid(invent);
  23. 	if (flags.menu_style != MENU_TRADITIONAL) {
  24. 	    if (flags.menu_style == MENU_FULL ||
  25. 				flags.menu_style == MENU_PARTIAL) {
  26. 		traditional = FALSE;
  27. 		i = UNPAID_TYPES;
  28. 		if (billx) i |= BILLED_TYPES;
  29. 		n = query_category(prompt, invent, i, &pick_list, PICK_ONE);
  30. 		if (!n) return 0;
  31. 		this_type = c = pick_list[0].item.a_int;
  32. 		free((genericptr_t) pick_list);
  33. 	    }
  34. 	}
  35. 	if (traditional) {
  36. 	    /* collect a list of classes of objects carried, for use as a prompt */
  37. 	    types[0] = 0;
  38. 	    class_count = collect_obj_classes(types, invent,
  39. 					      FALSE,
  40. #ifndef GOLDOBJ
  41. 					      (u.ugold != 0),
  42. #endif
  43. 					      (boolean FDECL((*),(OBJ_P))) 0, &itemcount);
  44. 	    if (unpaid_count) {
  45. 		Strcat(types, "u");
  46. 		class_count++;
  47. 	    }
  48. 	    if (billx) {
  49. 		Strcat(types, "x");
  50. 		class_count++;
  51. 	    }
  52. 	    /* add everything not already included; user won't see these */
  53. 	    extra_types = eos(types);
  54. 	    *extra_types++ = '\033';
  55. 	    if (!unpaid_count) *extra_types++ = 'u';
  56. 	    if (!billx) *extra_types++ = 'x';
  57. 	    *extra_types = '\0';	/* for index() */
  58. 	    for (i = 0; i < MAXOCLASSES; i++)
  59. 		if (!index(types, def_oc_syms[i])) {
  60. 		    *extra_types++ = def_oc_syms[i];
  61. 		    *extra_types = '\0';
  62. 		}
  63.  
  64. 	    if(class_count > 1) {
  65. 		c = yn_function(prompt, types, '\0');
  66. #ifdef REDO
  67. 		savech(c);
  68. #endif
  69. 		if(c == '\0') {
  70. 			clear_nhwindow(WIN_MESSAGE);
  71. 			return 0;
  72. 		}
  73. 	    } else {
  74. 		/* only one thing to itemize */
  75. 		if (unpaid_count)
  76. 		    c = 'u';
  77. 		else if (billx)
  78. 		    c = 'x';
  79. 		else
  80. 		    c = types[0];
  81. 	    }
  82. 	}
  83. 	if (c == 'x') {
  84. 	    if (billx)
  85. 		(void) doinvbill(1);
  86. 	    else
  87. 		pline("No used-up objects on your shopping bill.");
  88. 	    return 0;
  89. 	}
  90. 	if (c == 'u') {
  91. 	    if (unpaid_count)
  92. 		dounpaid();
  93. 	    else
  94. 		You("are not carrying any unpaid objects.");
  95. 	    return 0;
  96. 	}
  97. 	if (traditional) {
  98. 	    oclass = def_char_to_objclass(c); /* change to object class */
  99. 	    if (oclass == COIN_CLASS) {
  100. 		return doprgold();
  101. 	    } else if (index(types, c) > index(types, '\033')) {
  102. 		You("have no such objects.");
  103. 		return 0;
  104. 	    }
  105. 	    this_type = oclass;
  106. 	}
  107. 	if (query_objlist((char *) 0, invent,
  108. 		    (flags.invlet_constant ? USE_INVLET : 0)|INVORDER_SORT,
  109. 		    &pick_list, PICK_NONE, this_type_only) > 0)
  110. 	    free((genericptr_t)pick_list);
  111. 	return 0;
  112. }

dfeature_at[edit]

  1. /* return a string describing the dungeon feature at <x,y> if there
  2. is one worth mentioning at that location; otherwise null */
  3. const char *
  4. dfeature_at(x, y, buf)
  5. int x, y;
  6. char *buf;
  7. {
  8. 	struct rm *lev = &levl[x][y];
  9. 	int ltyp = lev->typ, cmap = -1;
  10. 	const char *dfeature = 0;
  11. 	static char altbuf[BUFSZ];
  12.  
  13. 	if (IS_DOOR(ltyp)) {
  14. 	    switch (lev->doormask) {
  15. 	    case D_NODOOR:	cmap = S_ndoor; break;	/* "doorway" */
  16. 	    case D_ISOPEN:	cmap = S_vodoor; break;	/* "open door" */
  17. 	    case D_BROKEN:	dfeature = "broken door"; break;
  18. 	    default:	cmap = S_vcdoor; break;	/* "closed door" */
  19. 	    }
  20. 	    /* override door description for open drawbridge */
  21. 	    if (is_drawbridge_wall(x, y) >= 0)
  22. 		dfeature = "open drawbridge portcullis",  cmap = -1;
  23. 	} else if (IS_FOUNTAIN(ltyp))
  24. 	    cmap = S_fountain;				/* "fountain" */
  25. 	else if (IS_THRONE(ltyp))
  26. 	    cmap = S_throne;				/* "opulent throne" */
  27. 	else if (is_lava(x,y))
  28. 	    cmap = S_lava;				/* "molten lava" */
  29. 	else if (is_ice(x,y))
  30. 	    cmap = S_ice;				/* "ice" */
  31. 	else if (is_pool(x,y))
  32. 	    dfeature = "pool of water";
  33. #ifdef SINKS
  34. 	else if (IS_SINK(ltyp))
  35. 	    cmap = S_sink;				/* "sink" */
  36. #endif
  37. 	else if (IS_ALTAR(ltyp)) {
  38. 	    Sprintf(altbuf, "altar to %s (%s)", a_gname(),
  39. 		    align_str(Amask2align(lev->altarmask & ~AM_SHRINE)));
  40. 	    dfeature = altbuf;
  41. 	} else if ((x == xupstair && y == yupstair) ||
  42. 		 (x == sstairs.sx && y == sstairs.sy && sstairs.up))
  43. 	    cmap = S_upstair;				/* "staircase up" */
  44. 	else if ((x == xdnstair && y == ydnstair) ||
  45. 		 (x == sstairs.sx && y == sstairs.sy && !sstairs.up))
  46. 	    cmap = S_dnstair;				/* "staircase down" */
  47. 	else if (x == xupladder && y == yupladder)
  48. 	    cmap = S_upladder;				/* "ladder up" */
  49. 	else if (x == xdnladder && y == ydnladder)
  50. 	    cmap = S_dnladder;				/* "ladder down" */
  51. 	else if (ltyp == DRAWBRIDGE_DOWN)
  52. 	    cmap = S_vodbridge;			/* "lowered drawbridge" */
  53. 	else if (ltyp == DBWALL)
  54. 	    cmap = S_vcdbridge;			/* "raised drawbridge" */
  55. 	else if (IS_GRAVE(ltyp))
  56. 	    cmap = S_grave;				/* "grave" */
  57. 	else if (ltyp == TREE)
  58. 	    cmap = S_tree;				/* "tree" */
  59. 	else if (ltyp == IRONBARS)
  60. 	    dfeature = "set of iron bars";
  61.  
  62. 	if (cmap >= 0) dfeature = defsyms[cmap].explanation;
  63. 	if (dfeature) Strcpy(buf, dfeature);
  64. 	return dfeature;
  65. }

look_here[edit]

  1. /* look at what is here; if there are many objects (5 or more),
  2. don't show them unless obj_cnt is 0 */
  3. int
  4. look_here(obj_cnt, picked_some)
  5. int obj_cnt;	/* obj_cnt > 0 implies that autopickup is in progess */
  6. boolean picked_some;
  7. {
  8. 	struct obj *otmp;
  9. 	struct trap *trap;
  10. 	const char *verb = Blind ? "feel" : "see";
  11. 	const char *dfeature = (char *)0;
  12. 	char fbuf[BUFSZ], fbuf2[BUFSZ];
  13. 	winid tmpwin;
  14. 	boolean skip_objects = (obj_cnt >= 5), felt_cockatrice = FALSE;
  15.  
  16. 	if (u.uswallow && u.ustuck) {
  17. 	    struct monst *mtmp = u.ustuck;
  18. 	    Sprintf(fbuf, "Contents of %s %s",
  19. 		s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH));
  20. 	    /* Skip "Contents of " by using fbuf index 12 */
  21. 	    You("%s to %s what is lying in %s.",
  22. 		Blind ? "try" : "look around", verb, &fbuf[12]);
  23. 	    otmp = mtmp->minvent;
  24. 	    if (otmp) {
  25. 		for ( ; otmp; otmp = otmp->nobj) {
  26. 			/* If swallower is an animal, it should have become stone but... */
  27. 			if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE);
  28. 		}
  29. 		if (Blind) Strcpy(fbuf, "You feel");
  30. 		Strcat(fbuf,":");
  31. 	    	(void) display_minventory(mtmp, MINV_ALL, fbuf);
  32. 	    } else {
  33. 		You("%s no objects here.", verb);
  34. 	    }
  35. 	    return(!!Blind);
  36. 	}
  37. 	if (!skip_objects && (trap = t_at(u.ux,u.uy)) && trap->tseen)
  38. 		There("is %s here.",
  39. 			an(defsyms[trap_to_defsym(trap->ttyp)].explanation));
  40.  
  41. 	otmp = level.objects[u.ux][u.uy];
  42. 	dfeature = dfeature_at(u.ux, u.uy, fbuf2);
  43. 	if (dfeature && !strcmp(dfeature, "pool of water") && Underwater)
  44. 		dfeature = 0;
  45.  
  46. 	if (Blind) {
  47. 		boolean drift = Is_airlevel(&u.uz) || Is_waterlevel(&u.uz);
  48. 		if (dfeature && !strncmp(dfeature, "altar ", 6)) {
  49. 		    /* don't say "altar" twice, dfeature has more info */
  50. 		    You("try to feel what is here.");
  51. 		} else {
  52. 		    You("try to feel what is %s%s.",
  53. 			drift ? "floating here" : "lying here on the ",
  54. 			drift ? ""		: surface(u.ux, u.uy));
  55. 		}
  56. 		if (dfeature && !drift && !strcmp(dfeature, surface(u.ux,u.uy)))
  57. 			dfeature = 0;		/* ice already identifed */
  58. 		if (!can_reach_floor()) {
  59. 			pline("But you can't reach it!");
  60. 			return(0);
  61. 		}
  62. 	}
  63.  
  64. 	if (dfeature)
  65. 		Sprintf(fbuf, "There is %s here.", an(dfeature));
  66.  
  67. 	if (!otmp || is_lava(u.ux,u.uy) || (is_pool(u.ux,u.uy) && !Underwater)) {
  68. 		if (dfeature) pline(fbuf);
  69. 		read_engr_at(u.ux, u.uy); /* Eric Backus */
  70. 		if (!skip_objects && (Blind || !dfeature))
  71. 		    You("%s no objects here.", verb);
  72. 		return(!!Blind);
  73. 	}
  74. 	/* we know there is something here */
  75.  
  76. 	if (skip_objects) {
  77. 	    if (dfeature) pline(fbuf);
  78. 	    read_engr_at(u.ux, u.uy); /* Eric Backus */
  79. 	    There("are %s%s objects here.",
  80. 		  (obj_cnt <= 10) ? "several" : "many",
  81. 		  picked_some ? " more" : "");
  82. 	} else if (!otmp->nexthere) {
  83. 	    /* only one object */
  84. 	    if (dfeature) pline(fbuf);
  85. 	    read_engr_at(u.ux, u.uy); /* Eric Backus */
  86. #ifdef INVISIBLE_OBJECTS
  87. 	    if (otmp->oinvis && !See_invisible) verb = "feel";
  88. #endif
  89. 	    You("%s here %s.", verb, doname(otmp));
  90. 	    if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE);
  91. 	} else {
  92. 	    display_nhwindow(WIN_MESSAGE, FALSE);
  93. 	    tmpwin = create_nhwindow(NHW_MENU);
  94. 	    if(dfeature) {
  95. 		putstr(tmpwin, 0, fbuf);
  96. 		putstr(tmpwin, 0, "");
  97. 	    }
  98. 	    putstr(tmpwin, 0, Blind ? "Things that you feel here:" :
  99. 				      "Things that are here:");
  100. 	    for ( ; otmp; otmp = otmp->nexthere) {
  101. 		if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) {
  102. 			char buf[BUFSZ];
  103. 			felt_cockatrice = TRUE;
  104. 			Strcpy(buf, doname(otmp));
  105. 			Strcat(buf, "...");
  106. 			putstr(tmpwin, 0, buf);
  107. 			break;
  108. 		}
  109. 		putstr(tmpwin, 0, doname(otmp));
  110. 	    }
  111. 	    display_nhwindow(tmpwin, TRUE);
  112. 	    destroy_nhwindow(tmpwin);
  113. 	    if (felt_cockatrice) feel_cockatrice(otmp, FALSE);
  114. 	    read_engr_at(u.ux, u.uy); /* Eric Backus */
  115. 	}
  116. 	return(!!Blind);
  117. }

dolook[edit]

  1. /* explicilty look at what is here, including all objects */
  2. int
  3. dolook()
  4. {
  5. 	return look_here(0, FALSE);
  6. }

will_feel_cockatrice[edit]

  1. boolean
  2. will_feel_cockatrice(otmp, force_touch)
  3. struct obj *otmp;
  4. boolean force_touch;
  5. {
  6. 	if ((Blind || force_touch) && !uarmg && !Stone_resistance &&
  7. 		(otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])))
  8. 			return TRUE;
  9. 	return FALSE;
  10. }

feel_cockatrice[edit]

  1. void
  2. feel_cockatrice(otmp, force_touch)
  3. struct obj *otmp;
  4. boolean force_touch;
  5. {
  6. 	char kbuf[BUFSZ];
  7.  
  8. 	if (will_feel_cockatrice(otmp, force_touch)) {
  9. 	    if(poly_when_stoned(youmonst.data))
  10. 			You("touched the %s corpse with your bare %s.",
  11. 				mons[otmp->corpsenm].mname, makeplural(body_part(HAND)));
  12. 	    else
  13. 			pline("Touching the %s corpse is a fatal mistake...",
  14. 				mons[otmp->corpsenm].mname);
  15. 		Sprintf(kbuf, "%s corpse", an(mons[otmp->corpsenm].mname));
  16. 		instapetrify(kbuf);
  17. 	}
  18. }
  19.  
  20. #endif /* OVLB */

stackobj[edit]

  1. #ifdef OVL1
  2.  
  3. void
  4. stackobj(obj)
  5. struct obj *obj;
  6. {
  7. 	struct obj *otmp;
  8.  
  9. 	for(otmp = level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere)
  10. 		if(otmp != obj && merged(&obj,&otmp))
  11. 			break;
  12. 	return;
  13. }

mergeable[edit]

  1. STATIC_OVL boolean
  2. mergable(otmp, obj)	/* returns TRUE if obj  & otmp can be merged */
  3. 	register struct obj *otmp, *obj;
  4. {
  5. 	if (obj->otyp != otmp->otyp) return FALSE;
  6. #ifdef GOLDOBJ
  7. 	/* coins of the same kind will always merge */
  8. 	if (obj->oclass == COIN_CLASS) return TRUE;
  9. #endif
  10. 	if (obj->unpaid != otmp->unpaid ||
  11. 	    obj->spe != otmp->spe || obj->dknown != otmp->dknown ||
  12. 	    (obj->bknown != otmp->bknown && !Role_if(PM_PRIEST)) ||
  13. 	    obj->cursed != otmp->cursed || obj->blessed != otmp->blessed ||
  14. 	    obj->no_charge != otmp->no_charge ||
  15. 	    obj->obroken != otmp->obroken ||
  16. 	    obj->otrapped != otmp->otrapped ||
  17. 	    obj->lamplit != otmp->lamplit ||
  18. #ifdef INVISIBLE_OBJECTS
  19. 		obj->oinvis != otmp->oinvis ||
  20. #endif
  21. 	    obj->greased != otmp->greased ||
  22. 	    obj->oeroded != otmp->oeroded ||
  23. 	    obj->oeroded2 != otmp->oeroded2 ||
  24. 	    obj->bypass != otmp->bypass)
  25. 	    return(FALSE);
  26.  
  27. 	if ((obj->oclass==WEAPON_CLASS || obj->oclass==ARMOR_CLASS) &&
  28. 	    (obj->oerodeproof!=otmp->oerodeproof || obj->rknown!=otmp->rknown))
  29. 	    return FALSE;
  30.  
  31. 	if (obj->oclass == FOOD_CLASS && (obj->oeaten != otmp->oeaten ||
  32. 					  obj->orotten != otmp->orotten))
  33. 	    return(FALSE);
  34.  
  35. 	if (obj->otyp == CORPSE || obj->otyp == EGG || obj->otyp == TIN) {
  36. 		if (obj->corpsenm != otmp->corpsenm)
  37. 				return FALSE;
  38. 	}
  39.  
  40. 	/* hatching eggs don't merge; ditto for revivable corpses */
  41. 	if ((obj->otyp == EGG && (obj->timed || otmp->timed)) ||
  42. 	    (obj->otyp == CORPSE && otmp->corpsenm >= LOW_PM &&
  43. 		is_reviver(&mons[otmp->corpsenm])))
  44. 	    return FALSE;
  45.  
  46. 	/* allow candle merging only if their ages are close */
  47. 	/* see begin_burn() for a reference for the magic "25" */
  48. 	if (Is_candle(obj) && obj->age/25 != otmp->age/25)
  49. 	    return(FALSE);
  50.  
  51. 	/* burning potions of oil never merge */
  52. 	if (obj->otyp == POT_OIL && obj->lamplit)
  53. 	    return FALSE;
  54.  
  55. 	/* don't merge surcharged item with base-cost item */
  56. 	if (obj->unpaid && !same_price(obj, otmp))
  57. 	    return FALSE;
  58.  
  59. 	/* if they have names, make sure they're the same */
  60. 	if ( (obj->onamelth != otmp->onamelth &&
  61. 		((obj->onamelth && otmp->onamelth) || obj->otyp == CORPSE)
  62. 	     ) ||
  63. 	    (obj->onamelth && otmp->onamelth &&
  64. 		    strncmp(ONAME(obj), ONAME(otmp), (int)obj->onamelth)))
  65. 		return FALSE;
  66.  
  67. 	/* for the moment, any additional information is incompatible */
  68. 	if (obj->oxlth || otmp->oxlth) return FALSE;
  69.  
  70. 	if(obj->oartifact != otmp->oartifact) return FALSE;
  71.  
  72. 	if(obj->known == otmp->known ||
  73. 		!objects[otmp->otyp].oc_uses_known) {
  74. 		return((boolean)(objects[obj->otyp].oc_merge));
  75. 	} else return(FALSE);
  76. }

doprgold[edit]

  1. int
  2. doprgold()
  3. {
  4. 	/* the messages used to refer to "carrying gold", but that didn't
  5. 	   take containers into account */
  6. #ifndef GOLDOBJ
  7. 	if(!u.ugold)
  8. 	    Your("wallet is empty.");
  9. 	else
  10. 	    Your("wallet contains %ld gold piece%s.", u.ugold, plur(u.ugold));
  11. #else
  12. long umoney = money_cnt(invent);
  13. 	if(!umoney)
  14. 	    Your("wallet is empty.");
  15. 	else
  16. 	    Your("wallet contains %ld %s.", umoney, currency(umoney));
  17. #endif
  18. 	shopper_financial_report();
  19. 	return 0;
  20. }
  21.  
  22. #endif /* OVL1 */

doprwep[edit]

  1. #ifdef OVLB
  2.  
  3. int
  4. doprwep()
  5. {
  6. if (!uwep) {
  7. 	You("are empty %s.", body_part(HANDED));
  8. } else {
  9. 	prinv((char *)0, uwep, 0L);
  10. 	if (u.twoweap) prinv((char *)0, uswapwep, 0L);
  11. }
  12. return 0;
  13. }

doprarm[edit]

  1. int
  2. doprarm()
  3. {
  4. 	if(!wearing_armor())
  5. 		You("are not wearing any armor.");
  6. 	else {
  7. #ifdef TOURIST
  8. 		char lets[8];
  9. #else
  10. 		char lets[7];
  11. #endif
  12. 		register int ct = 0;
  13.  
  14. #ifdef TOURIST
  15. 		if(uarmu) lets[ct++] = obj_to_let(uarmu);
  16. #endif
  17. 		if(uarm) lets[ct++] = obj_to_let(uarm);
  18. 		if(uarmc) lets[ct++] = obj_to_let(uarmc);
  19. 		if(uarmh) lets[ct++] = obj_to_let(uarmh);
  20. 		if(uarms) lets[ct++] = obj_to_let(uarms);
  21. 		if(uarmg) lets[ct++] = obj_to_let(uarmg);
  22. 		if(uarmf) lets[ct++] = obj_to_let(uarmf);
  23. 		lets[ct] = 0;
  24. 		(void) display_inventory(lets, FALSE);
  25. 	}
  26. 	return 0;
  27. }

doprring[edit]

  1. int
  2. doprring()
  3. {
  4. 	if(!uleft && !uright)
  5. 		You("are not wearing any rings.");
  6. 	else {
  7. 		char lets[3];
  8. 		register int ct = 0;
  9.  
  10. 		if(uleft) lets[ct++] = obj_to_let(uleft);
  11. 		if(uright) lets[ct++] = obj_to_let(uright);
  12. 		lets[ct] = 0;
  13. 		(void) display_inventory(lets, FALSE);
  14. 	}
  15. 	return 0;
  16. }

dopramulet[edit]

  1. int
  2. dopramulet()
  3. {
  4. 	if (!uamul)
  5. 		You("are not wearing an amulet.");
  6. 	else
  7. 		prinv((char *)0, uamul, 0L);
  8. 	return 0;
  9. }

tool_in_use[edit]

  1. STATIC_OVL boolean
  2. tool_in_use(obj)
  3. struct obj *obj;
  4. {
  5. 	if ((obj->owornmask & (W_TOOL
  6. #ifdef STEED
  7. 			| W_SADDLE
  8. #endif
  9. 			)) != 0L) return TRUE;
  10. 	if (obj->oclass != TOOL_CLASS) return FALSE;
  11. 	return (boolean)(obj == uwep || obj->lamplit ||
  12. 				(obj->otyp == LEASH && obj->leashmon));
  13. }

doprtool[edit]

  1. int
  2. doprtool()
  3. {
  4. 	struct obj *otmp;
  5. 	int ct = 0;
  6. 	char lets[52+1];
  7.  
  8. 	for (otmp = invent; otmp; otmp = otmp->nobj)
  9. 	    if (tool_in_use(otmp))
  10. 		lets[ct++] = obj_to_let(otmp);
  11. 	lets[ct] = '\0';
  12. 	if (!ct) You("are not using any tools.");
  13. 	else (void) display_inventory(lets, FALSE);
  14. 	return 0;
  15. }

doprinuse[edit]

  1. /* '*' command; combines the ')' + '[' + '=' + '"' + '(' commands;
  2. show inventory of all currently wielded, worn, or used objects */
  3. int
  4. doprinuse()
  5. {
  6. 	struct obj *otmp;
  7. 	int ct = 0;
  8. 	char lets[52+1];
  9.  
  10. 	for (otmp = invent; otmp; otmp = otmp->nobj)
  11. 	    if (is_worn(otmp) || tool_in_use(otmp))
  12. 		lets[ct++] = obj_to_let(otmp);
  13. 	lets[ct] = '\0';
  14. 	if (!ct) You("are not wearing or wielding anything.");
  15. 	else (void) display_inventory(lets, FALSE);
  16. 	return 0;
  17. }

useupf[edit]

  1. /*
  2. * uses up an object that's on the floor, charging for it as necessary
  3. */
  4. void
  5. useupf(obj, numused)
  6. register struct obj *obj;
  7. long numused;
  8. {
  9. 	register struct obj *otmp;
  10. 	boolean at_u = (obj->ox == u.ux && obj->oy == u.uy);
  11.  
  12. 	/* burn_floor_paper() keeps an object pointer that it tries to
  13. 	 * useupf() multiple times, so obj must survive if plural */
  14. 	if (obj->quan > numused)
  15. 		otmp = splitobj(obj, numused);
  16. 	else
  17. 		otmp = obj;
  18. 	if(costly_spot(otmp->ox, otmp->oy)) {
  19. 	    if(index(u.urooms, *in_rooms(otmp->ox, otmp->oy, 0)))
  20. 	        addtobill(otmp, FALSE, FALSE, FALSE);
  21. 	    else (void)stolen_value(otmp, otmp->ox, otmp->oy, FALSE, FALSE);
  22. 	}
  23. 	delobj(otmp);
  24. 	if (at_u && u.uundetected && hides_under(youmonst.data))
  25. 	    u.uundetected = OBJ_AT(u.ux, u.uy);
  26. }
  27.  
  28. #endif /* OVLB */

let_to_name[edit]

  1. #ifdef OVL1
  2.  
  3. /*
  4. * Conversion from a class to a string for printing.
  5. * This must match the object class order.
  6. */
  7. STATIC_VAR NEARDATA const char *names[] = { 0,
  8. 	"Illegal objects", "Weapons", "Armor", "Rings", "Amulets",
  9. 	"Tools", "Comestibles", "Potions", "Scrolls", "Spellbooks",
  10. 	"Wands", "Coins", "Gems", "Boulders/Statues", "Iron balls",
  11. 	"Chains", "Venoms"
  12. };
  13.  
  14. static NEARDATA const char oth_symbols[] = {
  15. 	CONTAINED_SYM,
  16. 	'\0'
  17. };
  18.  
  19. static NEARDATA const char *oth_names[] = {
  20. 	"Bagged/Boxed items"
  21. };
  22.  
  23. static NEARDATA char *invbuf = (char *)0;
  24. static NEARDATA unsigned invbufsiz = 0;
  25.  
  26. char *
  27. let_to_name(let,unpaid)
  28. char let;
  29. boolean unpaid;
  30. {
  31. 	const char *class_name;
  32. 	const char *pos;
  33. 	int oclass = (let >= 1 && let < MAXOCLASSES) ? let : 0;
  34. 	unsigned len;
  35.  
  36. 	if (oclass)
  37. 	    class_name = names[oclass];
  38. 	else if ((pos = index(oth_symbols, let)) != 0)
  39. 	    class_name = oth_names[pos - oth_symbols];
  40. 	else
  41. 	    class_name = names[0];
  42.  
  43. 	len = strlen(class_name) + (unpaid ? sizeof "unpaid_" : sizeof "");
  44. 	if (len > invbufsiz) {
  45. 	    if (invbuf) free((genericptr_t)invbuf);
  46. 	    invbufsiz = len + 10; /* add slop to reduce incremental realloc */
  47. 	    invbuf = (char *) alloc(invbufsiz);
  48. 	}
  49. 	if (unpaid)
  50. 	    Strcat(strcpy(invbuf, "Unpaid "), class_name);
  51. 	else
  52. 	    Strcpy(invbuf, class_name);
  53. 	return invbuf;
  54. }

free_invbuf[edit]

  1. void
  2. free_invbuf()
  3. {
  4. 	if (invbuf) free((genericptr_t)invbuf),  invbuf = (char *)0;
  5. 	invbufsiz = 0;
  6. }
  7.  
  8. #endif /* OVL1 */

reassign[edit]

  1. #ifdef OVLB
  2.  
  3. void
  4. reassign()
  5. {
  6. 	register int i;
  7. 	register struct obj *obj;
  8.  
  9. 	for(obj = invent, i = 0; obj; obj = obj->nobj, i++)
  10. 		obj->invlet = (i < 26) ? ('a'+i) : ('A'+i-26);
  11. 	lastinvnr = i;
  12. }
  13.  
  14. #endif /* OVLB */

doorganize[edit]

  1. #ifdef OVL1
  2.  
  3. int
  4. doorganize()	/* inventory organizer by Del Lamb */
  5. {
  6. 	struct obj *obj, *otmp;
  7. 	register int ix, cur;
  8. 	register char let;
  9. 	char alphabet[52+1], buf[52+1];
  10. 	char qbuf[QBUFSZ];
  11. 	char allowall[2];
  12. 	const char *adj_type;
  13.  
  14. 	if (!flags.invlet_constant) reassign();
  15. 	/* get a pointer to the object the user wants to organize */
  16. 	allowall[0] = ALL_CLASSES; allowall[1] = '\0';
  17. 	if (!(obj = getobj(allowall,"adjust"))) return(0);
  18.  
  19. 	/* initialize the list with all upper and lower case letters */
  20. 	for (let = 'a', ix = 0;  let <= 'z';) alphabet[ix++] = let++;
  21. 	for (let = 'A', ix = 26; let <= 'Z';) alphabet[ix++] = let++;
  22. 	alphabet[52] = 0;
  23.  
  24. 	/* blank out all the letters currently in use in the inventory */
  25. 	/* except those that will be merged with the selected object   */
  26. 	for (otmp = invent; otmp; otmp = otmp->nobj)
  27. 		if (otmp != obj && !mergable(otmp,obj)) {
  28. 			if (otmp->invlet <= 'Z')
  29. 				alphabet[(otmp->invlet) - 'A' + 26] = ' ';
  30. 			else	alphabet[(otmp->invlet) - 'a']	    = ' ';
  31. 		}
  32.  
  33. 	/* compact the list by removing all the blanks */
  34. 	for (ix = cur = 0; ix <= 52; ix++)
  35. 		if (alphabet[ix] != ' ') buf[cur++] = alphabet[ix];
  36.  
  37. 	/* and by dashing runs of letters */
  38. 	if(cur > 5) compactify(buf);
  39.  
  40. 	/* get new letter to use as inventory letter */
  41. 	for (;;) {
  42. 		Sprintf(qbuf, "Adjust letter to what [%s]?",buf);
  43. 		let = yn_function(qbuf, (char *)0, '\0');
  44. 		if(index(quitchars,let)) {
  45. 			pline(Never_mind);
  46. 			return(0);
  47. 		}
  48. 		if (let == '@' || !letter(let))
  49. 			pline("Select an inventory slot letter.");
  50. 		else
  51. 			break;
  52. 	}
  53.  
  54. 	/* change the inventory and print the resulting item */
  55. 	adj_type = "Moving:";
  56.  
  57. 	/*
  58. 	 * don't use freeinv/addinv to avoid double-touching artifacts,
  59. 	 * dousing lamps, losing luck, cursing loadstone, etc.
  60. 	 */
  61. 	extract_nobj(obj, &invent);
  62.  
  63. 	for (otmp = invent; otmp;)
  64. 		if (merged(&otmp,&obj)) {
  65. 			adj_type = "Merging:";
  66. 			obj = otmp;
  67. 			otmp = otmp->nobj;
  68. 			extract_nobj(obj, &invent);
  69. 		} else {
  70. 			if (otmp->invlet == let) {
  71. 				adj_type = "Swapping:";
  72. 				otmp->invlet = obj->invlet;
  73. 			}
  74. 			otmp = otmp->nobj;
  75. 		}
  76.  
  77. 	/* inline addinv (assuming flags.invlet_constant and !merged) */
  78. 	obj->invlet = let;
  79. 	obj->nobj = invent; /* insert at beginning */
  80. 	obj->where = OBJ_INVENT;
  81. 	invent = obj;
  82. 	reorder_invent();
  83.  
  84. 	prinv(adj_type, obj, 0L);
  85. 	update_inventory();
  86. 	return(0);
  87. }

invdisp_nothing[edit]

  1. /* common to display_minventory and display_cinventory */
  2. STATIC_OVL void
  3. invdisp_nothing(hdr, txt)
  4. const char *hdr, *txt;
  5. {
  6. 	winid win;
  7. 	anything any;
  8. 	menu_item *selected;
  9.  
  10. 	any.a_void = 0;
  11. 	win = create_nhwindow(NHW_MENU);
  12. 	start_menu(win);
  13. 	add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, hdr, MENU_UNSELECTED);
  14. 	add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
  15. 	add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, txt, MENU_UNSELECTED);
  16. 	end_menu(win, (char *)0);
  17. 	if (select_menu(win, PICK_NONE, &selected) > 0)
  18. 	    free((genericptr_t)selected);
  19. 	destroy_nhwindow(win);
  20. 	return;
  21. }

worn_wield_only[edit]

  1. /* query_objlist callback: return things that could possibly be worn/wielded */
  2. STATIC_OVL boolean
  3. worn_wield_only(obj)
  4. struct obj *obj;
  5. {
  6. return (obj->oclass == WEAPON_CLASS
  7. 		|| obj->oclass == ARMOR_CLASS
  8. 		|| obj->oclass == AMULET_CLASS
  9. 		|| obj->oclass == RING_CLASS
  10. 		|| obj->oclass == TOOL_CLASS);
  11. }

display_minventory[edit]

  1. /*
  2. * Display a monster's inventory.
  3. * Returns a pointer to the object from the monster's inventory selected
  4. * or NULL if nothing was selected.
  5. *
  6. * By default, only worn and wielded items are displayed.  The caller
  7. * can pick one.  Modifier flags are:
  8. *
  9. *	MINV_NOLET	- nothing selectable
  10. *	MINV_ALL	- display all inventory
  11. */
  12. struct obj *
  13. display_minventory(mon, dflags, title)
  14. register struct monst *mon;
  15. int dflags;
  16. char *title;
  17. {
  18. 	struct obj *ret;
  19. #ifndef GOLDOBJ
  20. 	struct obj m_gold;
  21. #endif
  22. 	char tmp[QBUFSZ];
  23. 	int n;
  24. 	menu_item *selected = 0;
  25. #ifndef GOLDOBJ
  26. 	int do_all = (dflags & MINV_ALL) != 0,
  27. 	    do_gold = (do_all && mon->mgold);
  28. #else
  29. 	int do_all = (dflags & MINV_ALL) != 0;
  30. #endif
  31.  
  32. 	Sprintf(tmp,"%s %s:", s_suffix(noit_Monnam(mon)),
  33. 		do_all ? "possessions" : "armament");
  34.  
  35. #ifndef GOLDOBJ
  36. 	if (do_all ? (mon->minvent || mon->mgold)
  37. #else
  38. 	if (do_all ? (mon->minvent != 0)
  39. #endif
  40. 		   : (mon->misc_worn_check || MON_WEP(mon))) {
  41. 	    /* Fool the 'weapon in hand' routine into
  42. 	     * displaying 'weapon in claw', etc. properly.
  43. 	     */
  44. 	    youmonst.data = mon->data;
  45.  
  46. #ifndef GOLDOBJ
  47. 	    if (do_gold) {
  48. 		/*
  49. 		 * Make temporary gold object and insert at the head of
  50. 		 * the mon's inventory.  We can get away with using a
  51. 		 * stack variable object because monsters don't carry
  52. 		 * gold in their inventory, so it won't merge.
  53. 		 */
  54. 		m_gold = zeroobj;
  55. 		m_gold.otyp = GOLD_PIECE;  m_gold.oclass = COIN_CLASS;
  56. 		m_gold.quan = mon->mgold;  m_gold.dknown = 1;
  57. 		m_gold.where = OBJ_FREE;
  58. 		/* we had better not merge and free this object... */
  59. 		if (add_to_minv(mon, &m_gold))
  60. 		    panic("display_minventory: static object freed.");
  61. 	    }
  62.  
  63. #endif
  64. 	    n = query_objlist(title ? title : tmp, mon->minvent, INVORDER_SORT, &selected,
  65. 			(dflags & MINV_NOLET) ? PICK_NONE : PICK_ONE,
  66. 			do_all ? allow_all : worn_wield_only);
  67.  
  68. #ifndef GOLDOBJ
  69. 	    if (do_gold) obj_extract_self(&m_gold);
  70. #endif
  71.  
  72. 	    set_uasmon();
  73. 	} else {
  74. 	    invdisp_nothing(title ? title : tmp, "(none)");
  75. 	    n = 0;
  76. 	}
  77.  
  78. 	if (n > 0) {
  79. 	    ret = selected[0].item.a_obj;
  80. 	    free((genericptr_t)selected);
  81. #ifndef GOLDOBJ
  82. 	    /*
  83. 	     * Unfortunately, we can't return a pointer to our temporary
  84. 	     * gold object.  We'll have to work out a scheme where this
  85. 	     * can happen.  Maybe even put gold in the inventory list...
  86. 	     */
  87. 	    if (ret == &m_gold) ret = (struct obj *) 0;
  88. #endif
  89. 	} else
  90. 	    ret = (struct obj *) 0;
  91. 	return ret;
  92. }

display_cinventory[edit]

  1. /*
  2. * Display the contents of a container in inventory style.
  3. * Currently, this is only used for statues, via wand of probing.
  4. */
  5. struct obj *
  6. display_cinventory(obj)
  7. register struct obj *obj;
  8. {
  9. 	struct obj *ret;
  10. 	char tmp[QBUFSZ];
  11. 	int n;
  12. 	menu_item *selected = 0;
  13.  
  14. 	Sprintf(tmp,"Contents of %s:", doname(obj));
  15.  
  16. 	if (obj->cobj) {
  17. 	    n = query_objlist(tmp, obj->cobj, INVORDER_SORT, &selected,
  18. 			    PICK_NONE, allow_all);
  19. 	} else {
  20. 	    invdisp_nothing(tmp, "(empty)");
  21. 	    n = 0;
  22. 	}
  23. 	if (n > 0) {
  24. 	    ret = selected[0].item.a_obj;
  25. 	    free((genericptr_t)selected);
  26. 	} else
  27. 	    ret = (struct obj *) 0;
  28. 	return ret;
  29. }

only_here[edit]

  1. /* query objlist callback: return TRUE if obj is at given location */
  2. static coord only;
  3.  
  4. STATIC_OVL boolean
  5. only_here(obj)
  6. struct obj *obj;
  7. {
  8. return (obj->ox == only.x && obj->oy == only.y);
  9. }

display_binventory[edit]

  1. /*
  2. * Display a list of buried items in inventory style.  Return a non-zero
  3. * value if there were items at that spot.
  4. *
  5. * Currently, this is only used with a wand of probing zapped downwards.
  6. */
  7. int
  8. display_binventory(x, y, as_if_seen)
  9. int x, y;
  10. boolean as_if_seen;
  11. {
  12. 	struct obj *obj;
  13. 	menu_item *selected = 0;
  14. 	int n;
  15.  
  16. 	/* count # of objects here */
  17. 	for (n = 0, obj = level.buriedobjlist; obj; obj = obj->nobj)
  18. 	    if (obj->ox == x && obj->oy == y) {
  19. 		if (as_if_seen) obj->dknown = 1;
  20. 		n++;
  21. 	    }
  22.  
  23. 	if (n) {
  24. 	    only.x = x;
  25. 	    only.y = y;
  26. 	    if (query_objlist("Things that are buried here:",
  27. 			      level.buriedobjlist, INVORDER_SORT,
  28. 			      &selected, PICK_NONE, only_here) > 0)
  29. 		free((genericptr_t)selected);
  30. 	    only.x = only.y = 0;
  31. 	}
  32. 	return n;
  33. }
  34.  
  35. #endif /* OVL1 */
  36.  
  37. /*invent.c*/