From dfd6225e667744753c7bfab94d87fcdbcf3fc93b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Aug 2018 04:45:56 +0300 Subject: Add packet ZC_FORMATSTRING_MSG_COLOR. --- src/map/clif.c | 31 +++++++++++++++++++++++++++++++ src/map/clif.h | 1 + src/map/packets_struct.h | 8 ++++++++ 3 files changed, 40 insertions(+) diff --git a/src/map/clif.c b/src/map/clif.c index beb9cdf47..a57f43613 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9479,6 +9479,36 @@ static void clif_msgtable_str(struct map_session_data *sd, enum clif_messages ms aFree(p); } +/** + * Displays a format string from msgstringtable.txt with a %s value and color (ZC_FORMATSTRING_MSG). + * + * @param sd The target character. + * @param msg_id msgstringtable message index, 0-based (@see enum clif_messages) + * @param value The value to fill %s. + * @param color The color to use + */ +static void clif_msgtable_str_color(struct map_session_data *sd, enum clif_messages msg_id, const char *value, uint32 color) +{ +#if PACKETVER >= 20160330 + nullpo_retv(sd); + nullpo_retv(value); + + int message_len = (int)strlen(value) + 1; + const int len = sizeof(struct PACKET_ZC_FORMATSTRING_MSG_COLOR) + message_len + 1; + struct PACKET_ZC_FORMATSTRING_MSG_COLOR *p = (struct PACKET_ZC_FORMATSTRING_MSG_COLOR *)aMalloc(len); + + p->PacketType = 0xa6f; + p->PacketLength = len; + p->messageId = msg_id; + p->color = color; + safestrncpy(p->messageString, value, message_len); + p->messageString[message_len] = 0; + + clif->send(p, p->PacketLength, &sd->bl, SELF); + aFree(p); +#endif +} + /** * Displays a format string from msgstringtable.txt with a color (ZC_MSG_COLOR). * @@ -22273,6 +22303,7 @@ void clif_defaults(void) clif->msgtable = clif_msgtable; clif->msgtable_num = clif_msgtable_num; clif->msgtable_str = clif_msgtable_str; + clif->msgtable_str_color = clif_msgtable_str_color; clif->msgtable_color = clif_msgtable_color; clif->message = clif_displaymessage; clif->messageln = clif_displaymessage2; diff --git a/src/map/clif.h b/src/map/clif.h index b74eb8625..9e71386b7 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -952,6 +952,7 @@ struct clif_interface { void (*msgtable_num) (struct map_session_data *sd, enum clif_messages msg_id, int value); void (*msgtable_skill) (struct map_session_data *sd, uint16 skill_id, enum clif_messages msg_id); void (*msgtable_str) (struct map_session_data *sd, enum clif_messages, const char *value); + void (*msgtable_str_color) (struct map_session_data *sd, enum clif_messages, const char *value, uint32 color); void (*msgtable_color) (struct map_session_data *sd, enum clif_messages, uint32 color); void (*message) (const int fd, const char* mes); void (*messageln) (const int fd, const char* mes); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index a92bc52ab..346c11692 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -1843,6 +1843,14 @@ struct PACKET_ZC_FORMATSTRING_MSG { char MessageString[]; } __attribute__((packed)); +struct PACKET_ZC_FORMATSTRING_MSG_COLOR { + uint16 PacketType; + uint16 PacketLength; + uint16 messageId; + uint32 color; + char messageString[]; +} __attribute__((packed)); + struct PACKET_ZC_MSG_COLOR { uint16 PacketType; uint16 MessageId; -- cgit v1.2.3-70-g09d2