From 4faf1f94fc7d38d0004b9694341c1c63c5785894 Mon Sep 17 00:00:00 2001 From: Asheraf Date: Wed, 4 Apr 2018 21:02:47 +0100 Subject: Add support for packet ZC_MSG_COLOR --- src/map/clif.c | 21 +++++++++++++++++++++ src/map/clif.h | 1 + src/map/packets_struct.h | 6 ++++++ 3 files changed, 28 insertions(+) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index dcb1919fb..942600a26 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9261,6 +9261,26 @@ void clif_msgtable_str(struct map_session_data *sd, uint16 msg_id, const char *v aFree(p); } +/** +* Displays a format string from msgstringtable.txt with a color (ZC_MSG_COLOR). +* +* @param sd The target character. +* @param msg_id msgstringtable message index, 0-based (@see enum clif_messages) +* @param color The color to use +*/ +void clif_msgtable_color(struct map_session_data *sd, uint16 msg_id, uint32 color) +{ + struct PACKET_ZC_MSG_COLOR p; + + nullpo_retv(sd); + + p.PacketType = 0x9cd; + p.MessageId = msg_id; + p.MessageColor = RGB2BGR(color); + + clif->send(&p, sizeof(p), &sd->bl, SELF); +} + /** * Validates and processes a global/guild/party message packet. * @@ -20954,6 +20974,7 @@ void clif_defaults(void) { clif->msgtable = clif_msgtable; clif->msgtable_num = clif_msgtable_num; clif->msgtable_str = clif_msgtable_str; + clif->msgtable_color = clif_msgtable_color; clif->message = clif_displaymessage; clif->messageln = clif_displaymessage2; clif->messages = clif_displaymessage_sprintf; diff --git a/src/map/clif.h b/src/map/clif.h index 00881db3b..eee978aac 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -887,6 +887,7 @@ struct clif_interface { void (*msgtable_num) (struct map_session_data *sd, unsigned short msg_id, int value); void (*msgtable_skill) (struct map_session_data *sd, uint16 skill_id, int msg_id); void (*msgtable_str) (struct map_session_data *sd, uint16 msg_id, const char *value); + void (*msgtable_color) (struct map_session_data *sd, uint16 msg_id, uint32 color); void (*message) (const int fd, const char* mes); void (*messageln) (const int fd, const char* mes); /* message+s(printf) */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 606057f52..7e154c12c 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -1706,6 +1706,12 @@ struct PACKET_ZC_FORMATSTRING_MSG { char MessageString[]; } __attribute__((packed)); +struct PACKET_ZC_MSG_COLOR { + uint16 PacketType; + uint16 MessageId; + uint32 MessageColor; +} __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 -- cgit v1.2.3-70-g09d2