diff options
author | Dastgir <dastgirpojee@rocketmail.com> | 2016-01-18 17:36:25 +0530 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-03-13 07:52:57 +0000 |
commit | d02ebf0532fe251bfac6c6aec78e72eb64156bd7 (patch) | |
tree | 44f4b87e9a429a97008386026a04beee7bb786a5 | |
parent | 974c7f982484341b58bf85c517bc81ab3b0e5ebe (diff) | |
download | hercules-d02ebf0532fe251bfac6c6aec78e72eb64156bd7.tar.gz hercules-d02ebf0532fe251bfac6c6aec78e72eb64156bd7.tar.bz2 hercules-d02ebf0532fe251bfac6c6aec78e72eb64156bd7.tar.xz hercules-d02ebf0532fe251bfac6c6aec78e72eb64156bd7.zip |
Added quest_notify_objective and its packet
-rw-r--r-- | src/map/clif.c | 38 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/packets_struct.h | 24 | ||||
-rw-r--r-- | src/map/quest.c | 8 |
4 files changed, 70 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 8adb24450..60300db37 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16327,6 +16327,43 @@ void clif_quest_update_objective(struct map_session_data *sd, struct quest *qd) aFree(buf); } +/// Notification of an hunting mission counter just after quest is added (ZC_HUNTING_QUEST_INFO). +/// 08fe <packet len>.W { <quest id>.L <mob id>.L <total count>.W <current count>.W }*3 +void clif_quest_notify_objective(struct map_session_data *sd, struct quest *qd) +{ + int i, len, real_len; + uint8 *buf = NULL; + struct packet_quest_hunt_info *packet = NULL; + struct quest_db *qi; + + nullpo_retv(sd); + nullpo_retv(qd); + + qi = quest->db(qd->quest_id); + Assert_retv(qi->objectives_count < MAX_QUEST_OBJECTIVES); + + len = sizeof(struct packet_quest_hunt_info) + + MAX_QUEST_OBJECTIVES * sizeof(struct packet_quest_hunt_info_sub); // >= than the actual length + + buf = aCalloc(1, len); + packet = (struct packet_quest_hunt_info *)WBUFP(buf, 0); + real_len = sizeof(*packet); + + packet->PacketType = questUpdateType2; + + for (i = 0; i < qi->objectives_count; i++) { + real_len += sizeof(packet->info[i]); + + packet->info[i].questID = qd->quest_id; + packet->info[i].mob_id = qi->objectives[i].mob; + packet->info[i].maxCount = qi->objectives[i].count; + packet->info[i].count = qd->count[i]; + } + 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))); /// Request to change the state of a quest (CZ_ACTIVE_QUEST). /// 02b6 <quest id>.L <active>.B @@ -20966,6 +21003,7 @@ void clif_defaults(void) { clif->quest_delete = clif_quest_delete; clif->quest_update_status = clif_quest_update_status; clif->quest_update_objective = clif_quest_update_objective; + clif->quest_notify_objective = clif_quest_notify_objective; clif->quest_show_event = clif_quest_show_event; /* mail-related */ clif->mail_window = clif_Mail_window; diff --git a/src/map/clif.h b/src/map/clif.h index acf79c373..58bd5b4bf 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1021,6 +1021,7 @@ struct clif_interface { void (*quest_delete) (struct map_session_data *sd, int quest_id); void (*quest_update_status) (struct map_session_data *sd, int quest_id, bool active); void (*quest_update_objective) (struct map_session_data *sd, struct quest *qd); + void (*quest_notify_objective) (struct map_session_data *sd, struct quest *qd); void (*quest_show_event) (struct map_session_data *sd, struct block_list *bl, short state, short color); /* mail-related */ void (*mail_window) (int fd, int flag); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index e7920aba4..d8a2c6b31 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -367,6 +367,7 @@ enum packet_headers { #else questUpdateType = 0x2b5, #endif // PACKETVER < 20150513 + questUpdateType2 = 0x8fe, }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1675,7 +1676,28 @@ struct packet_quest_update_header { uint16 PacketLength; int16 count; struct packet_quest_update_hunt objectives[]; -} __attribute__((packed)); +} __attribute__((packed)); + +/** + * Header for: + * PACKET_MOB_HUNTING (PACKETVER >= 20150513) + */ +struct packet_quest_hunt_info_sub { + uint32 questID; + uint32 mob_id; + int16 maxCount; + int16 count; +} __attribute__((packed)); + +/** + * Header for: + * ZC_HUNTING_QUEST_INFO (PACKETVER >= 20150513) + */ +struct packet_quest_hunt_info { + uint16 PacketType; + uint16 PacketLength; + struct packet_quest_hunt_info_sub info[]; +} __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) diff --git a/src/map/quest.c b/src/map/quest.c index 4c5dcb59f..581ecf45e 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -148,7 +148,11 @@ int quest_add(struct map_session_data *sd, int quest_id, unsigned int time_limit sd->save_quest = true; clif->quest_add(sd, &sd->quest_log[n]); +#if PACKETVER >= 20150513 + clif->quest_notify_objective(sd, &sd->quest_log[n]); +#else clif->quest_update_objective(sd, &sd->quest_log[n]); +#endif if ((map->save_settings & 64) != 0) chrif->save(sd, 0); @@ -201,7 +205,11 @@ int quest_change(struct map_session_data *sd, int qid1, int qid2) clif->quest_delete(sd, qid1); clif->quest_add(sd, &sd->quest_log[i]); +#if PACKETVER >= 20150513 + clif->quest_notify_objective(sd, &sd->quest_log[i]); +#else clif->quest_update_objective(sd, &sd->quest_log[i]); +#endif if( map->save_settings&64 ) chrif->save(sd,0); |