diff options
author | Andrei Karas <akaras@inbox.ru> | 2019-04-26 19:31:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2019-05-05 22:24:25 +0300 |
commit | 19a162b61f14883ae0a2e25b6252796cc4c77cb9 (patch) | |
tree | 1c74fe43af0cd31bd7d26b63ff5501b3e7b74ec3 | |
parent | 554072b191c0aadab9e874d6ec0e7b954477e595 (diff) | |
download | hercules-19a162b61f14883ae0a2e25b6252796cc4c77cb9.tar.gz hercules-19a162b61f14883ae0a2e25b6252796cc4c77cb9.tar.bz2 hercules-19a162b61f14883ae0a2e25b6252796cc4c77cb9.tar.xz hercules-19a162b61f14883ae0a2e25b6252796cc4c77cb9.zip |
Move packet ZC_SE_PC_BUY_CASHITEM_RESULT into separate function and convert to struct
-rw-r--r-- | src/map/clif.c | 23 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/packets_struct.h | 11 |
3 files changed, 27 insertions, 8 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 4ebdad5f1..1348889d3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -19518,18 +19518,24 @@ static void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) } else { result = CSBR_UNKONWN_ITEM; } - - WFIFOHEAD(fd, 16); - WFIFOW(fd, 0) = 0x849; - WFIFOL(fd, 2) = id; - WFIFOW(fd, 6) = result;/* result */ - WFIFOL(fd, 8) = sd->cashPoints;/* current cash point */ - WFIFOL(fd, 12) = sd->kafraPoints;// [Ryuuzaki] - WFIFOSET(fd, 16); + clif->cashShopBuyAck(fd, sd, id, result); } } +static void clif_cashShopBuyAck(int fd, struct map_session_data *sd, int itemId, enum CASH_SHOP_BUY_RESULT result) +{ + nullpo_retv(sd); + WFIFOHEAD(fd, sizeof(struct PACKET_ZC_SE_PC_BUY_CASHITEM_RESULT)); + struct PACKET_ZC_SE_PC_BUY_CASHITEM_RESULT *p = WFIFOP(fd, 0); + p->packetType = 0x849; + p->itemId = itemId; + p->result = result; + p->cashPoints = sd->cashPoints; + p->kafraPoints = sd->kafraPoints; + WFIFOSET(fd, sizeof(struct PACKET_ZC_SE_PC_BUY_CASHITEM_RESULT)); +} + static void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); /* [Ind/Hercules] */ static void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) @@ -23580,6 +23586,7 @@ void clif_defaults(void) clif->pCashShopReqTab = clif_parse_CashShopReqTab; clif->pCashShopSchedule = clif_parse_CashShopSchedule; clif->pCashShopBuy = clif_parse_CashShopBuy; + clif->cashShopBuyAck = clif_cashShopBuyAck; /* */ clif->pPartyTick = clif_parse_PartyTick; clif->pGuildInvite2 = clif_parse_GuildInvite2; diff --git a/src/map/clif.h b/src/map/clif.h index c1f2aca7f..aaf053274 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1499,6 +1499,7 @@ struct clif_interface { void (*pCashShopBuy) (int fd, struct map_session_data *sd); void (*pPartyTick) (int fd, struct map_session_data *sd); void (*pGuildInvite2) (int fd, struct map_session_data *sd); + void (*cashShopBuyAck) (int fd, struct map_session_data *sd, int itemId, enum CASH_SHOP_BUY_RESULT result); /* Group Search System Update */ void (*pPartyBookingAddFilter) (int fd, struct map_session_data *sd); void (*pPartyBookingSubFilter) (int fd, struct map_session_data *sd); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index a660de67b..45683596f 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -3308,6 +3308,17 @@ struct PACKET_ZC_MERGE_ITEM_OPEN { DEFINE_PACKET_HEADER(ZC_MERGE_ITEM_OPEN, 0x096d); #endif +#if PACKETVER_MAIN_NUM >= 20101123 || PACKETVER_RE_NUM >= 20120328 || defined(PACKETVER_ZERO) +struct PACKET_ZC_SE_PC_BUY_CASHITEM_RESULT { + int16 packetType; + uint32 itemId; // unused + uint16 result; + uint32 cashPoints; + uint32 kafraPoints; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_SE_PC_BUY_CASHITEM_RESULT, 0x0849); +#endif + #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 |