From baeacac7c2e48120dffcbb8660655c6b15aae5f1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 9 Jul 2018 23:39:16 +0300 Subject: Update packet ZC_PC_PURCHASE_ITEMLIST. --- src/map/clif.c | 30 +++++++++++++++++------------- src/map/packets_struct.h | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index c104194eb..17f108c18 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2093,12 +2093,13 @@ static void clif_buylist(struct map_session_data *sd, struct npc_data *nd) { struct npc_item_list *shop = NULL; unsigned short shop_size = 0; - int fd,i,c; + int fd, i, c, len; + struct PACKET_ZC_PC_PURCHASE_ITEMLIST *p; nullpo_retv(sd); nullpo_retv(nd); - if( nd->subtype == SCRIPT ) { + if (nd->subtype == SCRIPT) { shop = nd->u.scr.shop->item; shop_size = nd->u.scr.shop->items; } else { @@ -2108,26 +2109,29 @@ static void clif_buylist(struct map_session_data *sd, struct npc_data *nd) fd = sd->fd; - WFIFOHEAD(fd, 4 + shop_size * 11); - WFIFOW(fd,0) = 0xc6; + len = sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST) + shop_size * sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST_sub); + WFIFOHEAD(fd, len); + p = WFIFOP(fd, 0); + p->packetType = 0xc6; c = 0; - for( i = 0; i < shop_size; i++ ) { - if( shop[i].nameid ) { + for (i = 0; i < shop_size; i++) { + if (shop[i].nameid) { struct item_data* id = itemdb->exists(shop[i].nameid); int val = shop[i].value; - if( id == NULL ) + if (id == NULL) continue; - WFIFOL(fd, 4+c*11) = val; - WFIFOL(fd, 8+c*11) = pc->modifybuyvalue(sd,val); - WFIFOB(fd,12+c*11) = itemtype(id->type); - WFIFOW(fd,13+c*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; + p->items[c].price = val; + p->items[c].discountPrice = pc->modifybuyvalue(sd, val); + p->items[c].itemType = itemtype(id->type); + p->items[c].itemId = (id->view_id > 0) ? id->view_id : id->nameid; c++; } } - WFIFOW(fd,2) = 4 + c*11; - WFIFOSET(fd,WFIFOW(fd,2)); + len = sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST) + c * sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST_sub); + p->packetLength = len; + WFIFOSET(fd, len); } /// Presents list of items, that can be sold to an NPC shop (ZC_PC_SELL_ITEMLIST). diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 07cee8f34..2d6b3c4c4 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2248,6 +2248,23 @@ struct PACKET_ZC_PC_PURCHASE_MYITEMLIST { struct PACKET_ZC_PC_PURCHASE_MYITEMLIST_sub items[]; } __attribute__((packed)); +struct PACKET_ZC_PC_PURCHASE_ITEMLIST_sub { + uint32 price; + uint32 discountPrice; + uint8 itemType; +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; +#else + uint16 itemId; +#endif +} __attribute__((packed)); + +struct PACKET_ZC_PC_PURCHASE_ITEMLIST { + int16 packetType; + int16 packetLength; + struct PACKET_ZC_PC_PURCHASE_ITEMLIST_sub items[]; +} __attribute__((packed)); + #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) #endif // not NetBSD < 6 / Solaris -- cgit v1.2.3-60-g2f50