* 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://svn.code.sf.net/p/rathena/svn/trunk@14642 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
310d719f6e
commit
75ca2f146a
@ -1,5 +1,7 @@
|
|||||||
Date Added
|
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
|
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]
|
* 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.
|
- Few databases remain unchanged, which have either a custom layout or are otherwise incompatible with sv_readdb.
|
||||||
|
@ -6986,7 +6986,7 @@ ACMD_FUNC(mobinfo)
|
|||||||
strcpy(atcmd_output, " ");
|
strcpy(atcmd_output, " ");
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < MAX_MOB_DROP; i++) {
|
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;
|
continue;
|
||||||
if (item_data->slot)
|
if (item_data->slot)
|
||||||
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
|
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:");
|
strcpy(atcmd_output, " MVP Items:");
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < 3; i++) {
|
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;
|
continue;
|
||||||
if (mob->mvpitem[i].p > 0) {
|
if (mob->mvpitem[i].p > 0) {
|
||||||
j++;
|
j++;
|
||||||
@ -8323,7 +8323,7 @@ ACMD_FUNC(itemlist)
|
|||||||
const struct item* it = &items[i];
|
const struct item* it = &items[i];
|
||||||
struct item_data* itd;
|
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;
|
continue;
|
||||||
|
|
||||||
counter += it->amount;
|
counter += it->amount;
|
||||||
@ -8406,7 +8406,7 @@ ACMD_FUNC(itemlist)
|
|||||||
{
|
{
|
||||||
struct item_data* card;
|
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;
|
continue;
|
||||||
|
|
||||||
counter2++;
|
counter2++;
|
||||||
|
@ -12586,7 +12586,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
|
|||||||
WFIFOL(fd,72) = 0;
|
WFIFOL(fd,72) = 0;
|
||||||
WFIFOL(fd,76) = msg->zeny;
|
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;
|
WFIFOL(fd,80) = item->amount;
|
||||||
WFIFOW(fd,84) = (data->view_id)?data->view_id:item->nameid;
|
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;
|
struct item_data *data;
|
||||||
unsigned int weight;
|
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;
|
return;
|
||||||
|
|
||||||
switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) )
|
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;
|
WFIFOL(fd,k) = auction.auction_id;
|
||||||
safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
|
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;
|
WFIFOW(fd,28+k) = item->view_id;
|
||||||
else
|
else
|
||||||
WFIFOW(fd,28+k) = auction.item.nameid;
|
WFIFOW(fd,28+k) = auction.item.nameid;
|
||||||
@ -12926,7 +12926,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
|
|||||||
return;
|
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
|
{ // Consumible or pets are not allowed
|
||||||
clif_Auction_setitem(sd->fd, idx, true);
|
clif_Auction_setitem(sd->fd, idx, true);
|
||||||
return;
|
return;
|
||||||
@ -13027,7 +13027,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
|
|||||||
return;
|
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
|
{ // Just in case
|
||||||
clif_Auction_message(fd, 2); // The auction has been canceled
|
clif_Auction_message(fd, 2); // The auction has been canceled
|
||||||
return;
|
return;
|
||||||
|
@ -1183,7 +1183,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
|
|||||||
if( sd->state.trading )
|
if( sd->state.trading )
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
if( (item = itemdb_search(nameid)) == NULL )
|
if( (item = itemdb_exists(nameid)) == NULL )
|
||||||
return 5; // Invalid Item
|
return 5; // Invalid Item
|
||||||
|
|
||||||
ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid);
|
ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid);
|
||||||
|
@ -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;
|
struct flooritem_data *fitem = (struct flooritem_data *)target;
|
||||||
if(pd->loot->count < pd->loot->max){
|
if(pd->loot->count < pd->loot->max){
|
||||||
memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0]));
|
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);
|
map_clearflooritem(target->id);
|
||||||
}
|
}
|
||||||
//Target is unlocked regardless of whether it was picked or not.
|
//Target is unlocked regardless of whether it was picked or not.
|
||||||
|
@ -12312,7 +12312,7 @@ BUILDIN_FUNC(autoequip)
|
|||||||
struct item_data *item_data;
|
struct item_data *item_data;
|
||||||
nameid=script_getnum(st,2);
|
nameid=script_getnum(st,2);
|
||||||
flag=script_getnum(st,3);
|
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;
|
item_data->flag.autoequip = flag>0?1:0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -393,11 +393,12 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
|
|||||||
nullpo_retr(1, sd);
|
nullpo_retr(1, sd);
|
||||||
nullpo_retr(1, stor);
|
nullpo_retr(1, stor);
|
||||||
nullpo_retr(1, item_data);
|
nullpo_retr(1, item_data);
|
||||||
nullpo_retr(1, data = itemdb_search(item_data->nameid));
|
|
||||||
|
|
||||||
if(item_data->nameid <= 0 || amount <= 0)
|
if(item_data->nameid <= 0 || amount <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
data = itemdb_search(item_data->nameid);
|
||||||
|
|
||||||
if( !itemdb_canguildstore(item_data, pc_isGM(sd)) || item_data->expire_time )
|
if( !itemdb_canguildstore(item_data, pc_isGM(sd)) || item_data->expire_time )
|
||||||
{ //Check if item is storable. [Skotlex]
|
{ //Check if item is storable. [Skotlex]
|
||||||
clif_displaymessage (sd->fd, msg_txt(264));
|
clif_displaymessage (sd->fd, msg_txt(264));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user