diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-07-10 04:59:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-07-15 20:36:25 +0300 |
commit | 31d6cdc4cba0d8da14474c3120a2260b3f41d9f5 (patch) | |
tree | c40e7cef0425cdea5b0642035b586419b6cfdeb2 | |
parent | cc1aa52722516e2d903578faf214ddf85979feb8 (diff) | |
download | hercules-31d6cdc4cba0d8da14474c3120a2260b3f41d9f5.tar.gz hercules-31d6cdc4cba0d8da14474c3120a2260b3f41d9f5.tar.bz2 hercules-31d6cdc4cba0d8da14474c3120a2260b3f41d9f5.tar.xz hercules-31d6cdc4cba0d8da14474c3120a2260b3f41d9f5.zip |
Update packet ZC_PC_PURCHASE_ITEMLIST_FROMMC.
-rw-r--r-- | src/map/clif.c | 62 | ||||
-rw-r--r-- | src/map/packets_struct.h | 34 |
2 files changed, 59 insertions, 37 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 992525107..265757220 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6509,25 +6509,11 @@ static void clif_closevendingboard(struct block_list *bl, int fd) /// R 0800 <packet len>.W <owner id>.L <unique id>.L { <price>.L <amount>.W <index>.W <type>.B <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC2) static void clif_vendinglist(struct map_session_data *sd, unsigned int id, struct s_vending *vending_items) { - int i,fd; + int i, fd; int count; struct map_session_data* vsd; -#if PACKETVER < 20100105 - const int cmd = 0x133; - const int offset = 8; -#else - const int cmd = 0x800; - const int offset = 12; -#endif - -#if PACKETVER < 20150226 - const int item_length = 22; -// [4144] date 20160921 not confirmend. Can be bigger or smaller -#elif PACKETVER < 20160921 - const int item_length = 47; -#else - const int item_length = 53; -#endif + int len; + struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC *p; nullpo_retv(sd); nullpo_retv(vending_items); @@ -6535,37 +6521,39 @@ static void clif_vendinglist(struct map_session_data *sd, unsigned int id, struc fd = sd->fd; count = vsd->vend_num; + len = sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC) + count * sizeof(struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC_sub); - WFIFOHEAD(fd, offset+count*item_length); - WFIFOW(fd,0) = cmd; - WFIFOW(fd,2) = offset+count*item_length; - WFIFOL(fd,4) = id; + WFIFOHEAD(fd, len); + p = WFIFOP(fd, 0); + p->packetType = vendinglistType; + p->packetLength = len; + p->AID = id; #if PACKETVER >= 20100105 - WFIFOL(fd,8) = vsd->vender_id; + p->venderId = vsd->vender_id; #endif - for( i = 0; i < count; i++ ) { + for (i = 0; i < count; i++) { int index = vending_items[i].index; struct item_data* data = itemdb->search(vsd->status.cart[index].nameid); - WFIFOL(fd,offset+ 0+i*item_length) = vending_items[i].value; - WFIFOW(fd,offset+ 4+i*item_length) = vending_items[i].amount; - WFIFOW(fd,offset+ 6+i*item_length) = vending_items[i].index + 2; - WFIFOB(fd,offset+ 8+i*item_length) = itemtype(data->type); - WFIFOW(fd,offset+ 9+i*item_length) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid; - WFIFOB(fd,offset+11+i*item_length) = vsd->status.cart[index].identify; - WFIFOB(fd,offset+12+i*item_length) = vsd->status.cart[index].attribute; - WFIFOB(fd,offset+13+i*item_length) = vsd->status.cart[index].refine; - clif->addcards((struct EQUIPSLOTINFO*)WFIFOP(fd, offset + 14 + i * item_length), &vsd->status.cart[index]); + p->items[i].price = vending_items[i].value; + p->items[i].amount = vending_items[i].amount; + p->items[i].index = vending_items[i].index + 2; + p->items[i].itemType = itemtype(data->type); + p->items[i].itemId = (data->view_id > 0) ? data->view_id : vsd->status.cart[index].nameid; + p->items[i].identified = vsd->status.cart[index].identify; + p->items[i].damaged = vsd->status.cart[index].attribute; + p->items[i].refine = vsd->status.cart[index].refine; + clif->addcards(&p->items[i].slot, &vsd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd, offset + 22 + i * item_length), &vsd->status.cart[index]); + clif->add_item_options(&p->items[i].option_data[0], &vsd->status.cart[index]); #endif -// [4144] date 20160921 not confirmend. Can be bigger or smaller +// [4144] date 20160921 not confirmed. Can be bigger or smaller #if PACKETVER >= 20160921 - WFIFOL(fd, offset + 47 + i * item_length) = pc->item_equippoint(sd, data); - WFIFOW(fd, offset + 51 + i * item_length) = data->view_sprite; + p->items[i].location = pc->item_equippoint(sd, data); + p->items[i].viewSprite = data->view_sprite; #endif } - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOSET(fd, len); } /// Shop purchase failure (ZC_PC_PURCHASE_RESULT_FROMMC). diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 69bfa6f81..64a10e887 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2318,6 +2318,40 @@ struct PACKET_ZC_MYITEMLIST_BUYING_STORE { struct PACKET_ZC_MYITEMLIST_BUYING_STORE_sub items[]; } __attribute__((packed)); +struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC_sub { + uint32 price; + uint16 amount; + int16 index; + uint8 itemType; +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; +#else + uint16 itemId; +#endif + uint8 identified; + uint8 damaged; + uint8 refine; + struct EQUIPSLOTINFO slot; +#if PACKETVER >= 20150226 + struct ItemOptions option_data[MAX_ITEM_OPTIONS]; +#endif +// [4144] date 20160921 not confirmed. Can be bigger or smaller +#if PACKETVER >= 20160921 + uint32 location; + uint16 viewSprite; +#endif +} __attribute__((packed)); + +struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC { + int16 packetType; + int16 packetLength; + uint32 AID; +#if PACKETVER >= 20100105 + uint32 venderId; +#endif + struct PACKET_ZC_PC_PURCHASE_ITEMLIST_FROMMC_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 |