Add cell copying across instances - Fixes bugreport:7875
This commit is contained in:
parent
11860e2e1f
commit
e6565c0be2
@ -2182,7 +2182,7 @@ int map_addinstancemap(const char *name, int id)
|
|||||||
int src_m = map_mapname2mapid(name);
|
int src_m = map_mapname2mapid(name);
|
||||||
int dst_m = -1, i;
|
int dst_m = -1, i;
|
||||||
char iname[MAP_NAME_LENGTH];
|
char iname[MAP_NAME_LENGTH];
|
||||||
size_t size;
|
size_t num_cell, size;
|
||||||
|
|
||||||
if(src_m < 0)
|
if(src_m < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2229,6 +2229,11 @@ int map_addinstancemap(const char *name, int id)
|
|||||||
memset(map[dst_m].npc, 0, sizeof(map[dst_m].npc));
|
memset(map[dst_m].npc, 0, sizeof(map[dst_m].npc));
|
||||||
map[dst_m].npc_num = 0;
|
map[dst_m].npc_num = 0;
|
||||||
|
|
||||||
|
// Reallocate cells
|
||||||
|
num_cell = map[dst_m].xs * map[dst_m].ys;
|
||||||
|
CREATE( map[dst_m].cell, struct mapcell, num_cell );
|
||||||
|
memcpy( map[dst_m].cell, map[src_m].cell, num_cell * sizeof(struct mapcell) );
|
||||||
|
|
||||||
size = map[dst_m].bxs * map[dst_m].bys * sizeof(struct block_list*);
|
size = map[dst_m].bxs * map[dst_m].bys * sizeof(struct block_list*);
|
||||||
map[dst_m].block = (struct block_list **)aCalloc(1,size);
|
map[dst_m].block = (struct block_list **)aCalloc(1,size);
|
||||||
map[dst_m].block_mob = (struct block_list **)aCalloc(1,size);
|
map[dst_m].block_mob = (struct block_list **)aCalloc(1,size);
|
||||||
@ -2291,9 +2296,7 @@ static int map_instancemap_clean(struct block_list *bl, va_list ap)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
int map_delinstancemap(int m)
|
int map_delinstancemap(int m)
|
||||||
{
|
{
|
||||||
if(m < 0)
|
if(m < 0 || !map[m].instance_id)
|
||||||
return 0;
|
|
||||||
if(map[m].instance_id == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Kick everyone out
|
// Kick everyone out
|
||||||
@ -2308,6 +2311,7 @@ int map_delinstancemap(int m)
|
|||||||
mapindex_removemap( map[m].index );
|
mapindex_removemap( map[m].index );
|
||||||
|
|
||||||
// Free memory
|
// Free memory
|
||||||
|
aFree(map[m].cell);
|
||||||
aFree(map[m].block);
|
aFree(map[m].block);
|
||||||
aFree(map[m].block_mob);
|
aFree(map[m].block_mob);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user