|
@@ -5241,14 +5241,22 @@ char pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int
|
|
|
|
|
|
if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
|
|
|
{
|
|
|
- ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y);
|
|
|
+ ShowError("pc_setpos: attempt to place player '%s' (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y);
|
|
|
x = y = 0; // make it random
|
|
|
}
|
|
|
|
|
|
if( x == 0 && y == 0 ) { // pick a random walkable cell
|
|
|
+ int c=0;
|
|
|
do {
|
|
|
x = rnd()%(map[m].xs-2)+1;
|
|
|
y = rnd()%(map[m].ys-2)+1;
|
|
|
+ c++;
|
|
|
+
|
|
|
+ if(c > (map[m].xs * map[m].ys)*3){ //force out
|
|
|
+ ShowError("pc_setpos: couldn't found a valid coordinates for player '%s' (%d:%d) on (%s), preventing warp\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex));
|
|
|
+ return 0; //preventing warp
|
|
|
+ //break; //allow warp anyway
|
|
|
+ }
|
|
|
} while(map_getcell(m,x,y,CELL_CHKNOPASS) || (!battle_config.teleport_on_portal && npc_check_areanpc(1,m,x,y,1)));
|
|
|
}
|
|
|
|
|
@@ -5305,6 +5313,8 @@ char pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int
|
|
|
if(npc_check_areanpc(1,m,x,y,1)){
|
|
|
sd->count_rewarp++;
|
|
|
}
|
|
|
+ else
|
|
|
+ sd->count_rewarp = 0;
|
|
|
|
|
|
return 0;
|
|
|
}
|