Follow up ea8ccfc82e91efb9fc1be3d3397d538d80101c84

-Update message with Euphy suggestion.
-Add new test case.
-Fix **bugreport:9278** (infinte-warp-1ma-h-cpu-usage-100)
This commit is contained in:
lighta 2014-09-07 08:30:10 -04:00
parent f8f6a1f101
commit 3a88e8cf39
2 changed files with 13 additions and 3 deletions

View File

@ -969,8 +969,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
case NPCTYPE_WARP:
if (pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) || pc_isdead(sd))
break; // hidden or dead chars cannot use warps
if(sd->count_rewarp > 3){
ShowWarning("Prevent infinite warping loop, please fix script\n");
if(sd->count_rewarp > 10){
ShowWarning("Prevent infinite warping loop for player (%d:%d), please fix script npc:'%s', path:'%s' \n",sd->status.account_id, sd->status.char_id,map[m].npc[i]->exname,map[m].npc[i]->path);
sd->count_rewarp=0;
break;
}

View File

@ -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;
}