summaryrefslogtreecommitdiff
path: root/src/video/dedicated_v.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-04 15:07:17 +0000
committerrubidium <rubidium@openttd.org>2008-08-04 15:07:17 +0000
commitfb5c4e469bebcdc974f4242f4f5edfd9be353543 (patch)
tree8c1c4e7b2b2d849ee9b8c837e78dc3e2a160e358 /src/video/dedicated_v.cpp
parentd09727602275a2afac5e2524f43c391a7f48dc69 (diff)
downloadopenttd-fb5c4e469bebcdc974f4242f4f5edfd9be353543.tar.xz
(svn r13992) -Fix [FS#2189]: the dedicated console removed any character that was not a printable ASCII character instead. Now it allows UTF8 formated strings too.
Diffstat (limited to 'src/video/dedicated_v.cpp')
-rw-r--r--src/video/dedicated_v.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 616e8f77d..60a20f072 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -230,21 +230,16 @@ static void DedicatedHandleKeyInput()
SetEvent(_hWaitForInputHandling);
#endif
- /* XXX - strtok() does not 'forget' \n\r if it is the first character! */
- strtok(input_line, "\r\n"); // Forget about the final \n (or \r)
- { /* Remove any special control characters */
- uint i;
- for (i = 0; i < lengthof(input_line); i++) {
- if (input_line[i] == '\n' || input_line[i] == '\r') // cut missed beginning '\0'
- input_line[i] = '\0';
-
- if (input_line[i] == '\0')
- break;
-
- if (!IsInsideMM(input_line[i], ' ', 256))
- input_line[i] = ' ';
+ /* strtok() does not 'forget' \r\n if the string starts with it,
+ * so we have to manually remove that! */
+ strtok(input_line, "\r\n");
+ for (char *c = input_line; *c != '\0'; c++) {
+ if (*c == '\n' || *c == '\r' || c == lastof(input_line)) {
+ *c = '\0';
+ break;
}
}
+ str_validate(input_line);
IConsoleCmdExec(input_line); // execute command
}