From 37767f6505db9e7a4039621cfd77623b06d92606 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Mon, 8 Apr 2019 04:23:08 +0200 Subject: Rewrite clif_storageItems - The maximum packetsize is now decided during compile time depending on client version which fixes an issue started with clients supporting int32 as itemid where packet size would underflow - The function now have a single loop that is easier to read and understand Signed-off-by: Ibrahim Zidan --- src/map/clif.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/map/clif.h') diff --git a/src/map/clif.h b/src/map/clif.h index 6c9058cba..b3441f908 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -78,6 +78,11 @@ enum rodex_get_items; #define COLOR_YELLOW 0xffff00U #define COLOR_DEFAULT COLOR_GREEN +#define MAX_STORAGE_ITEM_PACKET_NORMAL ((INT16_MAX - (sizeof(struct ZC_STORE_ITEMLIST_NORMAL) - (sizeof(struct NORMALITEM_INFO) * MAX_ITEMLIST))) / sizeof(struct NORMALITEM_INFO)) +#define MAX_STORAGE_ITEM_PACKET_EQUIP ((INT16_MAX - (sizeof(struct ZC_STORE_ITEMLIST_EQUIP) - (sizeof(struct EQUIPITEM_INFO) * MAX_ITEMLIST))) / sizeof(struct EQUIPITEM_INFO)) +STATIC_ASSERT(MAX_STORAGE_ITEM_PACKET_NORMAL > 0, "Max items per storage item packet for normal items is less than 1, it's most likely to be a bug and shall not be ignored."); +STATIC_ASSERT(MAX_STORAGE_ITEM_PACKET_EQUIP > 0, "Max items per storage item packet for equip items is less than 1, it's most likely to be a bug and shall not be ignored."); + /** * Enumerations **/ -- cgit v1.2.3-60-g2f50