From 48ce547ec3ead9228f81404c7abf4ee99dbe2819 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 Jul 2016 19:44:17 +0300 Subject: Use VECTOR for allowed cards array. --- src/emap/pc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/emap/pc.c') diff --git a/src/emap/pc.c b/src/emap/pc.c index 898ea28..8980662 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -462,17 +462,23 @@ bool epc_can_insert_card_into_post(bool retVal, if (!sd) return retVal; struct ItemdExt *data = itemd_get(sd->inventory_data[idx_equip]); - if (!data || !data->allowedCards[0].id) // allow cards if AllowedCards list is empty + if (!data) + return retVal; + + const int sz = VECTOR_LENGTH(data->allowedCards); + + if (sz == 0) // allow cards if AllowedCards list is empty return retVal; const int newCardId = sd->status.inventory[idx_card].nameid; int cardAmountLimit = 0; - for (f = 0; f < 100 && data->allowedCards[f].id; f ++) + for (f = 0; f < sz; f ++) { - if (data->allowedCards[f].id == newCardId) + struct ItemCardExt *const card = &VECTOR_INDEX(data->allowedCards, f); + if (card->id == newCardId) { - cardAmountLimit = data->allowedCards[f].amount; + cardAmountLimit = card->amount; break; } } -- cgit v1.2.3-70-g09d2