Merge pull request #941 from sdburns1998/code-cleanup

api: client: code clean up
This commit is contained in:
Tyler Bochard
2019-07-08 19:20:39 -04:00
committed by GitHub
25 changed files with 89 additions and 104 deletions

View File

@@ -27,9 +27,9 @@ package net.runelite.api;
import java.awt.Canvas;
import java.awt.Dimension;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
@@ -1677,7 +1677,7 @@ public interface Client extends GameShell
/**
* Set spells excluded from above hiding
*/
void setUnhiddenCasts(HashSet<String> casts);
void setUnhiddenCasts(Set<String> casts);
/**
* Sorts the current menu entries in the same way the client does this.

View File

@@ -317,12 +317,6 @@ public class Perspective
final int neX = localLocation.getX() + (size * LOCAL_TILE_SIZE / 2);
final int neY = localLocation.getY() + (size * LOCAL_TILE_SIZE / 2);
final int seX = swX;
final int seY = neY;
final int nwX = neX;
final int nwY = swY;
final byte[][][] tileSettings = client.getTileSettings();
final int sceneX = localLocation.getSceneX();
@@ -340,14 +334,14 @@ public class Perspective
}
final int swHeight = getHeight(client, swX, swY, tilePlane);
final int nwHeight = getHeight(client, nwX, nwY, tilePlane);
final int nwHeight = getHeight(client, neX, swY, tilePlane);
final int neHeight = getHeight(client, neX, neY, tilePlane);
final int seHeight = getHeight(client, seX, seY, tilePlane);
final int seHeight = getHeight(client, swX, neY, tilePlane);
Point p1 = localToCanvas(client, swX, swY, swHeight);
Point p2 = localToCanvas(client, nwX, nwY, nwHeight);
Point p2 = localToCanvas(client, neX, swY, nwHeight);
Point p3 = localToCanvas(client, neX, neY, neHeight);
Point p4 = localToCanvas(client, seX, seY, seHeight);
Point p4 = localToCanvas(client, swX, neY, seHeight);
if (p1 == null || p2 == null || p3 == null || p4 == null)
{

View File

@@ -104,10 +104,6 @@ public class Point
{
return false;
}
if (this.y != other.y)
{
return false;
}
return true;
return this.y == other.y;
}
}

View File

@@ -271,8 +271,16 @@ public class WorldArea
LocalPoint lp = LocalPoint.fromWorld(client, x, y);
int startX = lp.getSceneX() + dx;
int startY = lp.getSceneY() + dy;
int startX = 0;
if (lp != null)
{
startX = lp.getSceneX() + dx;
}
int startY = 0;
if (lp != null)
{
startY = lp.getSceneY() + dy;
}
int checkX = startX + (dx > 0 ? width - 1 : 0);
int checkY = startY + (dy > 0 ? height - 1 : 0);
int endX = startX + width - 1;
@@ -427,11 +435,8 @@ public class WorldArea
}
if (height == 1)
{
if ((collisionDataFlags[checkX - dx][checkY] & yFlags) != 0 &&
extraCondition.test(WorldPoint.fromScene(client, startX, checkY, client.getPlane())))
{
return false;
}
return (collisionDataFlags[checkX - dx][checkY] & yFlags) == 0 ||
!extraCondition.test(WorldPoint.fromScene(client, startX, checkY, client.getPlane()));
}
}

View File

@@ -370,16 +370,12 @@ public class WorldPoint
*/
public static boolean isInZone(WorldPoint lowerBound, WorldPoint upperBound, WorldPoint userLocation)
{
if (userLocation.getX() < lowerBound.getX()
|| userLocation.getX() > upperBound.getX()
|| userLocation.getY() < lowerBound.getY()
|| userLocation.getY() > upperBound.getY()
|| userLocation.getPlane() < lowerBound.getPlane()
|| userLocation.getPlane() > upperBound.getPlane())
{
return false;
}
return true;
return userLocation.getX() >= lowerBound.getX()
&& userLocation.getX() <= upperBound.getX()
&& userLocation.getY() >= lowerBound.getY()
&& userLocation.getY() <= upperBound.getY()
&& userLocation.getPlane() >= lowerBound.getPlane()
&& userLocation.getPlane() <= upperBound.getPlane();
}
/**

View File

@@ -125,8 +125,7 @@ public class Jarvis
private static long crossProduct(Point p, Point q, Point r)
{
long val = (long)(q.getY() - p.getY()) * (r.getX() - q.getX())
return (long)(q.getY() - p.getY()) * (r.getX() - q.getX())
- (long)(q.getX() - p.getX()) * (r.getY() - q.getY());
return val;
}
}