diff options
-rw-r--r-- | src/map/clif.c | 39 | ||||
-rw-r--r-- | src/map/packets_struct.h | 25 |
2 files changed, 49 insertions, 15 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 2c9995835..e996db1f1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16224,31 +16224,40 @@ void clif_quest_send_mission(struct map_session_data *sd) /// 02b3 <quest id>.L <active>.B <start time>.L <expire time>.L <mobs>.W { <mob id>.L <mob count>.W <mob name>.24B }*3 void clif_quest_add(struct map_session_data *sd, struct quest *qd) { - int fd; - int i; + int i, len; + uint8 *buf = NULL; + struct packet_quest_add_header *packet = NULL; struct quest_db *qi; nullpo_retv(sd); nullpo_retv(qd); - fd = sd->fd; + qi = quest->db(qd->quest_id); - WFIFOHEAD(fd, packet_len(0x2b3)); - WFIFOW(fd, 0) = 0x2b3; - WFIFOL(fd, 2) = qd->quest_id; - WFIFOB(fd, 6) = qd->state; - WFIFOB(fd, 7) = qd->time - qi->time; - WFIFOL(fd, 11) = qd->time; - WFIFOW(fd, 15) = qi->objectives_count; + Assert_retv(qi->objectives_count < MAX_QUEST_OBJECTIVES); + + len = sizeof(struct packet_quest_add_header) + + MAX_QUEST_OBJECTIVES * sizeof(struct packet_quest_hunt_sub); // >= than the actual length + + buf = aCalloc(1, len); + packet = (struct packet_quest_add_header *)WBUFP(buf, 0); + + packet->PacketType = questAddType; + packet->questID = qd->quest_id; + packet->active = qd->state; + packet->quest_svrTime = qd->time - qi->time; + packet->quest_endTime = qd->time; + packet->count = qi->objectives_count; for (i = 0; i < qi->objectives_count; i++) { struct mob_db *monster; - WFIFOL(fd, i*30+17) = qi->objectives[i].mob; - WFIFOW(fd, i*30+21) = qd->count[i]; + monster = mob->db(qi->objectives[i].mob); - memcpy(WFIFOP(fd, i*30+23), monster->jname, NAME_LENGTH); + packet->objectives[i].mob_id = qi->objectives[i].mob; + packet->objectives[i].huntCount = qd->count[i]; + memcpy(packet->objectives[i].mobName, monster->jname, NAME_LENGTH); } - - WFIFOSET(fd, packet_len(0x2b3)); + clif->send(buf, len, &sd->bl, SELF); + aFree(buf); } /// Notification about a quest being removed (ZC_DEL_QUEST). diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index f75d0f24a..c8ed85947 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -357,6 +357,7 @@ enum packet_headers { clanLeave = 0x0989, ///< ZC_ACK_CLAN_LEAVE clanMessage = 0x098E, ///< ZC_NOTIFY_CLAN_CHAT #endif + questAddType = 0x2b3, }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1607,6 +1608,30 @@ struct PACKET_ZC_NOTIFY_CLAN_CHAT { char Message[]; } __attribute__((packed)); +/** + * PACKET_ZC_MISSION_HUNT (PACKETVER < 20150513) + */ +struct packet_quest_hunt_sub { + int32 mob_id; + int16 huntCount; + char mobName[NAME_LENGTH]; +} __attribute__((packed)); + +/** + * Header for: + * PACKET_ZC_ADD_QUEST (PACKETVER < 20150513) + * + */ +struct packet_quest_add_header { + uint16 PacketType; + uint32 questID; + uint8 active; + int32 quest_svrTime; + int32 quest_endTime; + int16 count; + struct packet_quest_hunt_sub 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 |