Jump to content

Recommended Posts

Posted (edited)

Hello guys, I'm brazilian and I was using the brAthena so decided test the rAthena. I had a problem here with the max length size, that problem when the npc's name are too long.

I looked on brAthena and could do the modification on NPC name length, to possibilite the brazilian users keep using their old npcs on rathena, so lets do it!

First you have to open your emulator folder src/map/script.c

if( instance_id && (nd = npc_name2id(str)) != NULL )

{

static char npcname[NAME_LENGTH];

snprintf(npcname, sizeof(npcname), "dup_%d_%d", instance_id, nd->bl.id);

script_pushconststr(st,npcname);

}

change the bold line to:

static char npcname[NPC_NAME_LENGTH];

Nice! Close the script.c and open your npc.c

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);

static void npc_parsename(struct npc_data* nd, const char* name, const char* start, const char* buffer, const char* filepath)

{

const char* p;

struct npc_data* dnd;// duplicate npc

char newname[NAME_LENGTH];

// 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);

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);

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);

safestrncpy(nd->name, name, sizeof(nd->name));

safestrncpy(nd->exname, name, sizeof(nd->exname));

}

void npc_duplicate4graveyard(struct block_list* bl, struct block_list* sbl)

{

char newname[NAME_LENGTH];

static char w1[50], w2[50], w3[50], w4[50];

const char* stat_buf = "- call from graveyard subsystem -\n";

struct npc_data* nd; // Source NPC

int npc_duplicate4instance(struct npc_data *snd, int m) {

char newname[NAME_LENGTH];

You will do the same thing right here. Change all the bold parts to NPC_NAME_LENGTH

Open your npc.h and do the same, changing all the NAME_LENGTH TO NPC_NAME_LENGTH

struct npc_timerevent_list {

int timer,pos;

};

struct npc_label_list {

char name[NAME_LENGTH];

int pos;

};

struct npc_item_list {

unsigned int nameid,value;

};

struct graveyard_info {

char name[NAME_LENGTH]; // Name of the Victim

char killed_by[NAME_LENGTH];

time_t killed_time;

};

struct npc_data {

struct block_list bl;

struct unit_data ud; //Because they need to be able to move....

struct view_data *vd;

struct status_change sc; //They can't have status changes, but.. they want the visual opt values.

struct npc_data *master_nd;

short class_;

short speed;

char name[NAME_LENGTH+1];// display name

char exname[NAME_LENGTH+1];// unique npc name

Great! After that, open src/common/mmo.h and add this:

#define NAME_LENGTH (23 + 1)

#define NPC_NAME_LENGTH 37

Finished! After you did it just recompile your emulator and test, in my case it worked perfectly.

Credits: Protimus, the admin of brAthena, he was the responsable to do the source modification, I just posted here to help someone that had this problem, like me :D

Hope you enjoy!!

Edited by synyster
  • Upvote 4
  • 7 months later...
Posted

In the case when you make a DIFF for this source edit, please note that inside the function "npc_parsename",  the function call of ShowWarning did not update its NPC_NAME_LENGTH, as seen below.

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);

 

Thanks!

Join the conversation

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

Guest
Reply to this topic...

×   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...