summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-07-10 05:35:29 +0300
committerAndrei Karas <akaras@inbox.ru>2018-07-15 20:36:25 +0300
commitb8d36d894c8e1c931ba2143c763cd2e562c8572e (patch)
tree3ba193955434d8da2392dfc8c29aef8de7d1ccdf
parentd172c28f9b25a780235c7c7a7f4db9ca9866f531 (diff)
downloadhercules-b8d36d894c8e1c931ba2143c763cd2e562c8572e.tar.gz
hercules-b8d36d894c8e1c931ba2143c763cd2e562c8572e.tar.bz2
hercules-b8d36d894c8e1c931ba2143c763cd2e562c8572e.tar.xz
hercules-b8d36d894c8e1c931ba2143c763cd2e562c8572e.zip
Update packet CZ_REQ_TRADE_BUYING_STORE.
-rw-r--r--src/map/buyingstore.c8
-rw-r--r--src/map/buyingstore.h3
-rw-r--r--src/map/clif.c25
-rw-r--r--src/map/packets_struct.h18
4 files changed, 36 insertions, 18 deletions
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 03a63291d..4b853bf75 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -241,7 +241,7 @@ static void buyingstore_open(struct map_session_data *sd, int account_id)
clif->buyingstore_itemlist(sd, pl_sd);
}
-static void buyingstore_trade(struct map_session_data *sd, int account_id, unsigned int buyer_id, const uint8 *itemlist, unsigned int count)
+static void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, unsigned int count)
{
int zeny = 0;
unsigned int i, weight, listidx, k;
@@ -292,9 +292,9 @@ static void buyingstore_trade(struct map_session_data *sd, int account_id, unsig
unsigned short nameid, amount;
int index;
- index = RBUFW(itemlist,i*6+0)-2;
- nameid = RBUFW(itemlist,i*6+2);
- amount = RBUFW(itemlist,i*6+4);
+ index = itemlist[i].index - 2;
+ nameid = itemlist[i].itemId;
+ amount = itemlist[i].amount;
if( i )
{// duplicate check. as the client does this too, only malicious intent should be caught here
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index b68e7b309..e96cc832d 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -31,6 +31,7 @@ struct map_session_data;
**/
struct s_search_store_search;
struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub;
+struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub;
/**
* Defines
@@ -83,7 +84,7 @@ struct buyingstore_interface {
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);
+ void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, unsigned int count);
bool (*search) (struct map_session_data* sd, unsigned short nameid);
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
unsigned int (*getuid) (void);
diff --git a/src/map/clif.c b/src/map/clif.c
index 5560eaa25..4bfda5325 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -17785,36 +17785,35 @@ static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data *sd)
/// 0819 <packet len>.W <account id>.L <store id>.L { <index>.W <name id>.W <amount>.W }*
static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data *sd)
{
- const unsigned int blocksize = 6;
- const uint8 *itemlist;
+ const unsigned int blocksize = sizeof(struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub);
+ const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub *itemlist;
int account_id;
unsigned int buyer_id;
int count, packet_len;
- struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
-
- packet_len = RFIFOW(fd,info->pos[0]);
+ const struct PACKET_CZ_REQ_TRADE_BUYING_STORE *p = RFIFOP(fd, 0);
+ packet_len = p->packetLength;
- if( packet_len < 12 )
+ if (packet_len < sizeof(struct PACKET_CZ_REQ_TRADE_BUYING_STORE))
{// minimum packet length
- ShowError("clif_parse_ReqTradeBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", 12U, packet_len, sd->bl.id);
+ ShowError("clif_parse_ReqTradeBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", (uint32)sizeof(struct PACKET_CZ_REQ_TRADE_BUYING_STORE), packet_len, sd->bl.id);
return;
}
- account_id = RFIFOL(fd,info->pos[1]);
- buyer_id = RFIFOL(fd,info->pos[2]);
- itemlist = RFIFOP(fd,info->pos[3]);
+ account_id = p->AID;
+ buyer_id = p->storeId;
+ itemlist = &p->items[0];
// so that buyingstore_trade knows, how many elements it has access to
- packet_len-= info->pos[3];
+ packet_len -= sizeof(struct PACKET_CZ_REQ_TRADE_BUYING_STORE);
if (packet_len < 0)
return;
- if( packet_len%blocksize )
+ if (packet_len % blocksize)
{
ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %d (account_id=%d, buyer_id=%d, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize);
return;
}
- count = packet_len/blocksize;
+ count = packet_len / blocksize;
buyingstore->trade(sd, account_id, buyer_id, itemlist, count);
}
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index c89093e01..211ae654b 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -2372,6 +2372,24 @@ struct PACKET_ZC_ACK_ITEMLIST_BUYING_STORE {
struct PACKET_ZC_ACK_ITEMLIST_BUYING_STORE_sub items[];
} __attribute__((packed));
+struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub {
+ int16 index;
+#if PACKETVER_RE_NUM >= 20180704
+ uint32 itemId;
+#else
+ uint16 itemId;
+#endif
+ uint16 amount;
+} __attribute__((packed));
+
+struct PACKET_CZ_REQ_TRADE_BUYING_STORE {
+ int16 packetType;
+ int16 packetLength;
+ uint32 AID;
+ uint32 storeId;
+ struct PACKET_CZ_REQ_TRADE_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