synyster Posted September 13, 2012 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 5 Reputation: 4 Joined: 09/13/12 Last Seen: November 17, 2012 Share Posted September 13, 2012 (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 Hope you enjoy!! Edited September 13, 2012 by synyster 4 Quote Link to comment Share on other sites More sharing options...
Start_ Posted April 23, 2013 Group: Members Topic Count: 26 Topics Per Day: 0.01 Content Count: 950 Reputation: 180 Joined: 04/05/13 Last Seen: 7 hours ago Share Posted April 23, 2013 I will try this Quote Link to comment Share on other sites More sharing options...
Emistry Posted April 23, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Thursday at 04:49 PM Share Posted April 23, 2013 @TS please read the rules.. http://rathena.org/board/forum-33/announcement-20-new-source-releases-rules/ Upload your diffs as an attachment or some other external link where it can be downloaded. Don't post a codebox/quote with it. Please edit your post as soon as possible.... Quote Link to comment Share on other sites More sharing options...
iwillnot Posted April 26, 2013 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 51 Reputation: 23 Joined: 04/28/12 Last Seen: April 22, 2022 Share Posted April 26, 2013 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.