Quellcode durchsuchen

Follow up ea8ccfc82e91efb9fc1be3d3397d538d80101c84
-Update message with Euphy suggestion.
-Add new test case.
-Fix **bugreport:9278** (infinte-warp-1ma-h-cpu-usage-100)

lighta vor 10 Jahren
Ursprung
Commit
3a88e8cf39
2 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
  1. 2 2
      src/map/npc.c
  2. 11 1
      src/map/pc.c

+ 2 - 2
src/map/npc.c

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

+ 11 - 1
src/map/pc.c

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