diff options
author | Andrei Karas <akaras@inbox.ru> | 2020-02-23 01:11:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2020-02-23 02:20:52 +0300 |
commit | 5d47d411af30565747b99a5f1b76b0b30f9c73c9 (patch) | |
tree | ab817ad49456905d0d7d6e37d434432ab237b361 /src/map/clif.c | |
parent | 9106bbab19b4feaa4623a3b8e5d59e08ef73b640 (diff) | |
download | hercules-5d47d411af30565747b99a5f1b76b0b30f9c73c9.tar.gz hercules-5d47d411af30565747b99a5f1b76b0b30f9c73c9.tar.bz2 hercules-5d47d411af30565747b99a5f1b76b0b30f9c73c9.tar.xz hercules-5d47d411af30565747b99a5f1b76b0b30f9c73c9.zip |
Add workaround for fix Visual Studio bug (error C2233)
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 660c516d7..3022d7f69 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -23232,7 +23232,8 @@ static void clif_parse_npc_expanded_barter_closed(int fd, struct map_session_dat #if PACKETVER_MAIN_NUM >= 20191120 || PACKETVER_RE_NUM >= 20191106 || PACKETVER_ZERO_NUM >= 20191127 #define NEXT_EXPANDED_BARTER_ITEM(var, count) \ var = (struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub *)((char*)item + \ - sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) + \ + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) - \ + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) + \ count * sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2)) #endif @@ -23252,7 +23253,11 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np packet->packetType = HEADER_ZC_NPC_EXPANDED_BARTER_OPEN; struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub *item = &packet->items[0]; - for (int i = 0; i < shop_size && buf_left >= sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub); i++) { + // Workaround for fix Visual Studio bug (error C2233) + // Here should be sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) + const int ptr_size = sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) - + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2); + for (int i = 0; i < shop_size && buf_left >= ptr_size; i++) { if (shop[i].nameid) { struct item_data *id = itemdb->exists(shop[i].nameid); if (id == NULL) @@ -23265,7 +23270,7 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np item->index = i; item->zeny = shop[i].value; item->currency_count = 0; - buf_left -= sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub); + buf_left -= ptr_size; items_count ++; int count = shop[i].value2; if (buf_left < sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) * count) { @@ -23294,7 +23299,7 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np packet->items_count = items_count; packet->packetLength = sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN) + - sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) * items_count + + ptr_size * items_count + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) * currencies_count; clif->send(packet, packet->packetLength, &sd->bl, SELF); #endif |