summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-12-31 14:48:00 +0100
committerHaru <haru@dotalux.com>2016-06-25 17:29:48 +0200
commit89d43a060f924e565650e7a8ed85c199c6f0db36 (patch)
tree476cf5efbe856eae366e699310bc16df59eee8ca /src/map/clif.c
parentbe570dd88f744efcf837a69901ad60bb1c78fffe (diff)
downloadhercules-89d43a060f924e565650e7a8ed85c199c6f0db36.tar.gz
hercules-89d43a060f924e565650e7a8ed85c199c6f0db36.tar.bz2
hercules-89d43a060f924e565650e7a8ed85c199c6f0db36.tar.xz
hercules-89d43a060f924e565650e7a8ed85c199c6f0db36.zip
Added option to strip hard line-breaks from `mes` dialogs
- The `\r` character, in a `mes` dialog, is normally represented by the client as a hard line-break. - Since a client may have different requirements in line lengths (for example using a font with different size or metrics), an user might wish to ignore hard-wraps and let the client automatically soft-wrap instead. - If you want to hard-wrap (official default), keep the SCRIPT_MES_STRIP_LINEBREAK define commented out. - If you want to let the client soft-wrap automatically (may work better for custom clients), uncomment it. - Imprved HULD handling of `\r` (to avoid control characters in the generated file) - Please note that this requires cooperation by script writers: * Each `mes` should contain one and only one sentence, possibly without using the '+' concatenation (but, rather, sprintf). * Two separate sentences (where a hard-wrap is required even for soft-wrapped text) should always go into separate `mes` commands. * Following the above two recommendations, also produces a better quality translations .pot file. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c14
1 files changed, 14 insertions, 0 deletions
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));
}