From 2f2ceeb24b8d469b98b410772563731d5921e470 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Jul 2018 05:31:10 +0300 Subject: Add packet struct ZC_ADD_ITEM_TO_STORE and update packet for latest RE client. --- src/map/clif.c | 33 +++++++++++++++++---------------- src/map/packets_struct.h | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+), 16 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index e6aadc80f..6723cbe9f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4311,31 +4311,32 @@ static void clif_updatestorageamount(struct map_session_data *sd, int amount, in /// 01c4 .W .L .W .B .B .B .B .W .W .W .W (ZC_ADD_ITEM_TO_STORE2) static void clif_storageitemadded(struct map_session_data *sd, struct item *i, int index, int amount) { - int view,fd; - int offset = 0; + int view, fd; + struct PACKET_ZC_ADD_ITEM_TO_STORE p; nullpo_retv(sd); nullpo_retv(i); - fd=sd->fd; + + fd = sd->fd; view = itemdb_viewid(i->nameid); - WFIFOHEAD(fd,packet_len(storageaddType)); - WFIFOW(fd, 0) = storageaddType; // Storage item added - WFIFOW(fd, 2) = index+1; // index - WFIFOL(fd, 4) = amount; // amount - WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id + WFIFOHEAD(fd, sizeof(p)); + p.packetType = storageaddType; // Storage item added + p.index = index + 1; // index + p.amount = amount; // amount + p.itemId = (view > 0) ? view : i->nameid; // id #if PACKETVER >= 5 - WFIFOB(fd,10) = itemtype(itemdb_type(i->nameid)); //type - offset += 1; + p.itemType = itemtype(itemdb_type(i->nameid)); //type #endif - WFIFOB(fd,10+offset) = i->identify; //identify flag - WFIFOB(fd,11+offset) = i->attribute; // attribute - WFIFOB(fd,12+offset) = i->refine; //refine - clif->addcards((struct EQUIPSLOTINFO*)WFIFOP(fd, 13 + offset), i); + p.identified = i->identify; //identify flag + p.damaged = i->attribute; // attribute + p.refine = i->refine; //refine + clif->addcards(&p.slot, i); #if PACKETVER >= 20150226 - clif->add_item_options(WFIFOP(fd, 21 + offset), i); + clif->add_item_options(&p.option_data[0], i); #endif - WFIFOSET(fd,packet_len(storageaddType)); + memcpy(WFIFOP(fd, 0), &p, sizeof(p)); + WFIFOSET(fd, sizeof(p)); } /// Notifies the client of an item being deleted from the storage (ZC_DELETE_ITEM_FROM_STORE). diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 75687c8ca..5d4790552 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -1841,6 +1841,25 @@ struct PACKET_ZC_ITEM_ENTRY { uint8 subY; } __attribute__((packed)); +struct PACKET_ZC_ADD_ITEM_TO_STORE { + int16 packetType; + int16 index; + int32 amount; +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; +#else + uint16 itemId; +#endif +#if PACKETVER >= 5 + uint8 itemType; +#endif + uint8 identified; + uint8 damaged; + uint8 refine; + struct EQUIPSLOTINFO slot; + struct ItemOptions option_data[MAX_ITEM_OPTIONS]; +} __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-70-g09d2