Jump to content
  • 0

properly reduce name length to 11


Question

Posted

so, i saw this in char.c

char name[NAME_LENGTH];
char esc_name[NAME_LENGTH * 2 + 1];
int char_id, flag, k;

safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));

and changed it into

char name[12];
char esc_name[12* 2 + 1];
int char_id, flag, k;

safestrncpy(name, name_, 12);
normalize_name(name,TRIM_CHARS);
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, 12));

It works, right. however, it doesn't trigger the error message on character create screen that it exceeded the character name length. it would create the character but truncate the exceeding characters. what i hope to achieve is it would trigger the error that the entered name was more than 11 letters.

thanks in advanced.

2 answers to this question

Recommended Posts

Posted

I think you should edit mmo.h instead.

//For character names, title names, guilds, maps, etc.
//Includes null-terminator as it is the length of the array.
#define NAME_LENGTH (23 + 1)
#define PASSWD_LENGTH (32+1)

Not sure. I haven't tested this. ;)

Posted

I believe that would affect everything that has something to do with the character name. I only want to reduce it to 11 chars on character creation time. This is to allow titles to be given to players from the achievement system that I am currently using. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...