summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-09-20 01:22:38 +0300
committerAndrei Karas <akaras@inbox.ru>2018-09-20 02:06:52 +0300
commit0f55a042a9eeb8334f28493f24e1dc9d72893425 (patch)
tree7abbd6dfb8300ce5cd59f9c38fdaeeef01aa3834 /src/map/clif.c
parent193f8b1c19b03d304bf48e7436abc9b3bb06057c (diff)
downloadhercules-0f55a042a9eeb8334f28493f24e1dc9d72893425.tar.gz
hercules-0f55a042a9eeb8334f28493f24e1dc9d72893425.tar.bz2
hercules-0f55a042a9eeb8334f28493f24e1dc9d72893425.tar.xz
hercules-0f55a042a9eeb8334f28493f24e1dc9d72893425.zip
Update inventory start packet for 2018-09-19 RE and zero packet versions.
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 03a6ba507..d70f69557 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2789,11 +2789,11 @@ static void clif_item_normal(short idx, struct NORMALITEM_INFO *p, struct item *
static void clif_inventoryList(struct map_session_data *sd)
{
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
clif->inventoryStart(sd, INVTYPE_INVENTORY, "");
#endif
clif->inventoryItems(sd, INVTYPE_INVENTORY);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
clif->inventoryEnd(sd, INVTYPE_INVENTORY);
#endif
}
@@ -2816,7 +2816,7 @@ static void clif_inventoryItems(struct map_session_data *sd, enum inventory_type
if (normal) {
itemlist_normal.PacketType = inventorylistnormalType;
itemlist_normal.PacketLength = (sizeof(itemlist_normal) - sizeof(itemlist_normal.list)) + (sizeof(struct NORMALITEM_INFO) * normal);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
itemlist_normal.invType = type;
#endif
@@ -2829,7 +2829,7 @@ static void clif_inventoryItems(struct map_session_data *sd, enum inventory_type
if( equip ) {
itemlist_equip.PacketType = inventorylistequipType;
itemlist_equip.PacketLength = (sizeof(itemlist_equip) - sizeof(itemlist_equip.list)) + (sizeof(struct EQUIPITEM_INFO) * equip);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
itemlist_equip.invType = type;
#endif
@@ -2849,7 +2849,7 @@ static void clif_inventoryItems(struct map_session_data *sd, enum inventory_type
static void clif_equipList(struct map_session_data *sd)
{
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
clif->inventoryStart(sd, INVTYPE_INVENTORY, "");
clif->inventoryItems(sd, INVTYPE_INVENTORY);
clif->inventoryEnd(sd, INVTYPE_INVENTORY);
@@ -2876,7 +2876,7 @@ static void clif_equipItems(struct map_session_data *sd, enum inventory_type typ
if (equip) {
itemlist_equip.PacketType = inventorylistequipType;
itemlist_equip.PacketLength = (sizeof(itemlist_equip) - sizeof(itemlist_equip.list)) + (sizeof(struct EQUIPITEM_INFO) * equip);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
itemlist_equip.invType = type;
#endif
@@ -2914,28 +2914,40 @@ static void clif_guildStorageList(struct map_session_data *sd, struct item *item
static void clif_inventoryStart(struct map_session_data *sd, enum inventory_type type, const char *name)
{
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
nullpo_retv(sd);
nullpo_retv(name);
- struct ZC_INVENTORY_START p;
- p.packetType = 0xb08;
-#if PACKETVER_RE_NUM >= 20180912
- p.invType = type;
+ char buf[sizeof(struct ZC_INVENTORY_START) + 24];
+ memset(buf, 0, sizeof(buf));
+ struct ZC_INVENTORY_START *p = (struct ZC_INVENTORY_START *)buf;
+ p->packetType = 0xb08;
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
+ p->invType = type;
+#endif
+#if PACKETVER_RE_NUM >= 20180919 || PACKETVER_ZERO_NUM >= 20180919
+ int strLen = (int)safestrnlen(name, 24);
+ if (strLen > 24)
+ strLen = 24;
+ const int len = sizeof(struct ZC_INVENTORY_START) + strLen;
+ p->packetLength = len;
+ safestrncpy(p->name, name, strLen);
+#else
+ const int len = sizeof(struct ZC_INVENTORY_START);
+ safestrncpy(p->name, name, NAME_LENGTH);
#endif
- safestrncpy(p.name, name, NAME_LENGTH);
- clif->send(&p, sizeof(p), &sd->bl, SELF);
+ clif->send(p, len, &sd->bl, SELF);
#endif
}
static void clif_inventoryEnd(struct map_session_data *sd, enum inventory_type type)
{
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
nullpo_retv(sd);
struct ZC_INVENTORY_END p;
p.packetType = 0xb0b;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
p.invType = type;
#endif
p.flag = 0;
@@ -2971,10 +2983,10 @@ static void clif_storageItems(struct map_session_data *sd, enum inventory_type t
storelist_normal.PacketType = storageListNormalType;
storelist_normal.PacketLength = ( sizeof( storelist_normal ) - sizeof( storelist_normal.list ) ) + (sizeof(struct NORMALITEM_INFO) * normal);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
storelist_normal.invType = type;
#endif
-#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829
+#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829 && PACKETVER_ZERO_NUM < 20180919
safestrncpy(storelist_normal.name, "Storage", NAME_LENGTH);
#endif
@@ -2985,10 +2997,10 @@ static void clif_storageItems(struct map_session_data *sd, enum inventory_type t
storelist_equip.PacketType = storageListEquipType;
storelist_equip.PacketLength = ( sizeof( storelist_equip ) - sizeof( storelist_equip.list ) ) + (sizeof(struct EQUIPITEM_INFO) * equip);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
storelist_equip.invType = type;
#endif
-#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829
+#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829 && PACKETVER_ZERO_NUM < 20180919
safestrncpy(storelist_equip.name, "Storage", NAME_LENGTH);
#endif
@@ -3001,11 +3013,11 @@ static void clif_storageItems(struct map_session_data *sd, enum inventory_type t
static void clif_cartList(struct map_session_data *sd)
{
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
clif->inventoryStart(sd, INVTYPE_CART, "");
#endif
clif->cartItems(sd, INVTYPE_CART);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
clif->inventoryEnd(sd, INVTYPE_CART);
#endif
}
@@ -3031,7 +3043,7 @@ static void clif_cartItems(struct map_session_data *sd, enum inventory_type type
if (normal) {
itemlist_normal.PacketType = cartlistnormalType;
itemlist_normal.PacketLength = (sizeof(itemlist_normal) - sizeof(itemlist_normal.list)) + (sizeof(struct NORMALITEM_INFO) * normal);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
itemlist_normal.invType = type;
#endif
@@ -3041,7 +3053,7 @@ static void clif_cartItems(struct map_session_data *sd, enum inventory_type type
if (equip) {
itemlist_equip.PacketType = cartlistequipType;
itemlist_equip.PacketLength = (sizeof(itemlist_equip) - sizeof(itemlist_equip.list)) + (sizeof(struct EQUIPITEM_INFO) * equip);
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
itemlist_equip.invType = type;
#endif