Selaa lähdekoodia

reverting [2481], there's a better way

Sami 16 vuotta sitten
vanhempi
sitoutus
3f8b42d6dc

+ 9 - 25
L2_GameServer/java/net/sf/l2j/gameserver/GeoEngine.java

@@ -485,7 +485,7 @@ public class GeoEngine extends GeoData
     {
     	int dx = (tx - x);
         int dy = (ty - y);
-        int distance2 = dx*dx+dy*dy;
+        final int distance2 = dx*dx+dy*dy;
 
         if (distance2 == 0)
         	return destiny;
@@ -501,14 +501,8 @@ public class GeoEngine extends GeoData
         	tz = startpoint.getZ() + (int)(divider * dz);
         	dx = (tx - x);
         	dy = (ty - y);
-        	distance2 = dx*dx+dy*dy;
             //return startpoint;
         }
-        
-        // required to compare Z axis movement compared to direct movement
-        final double dz = (tz - z);
-        double maxDZtoDirectLine = 0;
-        double linearMovementZ = z;
 
         // Increment in Z coordinate when moving along X or Y axis
         // and not straight to the target. This is done because
@@ -517,9 +511,7 @@ public class GeoEngine extends GeoData
         final int inc_y = sign(dy);
         dx = Math.abs(dx);
         dy = Math.abs(dy);
-        final double inc_z_directionx = dz*dx / (distance2);
-        final double inc_z_directiony = dz*dy / (distance2);
-        
+
         //gm.sendMessage("MoveCheck: from X: "+x+ "Y: "+y+ "--->> X: "+tx+" Y: "+ty);
 
         // next_* are used in NcanMoveNext check from x,y
@@ -545,16 +537,14 @@ public class GeoEngine extends GeoData
             		next_x += inc_x;
             		tempz = nCanMoveNext(x,y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
             		next_y += inc_y;
             		//_log.warning("2: next_x:"+next_x+" next_y"+next_y);
             		tempz = nCanMoveNext(next_x,y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
-            		linearMovementZ += inc_z_directiony + inc_z_directionx;
-            		maxDZtoDirectLine = Math.max(maxDZtoDirectLine, Math.abs(z-linearMovementZ));
             	}
             	else
             	{
@@ -563,10 +553,8 @@ public class GeoEngine extends GeoData
             		//_log.warning("3: next_x:"+next_x+" next_y"+next_y);
             		tempz = nCanMoveNext(x,y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
-            		linearMovementZ += inc_z_directionx;
-            		maxDZtoDirectLine = Math.max(maxDZtoDirectLine, Math.abs(z-linearMovementZ));
             	}
             }
         }
@@ -585,16 +573,14 @@ public class GeoEngine extends GeoData
             		next_y += inc_y;
             		tempz = nCanMoveNext(x,y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
             		next_x += inc_x;
             		//_log.warning("5: next_x:"+next_x+" next_y"+next_y);
             		tempz = nCanMoveNext(x,next_y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
-            		linearMovementZ += inc_z_directiony + inc_z_directionx;
-            		maxDZtoDirectLine = Math.max(maxDZtoDirectLine, Math.abs(z-linearMovementZ));
             	}
             	else
             	{
@@ -603,17 +589,15 @@ public class GeoEngine extends GeoData
             		//_log.warning("6: next_x:"+next_x+" next_y"+next_y);
             		tempz = nCanMoveNext(x,y,(int)z,next_x,next_y,tz);
             		if (tempz == Double.MIN_VALUE)
-            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z, maxDZtoDirectLine);
+            			return new Location((x << 4) + L2World.MAP_MIN_X,(y << 4) + L2World.MAP_MIN_Y,(int)z);
             		else z = tempz;
-            		linearMovementZ += inc_z_directiony;
-            		maxDZtoDirectLine = Math.max(maxDZtoDirectLine, Math.abs(z-linearMovementZ));
             	}
             }
         }
         if (z == startpoint.getZ()) // geodata hasn't modified Z in any coordinate, i.e. doesn't exist
         	return destiny;
         else
-        	return new Location(destiny.getX(),destiny.getY(),(int)z, maxDZtoDirectLine);
+        	return new Location(destiny.getX(),destiny.getY(),(int)z);
     }
 
     private static byte sign(int x)

+ 4 - 25
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Character.java

@@ -4112,7 +4112,6 @@ public abstract class L2Character extends L2Object
 		double dy = (y - curY);
 		double dz = (z - curZ);
 		double distance = Math.sqrt(dx*dx + dy*dy);
-		double geoFactor = -1;
 		
 		// make water move short and use no geodata checks for swimming chars
 		// distance in a click can easily be over 3000
@@ -4229,9 +4228,6 @@ public abstract class L2Character extends L2Object
 				y = destiny.getY();
 				z = destiny.getZ();
 				distance = Math.sqrt((x - curX)*(x - curX) + (y - curY)*(y - curY));
-				// approximation for longer distance to travel than the direct line
-				if (distance > 10)
-					geoFactor = distance/(2*Math.sqrt((distance/2)*(distance/2) + destiny.getMaxDZtoDirect()*destiny.getMaxDZtoDirect()));
 				
 			}
 			// Pathfinding checks. Only when geodata setting is 2, the LoS check gives shorter result
@@ -4263,7 +4259,6 @@ public abstract class L2Character extends L2Object
                 			y = originalY;
                 			z = originalZ;
                 			distance = originalDistance;
-                			geoFactor = -1;
                 		}
                 	}
                 	else
@@ -4300,7 +4295,6 @@ public abstract class L2Character extends L2Object
                 		distance = Math.sqrt(dx*dx + dy*dy);
                 		sin = dy/distance;
                 		cos = dx/distance;
-                		geoFactor = -1;
                 	}
 				}
 			}
@@ -4319,26 +4313,11 @@ public abstract class L2Character extends L2Object
 
 		// Caclulate the Nb of ticks between the current position and the destination
 		// One tick added for rounding reasons
-		if (geoFactor > 0)
-		{
-			// a factor calculated from geodata indicating there's no
-			// straight line to the target
-			if (geoFactor < 0.8) // probably some drop and short distance (which is fast)
-				geoFactor = 0.8;
-			m._ticksToMove = 1+(int)(GameTimeController.TICKS_PER_SECOND * distance / (speed*geoFactor));
-			// Calculate the xspeed and yspeed in unit/ticks in function of the movement speed
-			m._xSpeedTicks = (float)(cos * (speed*geoFactor) / GameTimeController.TICKS_PER_SECOND);
-			m._ySpeedTicks = (float)(sin * (speed*geoFactor) / GameTimeController.TICKS_PER_SECOND);
-		}
-		else
-		{
-			m._ticksToMove = 1+(int)(GameTimeController.TICKS_PER_SECOND * distance / speed);
-			// Calculate the xspeed and yspeed in unit/ticks in function of the movement speed
-			m._xSpeedTicks = (float)(cos * speed / GameTimeController.TICKS_PER_SECOND);
-			m._ySpeedTicks = (float)(sin * speed / GameTimeController.TICKS_PER_SECOND);
-		}
+		m._ticksToMove = 1+(int)(GameTimeController.TICKS_PER_SECOND * distance / speed);
 
-		
+		// Calculate the xspeed and yspeed in unit/ticks in function of the movement speed
+		m._xSpeedTicks = (float)(cos * speed / GameTimeController.TICKS_PER_SECOND);
+		m._ySpeedTicks = (float)(sin * speed / GameTimeController.TICKS_PER_SECOND);
 
 		// Calculate and set the heading of the L2Character
 		setHeading(Util.calculateHeadingFrom(cos, sin));

+ 0 - 14
L2_GameServer/java/net/sf/l2j/gameserver/model/Location.java

@@ -26,7 +26,6 @@ public final class Location
 	private int _y;
 	private int _z;
 	private int _heading;
-	private int _maxDZtoDirectLine;
 
 
 	public Location(int x, int y, int z)
@@ -35,14 +34,6 @@ public final class Location
 		_y = y;
 		_z = z;
 	}
-	
-	public Location(int x, int y, int z, double maxDZtoDirectLine)
-	{
-		_x = x;
-		_y = y;
-		_z = z;
-		_maxDZtoDirectLine = (int)maxDZtoDirectLine;
-	}
 
 	public Location(int x, int y, int z, int heading)
 	{
@@ -71,9 +62,4 @@ public final class Location
 	{
 		return _heading;
 	}
-	
-	public int getMaxDZtoDirect()
-	{
-		return _maxDZtoDirectLine;
-	}
 }