summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFate <fate.tmw@googlemail.com>2008-11-07 18:08:57 +0000
committerFate <fate.tmw@googlemail.com>2008-11-07 18:08:57 +0000
commit0b6f8a2561b67cf9731525887ed2bcaf2910bb0a (patch)
treecb066e7b183f36a0f7d0b1ccc8f02d23fc67d7c8
parent1b35a068600580dc70fdbc4232297b55c84d8868 (diff)
downloadtmwa-0b6f8a2561b67cf9731525887ed2bcaf2910bb0a.tar.gz
tmwa-0b6f8a2561b67cf9731525887ed2bcaf2910bb0a.tar.bz2
tmwa-0b6f8a2561b67cf9731525887ed2bcaf2910bb0a.tar.xz
tmwa-0b6f8a2561b67cf9731525887ed2bcaf2910bb0a.zip
* Strip preceding/trailing blanks from new character names (#524)
-rw-r--r--src/char/char.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 5de186c..6b6b1f1 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -726,6 +726,31 @@ int mmo_char_sync_timer(int tid, unsigned int tick, int id, int data) {
return 0;
}
+//----------------------------------------------------
+// Remove trailing whitespace from a name
+//----------------------------------------------------
+static void remove_trailing_blanks(char *name)
+{
+ char *tail = name + strlen(name) - 1;
+
+ while (tail > name
+ && *tail == ' ')
+ *tail-- = 0;
+}
+
+//----------------------------------------------------
+// Remove prefix whitespace from a name
+//----------------------------------------------------
+static void remove_prefix_blanks(char *name)
+{
+ char *dst = name;
+ char *src = name;
+
+ while (*src == ' ') // find first nonblank
+ ++src;
+ while (*dst++ = *src++); // `strmove'
+}
+
//-----------------------------------
// Function to create a new character
//-----------------------------------
@@ -743,6 +768,10 @@ int make_new_char(int fd, unsigned char *dat) {
return -1;
}
+ // Eliminate whitespace
+ remove_trailing_blanks((char *)dat);
+ remove_prefix_blanks((char *)dat);
+
// check lenght of character name
if (strlen(dat) < 4) {
char_log("Make new char error (character name too small): (connection #%d, account: %d, name: '%s')." RETCODE,