view arogue7/pack.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents 1cd604c827a3
children e1cd27c5464f
line wrap: on
line source

/*
 * pack.c - Routines to deal with the pack.
 *
 * Advanced Rogue
 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
 * All rights reserved.
 *
 * Based on "Rogue: Exploring the Dungeons of Doom"
 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
 * All rights reserved.
 *
 * See the file LICENSE.TXT for full copyright and licensing information.
 */

#include "curses.h"
#include <ctype.h>
#include <string.h>
#include "rogue.h"
#ifdef PC7300
#include "menu.h"
#endif

bool is_type (struct object *obj, int type);

/*
 * Routines to deal with the pack
 */

/*
 * add_pack:
 *	Pick up an object and add it to the pack.  If the argument is non-null
 * use it as the linked_list pointer instead of gettting it off the ground.
 */
bool
add_pack(struct linked_list *item, bool silent, struct linked_list **packret)
{
    register struct linked_list *ip, *lp = NULL, *ap;
    register struct object *obj, *op = NULL;
    register bool exact, from_floor;

    if (packret != NULL)
	*packret = NULL;

    if (item == NULL)
    {
	from_floor = TRUE;
	if ((item = find_obj(hero.y, hero.x)) == NULL)
	    return(FALSE);
    }
    else
	from_floor = FALSE;
    obj = OBJPTR(item);
    /*
     * If it is gold, just add its value to rogue's purse and get rid
     * of it.
     */
    if (obj->o_type == GOLD) {
	register struct linked_list *mitem;
	register struct thing *tp;

	if (!silent) {
	    if (!terse) addmsg("You found ");
	    msg("%d gold pieces.", obj->o_count);
	}

	/* First make sure no greedy monster is after this gold.
	 * If so, make the monster run after the rogue instead.
	 */
	 for (mitem = mlist; mitem != NULL; mitem = next(mitem)) {
	    tp = THINGPTR(mitem);
	    if (tp->t_dest == &obj->o_pos) tp->t_dest = &hero;
	}

	purse += obj->o_count;
	if (from_floor) {
	    detach(lvl_obj, item);
	    if ((ap = find_obj(hero.y, hero.x)) == NULL)
		mvaddch(hero.y,hero.x,(roomin(&hero)==NULL ? PASSAGE : FLOOR));
	    else 
		mvaddch(hero.y,hero.x,(OBJPTR(ap))->o_type);
	}
	o_discard(item);
	return(TRUE);
    }

    /*
     * see if he can carry any more weight
     */
    if (itemweight(obj) + pstats.s_pack > pstats.s_carry) {
	msg("Too much for you to carry.");
	return FALSE;
    }
    /*
     * Link it into the pack.  Search the pack for a object of similar type
     * if there isn't one, stuff it at the beginning, if there is, look for one
     * that is exactly the same and just increment the count if there is.
     * it  that.  Food is always put at the beginning for ease of access, but
     * is not ordered so that you can't tell good food from bad.  First check
     * to see if there is something in thr same group and if there is then
     * increment the count.
     */
    if (obj->o_group)
    {
	for (ip = pack; ip != NULL; ip = next(ip))
	{
	    op = OBJPTR(ip);
	    if (op->o_group == obj->o_group)
	    {
		/*
		 * Put it in the pack and notify the user
		 */
		op->o_count += obj->o_count;
		if (from_floor)
		{
		    detach(lvl_obj, item);
		    if ((ap = find_obj(hero.y, hero.x)) == NULL)
			mvaddch(hero.y,hero.x,
				(roomin(&hero)==NULL ? PASSAGE : FLOOR));
		    else 
			mvaddch(hero.y,hero.x,(OBJPTR(ap))->o_type);
		}
		o_discard(item);
		item = ip;
		goto picked_up;
	    }
	}
    }

    /*
     * Check for and deal with scare monster scrolls
     */
    if (obj->o_type == SCROLL && obj->o_which == S_SCARE)
	if (obj->o_flags & ISCURSED)
	{
	    msg("The scroll turns to dust as you pick it up.");
	    detach(lvl_obj, item);
	    if ((ap = find_obj(hero.y, hero.x)) == NULL)
		mvaddch(hero.y,hero.x,(roomin(&hero)==NULL ? PASSAGE : FLOOR));
	    else 
		mvaddch(hero.y,hero.x,(OBJPTR(ap))->o_type);
	    return(TRUE);
	}

    /*
     * Search for an object of the same type
     */
    exact = FALSE;
    for (ip = pack; ip != NULL; ip = next(ip))
    {
	op = OBJPTR(ip);
	if (obj->o_type == op->o_type)
	    break;
    }
    if (ip == NULL)
    {
	/*
	 * Put it at the end of the pack since it is a new type
	 */
	for (ip = pack; ip != NULL; ip = next(ip))
	{
	    op = OBJPTR(ip);
	    if (op->o_type != FOOD)
		break;
	    lp = ip;
	}
    }
    else
    {
	/*
	 * Search for an object which is exactly the same
	 */
	while (ip != NULL && op->o_type == obj->o_type)
	{
	    if (op->o_which == obj->o_which)
	    {
		exact = TRUE;
		break;
	    }
	    lp = ip;
	    if ((ip = next(ip)) == NULL)
		break;
	    op = OBJPTR(ip);
	}
    }
    /*
     * Check if there is room
     */
    if (ip == NULL || !exact || !ISMULT(obj->o_type)) {
	if (inpack == MAXPACK-1) {
	    msg(terse ? "No room." : "You can't carry anything else.");
	    return(FALSE);
	}
    }
    inpack++;
    if (from_floor)
    {
	detach(lvl_obj, item);
	if ((ap = find_obj(hero.y, hero.x)) == NULL)
	    mvaddch(hero.y,hero.x,(roomin(&hero)==NULL ? PASSAGE : FLOOR));
	else 
	    mvaddch(hero.y,hero.x,(OBJPTR(ap))->o_type);
    }
    if (ip == NULL)
    {
	/*
	 * Didn't find an exact match, just stick it here
	 */
	if (pack == NULL)
	    pack = item;
	else
	{
	    lp->l_next = item;
	    item->l_prev = lp;
	    item->l_next = NULL;
	}
    }
    else
    {
	/*
	 * If we found an exact match.  If it is food,
	 * increase the count, otherwise put it with its clones.
	 */
	if (exact && ISMULT(obj->o_type))
	{
	    op->o_count += obj->o_count;
	    inpack--;			/* adjust for previous addition */
	    o_discard(item);
	    item = ip;
	    goto picked_up;
	}
	if ((item->l_prev = prev(ip)) != NULL)
	    item->l_prev->l_next = item;
	else
	    pack = item;
	item->l_next = ip;
	ip->l_prev = item;
    }
picked_up:
    /*
     * Notify the user
     */
    obj = OBJPTR(item);
    if (!silent)
    {
	if (!terse)
	    addmsg("You now have ");
	msg("%s (%c)", inv_name(obj, !terse), pack_char(pack, obj));
    }

    /* Relics can do strange things when you pick them up */
    if (obj->o_type == RELIC) {
	switch (obj->o_which) {
	    /* the ankh of Heil gives you prayers */
	    case HEIL_ANKH:
		msg("The ankh welds itself into your hand.");
		if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN)
		    fuse(prayer_recovery, 0, SPELLTIME, AFTER);

	    /* A cloak must be worn. */
	    when EMORI_CLOAK:
		if (cur_armor != NULL || cur_misc[WEAR_CLOAK]) {
		    msg("The cloak insists you remove your current garments.");
		    if (!dropcheck(cur_armor != NULL ? cur_armor
						     : cur_misc[WEAR_CLOAK])) {
			pstats.s_hpt = -1;
			msg("The cloak constricts around you.");
			msg("It draws your life force from you!!! -- More --");
			wait_for(' ');
			death(D_RELIC);
		    }
		}
		if (obj->o_charges < 0) /* should never happen, but.... */
		    obj->o_charges = 0;
		if (obj->o_charges == 0)
			fuse(cloak_charge, obj, CLOAK_TIME, AFTER);

	    /* The amulet must be worn. */
	    when STONEBONES_AMULET:
	    case YENDOR_AMULET:
		if (cur_misc[WEAR_JEWEL]		|| 
		    cur_relic[STONEBONES_AMULET]	||
		    cur_relic[YENDOR_AMULET]) {
		        msg("You have an urge to remove your current amulet.");
		}
		if((cur_misc[WEAR_JEWEL] && !dropcheck(cur_misc[WEAR_JEWEL])) ||
		    cur_relic[STONEBONES_AMULET]			      ||
		    cur_relic[YENDOR_AMULET]) {
			pstats.s_hpt = -1;
			msg("The %s begins pulsing.", inv_name(obj, TRUE));
			msg("It fades away.... -- More --");
			wait_for(' ');
			death(D_RELIC);
		}
		msg("The %s welds itself into your chest.",inv_name(obj,TRUE));

	    /* The eye must be inserted in eye socket */
	    when EYE_VECNA:
		msg("The eye forces you to jam it into your eye socket!");
		pstats.s_hpt -= 75;
		if (pstats.s_hpt < 0) {
			msg ("The pain is too much for you! -- More --");
			wait_for(' ');
			death(D_RELIC);
		}
		waste_time();
		msg("The excrutiating pain slowly turns into a dull throb.");
		
	    when QUILL_NAGROM:
	        fuse(quill_charge,0,player.t_ctype==C_MAGICIAN ? 4 : 8,AFTER);

	    /* Weapons will insist on being wielded. */
	    when MUSTY_DAGGER:
	    case HRUGGEK_MSTAR:
	    case YEENOGHU_FLAIL:
	    case AXE_AKLAD:
		/* For the daggers start a fuse to change player to a thief. */
		/* and set a daemon to eat gold.			     */
		if (obj->o_which == MUSTY_DAGGER) {
		    fuse(changeclass, C_THIEF, roll(20, 20), AFTER);
		    if (purse > 0)
			msg("Your purse feels lighter");
		    else
			purse = 1; /* fudge to get right msg from eat_gold() */
		    eat_gold(obj);
		    start_daemon(eat_gold, obj, AFTER);
		}
		/* For the axe start a fuse to change player to a fighter. */
		if (obj->o_which == AXE_AKLAD)
		    fuse(changeclass, C_FIGHTER, roll(20, 20), AFTER);
		if (cur_weapon != NULL) {
		    msg("The artifact insists you release your current weapon.");
		    if (!dropcheck(cur_weapon)) {
			pstats.s_hpt = -1;
			msg("The artifact forces your weapon into your heart.");
			msg("It hums with satisfaction. -- More --");
			wait_for(' ');
			death(D_RELIC);
		    }
		}
		cur_weapon = obj;

	when SURTUR_RING:
		msg("The ring forces itself through your nose!");
		pstats.s_hpt -= 22;
		if (pstats.s_hpt < 0) {
			msg ("The pain is too much for you! -- More --");
			wait_for(' ');
			death(D_RELIC);
		}
		waste_time();
		turn_on(player, NOFIRE);
		msg("The pain slowly subsides.");
	otherwise:
		break;
	}
	cur_relic[obj->o_which]++;	/* Note that we have it */
    }

    updpack(FALSE, &player);
    if (packret != NULL)
	*packret = item;
    return(TRUE);
}

#ifdef PC7300
static menu_t Display;				/* The menu structure */
static mitem_t Dispitems[MAXPACK+1];		/* Info for each line */
static char Displines[MAXPACK+1][LINELEN+1];	/* The lines themselves */
#endif

/*
 * inventory:
 *	list what is in the pack
 */
bool
inventory(struct linked_list *list, int type)
{
    register struct object *obj;
    register char ch;
    register int n_objs, cnt, maxx, curx;
    char inv_temp[2*LINELEN+1];

    cnt = 0;
    n_objs = 0;
    for (ch = 'a'; list != NULL; ch++, list = next(list)) {
	obj = OBJPTR(list);
	if (!is_type(obj, type))
	    continue;
	switch (n_objs++) {
	    /*
	     * For the first thing in the inventory, just save the string
	     * in case there is only one.
	     */
	    case 0:
		sprintf(inv_temp, "%c) %s", ch, inv_name(obj, FALSE));
		break;
	    /*
	     * If there is more than one, clear the screen, print the
	     * saved message and fall through to ...
	     */
	    case 1:
		if (slow_invent)
		    msg(inv_temp);
		else
		{
		    wclear(hw);
		    waddstr(hw, inv_temp);
		    waddch(hw, '\n');

		    maxx = strlen(inv_temp);	/* Length of the listing */

#ifdef PC7300
		    /* Put it into the PC menu display */
		    strcpy(Displines[0], inv_temp);
		    Dispitems[0].mi_name = Displines[0];
		    Dispitems[0].mi_flags = 0;
		    Dispitems[0].mi_val = 0;
#endif
		}
	    /*
	     * Print the line for this object
	     */
	    default:
		if (ch > 'z')
		    ch = 'A';
		if (slow_invent)
		    msg("%c) %s", ch, inv_name(obj, FALSE));
		else {
		    if (++cnt >= lines - 2) { /* if bottom of screen */
			dbotline(hw, morestr);
			cnt = 0;
			wclear(hw);
		    }
		    sprintf(inv_temp, "%c) %s\n", ch, inv_name(obj, FALSE));
		    curx = strlen(inv_temp) - 1; /* Don't count new-line */
		    if (curx > maxx) maxx = curx;
		    waddstr(hw, inv_temp);
#ifdef PC7300
		    /* Put it into the PC menu display */
		    strcpy(Displines[n_objs-1], inv_temp);
		    Displines[n_objs-1][curx] = '\0'; /* Strip newline */
		    Dispitems[n_objs-1].mi_name = Displines[n_objs-1];
		    Dispitems[n_objs-1].mi_flags = 0;
		    Dispitems[n_objs-1].mi_val = 0;
#endif
		}
	}
    }
    if (n_objs == 0) {
	if (terse)
	    msg(type == ALL ? "Empty handed." :
			    "Nothing appropriate");
	else
	    msg(type == ALL ? "You are empty handed." :
			    "You don't have anything appropriate");
	return FALSE;
    }
    if (n_objs == 1) {
	msg(inv_temp);
	return TRUE;
    }
    if (!slow_invent)
    {
#ifdef PC7300
	/* Place an end marker for the items */
	Dispitems[n_objs].mi_name = 0;

	/* Set up the main menu structure */
	Display.m_label = "Inventory";
	Display.m_title = "Pack Contents";
	Display.m_prompt = "Press Cancl to continue.";
	Display.m_curptr = '\0';
	Display.m_markptr = '\0';
	Display.m_flags = 0;
	Display.m_selcnt = 0;
	Display.m_items = Dispitems;
	Display.m_curi = 0;

	/*
	 * Try to display the menu.  If we don't have a local terminal,
	 * the call will fail and we will just continue with the
	 * normal mode.
	 */
	if (menu(&Display) >= 0) return TRUE;
#endif
	waddstr(hw, spacemsg);
	curx = strlen(spacemsg);
	if (curx > maxx) maxx = curx;

	/*
	 * If we have fewer than half a screenful, don't clear the screen.
	 * Leave an extra blank line at the bottom and 3 blank columns
	 * to he right.
	 */
	if (menu_overlay && n_objs < lines / 2 + 2) {
	    over_win(cw, hw, n_objs + 2, maxx + 3, n_objs, curx, ' ');
	    return TRUE;
	}

	draw(hw);
	wait_for(' ');
	clearok(cw, TRUE);
	touchwin(cw);
    }
    return TRUE;
}

/*
 * picky_inven:
 *	Allow player to inventory a single item
 */
void
picky_inven(void)
{
    register struct linked_list *item;
    register char ch, mch;

    if (pack == NULL)
	msg("You aren't carrying anything");
    else if (next(pack) == NULL)
	msg("a) %s", inv_name(OBJPTR(pack), FALSE));
    else
    {
	msg(terse ? "Item: " : "Which item do you wish to inventory: ");
	mpos = 0;
	if ((mch = readchar()) == ESCAPE)
	{
	    msg("");
	    return;
	}

	/* Check for a special character */
	switch (mch) {
	    case FOOD:
	    case SCROLL:
	    case POTION:
	    case RING:
	    case STICK:
	    case RELIC:
	    case ARMOR:
	    case WEAPON:
	    case MM:
		msg("");
		if (get_item(pack, NULL, mch, FALSE, FALSE) == NULL) {
		    if (terse) msg("None in pack.");
		    else msg("You have no %c in your pack.", mch);
		}
		return;
	}

	for (ch = 'a', item = pack; item != NULL; item = next(item), ch++)
	    if (ch == mch)
	    {
		msg("%c) %s",ch,inv_name(OBJPTR(item), FALSE));
		return;
	    }
	if (!terse)
	    msg("'%s' not in pack.", unctrl(mch));
	msg("Range is 'a' to '%c'", --ch);
    }
}


/*
 * get_item:
 *	pick something out of a pack for a purpose
 *	purpose: NULL if we should be silent (no prompts)
 */
struct linked_list *
get_item(struct linked_list *list, char *purpose, int type, bool askfirst, 
         bool showcost)
{
    reg struct linked_list *item;
    reg struct object *obj;
    reg int cnt, pagecnt, ch, och, maxx, curx, confused;
    struct linked_list *saveitem = NULL;
    char description[2*LINELEN+1];
    char cost[LINELEN/2];
#ifdef PC7300
    int menucount = 0;
    int usemenu = 1;
#endif

    /*
     * If this is the player's pack and the player is confused, we
     * might just take anything.
     */
    if (list == player.t_pack && on(player, ISHUH) && rnd(100) < 75)
	confused = 1;
    else confused = 0;

    cnt = 0;
    if (list == NULL) {
	msg("You aren't carrying anything.");
	return NULL;
    }
    /* see if we have any of the type requested */
    for(ch = 'a',item = list ; item != NULL ; item = next(item), ch++) {
	obj = OBJPTR(item);
	if (is_type(obj, type)) {
	    cnt++;
	    saveitem = item;
	}
    }
    if (cnt == 0) {
	if (purpose) msg("Nothing to %s", purpose);
	after = FALSE;
	return NULL;
    }
    else if (cnt == 1) {	/* only found one of 'em */
	obj = OBJPTR(saveitem);
	while(TRUE)  {
	    if (purpose) {	/* Should we prompt the player? */
		msg("%s what (* for the item)?",purpose);
		ch = tolower(readchar());
	    }
	    else {
		ch = pack_char(list, obj);
		msg("%c) %s", ch, inv_name(obj,FALSE));
	    }

	    if (ch == '*') {
		mpos = 0;
		msg("%c) %s",pack_char(list, obj),inv_name(obj,FALSE));
		continue;
	    }
	    if (ch == ESCAPE) {
		msg("");
		after = FALSE;
		return NULL;
	    }
	    for(item = list,och = 'a'; item != NULL; item = next(item),och++) {
		if (ch == och) break;
		if (och == 'z') och = 'A' - 1;
	    }
	    if (item == NULL) {
		msg("Please specify a letter between 'a' and '%c'",
		    och == 'A' ? 'z' : och-1);
		continue;
	    }
	    if (is_type (OBJPTR(item), type)) {
		if (purpose) mpos = 0;
		return item;
	    }
	    else
		msg ("You can't %s that!", purpose);

	} 
    }
    while (TRUE) {
	if (!askfirst && purpose) {
	    msg("%s what? (* for list): ",purpose);
	    ch = readchar();
	}
	else ch = '*';

	mpos = 0;
	if (ch == ESCAPE) {		/* abort if escape hit */
	    after = FALSE;
	    msg("");		/* clear display */
	    return NULL;
	}

	if (ch == '*') {
	    wclear(hw);
	    pagecnt = 0;
	    maxx = 0;
	    for(item = list,ch = 'a'; item != NULL ; item = next(item), ch++) {
		obj = OBJPTR(item);
		if (!is_type(OBJPTR(item), type))
		    continue;
		cost[0] = '\0';
		if (showcost) {
		    sprintf(description, "[%d] ", get_worth(obj));
		    sprintf(cost, "%8.8s", description);
		}
		sprintf(description,"%c) %s%s\n\r",ch,cost,inv_name(obj,FALSE));
		waddstr(hw, description);
		curx = strlen(description) - 2;	/* Don't count \n or \r */
		if (maxx < curx) maxx = curx;
#ifdef PC7300
		if (usemenu) {
		    /* Put it into the PC menu display */
		    strcpy(Displines[menucount], description);
		    Displines[menucount][curx] = '\0'; /* Strip newline */
		    Dispitems[menucount].mi_name = Displines[menucount];
		    Dispitems[menucount].mi_flags = 0;
		    Dispitems[menucount++].mi_val = (int) item;
		}
#endif
		if (++pagecnt >= lines - 2 && next(item) != NULL) {
		    pagecnt = 0;
		    dbotline(hw, spacemsg);
		    wclear(hw);
		}
		if (ch == 'z') ch = 'A' - 1;
	    }

	    /* Put in the prompt */
	    if (purpose) sprintf(description, "%s what? ", purpose);
	    else strcpy(description, spacemsg);
	    waddstr(hw, description);
	    curx = strlen(description);
	    if (maxx < curx) maxx = curx;

#ifdef PC7300
	    if (usemenu) {
		/* Place an end marker for the items */
		Dispitems[menucount].mi_name = 0;

		/* Set up the main menu structure */
		Display.m_label = "Sub-Inventory";
		if (purpose) {
		    Display.m_title = description;
		    Display.m_prompt =
			"Select an item or press Cancl for no selection.";
		    Display.m_selcnt = 1;
		}
		else {
		    Display.m_title = 0;
		    Display.m_prompt = "Press Cancl to continue.";
		    Display.m_selcnt = 0;
		}
		Display.m_curptr = '\0';
		Display.m_markptr = '\0';
		Display.m_flags = 0;
		Display.m_items = Dispitems;
		Display.m_curi = 0;

		/*
		 * Try to display the menu.  If we don't have a local terminal,
		 * the call will fail and we will just continue with the
		 * normal mode.
		 */
		if (menu(&Display) >= 0) {
		    msg("");
		    if (Display.m_selcnt == 0) {
			/* Menu was cancelled */
			if (purpose) {
			    after = FALSE;
			    return NULL;	/* all done if abort */
			}
			else return saveitem;
		    }
		    else return (struct linked_list *) Display.m_curi->mi_val;
		}
		else {
		    usemenu = 0;	/* Can't use the menu facilities */
		}
	    }
#endif
	    /* Write the screen */
	    if ((menu_overlay && cnt < lines / 2 + 2) || cnt == 1) {
		over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, '\0');
		cnt = -1;	/* Indicate we used over_win */
	    }
	    else draw(hw);

	    if (purpose) {
		do {
		    ch = tolower(readchar());
		} until (isalpha(ch) || ch == ESCAPE);
	    }
	    else {
		ch = pack_char(list, OBJPTR(saveitem)); /* Pick a valid item */
		wait_for(' ');
	    }

	    /* Redraw original screen */
	    if (cnt < 0) {
		clearok(cw, FALSE);	/* Setup to redraw current screen */
		touchwin(cw);	/* clearing first */
	    }
	    else restscr(cw);

	    if(ch == ESCAPE) {
		after = FALSE;
		msg("");		/* clear top line */
		return NULL;	/* all done if abort */
	    }
	    /* ch has item to get from list */
	}

	for (item = list,och = 'a'; item != NULL; item = next(item),och++) {
	    if (confused) {
		/*
		 * Confused is incremented each time so that if the rnd(cnt)
		 * clause keeps failing, confused will equal cnt for the
		 * last item of the correct type and rnd(cnt) < cnt will
		 * have to be true.
		 */
		if (is_type(OBJPTR(item), type) && rnd(cnt) < confused++)
		    break;
	    }
	    else if (ch == och) break;
	    if (och == 'z') och = 'A' - 1;
	}

	if (item == NULL) {
	    msg("Please specify a letter between 'a' and '%c'",
		och == 'A' ? 'z' : och-1);
	    continue;
	}

	if (is_type(OBJPTR(item), type))
	    return (item);
	else
	    msg ("You can't %s that!", purpose);
    }
}

char
pack_char(struct linked_list *list, struct object *obj)
{
    register struct linked_list *item;
    register char c;

    c = 'a';
    for (item = list; item != NULL; item = next(item)) {
	if (OBJPTR(item) == obj)
	    return c;
	else {
	    if (c == 'z') c = 'A';
	    else c++;
	}
    }
    return 'z';
}


/*
 * cur_null:
 *	This updates cur_weapon etc for dropping things
 */
void
cur_null(struct object *op)
{
	if (op == cur_weapon)			cur_weapon = NULL;
	else if (op == cur_armor)		cur_armor = NULL;
	else if (op == cur_ring[LEFT_1])	cur_ring[LEFT_1] = NULL;
	else if (op == cur_ring[LEFT_2])	cur_ring[LEFT_2] = NULL;
	else if (op == cur_ring[LEFT_3])	cur_ring[LEFT_3] = NULL;
	else if (op == cur_ring[LEFT_4])	cur_ring[LEFT_4] = NULL;
	else if (op == cur_ring[RIGHT_1])	cur_ring[RIGHT_1] = NULL;
	else if (op == cur_ring[RIGHT_2])	cur_ring[RIGHT_2] = NULL;
	else if (op == cur_ring[RIGHT_3])	cur_ring[RIGHT_3] = NULL;
	else if (op == cur_ring[RIGHT_4])	cur_ring[RIGHT_4] = NULL;
	else if (op == cur_misc[WEAR_BOOTS])	cur_misc[WEAR_BOOTS] = NULL;
	else if (op == cur_misc[WEAR_JEWEL])	cur_misc[WEAR_JEWEL] = NULL;
	else if (op == cur_misc[WEAR_GAUNTLET]) cur_misc[WEAR_GAUNTLET] = NULL;
	else if (op == cur_misc[WEAR_CLOAK])	cur_misc[WEAR_CLOAK] = NULL;
	else if (op == cur_misc[WEAR_BRACERS])	cur_misc[WEAR_BRACERS] = NULL;
	else if (op == cur_misc[WEAR_NECKLACE]) cur_misc[WEAR_NECKLACE] = NULL;
}

/*
 * idenpack:
 *	Identify all the items in the pack
 */
void
idenpack(void)
{
	reg struct linked_list *pc;

	for (pc = pack ; pc != NULL ; pc = next(pc))
		whatis(pc);
}

bool
is_type (struct object *obj, int type)
{
    register bool current;

    if (type == obj->o_type)
	return (TRUE);

    switch (type) {
	case ALL:
	    return (TRUE);
	when READABLE:
	    if (obj->o_type == SCROLL ||
		(obj->o_type == MM && obj->o_which == MM_SKILLS))
		    return (TRUE);