summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-27 11:06:55 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-27 11:06:55 +0000
commitaf99be9bd11d716e0b8ef8eab4a36c9b9925e4c8 (patch)
tree45c74210524f6069f3cb6750744cb59af5031c30 /src/map/clif.c
parent8dedf18e168afd90230af1997edb593431b36e03 (diff)
downloadhercules-af99be9bd11d716e0b8ef8eab4a36c9b9925e4c8.tar.gz
hercules-af99be9bd11d716e0b8ef8eab4a36c9b9925e4c8.tar.bz2
hercules-af99be9bd11d716e0b8ef8eab4a36c9b9925e4c8.tar.xz
hercules-af99be9bd11d716e0b8ef8eab4a36c9b9925e4c8.zip
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
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c23
1 files changed, 15 insertions, 8 deletions
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;