diff options
-rw-r--r-- | src/config/core.h | 11 | ||||
-rw-r--r-- | src/map/clif.c | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/config/core.h b/src/config/core.h index 09954e0cb..afd138a43 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -40,6 +40,17 @@ /// your map-server using more resources while this is active, comment the line #define SCRIPT_CALLFUNC_CHECK +/** + * Strip linebreaks from `mes` dialogs. + * + * Leave this line commented out to keep the hard line-breaks (`\r`) in the + * displayed `mes` dialogs (as in official servers). + * Uncomment it to strip the line-breaks and replace them with spaces, letting + * the client automatically wrap text in dialogs, depending on font size and + * dialog window size (may work better for clients using a non-standard font). + */ +//#define SCRIPT_MES_STRIP_LINEBREAK + /// Comment to disable Hercules' console_parse /// CONSOLE_INPUT allows you to type commands into the server's console, /// Disabling it saves one thread. diff --git a/src/map/clif.c b/src/map/clif.c index 40545cd6d..13a7b0839 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1978,6 +1978,10 @@ void clif_selllist(struct map_session_data *sd) void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) { int fd, slen; +#ifdef SCRIPT_MES_STRIP_LINEBREAK + char *stripmes = NULL; + int i; +#endif nullpo_retv(sd); nullpo_retv(mes); @@ -1992,7 +1996,17 @@ void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) WFIFOW(fd,0) = 0xb4; WFIFOW(fd,2) = slen; WFIFOL(fd,4) = npcid; +#ifdef SCRIPT_MES_STRIP_LINEBREAK + stripmes = aStrdup(mes); + for (i = 0; stripmes[i] != '\0'; ++i) { + if (stripmes[i] == '\r') + stripmes[i] = ' '; + } + memcpy(WFIFOP(fd,8), stripmes, slen-8); + aFree(stripmes); +#else // ! SCRIPT_MES_STRIP_LINEBREAK memcpy(WFIFOP(fd,8), mes, slen-8); +#endif // SCRIPT_MES_STRIP_LINEBREAK WFIFOSET(fd,WFIFOW(fd,2)); } |