Expand NPC Name Length to 50

Signed-off-by: Cydh Ramdh <cydh@pservero.com>
This commit is contained in:
Cydh Ramdh 2016-09-19 10:03:53 +07:00 committed by Lemongrass3110
parent b2c4178209
commit d3077435e8
3 changed files with 18 additions and 16 deletions

View File

@ -96,6 +96,8 @@
//Includes null-terminator as it is the length of the array.
#define NAME_LENGTH (23 + 1)
#define PASSWD_LENGTH (32+1)
//NPC names can be longer than it's displayed on client (NAME_LENGTH).
#define NPC_NAME_LENGTH 50
//For item names, which tend to have much longer names.
#define ITEM_NAME_LENGTH 50
//For Map Names, which the client considers to be 16 in length including the .gat extension

View File

@ -2222,27 +2222,27 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
{
const char* p;
struct npc_data* dnd;// duplicate npc
char newname[NAME_LENGTH];
char newname[NPC_NAME_LENGTH+1];
// parse name
p = strstr(name,"::");
if( p ) { // <Display name>::<Unique name>
size_t len = p-name;
if( len > NAME_LENGTH ) {
ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH);
if( len > NPC_NAME_LENGTH ) {
ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
safestrncpy(nd->name, name, sizeof(nd->name));
} else {
memcpy(nd->name, name, len);
memset(nd->name+len, 0, sizeof(nd->name)-len);
}
len = strlen(p+2);
if( len > NAME_LENGTH )
ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH);
if( len > NPC_NAME_LENGTH )
ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
safestrncpy(nd->exname, p+2, sizeof(nd->exname));
} else {// <Display name>
size_t len = strlen(name);
if( len > NAME_LENGTH )
ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH);
if( len > NPC_NAME_LENGTH )
ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
safestrncpy(nd->name, name, sizeof(nd->name));
safestrncpy(nd->exname, name, sizeof(nd->exname));
}
@ -2773,9 +2773,9 @@ int npc_convertlabel_db(DBKey key, DBData *data, va_list ap)
len = p-lname;
// here we check if the label fit into the buffer
if( len > 23 )
if( len > NAME_LENGTH )
{
ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, filepath);
ShowError("npc_parse_script: label name longer than %d chars! '%s'\n (%s)", NAME_LENGTH, lname, filepath);
return 0;
}
@ -3152,7 +3152,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
}
int npc_duplicate4instance(struct npc_data *snd, int16 m) {
char newname[NAME_LENGTH];
char newname[NPC_NAME_LENGTH+1];
if( map[m].instance_id == 0 )
return 1;
@ -4627,11 +4627,11 @@ void do_init_npc(void){
for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ )
npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i;
ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1);
npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);
ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), EVENT_NAME_LENGTH);
npcname_db = strdb_alloc(DB_OPT_BASE, NPC_NAME_LENGTH+1);
npc_path_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,80);
#if PACKETVER >= 20131223
NPCMarketDB = strdb_alloc(DB_OPT_BASE, NAME_LENGTH+1);
NPCMarketDB = strdb_alloc(DB_OPT_BASE, NPC_NAME_LENGTH+1);
npc_market_fromsql();
#endif

View File

@ -17,7 +17,7 @@ struct npc_timerevent_list {
};
struct npc_label_list {
char name[NAME_LENGTH];
char name[NAME_LENGTH+1];
int pos;
};
@ -44,8 +44,8 @@ struct npc_data {
struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
struct npc_data *master_nd;
short class_,speed,instance_id;
char name[NAME_LENGTH+1];// display name
char exname[NAME_LENGTH+1];// unique npc name
char name[NPC_NAME_LENGTH+1];// display name
char exname[NPC_NAME_LENGTH+1];// unique npc name
int chat_id,touching_id;
unsigned int next_walktime;