From 74a30ea8d414cec9fba211298c72b2a686b0582a Mon Sep 17 00:00:00 2001 From: Lance Date: Sat, 1 Apr 2006 09:37:50 +0000 Subject: Fixed the dynamic shop system memory allocation and id_db problem. Added sample script. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5842 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 9 ++++----- src/map/npc.c | 4 ++-- src/map/script.c | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 9ce77129d..1f51506b1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8974,7 +8974,6 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) n = (RFIFOW(fd,2)-4) /4; item_list = (unsigned short*)RFIFOP(fd,4); - if (sd->trade_partner || !sd->npc_shopid){ fail = 1; }else{ @@ -8983,8 +8982,8 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) for(i=0;inpc_shopid))->master_nd)){ sprintf(npc_ev, "%s::OnSellItem", nd->exname); for(i=0;istatus.inventory[item_list[i*2]-2].nameid); + setd_sub(sd, "@sold_quantity", i, (void *)item_list[i*2+1]); } + npc_event(sd, npc_ev, 0); fail = 0; }else{ fail = npc_selllist(sd,n,item_list); diff --git a/src/map/npc.c b/src/map/npc.c index d1a35ff61..eaed2bdee 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2766,14 +2766,14 @@ int do_init_npc(void) return 0; } // [Lance] - int npc_changename(const char *name, const char *newname, short look){ +int npc_changename(const char *name, const char *newname, short look){ struct npc_data *nd= (struct npc_data *) strdb_remove(npcname_db,(unsigned char*)name); if (nd==NULL) return 0; npc_enable(name,0); strcpy(nd->name,newname); nd->class_ = look; - strdb_put(npcname_db,nd->name,nd); npc_enable(newname,1); return 0; } + diff --git a/src/map/script.c b/src/map/script.c index fdae52784..204922fa5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9871,7 +9871,9 @@ int buildin_npcshopitem(struct script_state *st) } nd = (struct npc_data *)aRealloc(nd,sizeof(struct npc_data) + - sizeof(nd->u.shop_item[0]) * n); + sizeof(nd->u.shop_item[0]) * (n+1)); + + map_addiddb(&nd->bl); nd->master_nd = ((struct npc_data *)map_id2bl(st->oid)); } else { -- cgit v1.2.3-70-g09d2