diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 5bd122ce68..369cf18558 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -1016,7 +1016,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) struct npc_data *nd = map_id2nd(sd->areanpc[i]); if (!nd || nd->subtype != NPCTYPE_SCRIPT || - !(x >= nd->bl.x - nd->u.scr.xs && x <= nd->bl.x + nd->u.scr.xs && y >= nd->bl.y - nd->u.scr.ys && y <= nd->bl.y + nd->u.scr.ys)) + !(nd->bl.m == m && x >= nd->bl.x - nd->u.scr.xs && x <= nd->bl.x + nd->u.scr.xs && y >= nd->bl.y - nd->u.scr.ys && y <= nd->bl.y + nd->u.scr.ys)) sd->areanpc.erase(sd->areanpc.begin() + i); } diff --git a/src/map/unit.cpp b/src/map/unit.cpp index f35f0a032f..58a1bfeca5 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -1243,6 +1243,12 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) bl->y = ud->to_y = y; bl->m = m; + if (bl->type == BL_NPC) { + TBL_NPC *nd = (TBL_NPC*)bl; + map_addnpc(m, nd); + npc_setcells(nd); + } + if(map_addblock(bl)) return 4; //error on adding bl to map @@ -3093,6 +3099,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, } break; } + case BL_NPC: + if (npc_remove_map( (TBL_NPC*)bl ) != 0) + return 0; + break; default: break;// do nothing } @@ -3101,11 +3111,24 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, skill_unit_move(bl,gettick(),4); skill_cleartimerskill(bl); } - // /BL_MOB is handled by mob_dead unless the monster is not dead. - if( bl->type != BL_MOB || !status_isdead(bl) ) - clif_clearunit_area(bl,clrtype); - map_delblock(bl); + switch (bl->type) { + case BL_NPC: + // already handled by npc_remove_map + break; + case BL_MOB: + // /BL_MOB is handled by mob_dead unless the monster is not dead. + if (status_isdead(bl)) { + map_delblock(bl); + break; + } + // Fall through + default: + clif_clearunit_area(bl, clrtype); + map_delblock(bl); + break; + } + map_freeblock_unlock(); return 1;