summaryrefslogtreecommitdiff
path: root/src/emap/pc.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-31 19:44:17 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-31 19:44:17 +0300
commit48ce547ec3ead9228f81404c7abf4ee99dbe2819 (patch)
tree20d0f2e21b729a7f59cece8b2c1102ca569bb166 /src/emap/pc.c
parent1a4218d46ecbed547be1a6849448bbfa3ef82bf3 (diff)
downloadevol-hercules-48ce547ec3ead9228f81404c7abf4ee99dbe2819.tar.gz
evol-hercules-48ce547ec3ead9228f81404c7abf4ee99dbe2819.tar.bz2
evol-hercules-48ce547ec3ead9228f81404c7abf4ee99dbe2819.tar.xz
evol-hercules-48ce547ec3ead9228f81404c7abf4ee99dbe2819.zip
Use VECTOR for allowed cards array.
Diffstat (limited to 'src/emap/pc.c')
-rw-r--r--src/emap/pc.c14
1 files changed, 10 insertions, 4 deletions
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;
}
}