warp_get_suggestions(sd, map_name);
return -1;
}
- if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
- { //This is to prevent the pc_setpos call from printing an error.
- clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
- if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
- x = y = 0; //Invalid cell, use random spot.
- }
+ if (x || y) { //This is to prevent the pc_setpos call from printing an error.
+ if(map_getcell(m, x, y, CELL_CHKNOPASS)){
+ clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
+ if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
+ x = y = 0; //Invalid cell, use random spot.
+ } else {
+ struct map_data *mapdata = map_getmapdata(m);
+ for (int i = 0; i < mapdata->npc_num; i++)
+ if( x == mapdata->npc[i]->bl.x && y == mapdata->npc[i]->bl.y ){
+ if (!map_search_freecell(NULL, m, &x, &y, 1, 1, 1))
+ x = y = 0;
+ break;
+ }
+ }
+ }