From 83077740c7c996d198617d45a1916cd31ff38e9a Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 18 Jan 2015 15:30:25 -0200 Subject: Fixed Bug Report 8438 Addresses instances crashing when running with the CELL_NOSTACK define enabled. Caused by the define not being readily available to all areas that played with mapcell (now with it being included from map.h this no longer is the case) http://hercules.ws/board/tracker/issue-8438-cell-nostack-and-instances-crash/ Signed-off-by: shennetsind --- src/map/instance.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/map/instance.c') diff --git a/src/map/instance.c b/src/map/instance.c index 96bdcc053..168a03da6 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -151,7 +151,7 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ int instance_add_map(const char *name, int instance_id, bool usebasename, const char *map_name) { int16 m = map->mapname2mapid(name); int i, im = -1; - size_t num_cell, size; + size_t num_cell, size, j; if( m < 0 ) return -1; // source map not found @@ -205,6 +205,15 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const CREATE( map->list[im].cell, struct mapcell, num_cell ); memcpy( map->list[im].cell, map->list[m].cell, num_cell * sizeof(struct mapcell) ); + // Appropriately clear cell data + for(j = 0; j < num_cell; j++) { + map->list[im].cell[j].cell_bl = 0; + map->list[im].cell[j].basilica = 0; + map->list[im].cell[j].icewall = 0; + map->list[im].cell[j].npc = 0; + map->list[im].cell[j].landprotector = 0; + } + size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); map->list[im].block = (struct block_list**)aCalloc(size, 1); map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); -- cgit v1.2.3-60-g2f50