Fixes instance map name faults (#4945)
* Fixes #4915. * Fixes instance map names when it reaches 1000. * Fixes instances with more than 8 character crashing the client. * Other minor cleanups. Thanks to @voyfmyuh and @Atemo! Co-authored-by: Atemo <Atemo@users.noreply.github.com>
This commit is contained in:
@@ -2703,7 +2703,7 @@ int map_addinstancemap(int src_m, int instance_id)
|
||||
|
||||
if(strlen(name) > 20) {
|
||||
// against buffer overflow
|
||||
ShowError("map_addinstancemap: can't add long map name \"%s\"\n", name);
|
||||
ShowError("map_addinstancemap: Map name \"%s\" is too long.\n", name);
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -2732,7 +2732,7 @@ int map_addinstancemap(int src_m, int instance_id)
|
||||
// Alter the name
|
||||
// Due to this being custom we only worry about preserving as many characters as necessary for accurate map distinguishing
|
||||
// This also allows us to maintain complete independence with main map functions
|
||||
if ((strchr(iname, '@') == NULL) && strlen(iname) > 8) {
|
||||
if ((strchr(iname, '@') == nullptr) && strlen(iname) > 8) {
|
||||
memmove(iname, iname + (strlen(iname) - 9), strlen(iname));
|
||||
snprintf(dst_map->name, sizeof(dst_map->name), "%d#%s", (instance_id % 1000), iname);
|
||||
} else
|
||||
@@ -2766,12 +2766,12 @@ int map_addinstancemap(int src_m, int instance_id)
|
||||
dst_map->block_mob = (struct block_list **)aCalloc(1,size);
|
||||
|
||||
dst_map->index = mapindex_addmap(-1, dst_map->name);
|
||||
dst_map->channel = NULL;
|
||||
dst_map->channel = nullptr;
|
||||
dst_map->mob_delete_timer = INVALID_TIMER;
|
||||
|
||||
map_data_copy(dst_map, src_map);
|
||||
|
||||
ShowInfo("[Instance] Created map '%s' ('%d') from map '%s' ('%d')\n", dst_map->name, dst_map->m, name, src_map->m);
|
||||
ShowInfo("[Instance] Created map '%s' (%d) from '%s' (%d).\n", dst_map->name, dst_map->m, name, src_map->m);
|
||||
|
||||
map_addmap2db(dst_map);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user