diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-07-06 02:07:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-07-15 20:36:17 +0300 |
commit | 6900b9087b83da2aa5a4ab62e8618499f7f4835f (patch) | |
tree | 72a4b5547b3627c8950cc27111bbe5a7f6759f79 | |
parent | b5059175f726b31e7d231523bb86a914e22fcfdf (diff) | |
download | hercules-6900b9087b83da2aa5a4ab62e8618499f7f4835f.tar.gz hercules-6900b9087b83da2aa5a4ab62e8618499f7f4835f.tar.bz2 hercules-6900b9087b83da2aa5a4ab62e8618499f7f4835f.tar.xz hercules-6900b9087b83da2aa5a4ab62e8618499f7f4835f.zip |
Update packet PACKET_ZC_USE_ITEM_ACK.
-rw-r--r-- | src/map/clif.c | 53 | ||||
-rw-r--r-- | src/map/packets_struct.h | 19 |
2 files changed, 42 insertions, 30 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 47f45157d..89164657d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3808,40 +3808,33 @@ static void clif_changeoption2(struct block_list *bl) /// 01c8 <index>.W <name id>.W <id>.L <amount>.W <result>.B (ZC_USE_ITEM_ACK2) static void clif_useitemack(struct map_session_data *sd, int index, int amount, bool ok) { + struct PACKET_ZC_USE_ITEM_ACK p; + int fd; + nullpo_retv(sd); - if(!ok) { - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xa8)); - WFIFOW(fd,0)=0xa8; - WFIFOW(fd,2)=index+2; - WFIFOW(fd,4)=amount; - WFIFOB(fd,6)=ok; - WFIFOSET(fd,packet_len(0xa8)); - } - else { -#if PACKETVER < 3 - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xa8)); - WFIFOW(fd,0)=0xa8; - WFIFOW(fd,2)=index+2; - WFIFOW(fd,4)=amount; - WFIFOB(fd,6)=ok; - WFIFOSET(fd,packet_len(0xa8)); -#else - unsigned char buf[32]; + if (index < 0 || index >= MAX_INVENTORY) + return; - WBUFW(buf,0)=0x1c8; - WBUFW(buf,2)=index+2; - if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) - WBUFW(buf,4)=sd->inventory_data[index]->view_id; - else - WBUFW(buf,4)=sd->status.inventory[index].nameid; - WBUFL(buf,6)=sd->bl.id; - WBUFW(buf,10)=amount; - WBUFB(buf,12)=ok; - clif->send(buf,packet_len(0x1c8),&sd->bl,AREA); + fd = sd->fd; + p.packetType = useItemAckType; + p.index = index + 2; +#if PACKETVER > 3 + if (sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) + p.itemId = sd->inventory_data[index]->view_id; + else + p.itemId = sd->status.inventory[index].nameid; + p.AID = sd->bl.id; #endif + p.amount = amount; + p.result = ok; + + if (!ok) { + WFIFOHEAD(fd, sizeof(p)); + memcpy(WFIFOP(fd, 0), &p, sizeof(p)); + WFIFOSET(fd, sizeof(p)); + } else { + clif->send(&p, sizeof(p), &sd->bl, AREA); } } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 028cefa99..b8abe0b23 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -380,6 +380,11 @@ enum packet_headers { #else authError = 0x6a, #endif +#if PACKETVER >= 3 + useItemAckType = 0x1c8, +#else + useItemAckType = 0xa8, +#endif }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1943,6 +1948,20 @@ struct PACKET_ZC_FEED_MER { #endif } __attribute__((packed)); +struct PACKET_ZC_USE_ITEM_ACK { + int16 packetType; + int16 index; +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; + uint32 AID; +#elif PACKETVER >= 3 + uint16 itemId; + uint32 AID; +#endif + int16 amount; + uint8 result; +} __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 |