summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,