diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-08-23 04:45:56 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-08-23 04:49:03 +0300 |
commit | dfd6225e667744753c7bfab94d87fcdbcf3fc93b (patch) | |
tree | cd9735c5cb1c6c90fbf35104aaa497bf459d86a9 | |
parent | a365de2b0735e51fc3c089253a8b4a2a54050be7 (diff) | |
download | hercules-dfd6225e667744753c7bfab94d87fcdbcf3fc93b.tar.gz hercules-dfd6225e667744753c7bfab94d87fcdbcf3fc93b.tar.bz2 hercules-dfd6225e667744753c7bfab94d87fcdbcf3fc93b.tar.xz hercules-dfd6225e667744753c7bfab94d87fcdbcf3fc93b.zip |
Add packet ZC_FORMATSTRING_MSG_COLOR.
-rw-r--r-- | src/map/clif.c | 31 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/packets_struct.h | 8 |
3 files changed, 40 insertions, 0 deletions
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 @@ -9480,6 +9480,36 @@ static void clif_msgtable_str(struct map_session_data *sd, enum clif_messages ms } /** + * 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). * * @param sd The target character. @@ -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; |