Ejemplo n.º 1
0
/**
 * Destroy all {squelch}able items.
 *
 * Imported, with thanks, from Ey... much cleaner than the original.
 */
void squelch_items(void)
{
	int floor_list[MAX_FLOOR_STACK];
	int floor_num, n;
	int count = 0;

	object_type *o_ptr;

	/* Set the hook and scan the floor */
	item_tester_hook = squelch_item_ok;
	floor_num = scan_floor(floor_list, N_ELEMENTS(floor_list), p_ptr->py,
						   p_ptr->px, 0x01);

	if (floor_num) {
		for (n = 0; n < floor_num; n++) {
			o_ptr = &o_list[floor_list[n]];

			/* Avoid artifacts */
			if (artifact_p(o_ptr))
				continue;

			if (item_tester_okay(o_ptr)) {
				/* Destroy item */
				floor_item_increase(floor_list[n], -o_ptr->number);
				floor_item_optimize(floor_list[n]);
				count++;
			}
		}
	}

	/* Scan through the slots backwards */
	for (n = INVEN_PACK - 1; n >= 0; n--) {
		o_ptr = &p_ptr->inventory[n];

		/* Skip non-objects and artifacts */
		if (!o_ptr->k_idx)
			continue;
		if (artifact_p(o_ptr))
			continue;

		if (item_tester_okay(o_ptr)) {
			/* Destroy item */
			inven_item_increase(n, -o_ptr->number);
			inven_item_optimize(n);
			count++;
		}
	}

	item_tester_hook = NULL;

	/* Mention casualties */
	if (count > 0) {
		msgt(MSG_GENERIC, "%d item%s squelched.",
			 count, ((count > 1) ? "s" : ""));

		/* Combine/reorder the pack */
		p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);
	}
}
Ejemplo n.º 2
0
/*
 * Display the floor.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_floor(const int *floor_list, int floor_num, int mode)
{
	int i;

	object_type *o_ptr;

	int num_obj = 0;
	char labels[50][80];
	object_type *objects[50];

	if (floor_num > MAX_FLOOR_STACK) floor_num = MAX_FLOOR_STACK;

	/* Build the object list */
	for (i = 0; i < floor_num; i++)
	{
		o_ptr = object_byid(floor_list[i]);

		/* Tester always skips gold. When gold should be displayed,
		 * only test items that are not gold.
		 */
		if ((o_ptr->tval != TV_GOLD || !(mode & OLIST_GOLD)) &&
		    !item_tester_okay(o_ptr))
			continue;

		strnfmt(labels[num_obj], sizeof(labels[num_obj]),
		        "%c) ", index_to_label(i));

		/* Save the object */
		objects[num_obj] = o_ptr;
		num_obj++;
	}

	/* Display the object list */
	show_obj_list(num_obj, 0, labels, objects, mode);
}
Ejemplo n.º 3
0
/*
 * Display the inventory.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_inven(olist_detail_t mode)
{
	int i, last_slot = 0;
	int diff = weight_remaining();

	object_type *o_ptr;

   int num_obj = 0;
   char labels[50][80];
   object_type *objects[50];

   bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

	/* Include burden for term windows */
	if (in_term)
	{
		strnfmt(labels[num_obj], sizeof(labels[num_obj]),
		        "Burden %d.%d lb (%d.%d lb %s) ",
		        p_ptr->total_weight / 10, p_ptr->total_weight % 10,
		        abs(diff) / 10, abs(diff) % 10,
		        (diff < 0 ? "overweight" : "remaining"));

		objects[num_obj] = NULL;
		num_obj++;
	}

	/* Find the last occupied inventory slot */
	for (i = 0; i < INVEN_PACK; i++)
	{
		o_ptr = &p_ptr->inventory[i];
		if (o_ptr->k_idx) last_slot = i;
	}

	/* Build the object list */
	for (i = 0; i <= last_slot; i++)
	{
		o_ptr = &p_ptr->inventory[i];

		/* Acceptable items get a label */
		if (item_tester_okay(o_ptr))
			strnfmt(labels[num_obj], sizeof(labels[num_obj]), "%c) ", index_to_label(i));

		/* Unacceptable items are still displayed in term windows */
		else if (in_term)
			my_strcpy(labels[num_obj], "   ", sizeof(labels[num_obj]));

		/* Unacceptable items are skipped in the main window */
		else continue;

		/* Save the object */
		objects[num_obj] = o_ptr;
		num_obj++;
	}

	/* Display the object list */
	show_obj_list(num_obj, labels, objects, mode);
}
Ejemplo n.º 4
0
/*
 * Display the equipment.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_equip(int mode)
{
	int i, last_slot = 0;

	object_type *o_ptr;

	int num_obj = 0;
	char labels[50][80];
	object_type *objects[50];

	char tmp_val[80];

	bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;
	bool show_empty = (mode & OLIST_SEMPTY) ? TRUE : FALSE;

	/* Find the last equipment slot to display */
	for (i = INVEN_WIELD; i < ALL_INVEN_TOTAL; i++)
	{
		o_ptr = &p_ptr->inventory[i];
		if (i < INVEN_TOTAL || o_ptr->kind) last_slot = i;
	}

	/* Build the object list */
	for (i = INVEN_WIELD; i <= last_slot; i++)
	{
		o_ptr = &p_ptr->inventory[i];

		/* May need a blank line to separate the quiver */
		if (i == INVEN_TOTAL)
		{
			int j;
			bool need_spacer = FALSE;
			
			/* Scan the rest of the items for acceptable entries */
			for (j = i; j < last_slot; j++)
			{
				o_ptr = &p_ptr->inventory[j];
				if (item_tester_okay(o_ptr)) need_spacer = TRUE;
			}

			/* Add a spacer between equipment and quiver */
			if (num_obj > 0 && need_spacer)
			{
				my_strcpy(labels[num_obj], "", sizeof(labels[num_obj]));
				objects[num_obj] = NULL;
				num_obj++;
			}

			continue;
		}

		/* Acceptable items get a label */
		if (item_tester_okay(o_ptr))
			strnfmt(labels[num_obj], sizeof(labels[num_obj]), "%c) ", index_to_label(i));

		/* Unacceptable items are still sometimes shown */
		else if ((!o_ptr->kind && show_empty) || in_term)
			my_strcpy(labels[num_obj], "   ", sizeof(labels[num_obj]));

		/* Unacceptable items are skipped in the main window */
		else continue;

		/* Show full slot labels */
		strnfmt(tmp_val, sizeof(tmp_val), "%-14s: ", mention_use(i));
		my_strcat(labels[num_obj], tmp_val, sizeof(labels[num_obj]));

		/* Save the object */
		objects[num_obj] = o_ptr;
		num_obj++;
	}

	/* Display the object list */
	show_obj_list(num_obj, 0, labels, objects, mode);
}
Ejemplo n.º 5
0
/*
 * Display the equipment.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_equip(olist_detail_t mode)
{
	int i, last_slot = 0;

	object_type *o_ptr;

   int num_obj = 0;
   char labels[50][80];
   object_type *objects[50];

	char tmp_val[80];

   bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

	/* Find the last equipment slot to display */
	for (i = INVEN_WIELD; i < ALL_INVEN_TOTAL; i++)
	{
		o_ptr = &p_ptr->inventory[i];
		if (i < INVEN_TOTAL || o_ptr->k_idx) last_slot = i;
	}

	/* Build the object list */
	for (i = INVEN_WIELD; i <= last_slot; i++)
	{
		if (((i >= INVEN_WIELD) && (i < (INVEN_WIELD + rp_ptr->melee_slots)))
			|| ((i >= INVEN_BOW) && (i < (INVEN_BOW + rp_ptr->range_slots)))
			|| ((i >= INVEN_FINGER) && (i < (INVEN_FINGER + rp_ptr->ring_slots)))
			|| ((i >= INVEN_NECK) && (i < (INVEN_NECK + rp_ptr->amulet_slots)))
			|| ((i >= INVEN_LIGHT) && (i < (INVEN_LIGHT + rp_ptr->light_slots)))
			|| ((i >= INVEN_BODY) && (i < (INVEN_BODY + rp_ptr->body_slots)))
			|| ((i >= INVEN_OUTER) && (i < (INVEN_OUTER + rp_ptr->cloak_slots)))
			|| ((i >= INVEN_ARM) && (i < (INVEN_ARM + rp_ptr->shield_slots)))
			|| ((i >= INVEN_HEAD) && (i < (INVEN_HEAD + rp_ptr->helm_slots)))
			|| ((i >= INVEN_HANDS) && (i < (INVEN_HANDS + rp_ptr->glove_slots)))
			|| ((i >= INVEN_FEET) && (i < (INVEN_FEET + rp_ptr->boot_slots))))
		{
			o_ptr = &p_ptr->inventory[i];

			/* May need a blank line to separate the quiver */
			if (i == INVEN_TOTAL)
			{
				int j;
				bool need_spacer = FALSE;
				
				/* Scan the rest of the items for acceptable entries */
				for (j = i; j < last_slot; j++)
				{
					o_ptr = &p_ptr->inventory[j];
					if (item_tester_okay(o_ptr)) need_spacer = TRUE;
				}

				/* Add a spacer between equipment and quiver */
				if (num_obj > 0 && need_spacer)
				{
					my_strcpy(labels[num_obj], "", sizeof(labels[num_obj]));
					objects[num_obj] = NULL;
					num_obj++;
				}

				continue;
			}

			/* Acceptable items get a label */
			//if (item_tester_okay(o_ptr))
				strnfmt(labels[num_obj], sizeof(labels[num_obj]), "%c) ", index_to_label(num_obj));

			/* Unacceptable items are still displayed in term windows */
			//else if (in_term)
			//	my_strcpy(labels[num_obj], "   ", sizeof(labels[num_obj]));

			/* Unacceptable items are skipped in the main window */
			//else continue;

			/* Show full slot labels */
			if (TRUE)//OPT(show_labels))
			{
				strnfmt(tmp_val, sizeof(tmp_val), "%-14s: ", mention_use(i));
				my_strcat(labels[num_obj], tmp_val, sizeof(labels[num_obj]));
			}

			/* Otherwise only show short quiver labels */
			else if (i >= QUIVER_START)
			{
				strnfmt(tmp_val, sizeof(tmp_val), "[f%d]: ", i - QUIVER_START);
				my_strcat(labels[num_obj], tmp_val, sizeof(labels[num_obj]));
			}

			/* Save the object */
			objects[num_obj] = o_ptr;
			num_obj++;
		}
	}

	/* Display the object list */
	show_obj_list(num_obj, labels, objects, mode);
}
Ejemplo n.º 6
0
/* 
 * Build the object list.  Note that only the equipment has first non-zero. 
 */
static void build_obj_list(int first, int last, const int *floor_list, 
			   olist_detail_t mode)
{
    int i;
    object_type *o_ptr;
    bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

    need_spacer = FALSE;
    offset = 0;
    num_obj = 0;

    /* Clear the existing contents */
    for (i = 0; i < 50; i++)
    {
	items[i].object = NULL;
	items[i].index = 0;
	items[i].key = '\0';
	my_strcpy(items[i].label, "", sizeof(items[i].label));
    }

    /* Leave top line clear for inventory subwindow */
    if (!first && !floor_list && in_term) 
	offset = 1;
    
    for (i = first; i <= last; i++)
    {
	if (floor_list)
	    o_ptr = &o_list[floor_list[i]];
	else
	    o_ptr = &p_ptr->inventory[i];

	/* May need a blank line to separate equipment and quiver */
	if ((i == INVEN_TOTAL) && (first))
	{
	    int j;
	    
	    /* Scan the rest of the items for acceptable entries */
	    for (j = i; j <= last; j++)
	    {
		o_ptr = &p_ptr->inventory[j];
		if (item_tester_okay(o_ptr) || in_term) need_spacer = TRUE;
	    }

	    continue;
	}

	/* Tester always skips gold. When gold should be displayed,
	 * only test items that are not gold.
	 */
	if (((o_ptr->tval == TV_GOLD) && (mode & OLIST_GOLD)) ||
	    item_tester_okay(o_ptr)) 
	    strnfmt(items[num_obj].label, sizeof(items[num_obj].label), "%c) ", 
		    index_to_label(i));
		
	/* Unacceptable carried items are still displayed in term windows */
	else if ((in_term) && (!floor_list))
	    my_strcpy(items[num_obj].label, "   ", 
		      sizeof(items[num_obj].label));

	/* Unacceptable items are skipped in the main window */
	else continue;

	/* Special labels for equipment */
	if (first){
	    char tmp_val[80];

	    /* Show full slot labels */
	    if (OPT(show_labels))
	    {
		strnfmt(tmp_val, sizeof(tmp_val), "%-14s: ", mention_use(i));
		my_strcat(items[num_obj].label, tmp_val, 
			  sizeof(items[num_obj].label));
	    }

	    /* Otherwise only show short quiver labels */
	    else if (i >= QUIVER_START)
	    {
		strnfmt(tmp_val, sizeof(tmp_val), "[f%d]: ", i - QUIVER_START);
		my_strcat(items[num_obj].label, tmp_val, 
			  sizeof(items[num_obj].label));
	    }
	}

	/* Save the object */
	items[num_obj].object = o_ptr;
	items[num_obj].index = i;
	items[num_obj].key = (items[num_obj].label)[0];
	num_obj++;
    }
}