Ejemplo n.º 1
0
/**
 * Match slays in flags against a chosen flag mask
 *
 * count is the number of matches
 * \param flags is the flagset to analyse for matches
 * \param mask is the flagset against which to test
 * \param desc is the array of descriptions of matching slays - can be null
 * \param brand is the array of descriptions of brands - can be null
 * \param mult is the array of multipliers of those slays - can be null
 * \param dedup is whether or not to remove duplicates
 *
 * desc[], brand[] and mult[] must be >= SL_MAX in size
 */
int list_slays(const bitflag flags[OF_SIZE], const bitflag mask[OF_SIZE],
	const char *desc[], const char *brand[], int mult[], bool dedup)
{
	int i, count = 0;
	bitflag f[OF_SIZE];

	/* We are only interested in the flags specified in mask */
	of_copy(f, flags);
	of_inter(f, mask);

	/* Remove "duplicate" flags if desired */
	if (dedup) dedup_slays(f);

	/* Collect slays */
	for (i = 0; i < SL_MAX; i++) {
		const struct slay *s_ptr = &slay_table[i];
		if (of_has(f, s_ptr->object_flag)) {
			if (mult)
				mult[count] = s_ptr->mult;
			if (brand)
				brand[count] = s_ptr->brand;
			if (desc)
				desc[count] = s_ptr->desc;
			count++;
		}
	}

	return count;
}
Ejemplo n.º 2
0
/**
 * Check item flags for legality. This function currently does three things:
 *  - checks slay_table for slay & brand contradictions (dedup_slays)
 *  - checks gf_table for imm/res/vuln contradictions (dedup_gf_flags)
 *  - removes all attrs from ammo except slays/brands/ignore/hates
 */
void check_flags(object_type *o_ptr)
{
	bitflag f[OF_SIZE];
	int i;

	dedup_slays(o_ptr->flags);

	dedup_gf_flags(o_ptr->flags);

	if (kind_is_ammo(o_ptr->tval)) {
		create_mask(f, FALSE, OFT_SLAY, OFT_BRAND, OFT_KILL, OFT_IGNORE,
			OFT_HATES, OFT_INT, OFT_MAX);
		of_inter(o_ptr->flags, f);
		for (i = 0; i < MAX_PVALS; i++)
			of_wipe(o_ptr->pval_flags[i]);
		o_ptr->num_pvals = 0;
		o_ptr->ac = 0;
		o_ptr->to_a = 0;
	}

	return;
}