diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-07-10 01:59:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-07-15 20:36:25 +0300 |
commit | d82c06ba163ee9529358e4de83370d0b2fa77769 (patch) | |
tree | 05d6c28dcb21d09d1e31b289fddac983ec8ba80f /src | |
parent | d8864002e09274f630cfe283f2b13e70e1b2ad62 (diff) | |
download | hercules-d82c06ba163ee9529358e4de83370d0b2fa77769.tar.gz hercules-d82c06ba163ee9529358e4de83370d0b2fa77769.tar.bz2 hercules-d82c06ba163ee9529358e4de83370d0b2fa77769.tar.xz hercules-d82c06ba163ee9529358e4de83370d0b2fa77769.zip |
Update packet CZ_REQ_OPEN_BUYING_STORE.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/buyingstore.c | 8 | ||||
-rw-r--r-- | src/map/buyingstore.h | 3 | ||||
-rw-r--r-- | src/map/clif.c | 26 | ||||
-rw-r--r-- | src/map/packets_struct.h | 19 |
4 files changed, 38 insertions, 18 deletions
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index ade2c5bf2..03a63291d 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -81,7 +81,7 @@ static bool buyingstore_setup(struct map_session_data *sd, unsigned char slots) return true; } -static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsigned char result, const char *storename, const uint8 *itemlist, unsigned int count) +static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsigned char result, const char *storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub *itemlist, unsigned int count) { unsigned int i, weight, listidx; @@ -132,9 +132,9 @@ static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsig int price, idx; struct item_data* id; - nameid = RBUFW(itemlist,i*8+0); - amount = RBUFW(itemlist,i*8+2); - price = RBUFL(itemlist,i*8+4); + nameid = itemlist[i].itemId; + amount = itemlist[i].amount; + price = itemlist[i].price; if( ( id = itemdb->exists(nameid) ) == NULL || amount == 0 ) {// invalid input diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 408678e8e..b68e7b309 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -30,6 +30,7 @@ struct map_session_data; * Declarations **/ struct s_search_store_search; +struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub; /** * Defines @@ -79,7 +80,7 @@ struct buyingstore_interface { struct item_option blankoptions[MAX_ITEM_OPTIONS]; // used for search result temporary. /* */ bool (*setup) (struct map_session_data* sd, unsigned char slots); - void (*create) (struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count); + void (*create) (struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub* itemlist, unsigned int count); void (*close) (struct map_session_data* sd); void (*open) (struct map_session_data* sd, int account_id); void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count); diff --git a/src/map/clif.c b/src/map/clif.c index 4648b4229..6430c933b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -17590,40 +17590,40 @@ static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data *sd) _ /// 1 = open static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data *sd) { - const unsigned int blocksize = 8; - const uint8 *itemlist; + const unsigned int blocksize = sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub); + const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub *itemlist; char storename[MESSAGE_SIZE]; unsigned char result; int zenylimit; int count, packet_len; - struct s_packet_db* info = &packet_db[RFIFOW(fd,0)]; + const struct PACKET_CZ_REQ_OPEN_BUYING_STORE *p = RFIFOP(fd, 0); - packet_len = RFIFOW(fd,info->pos[0]); + packet_len = p->packetLength; // TODO: Make this check global for all variable length packets. - if( packet_len < 89 ) + if (packet_len < sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE)) {// minimum packet length - ShowError("clif_parse_ReqOpenBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", 89U, packet_len, sd->bl.id); + ShowError("clif_parse_ReqOpenBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", (uint32)sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE), packet_len, sd->bl.id); return; } - zenylimit = RFIFOL(fd,info->pos[1]); - result = RFIFOL(fd,info->pos[2]); - safestrncpy(storename, RFIFOP(fd,info->pos[3]), sizeof(storename)); - itemlist = RFIFOP(fd,info->pos[4]); + zenylimit = p->zenyLimit; + result = p->result; + safestrncpy(storename, p->storeName, sizeof(storename)); + itemlist = &p->items[0]; // so that buyingstore_create knows, how many elements it has access to - packet_len-= info->pos[4]; + packet_len -= sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE); if (packet_len < 0) return; - if( packet_len%blocksize ) + if (packet_len % blocksize) { ShowError("clif_parse_ReqOpenBuyingStore: Unexpected item list size %d (account_id=%d, block size=%u)\n", packet_len, sd->bl.id, blocksize); return; } - count = packet_len/blocksize; + count = packet_len / blocksize; buyingstore->create(sd, zenylimit, result, storename, itemlist, count); } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 17ff1b159..3c2d5dee1 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2280,6 +2280,25 @@ struct PACKET_CZ_PC_PURCHASE_ITEMLIST { struct PACKET_CZ_PC_PURCHASE_ITEMLIST_sub items[]; } __attribute__((packed)); +struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub { +#if PACKETVER_RE_NUM >= 20180704 + uint32 itemId; +#else + uint16 itemId; +#endif + uint16 amount; + uint32 price; +} __attribute__((packed)); + +struct PACKET_CZ_REQ_OPEN_BUYING_STORE { + int16 packetType; + int16 packetLength; + uint32 zenyLimit; + uint8 result; + char storeName[MESSAGE_SIZE]; + struct PACKET_CZ_REQ_OPEN_BUYING_STORE_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 |