Пример #1
0
/// Searches for all items in a vending, that match given ids, price and possible cards.
/// @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;
}
Пример #2
0
/// Searches for all items in a vending, that match given ids, price and possible cards.
/// @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 ) // não vendendo
		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 ) {// não econtrado
			continue;
		}
		it = &sd->status.cart[sd->vending[i].index];

		if( s->min_price && s->min_price > sd->vending[i].value ) {// preço muito baixo
			continue;
		}

		if( s->max_price && s->max_price < sd->vending[i].value ) {// preço muito alto
			continue;
		}

		if( s->card_count ) {// checa cartas
			if( itemdb_isspecial(it->card[0]) ) {// alguma coisa, que não é uma carta
				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 )
				{// encontrado
					break;
				}
			}

			if( c == slot || !it->card[c] ) {// nenhuma carta equivalente
				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) )
		{// resulta conjunto completo
			return false;
		}
	}

	return true;
}
Пример #3
0
int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int))
{
	struct item_data* item_data = itemdb_search(item->nameid);
	int i;

	if (!func(item_data, gmlv, gmlv2))
		return 0;
	
	if(item_data->slot == 0 || itemdb_isspecial(item->card[0]))
		return 1;
	
	for(i = 0; i < item_data->slot; i++) {
		if (!item->card[i]) continue;
		if (!func(itemdb_search(item->card[i]), gmlv, gmlv2))
			return 0;
	}
	return 1;
}