diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-31 19:44:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-31 19:44:17 +0300 |
commit | 48ce547ec3ead9228f81404c7abf4ee99dbe2819 (patch) | |
tree | 20d0f2e21b729a7f59cece8b2c1102ca569bb166 /src/emap/itemdb.c | |
parent | 1a4218d46ecbed547be1a6849448bbfa3ef82bf3 (diff) | |
download | evol-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/itemdb.c')
-rw-r--r-- | src/emap/itemdb.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/emap/itemdb.c b/src/emap/itemdb.c index 0c2ca9d..3a90eab 100644 --- a/src/emap/itemdb.c +++ b/src/emap/itemdb.c @@ -9,6 +9,7 @@ #include "common/conf.h" #include "common/HPMi.h" +#include "common/db.h" #include "common/memmgr.h" #include "common/mmo.h" #include "common/socket.h" @@ -140,22 +141,27 @@ void eitemdb_readdb_additional_fields_pre(int *itemid, { int idx = 0; struct config_setting_t *it2 = NULL; - int cnt = 0; + int cnt = VECTOR_LENGTH(data->allowedCards); while ((it2 = libconfig->setting_get_elem(group, idx ++))) { const char *name = config_setting_name(it2); if (name && strncmp(name, "id", 2) && strncmp(name, "Id", 2)) continue; const int val = libconfig->setting_get_int(it2); + + VECTOR_ENSURE(data->allowedCards, cnt + 1, 1); + VECTOR_INSERTZEROED(data->allowedCards, cnt); + struct ItemCardExt *allowedCard = &VECTOR_INDEX(data->allowedCards, cnt); + if (name) { - data->allowedCards[cnt].id = atoi(name + 2); - data->allowedCards[cnt].amount = val; + allowedCard->id = atoi(name + 2); + allowedCard->amount = val; } else { - data->allowedCards[cnt].id = val; - data->allowedCards[cnt].amount = 1; + allowedCard->id = val; + allowedCard->amount = 1; } cnt ++; } |