diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/clif.c | 35 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/packets_struct.h | 17 |
3 files changed, 41 insertions, 12 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 2e08cd14b..eaf5ec30d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18566,25 +18566,35 @@ static void clif_parse_CashShopClose(int fd, struct map_session_data *sd) static void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) { + clif->cashShopSchedule(fd, sd); +} + +void clif_cashShopSchedule(int fd, struct map_session_data *sd) +{ #if PACKETVER >= 20110614 - int i, j = 0; + int i = 0; - for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) { - if( clif->cs.item_count[i] == 0 ) + nullpo_retv(sd); + for (i = 0; i < CASHSHOP_TAB_MAX; i++) { + const int len = sizeof(struct PACKET_ZC_ACK_SCHEDULER_CASHITEM) + (clif->cs.item_count[i] * sizeof(struct PACKET_ZC_ACK_SCHEDULER_CASHITEM_sub)); + int j = 0; + struct PACKET_ZC_ACK_SCHEDULER_CASHITEM *p; + if (clif->cs.item_count[i] == 0) continue; // Skip empty tabs, the client only expects filled ones - WFIFOHEAD(fd, 8 + ( clif->cs.item_count[i] * 6 ) ); - WFIFOW(fd, 0) = 0x8ca; - WFIFOW(fd, 2) = 8 + ( clif->cs.item_count[i] * 6 ); - WFIFOW(fd, 4) = clif->cs.item_count[i]; - WFIFOW(fd, 6) = i; + WFIFOHEAD(fd, len); + p = WFIFOP(fd, 0); + p->packetType = 0x8ca; + p->packetLength = len; + p->count = clif->cs.item_count[i]; + p->tabNum = i; - for( j = 0; j < clif->cs.item_count[i]; j++ ) { - WFIFOW(fd, 8 + ( 6 * j ) ) = clif->cs.data[i][j]->id; - WFIFOL(fd, 10 + ( 6 * j ) ) = clif->cs.data[i][j]->price; + for (j = 0; j < clif->cs.item_count[i]; j++) { + p->items[j].itemId = clif->cs.data[i][j]->id; + p->items[j].price = clif->cs.data[i][j]->price; } - WFIFOSET(fd, 8 + ( clif->cs.item_count[i] * 6 )); + WFIFOSET(fd, len); } #endif } @@ -21615,6 +21625,7 @@ void clif_defaults(void) clif->getareachar_item = clif_getareachar_item; clif->cart_additem_ack = clif_cart_additem_ack; clif->cashshop_load = clif_cashshop_db; + clif->cashShopSchedule = clif_cashShopSchedule; clif->package_announce = clif_package_item_announce; clif->item_drop_announce = clif_item_drop_announce; /* unit-related */ diff --git a/src/map/clif.h b/src/map/clif.h index 92db684bd..a60a09852 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -726,6 +726,7 @@ struct clif_interface { void (*getareachar_item) (struct map_session_data* sd,struct flooritem_data* fitem); void (*cart_additem_ack) (struct map_session_data *sd, int flag); void (*cashshop_load) (void); + void (*cashShopSchedule) (int fd, struct map_session_data *sd); void (*package_announce) (struct map_session_data *sd, unsigned short nameid, unsigned short containerid); void (*item_drop_announce) (struct map_session_data *sd, unsigned short nameid, char *monsterName); /* unit-related */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 103072059..adebd87b3 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2201,6 +2201,23 @@ struct PACKET_CZ_SSILIST_ITEM_CLICK { #endif } __attribute__((packed)); +struct PACKET_ZC_ACK_SCHEDULER_CASHITEM_sub { +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; +#else + uint16 itemId; +#endif + uint32 price; +} __attribute__((packed)); + +struct PACKET_ZC_ACK_SCHEDULER_CASHITEM { + int16 packetType; + int16 packetLength; + int16 count; + int16 tabNum; + struct PACKET_ZC_ACK_SCHEDULER_CASHITEM_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 |