summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-01-08 17:21:29 +0300
committerAndrei Karas <akaras@inbox.ru>2018-01-14 18:09:35 +0300
commit499745c3eb6d79573e627433bd77881bd26afb7c (patch)
treee90632239ab5eb143b1f6261a588388fe9572fe1 /src/map
parentcd9fca48ad3fcb86fe4b4f159c68595859077998 (diff)
downloadhercules-499745c3eb6d79573e627433bd77881bd26afb7c.tar.gz
hercules-499745c3eb6d79573e627433bd77881bd26afb7c.tar.bz2
hercules-499745c3eb6d79573e627433bd77881bd26afb7c.tar.xz
hercules-499745c3eb6d79573e627433bd77881bd26afb7c.zip
Update party member and party info packets.
Also remove extra parts of party info packet.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c98
-rw-r--r--src/map/packets_struct.h55
2 files changed, 94 insertions, 59 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 378e5c268..988e821e7 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -6594,9 +6594,6 @@ void clif_party_created(struct map_session_data *sd,int result)
}
/// Adds new member to a party.
-/// 0104 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B (ZC_ADD_MEMBER_TO_GROUP)
-/// 01e9 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B <item pickup rule>.B <item share rule>.B (ZC_ADD_MEMBER_TO_GROUP2)
-/// 0a43 <account id>.L <role>.L <class>.W <base level>.W <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B <item pickup rule>.B <item share rule>.B (ZC_ADD_MEMBER_TO_GROUP3)
/// role:
/// 0 = leader
/// 1 = normal
@@ -6606,19 +6603,12 @@ void clif_party_created(struct map_session_data *sd,int result)
void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
{
int i;
-#if PACKETVER < 20170502
- unsigned char buf[81];
- const int cmd = 0x1e9;
- const int offset = 0;
-#else
- unsigned char buf[85];
-// [4144] probably 0xa43 packet can works on older clients because in client was added in 2015-10-07
- const int cmd = 0xa43;
- int offset = 4;
-#endif
+ struct PACKET_ZC_ADD_MEMBER_TO_GROUP packet;
nullpo_retv(p);
nullpo_retv(sd);
+
+ memset(&packet, 0, sizeof(packet));
if (!sd) { //Pick any party member (this call is used when changing item share rules)
ARR_FIND(0, MAX_PARTY, i, p->data[i].sd != 0);
} else {
@@ -6628,27 +6618,28 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
return; //Should never happen...
sd = p->data[i].sd;
- WBUFW(buf, 0) = cmd;
- WBUFL(buf, 2) = sd->status.account_id;
- WBUFL(buf, 6) = (p->party.member[i].leader) ? 0 : 1;
+ packet.packetType = partymemberinfo;
+ packet.AID = sd->status.account_id;
+#if PACKETVER >= 20171207
+ packet.GID = sd->status.char_id;
+#endif
+ packet.leader = (p->party.member[i].leader) ? 0 : 1;
#if PACKETVER >= 20170502
- WBUFW(buf, 10) = sd->status.class;
- WBUFW(buf, 12) = sd->status.base_level;
+ packet.class = sd->status.class;
+ packet.baseLevel = sd->status.base_level;
#endif
- WBUFW(buf, offset + 10) = sd->bl.x;
- WBUFW(buf, offset + 12) = sd->bl.y;
- WBUFB(buf, offset + 14) = (p->party.member[i].online) ? 0 : 1;
- memcpy(WBUFP(buf, offset + 15), p->party.name, NAME_LENGTH);
- memcpy(WBUFP(buf, offset + 39), sd->status.name, NAME_LENGTH);
- mapindex->getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, WBUFP(buf, offset + 63));
- WBUFB(buf, offset + 79) = (p->party.item & 1) ? 1 : 0;
- WBUFB(buf, offset + 80) = (p->party.item & 2) ? 1 : 0;
- clif->send(buf, packet_len(cmd), &sd->bl, PARTY);
+ packet.x = sd->bl.x;
+ packet.y = sd->bl.y;
+ packet.offline = (p->party.member[i].online) ? 0 : 1;
+ memcpy(packet.partyName, p->party.name, NAME_LENGTH);
+ memcpy(packet.playerName, sd->status.name, NAME_LENGTH);
+ mapindex->getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, packet.mapName);
+ packet.sharePickup = (p->party.item & 1) ? 1 : 0;
+ packet.shareLoot = (p->party.item & 2) ? 1 : 0;
+ clif->send(&packet, sizeof(packet), &sd->bl, PARTY);
}
/// Sends party information (ZC_GROUP_LIST).
-/// 00fb <packet len>.W <party name>.24B { <account id>.L <nick>.24B <map name>.16B <role>.B <state>.B }*
-/// 0a44 <packet len>.W <party name>.24B { <account id>.L <nick>.24B <map name>.16B <role>.B <state>.B <class>.W <base level>.W }* <item pickup rule>.B <item share rule>.B <unknown>.L
/// role:
/// 0 = leader
/// 1 = normal
@@ -6657,23 +6648,16 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
/// 1 = disconnected
void clif_party_info(struct party_data* p, struct map_session_data *sd)
{
+ struct PACKET_ZC_GROUP_LIST *packet;
struct map_session_data* party_sd = NULL;
int i, c;
-#if PACKETVER < 20170502
- const int cmd = 0xfb;
- const int size = 46;
- unsigned char buf[2 + 2 + NAME_LENGTH + 46 * MAX_PARTY];
-#else
-// [4144] probably 0xa44 packet can works on older clients because in client was added in 2015-10-07
- const int cmd = 0xa44;
- const int size = 50;
- unsigned char buf[2 + 2 + NAME_LENGTH + 50 * MAX_PARTY + 6];
-#endif
-
+ unsigned char buf[sizeof(*packet) + sizeof(struct PACKET_ZC_GROUP_LIST_SUB) * MAX_PARTY];
nullpo_retv(p);
- WBUFW(buf, 0) = cmd;
- memcpy(WBUFP(buf, 4), p->party.name, NAME_LENGTH);
+ memset(buf, 0, sizeof(buf));
+ packet = (struct PACKET_ZC_GROUP_LIST *)buf;
+ packet->packetType = partyinfo;
+ memcpy(packet->partyName, p->party.name, NAME_LENGTH);
for(i = 0, c = 0; i < MAX_PARTY; i++)
{
struct party_member *m = &p->party.member[i];
@@ -6683,30 +6667,26 @@ void clif_party_info(struct party_data* p, struct map_session_data *sd)
if (party_sd == NULL)
party_sd = p->data[i].sd;
- WBUFL(buf, 28 + c * size) = m->account_id;
- memcpy(WBUFP(buf, 28 + c * size + 4), m->name, NAME_LENGTH);
- mapindex->getmapname_ext(mapindex_id2name(m->map), WBUFP(buf, 28 + c * size + 28));
- WBUFB(buf, 28 + c * size + 44) = (m->leader) ? 0 : 1;
- WBUFB(buf, 28 + c * size + 45) = (m->online) ? 0 : 1;
+ packet->members[c].AID = m->account_id;
+#if PACKETVER >= 20171207
+ packet->members[c].GID = m->char_id;
+#endif
+ memcpy(packet->members[c].playerName, m->name, NAME_LENGTH);
+ mapindex->getmapname_ext(mapindex_id2name(m->map), packet->members[c].mapName);
+ packet->members[c].leader = (m->leader) ? 0 : 1;
+ packet->members[c].offline = (m->online) ? 0 : 1;
#if PACKETVER >= 20170502
- WBUFW(buf, 28 + c * size + 46) = m->class;
- WBUFW(buf, 28 + c * size + 48) = m->lv;
+ packet->members[c].class = m->class;
+ packet->members[c].baseLevel = m->lv;
#endif
c++;
}
-#if PACKETVER < 20170502
- WBUFW(buf, 2) = 28 + c * size;
-#else
- WBUFB(buf, 28 + c * size) = (p->party.item & 1) ? 1 : 0;
- WBUFB(buf, 28 + c * size + 1) = (p->party.item & 2) ? 1 : 0;
- WBUFL(buf, 28 + c * size + 2) = 0; // unknown
- WBUFW(buf, 2) = 28 + c * size + 6;
-#endif
+ packet->packetLen = sizeof(*packet) + c * sizeof(struct PACKET_ZC_GROUP_LIST_SUB);
if (sd) { // send only to self
- clif->send(buf, WBUFW(buf, 2), &sd->bl, SELF);
+ clif->send(buf, packet->packetLen, &sd->bl, SELF);
} else if (party_sd) { // send to whole party
- clif->send(buf, WBUFW(buf, 2), &party_sd->bl, PARTY);
+ clif->send(buf, packet->packetLen, &party_sd->bl, PARTY);
}
}
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index cfeb3a67d..1105bec96 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -338,6 +338,17 @@ enum packet_headers {
#if PACKETVER >= 20130821
progressbarunit = 0x09D1,
#endif
+#if PACKETVER >= 20171207
+ partymemberinfo = 0x0ae4,
+ partyinfo = 0x0ae5,
+#elif PACKETVER >= 20170502
+// [4144] probably 0xa43 packet can works on older clients because in client was added in 2015-10-07
+ partymemberinfo = 0x0a43,
+ partyinfo = 0x0a44,
+#else
+ partymemberinfo = 0x01e9,
+ partyinfo = 0x00fb,
+#endif
};
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
@@ -1507,6 +1518,50 @@ struct ZC_PROGRESS_ACTOR {
uint32 time;
} __attribute__((packed));
+struct PACKET_ZC_ADD_MEMBER_TO_GROUP {
+ int16 packetType;
+ uint32 AID;
+#if PACKETVER >= 20171207
+ uint32 GID;
+#endif
+ uint32 leader;
+// [4144] probably 0xa43 packet can works on older clients because in client was added in 2015-10-07
+#if PACKETVER >= 20170502
+ int16 class;
+ int16 baseLevel;
+#endif
+ int16 x;
+ int16 y;
+ uint8 offline;
+ char partyName[NAME_LENGTH];
+ char playerName[NAME_LENGTH];
+ char mapName[MAP_NAME_LENGTH_EXT];
+ int8 sharePickup;
+ int8 shareLoot;
+} __attribute__((packed));
+
+struct PACKET_ZC_GROUP_LIST_SUB {
+ uint32 AID;
+#if PACKETVER >= 20171207
+ uint32 GID;
+#endif
+ char playerName[NAME_LENGTH];
+ char mapName[MAP_NAME_LENGTH_EXT];
+ uint8 leader;
+ uint8 offline;
+#if PACKETVER >= 20170502
+ int16 class;
+ int16 baseLevel;
+#endif
+} __attribute__((packed));
+
+struct PACKET_ZC_GROUP_LIST {
+ int16 packetType;
+ int16 packetLen;
+ char partyName[NAME_LENGTH];
+ struct PACKET_ZC_GROUP_LIST_SUB members[];
+} __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