From af99be9bd11d716e0b8ef8eab4a36c9b9925e4c8 Mon Sep 17 00:00:00 2001 From: ultramage Date: Sun, 27 Apr 2008 11:06:55 +0000 Subject: Cleaning up the itemdb reload mess (see r12635, r12643, r12650, r12661, r12662, r12663) * the player data inventory-itemdb index is now refreshed using pc_setinventorydata() * mobdb will no longer initialize with nonexistent items, and mobs will no longer drop them in case of a reload * the clif_buylist() function once again hides invalid npc shop items * it is no longer possible to purchase nonexistent items from a npc shop * npc shop loading will not abort if there is a nonexistent item entry, it will just skip over it git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12665 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 55e9b1776..4e6637a5e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1389,26 +1389,32 @@ int clif_npcbuysell(struct map_session_data* sd, int id) *------------------------------------------*/ int clif_buylist(struct map_session_data *sd, struct npc_data *nd) { - int fd,i; + int fd,i,c; nullpo_retr(0, sd); nullpo_retr(0, nd); fd = sd->fd; - WFIFOHEAD(fd, 200 * 11 + 4); + WFIFOHEAD(fd, 4 + nd->u.shop.count * 11); WFIFOW(fd,0) = 0xc6; - WFIFOW(fd,2) = 4 + nd->u.shop.count*11; + + c = 0; for( i = 0; i < nd->u.shop.count; i++ ) { - struct item_data* id = itemdb_search(nd->u.shop.shop_item[i].nameid); + struct item_data* id = itemdb_exists(nd->u.shop.shop_item[i].nameid); int val = nd->u.shop.shop_item[i].value; - WFIFOL(fd,4+i*11) = val; + if( id == NULL ) + continue; + WFIFOL(fd, 4+c*11) = val; if (!id->flag.value_notdc) val = pc_modifybuyvalue(sd,val); - WFIFOL(fd,8+i*11) = val; - WFIFOB(fd,12+i*11) = itemtype(id->type); - WFIFOW(fd,13+i*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; + WFIFOL(fd, 8+c*11) = val; + WFIFOB(fd,12+c*11) = itemtype(id->type); + WFIFOW(fd,13+c*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; + c++; } + + WFIFOW(fd,2) = 4 + c*11; WFIFOSET(fd,WFIFOW(fd,2)); return 0; @@ -8838,6 +8844,7 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) fail = npc_buylist(sd,n,item_list); sd->npc_shopid = 0; //Clear shop data. + WFIFOHEAD(fd,packet_len(0xca)); WFIFOW(fd,0)=0xca; WFIFOB(fd,2)=fail; -- cgit v1.2.3-70-g09d2