summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c38
-rw-r--r--src/map/packets_struct.h22
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 <packet len>.W <mobs>.W { <quest id>.L <mob id>.L <total count>.W <current count>.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