Esempio n. 1
0
// Searches for all items in a buyingstore, that match given ids, price and possible cards.
// @return Whether or not the search should be continued.
bool buyingstore_searchall(struct map_session_data *sd, const struct s_search_store_search *s)
{
	unsigned int i, idx;
	struct s_buyingstore_item *it;

	nullpo_retr(false, sd);

	if( !sd->state.buyingstore ) // Not buying
		return true;

	for( idx = 0; idx < s->item_count; idx++ ) {
		ARR_FIND(0, sd->buyingstore.slots, i, sd->buyingstore.items[i].nameid == s->itemlist[idx] && sd->buyingstore.items[i].amount);
		if( i == sd->buyingstore.slots ) // Not found
			continue;

		it = &sd->buyingstore.items[i];

		if( s->min_price && s->min_price > (unsigned int)it->price ) // Too low price
			continue;

		if( s->max_price && s->max_price < (unsigned int)it->price ) // Too high price
			continue;

		if( s->card_count ) { // Ignore cards, as there cannot be any
			;
		}

		// Result set full
		if( !searchstore_result(s->search_sd, sd->buyer_id, sd->status.account_id, sd->message,
			it->nameid, it->amount, it->price, buyingstore_blankslots, 0) )
			return false;
	}

	return true;
}
Esempio n. 2
0
/**
 * Searches for all items in a vending, that match given ids, price and possible cards.
 * @param sd : The vender session to search into
 * @param s : parameter of the search (see s_search_store_search)
 * @return Whether or not the search should be continued.
 */
bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s) {
	int i, c, slot;
	unsigned int idx, cidx;
	struct item* it;

	if( !sd->state.vending ) // not vending
		return true;

	for( idx = 0; idx < s->item_count; idx++ ) {
		ARR_FIND( 0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == (short)s->itemlist[idx] );
		if( i == sd->vend_num ) {// not found
			continue;
		}
		it = &sd->status.cart[sd->vending[i].index];

		if( s->min_price && s->min_price > sd->vending[i].value ) {// too low price
			continue;
		}

		if( s->max_price && s->max_price < sd->vending[i].value ) {// too high price
			continue;
		}

		if( s->card_count ) {// check cards
			if( itemdb_isspecial(it->card[0]) ) {// something, that is not a carded
				continue;
			}
			slot = itemdb_slot(it->nameid);

			for( c = 0; c < slot && it->card[c]; c ++ ) {
				ARR_FIND( 0, s->card_count, cidx, s->cardlist[cidx] == it->card[c] );
				if( cidx != s->card_count )
				{// found
					break;
				}
			}

			if( c == slot || !it->card[c] ) {// no card match
				continue;
			}
		}

		if( !searchstore_result(s->search_sd, sd->vender_id, sd->status.account_id, sd->message, it->nameid, sd->vending[i].amount, sd->vending[i].value, it->card, it->refine) )
		{// result set full
			return false;
		}
	}

	return true;
}