summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-18 10:36:09 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-18 10:36:09 +0000
commitad3c28295537a5d942809ca07cae49bc350c45ab (patch)
tree36ca2554405b41fcb8d279d85e1efe7ad76923ab /src/map/clif.c
parent16ef82dd78c2facf754e911fbaab1e5f279c50d4 (diff)
downloadhercules-ad3c28295537a5d942809ca07cae49bc350c45ab.tar.gz
hercules-ad3c28295537a5d942809ca07cae49bc350c45ab.tar.bz2
hercules-ad3c28295537a5d942809ca07cae49bc350c45ab.tar.xz
hercules-ad3c28295537a5d942809ca07cae49bc350c45ab.zip
* Replaced jA's way of allocating npc shop data with a simple dynamic array that gets allocated during loading and freed on unload
- automatically fixes bugreport:404, which would otherwise require manipulating the npcname_db (the original author didn't, hence the bug) - now a supporting variable 'count' is used for tracking the length instead of an extra dummy entry at the end of the shop list - partially removed the MAX_SHOPITEM restriction (if this was written properly, the system could support an unlimited amount of entries) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11753 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 4a393a332..360010406 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1700,29 +1700,26 @@ int clif_npcbuysell(struct map_session_data* sd, int id)
*------------------------------------------*/
int clif_buylist(struct map_session_data *sd, struct npc_data *nd)
{
- struct item_data *id;
- int fd,i,val;
+ int fd,i;
nullpo_retr(0, sd);
nullpo_retr(0, nd);
- fd=sd->fd;
+ fd = sd->fd;
WFIFOHEAD(fd, 200 * 11 + 4);
- WFIFOW(fd,0)=0xc6;
- for(i=0;nd->u.shop_item[i].nameid > 0;i++){
- id = itemdb_search(nd->u.shop_item[i].nameid);
- val=nd->u.shop_item[i].value;
- WFIFOL(fd,4+i*11)=val;
+ WFIFOW(fd,0) = 0xc6;
+ WFIFOW(fd,2) = 4 + nd->u.shop.count*11;
+ for( i = 0; i < nd->u.shop.count; i++ )
+ {
+ struct item_data* id = itemdb_search(nd->u.shop.shop_item[i].nameid);
+ int val = nd->u.shop.shop_item[i].value;
+ WFIFOL(fd,4+i*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);
- if (id->view_id > 0)
- WFIFOW(fd,13+i*11)=id->view_id;
- else
- WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
+ 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;
}
- WFIFOW(fd,2)=i*11+4;
WFIFOSET(fd,WFIFOW(fd,2));
return 0;