diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-30 17:23:54 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-30 17:23:54 +0000 |
commit | 457f404245134d0a84d83d697111bf17fb68b0f4 (patch) | |
tree | 0ceaa9b19fba1c05ddb6e3e01c6efaf68879c3a4 | |
parent | 10b223a4bfb9c60bb8bc86f18feb69b7313d854b (diff) | |
download | hercules-457f404245134d0a84d83d697111bf17fb68b0f4.tar.gz hercules-457f404245134d0a84d83d697111bf17fb68b0f4.tar.bz2 hercules-457f404245134d0a84d83d697111bf17fb68b0f4.tar.xz hercules-457f404245134d0a84d83d697111bf17fb68b0f4.zip |
* Fixed improper use of itemdb_search. It does not return NULL but a dummy item, if the item id is invalid.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14642 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/map/atcommand.c | 8 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/npc.c | 2 | ||||
-rw-r--r-- | src/map/pet.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/storage.c | 3 |
7 files changed, 16 insertions, 13 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4549e41ca..2b5592929 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2010/12/30 + * Fixed improper use of itemdb_search. It does not return NULL but a dummy item, if the item id is invalid. [Ai4rei] 2010/12/29 * Made remaining csv databases (guild, castle, homunculus, itemdb, mercenary) use sv_readdb, where applicable (follow up to r14524, r14526 and r14532). [Ai4rei] - Few databases remain unchanged, which have either a custom layout or are otherwise incompatible with sv_readdb. diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 95b3dc33e..2747a8bfa 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6986,7 +6986,7 @@ ACMD_FUNC(mobinfo) strcpy(atcmd_output, " "); j = 0; for (i = 0; i < MAX_MOB_DROP; i++) { - if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL) + if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL) continue; if (item_data->slot) sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100); @@ -7009,7 +7009,7 @@ ACMD_FUNC(mobinfo) strcpy(atcmd_output, " MVP Items:"); j = 0; for (i = 0; i < 3; i++) { - if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL) + if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL) continue; if (mob->mvpitem[i].p > 0) { j++; @@ -8323,7 +8323,7 @@ ACMD_FUNC(itemlist) const struct item* it = &items[i]; struct item_data* itd; - if( it->nameid == 0 || (itd = itemdb_search(it->nameid)) == NULL ) + if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL ) continue; counter += it->amount; @@ -8406,7 +8406,7 @@ ACMD_FUNC(itemlist) { struct item_data* card; - if( it->card[j] == 0 || (card = itemdb_search(it->card[j])) == NULL ) + if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL ) continue; counter2++; diff --git a/src/map/clif.c b/src/map/clif.c index b640780a9..36b72788d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12586,7 +12586,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id) WFIFOL(fd,72) = 0; WFIFOL(fd,76) = msg->zeny; - if( item->nameid && (data = itemdb_search(item->nameid)) != NULL ) + if( item->nameid && (data = itemdb_exists(item->nameid)) != NULL ) { WFIFOL(fd,80) = item->amount; WFIFOW(fd,84) = (data->view_id)?data->view_id:item->nameid; @@ -12652,7 +12652,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) struct item_data *data; unsigned int weight; - if ((data = itemdb_search(sd->mail.inbox.msg[i].item.nameid)) == NULL) + if ((data = itemdb_exists(sd->mail.inbox.msg[i].item.nameid)) == NULL) return; switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) @@ -12865,7 +12865,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages, WFIFOL(fd,k) = auction.auction_id; safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH); - if( (item = itemdb_search(auction.item.nameid)) != NULL && item->view_id > 0 ) + if( (item = itemdb_exists(auction.item.nameid)) != NULL && item->view_id > 0 ) WFIFOW(fd,28+k) = item->view_id; else WFIFOW(fd,28+k) = auction.item.nameid; @@ -12926,7 +12926,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) return; } - if( (item = itemdb_search(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) ) + if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) ) { // Consumible or pets are not allowed clif_Auction_setitem(sd->fd, idx, true); return; @@ -13027,7 +13027,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) return; } - if( (item = itemdb_search(sd->status.inventory[sd->auction.index].nameid)) == NULL ) + if( (item = itemdb_exists(sd->status.inventory[sd->auction.index].nameid)) == NULL ) { // Just in case clif_Auction_message(fd, 2); // The auction has been canceled return; diff --git a/src/map/npc.c b/src/map/npc.c index 4b188c177..b8fd5712c 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1183,7 +1183,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( sd->state.trading ) return 4; - if( (item = itemdb_search(nameid)) == NULL ) + if( (item = itemdb_exists(nameid)) == NULL ) return 5; // Invalid Item ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid); diff --git a/src/map/pet.c b/src/map/pet.c index 843f1cc11..6af48f3dd 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -915,7 +915,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns struct flooritem_data *fitem = (struct flooritem_data *)target; if(pd->loot->count < pd->loot->max){ memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0])); - pd->loot->weight += itemdb_search(fitem->item_data.nameid)->weight*fitem->item_data.amount; + pd->loot->weight += itemdb_weight(fitem->item_data.nameid)*fitem->item_data.amount; map_clearflooritem(target->id); } //Target is unlocked regardless of whether it was picked or not. diff --git a/src/map/script.c b/src/map/script.c index 516bcee5a..5d9639d1b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12312,7 +12312,7 @@ BUILDIN_FUNC(autoequip) struct item_data *item_data; nameid=script_getnum(st,2); flag=script_getnum(st,3); - if(nameid>=500 && (item_data = itemdb_search(nameid)) != NULL){ + if(nameid>=500 && (item_data = itemdb_exists(nameid)) != NULL){ item_data->flag.autoequip = flag>0?1:0; } return 0; diff --git a/src/map/storage.c b/src/map/storage.c index eb64d3eb4..4eb1beb32 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -393,11 +393,12 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto nullpo_retr(1, sd); nullpo_retr(1, stor); nullpo_retr(1, item_data); - nullpo_retr(1, data = itemdb_search(item_data->nameid)); if(item_data->nameid <= 0 || amount <= 0) return 1; + data = itemdb_search(item_data->nameid); + if( !itemdb_canguildstore(item_data, pc_isGM(sd)) || item_data->expire_time ) { //Check if item is storable. [Skotlex] clif_displaymessage (sd->fd, msg_txt(264)); |