summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/map/clif.c58
-rw-r--r--src/map/packets_struct.h35
2 files changed, 56 insertions, 37 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
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index d82a413a1..549923b99 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -198,7 +198,7 @@ enum packet_headers {
#else
dropflooritemType = 0x9e,
#endif
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
inventorylistnormalType = 0xb09,
#elif PACKETVER >= 20120925
inventorylistnormalType = 0x991,
@@ -209,7 +209,7 @@ enum packet_headers {
#else
inventorylistnormalType = 0xa3,
#endif
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
inventorylistequipType = 0xb0a,
#elif PACKETVER >= 20150226
inventorylistequipType = 0xa0d,
@@ -222,7 +222,7 @@ enum packet_headers {
#else
inventorylistequipType = 0xa4,
#endif
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
storageListNormalType = 0xb09,
#elif PACKETVER >= 20120925
storageListNormalType = 0x995,
@@ -233,7 +233,7 @@ enum packet_headers {
#else
storageListNormalType = 0xa5,
#endif
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
storageListEquipType = 0xb0a,
#elif PACKETVER >= 20150226
storageListEquipType = 0xa10,
@@ -246,7 +246,7 @@ enum packet_headers {
#else
storageListEquipType = 0xa6,
#endif
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
cartlistnormalType = 0xb09,
#elif PACKETVER >= 20120925
cartlistnormalType = 0x993,
@@ -257,7 +257,7 @@ enum packet_headers {
#else
cartlistnormalType = 0x123,
#endif
-#if PACKETVER_RE_NUM >= 20180829
+#if PACKETVER_RE_NUM >= 20180829 || PACKETVER_ZERO_NUM >= 20180919
cartlistequipType = 0xb0a,
#elif PACKETVER >= 20150226
cartlistequipType = 0xa0f,
@@ -1174,7 +1174,7 @@ struct packet_roulette_itemrecv_ack {
struct packet_itemlist_normal {
int16 PacketType;
int16 PacketLength;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
struct NORMALITEM_INFO list[MAX_ITEMLIST];
@@ -1183,7 +1183,7 @@ struct packet_itemlist_normal {
struct packet_itemlist_equip {
int16 PacketType;
int16 PacketLength;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
struct EQUIPITEM_INFO list[MAX_ITEMLIST];
@@ -1192,10 +1192,10 @@ struct packet_itemlist_equip {
struct ZC_STORE_ITEMLIST_NORMAL {
int16 PacketType;
int16 PacketLength;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
-#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829
+#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829 && PACKETVER_ZERO_NUM < 20180919
char name[NAME_LENGTH];
#endif
struct NORMALITEM_INFO list[MAX_ITEMLIST];
@@ -1203,15 +1203,22 @@ struct ZC_STORE_ITEMLIST_NORMAL {
struct ZC_INVENTORY_START {
int16 packetType;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180919 || PACKETVER_ZERO_NUM >= 20180919
+ int16 packetLength;
+#endif
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
+#if PACKETVER_RE_NUM >= 20180919 || PACKETVER_ZERO_NUM >= 20180919
+ char name[];
+#else
char name[NAME_LENGTH];
+#endif
} __attribute__((packed));
struct ZC_INVENTORY_END {
int16 packetType;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
char flag;
@@ -1220,10 +1227,10 @@ struct ZC_INVENTORY_END {
struct ZC_STORE_ITEMLIST_EQUIP {
int16 PacketType;
int16 PacketLength;
-#if PACKETVER_RE_NUM >= 20180912
+#if PACKETVER_RE_NUM >= 20180912 || PACKETVER_ZERO_NUM >= 20180919
uint8 invType;
#endif
-#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829
+#if PACKETVER >= 20120925 && PACKETVER_RE_NUM < 20180829 && PACKETVER_ZERO_NUM < 20180919
char name[NAME_LENGTH];
#endif
struct EQUIPITEM_INFO list[MAX_ITEMLIST];