From 7a73c1cef1a60cc7282e1f60b5ed8e4a79d0dae7 Mon Sep 17 00:00:00 2001 From: Dastgir Date: Mon, 18 Jan 2016 17:04:50 +0530 Subject: Changed UPDATE_MISSION_HUNT packet to structure form --- src/map/clif.c | 38 +++++++++++++++++++++++--------------- src/map/packets_struct.h | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index f0c090a03..a8f958241 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16288,30 +16288,38 @@ void clif_quest_delete(struct map_session_data *sd, int quest_id) { /// 02b5 .W .W { .L .L .W .W }*3 void clif_quest_update_objective(struct map_session_data *sd, struct quest *qd) { - int fd; - int i; + int i, len, real_len; + uint8 *buf = NULL; + struct packet_quest_update_header *packet = NULL; struct quest_db *qi; - int len; nullpo_retv(sd); nullpo_retv(qd); - fd = sd->fd; + qi = quest->db(qd->quest_id); - len = qi->objectives_count * 12 + 6; + Assert_retv(qi->objectives_count < MAX_QUEST_OBJECTIVES); + + len = sizeof(struct packet_quest_update_header) + + MAX_QUEST_OBJECTIVES * sizeof(struct packet_quest_update_hunt); // >= than the actual length - WFIFOHEAD(fd, len); - WFIFOW(fd, 0) = 0x2b5; - WFIFOW(fd, 2) = len; - WFIFOW(fd, 4) = qi->objectives_count; + buf = aCalloc(1, len); + packet = (struct packet_quest_update_header *)WBUFP(buf, 0); + real_len = sizeof(*packet); + + packet->PacketType = questUpdateType; + packet->count = qi->objectives_count; for (i = 0; i < qi->objectives_count; i++) { - WFIFOL(fd, i*12+6) = qd->quest_id; - WFIFOL(fd, i*12+10) = qi->objectives[i].mob; - WFIFOW(fd, i*12+14) = qi->objectives[i].count; - WFIFOW(fd, i*12+16) = qd->count[i]; + real_len += sizeof(packet->objectives[i]); + + packet->objectives[i].questID = qd->quest_id; + packet->objectives[i].mob_id = qi->objectives[i].mob; + packet->objectives[i].maxCount = qi->objectives[i].count; + packet->objectives[i].count = qd->count[i]; } - - WFIFOSET(fd, len); + packet->PacketLength = real_len; + clif->send(buf, real_len, &sd->bl, SELF); + aFree(buf); } void clif_parse_questStateAck(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 309c5f007..159aba98c 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -362,6 +362,7 @@ enum packet_headers { #else questAddType = 0x2b3, #endif // PACKETVER < 20150513 + questUpdateType = 0x2b5, }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1645,6 +1646,27 @@ struct packet_quest_add_header { struct packet_quest_hunt_sub objectives[]; } __attribute__((packed)); +/** + * PACKET_MOB_HUNTING (PACKETVER < 20150513) + */ +struct packet_quest_update_hunt { + uint32 questID; + uint32 mob_id; + int16 maxCount; + int16 count; +} __attribute__((packed)); + +/** + * Header for: + * PACKET_ZC_UPDATE_MISSION_HUNT (PACKETVER < 20150513) + */ +struct packet_quest_update_header { + uint16 PacketType; + uint16 PacketLength; + int16 count; + struct packet_quest_update_hunt objectives[]; +} __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 -- cgit v1.2.3-70-g09d2