diff options
author | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-01 07:29:54 +0000 |
---|---|---|
committer | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-01 07:29:54 +0000 |
commit | a41884fbb032359e4f0bfcdaee50acb749ed8862 (patch) | |
tree | 3320f97861c84c9fb20a9bb6422f60633d3edb1a /src/map/clif.c | |
parent | 436240246bcf3f5368b08f709e1c0774f1f98607 (diff) | |
download | hercules-a41884fbb032359e4f0bfcdaee50acb749ed8862.tar.gz hercules-a41884fbb032359e4f0bfcdaee50acb749ed8862.tar.bz2 hercules-a41884fbb032359e4f0bfcdaee50acb749ed8862.tar.xz hercules-a41884fbb032359e4f0bfcdaee50acb749ed8862.zip |
* Dynamic shops support with script callback. (needs testing)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5841 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 8705b30bf..9ce77129d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8965,17 +8965,31 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd) */
void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
{
- int fail=0,n;
+ int fail=0,n, i;
unsigned short *item_list;
+ unsigned char npc_ev[51];
+ struct npc_data *nd;
RFIFOHEAD(fd);
n = (RFIFOW(fd,2)-4) /4;
item_list = (unsigned short*)RFIFOP(fd,4);
- if (sd->trade_partner || !sd->npc_shopid)
+
+ if (sd->trade_partner || !sd->npc_shopid){
fail = 1;
- else
- fail = npc_buylist(sd,n,item_list);
+ }else{
+ if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){
+ sprintf(npc_ev, "%s::OnBuyItem", nd->exname);
+ for(i=0;i<n;i++){
+ setd_sub(sd, "@bought_nameid", i, (void *)item_list[i*2+1]);
+ setd_sub(sd, "@bought_quantity", i, (void *)item_list[i*2]);
+ npc_event(sd, npc_ev, 0);
+ }
+ fail = 0;
+ }else{
+ fail = npc_buylist(sd,n,item_list);
+ }
+ }
sd->npc_shopid = 0; //Clear shop data.
WFIFOHEAD(fd,packet_len_table[0xca]);
@@ -8990,17 +9004,30 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) */
void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
{
- int fail=0,n;
+ int fail=0,n,i;
unsigned short *item_list;
+ unsigned char npc_ev[51];
+ struct npc_data *nd;
RFIFOHEAD(fd);
n = (RFIFOW(fd,2)-4) /4;
item_list = (unsigned short*)RFIFOP(fd,4);
- if (sd->trade_partner || !sd->npc_shopid)
+ if (sd->trade_partner || !sd->npc_shopid){
fail = 1;
- else
- fail = npc_selllist(sd,n,item_list);
+ }else{
+ if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){
+ sprintf(npc_ev, "%s::OnSellItem", nd->exname);
+ for(i=0;i<n;i++){
+ setd_sub(sd, "@sold_nameid", i, (void *)item_list[i*2+1]);
+ setd_sub(sd, "@sold_quantity", i, (void *)item_list[i*2]);
+ npc_event(sd, npc_ev, 0);
+ }
+ fail = 0;
+ }else{
+ fail = npc_selllist(sd,n,item_list);
+ }
+ }
sd->npc_shopid = 0; //Clear shop data.
WFIFOHEAD(fd,packet_len_table[0xcb]);
|