Fixed attacking throu doors.

This commit is contained in:
MobiusDev 2017-08-28 02:50:08 +00:00
parent 46f52aa8e2
commit cfb8cc59e2
20 changed files with 275 additions and 270 deletions

View File

@ -54,8 +54,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{
@ -72,8 +72,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{

View File

@ -226,7 +226,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public final int getGeoX(int worldX)
public static final int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@ -236,7 +236,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public final int getGeoY(int worldY)
public static final int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@ -246,7 +246,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public final int getWorldX(int geoX)
public static final int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@ -256,7 +256,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public final int getWorldY(int geoY)
public static final int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@ -568,6 +568,16 @@ public class GeoEngine
final int ty = target.getY();
final int tz = target.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -609,7 +619,7 @@ public class GeoEngine
}
// perform geodata check
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight);
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld()) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld());
}
/**
@ -628,6 +638,16 @@ public class GeoEngine
final int ty = position.getY();
final int tz = position.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -662,7 +682,7 @@ public class GeoEngine
}
// perform geodata check
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0);
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0, origin.getInstanceWorld());
}
/**
@ -675,9 +695,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -857,9 +878,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character} or {@link L2DoorInstance})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -1040,16 +1062,6 @@ public class GeoEngine
*/
public final boolean canMoveToTarget(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -1094,16 +1106,6 @@ public class GeoEngine
*/
public final Location canMoveToTargetLoc(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);

View File

@ -51,13 +51,13 @@ public class GeoLocation extends Location
@Override
public int getX()
{
return GeoEngine.getInstance().getWorldX(_x);
return GeoEngine.getWorldX(_x);
}
@Override
public int getY()
{
return GeoEngine.getInstance().getWorldY(_y);
return GeoEngine.getWorldY(_y);
}
public byte getNSWE()

View File

@ -30,21 +30,21 @@ public final class GeoUtils
{
public static void debug2DLine(L2PcInstance player, int x, int y, int tx, int ty, int z)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug2DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), z);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), z);
final LinePointIterator iter = new LinePointIterator(gx, gy, tgx, tgy);
while (iter.next())
{
final int wx = GeoEngine.getInstance().getWorldX(iter.x());
final int wy = GeoEngine.getInstance().getWorldY(iter.y());
final int wx = GeoEngine.getWorldX(iter.x());
final int wy = GeoEngine.getWorldY(iter.y());
prim.addPoint(Color.RED, wx, wy, z);
}
@ -53,21 +53,21 @@ public final class GeoUtils
public static void debug3DLine(L2PcInstance player, int x, int y, int z, int tx, int ty, int tz)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug3DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), tz);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), tz);
final LinePointIterator3D iter = new LinePointIterator3D(gx, gy, z, tgx, tgy, tz);
iter.next();
int prevX = iter.x();
int prevY = iter.y();
int wx = GeoEngine.getInstance().getWorldX(prevX);
int wy = GeoEngine.getInstance().getWorldY(prevY);
int wx = GeoEngine.getWorldX(prevX);
int wy = GeoEngine.getWorldY(prevY);
int wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -78,8 +78,8 @@ public final class GeoUtils
if ((curX != prevX) || (curY != prevY))
{
wx = GeoEngine.getInstance().getWorldX(curX);
wy = GeoEngine.getInstance().getWorldY(curY);
wx = GeoEngine.getWorldX(curX);
wy = GeoEngine.getWorldY(curY);
wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -109,9 +109,8 @@ public final class GeoUtils
int iPacket = 0;
ExServerPrimitive exsp = null;
final GeoEngine gd = GeoEngine.getInstance();
final int playerGx = gd.getGeoX(player.getX());
final int playerGy = gd.getGeoY(player.getY());
final int playerGx = GeoEngine.getGeoX(player.getX());
final int playerGy = GeoEngine.getGeoY(player.getY());
for (int dx = -geoRadius; dx <= geoRadius; ++dx)
{
for (int dy = -geoRadius; dy <= geoRadius; ++dy)
@ -135,9 +134,9 @@ public final class GeoUtils
final int gx = playerGx + dx;
final int gy = playerGy + dy;
final int x = gd.getWorldX(gx);
final int y = gd.getWorldY(gy);
final int z = gd.getHeightNearest(gx, gy, player.getZ());
final int x = GeoEngine.getWorldX(gx);
final int y = GeoEngine.getWorldY(gy);
final int z = GeoEngine.getInstance().getHeightNearest(gx, gy, player.getZ());
// north arrow
Color col = getDirectionColor(gx, gy, z, GeoStructure.CELL_FLAG_N);

View File

@ -54,8 +54,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{
@ -72,8 +72,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{

View File

@ -226,7 +226,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public final int getGeoX(int worldX)
public static final int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@ -236,7 +236,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public final int getGeoY(int worldY)
public static final int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@ -246,7 +246,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public final int getWorldX(int geoX)
public static final int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@ -256,7 +256,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public final int getWorldY(int geoY)
public static final int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@ -568,6 +568,16 @@ public class GeoEngine
final int ty = target.getY();
final int tz = target.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -609,7 +619,7 @@ public class GeoEngine
}
// perform geodata check
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight);
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld()) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld());
}
/**
@ -628,6 +638,16 @@ public class GeoEngine
final int ty = position.getY();
final int tz = position.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -662,7 +682,7 @@ public class GeoEngine
}
// perform geodata check
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0);
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0, origin.getInstanceWorld());
}
/**
@ -675,9 +695,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -857,9 +878,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character} or {@link L2DoorInstance})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -1040,16 +1062,6 @@ public class GeoEngine
*/
public final boolean canMoveToTarget(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -1094,16 +1106,6 @@ public class GeoEngine
*/
public final Location canMoveToTargetLoc(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);

View File

@ -51,13 +51,13 @@ public class GeoLocation extends Location
@Override
public int getX()
{
return GeoEngine.getInstance().getWorldX(_x);
return GeoEngine.getWorldX(_x);
}
@Override
public int getY()
{
return GeoEngine.getInstance().getWorldY(_y);
return GeoEngine.getWorldY(_y);
}
public byte getNSWE()

View File

@ -30,21 +30,21 @@ public final class GeoUtils
{
public static void debug2DLine(L2PcInstance player, int x, int y, int tx, int ty, int z)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug2DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), z);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), z);
final LinePointIterator iter = new LinePointIterator(gx, gy, tgx, tgy);
while (iter.next())
{
final int wx = GeoEngine.getInstance().getWorldX(iter.x());
final int wy = GeoEngine.getInstance().getWorldY(iter.y());
final int wx = GeoEngine.getWorldX(iter.x());
final int wy = GeoEngine.getWorldY(iter.y());
prim.addPoint(Color.RED, wx, wy, z);
}
@ -53,21 +53,21 @@ public final class GeoUtils
public static void debug3DLine(L2PcInstance player, int x, int y, int z, int tx, int ty, int tz)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug3DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), tz);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), tz);
final LinePointIterator3D iter = new LinePointIterator3D(gx, gy, z, tgx, tgy, tz);
iter.next();
int prevX = iter.x();
int prevY = iter.y();
int wx = GeoEngine.getInstance().getWorldX(prevX);
int wy = GeoEngine.getInstance().getWorldY(prevY);
int wx = GeoEngine.getWorldX(prevX);
int wy = GeoEngine.getWorldY(prevY);
int wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -78,8 +78,8 @@ public final class GeoUtils
if ((curX != prevX) || (curY != prevY))
{
wx = GeoEngine.getInstance().getWorldX(curX);
wy = GeoEngine.getInstance().getWorldY(curY);
wx = GeoEngine.getWorldX(curX);
wy = GeoEngine.getWorldY(curY);
wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -109,9 +109,8 @@ public final class GeoUtils
int iPacket = 0;
ExServerPrimitive exsp = null;
final GeoEngine gd = GeoEngine.getInstance();
final int playerGx = gd.getGeoX(player.getX());
final int playerGy = gd.getGeoY(player.getY());
final int playerGx = GeoEngine.getGeoX(player.getX());
final int playerGy = GeoEngine.getGeoY(player.getY());
for (int dx = -geoRadius; dx <= geoRadius; ++dx)
{
for (int dy = -geoRadius; dy <= geoRadius; ++dy)
@ -135,9 +134,9 @@ public final class GeoUtils
final int gx = playerGx + dx;
final int gy = playerGy + dy;
final int x = gd.getWorldX(gx);
final int y = gd.getWorldY(gy);
final int z = gd.getHeightNearest(gx, gy, player.getZ());
final int x = GeoEngine.getWorldX(gx);
final int y = GeoEngine.getWorldY(gy);
final int z = GeoEngine.getInstance().getHeightNearest(gx, gy, player.getZ());
// north arrow
Color col = getDirectionColor(gx, gy, z, GeoStructure.CELL_FLAG_N);

View File

@ -54,8 +54,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{
@ -72,8 +72,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{

View File

@ -226,7 +226,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public final int getGeoX(int worldX)
public static final int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@ -236,7 +236,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public final int getGeoY(int worldY)
public static final int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@ -246,7 +246,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public final int getWorldX(int geoX)
public static final int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@ -256,7 +256,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public final int getWorldY(int geoY)
public static final int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@ -568,6 +568,16 @@ public class GeoEngine
final int ty = target.getY();
final int tz = target.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -609,7 +619,7 @@ public class GeoEngine
}
// perform geodata check
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight);
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld()) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld());
}
/**
@ -628,6 +638,16 @@ public class GeoEngine
final int ty = position.getY();
final int tz = position.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -662,7 +682,7 @@ public class GeoEngine
}
// perform geodata check
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0);
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0, origin.getInstanceWorld());
}
/**
@ -675,9 +695,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -857,9 +878,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character} or {@link L2DoorInstance})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -1040,16 +1062,6 @@ public class GeoEngine
*/
public final boolean canMoveToTarget(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -1094,16 +1106,6 @@ public class GeoEngine
*/
public final Location canMoveToTargetLoc(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);

View File

@ -51,13 +51,13 @@ public class GeoLocation extends Location
@Override
public int getX()
{
return GeoEngine.getInstance().getWorldX(_x);
return GeoEngine.getWorldX(_x);
}
@Override
public int getY()
{
return GeoEngine.getInstance().getWorldY(_y);
return GeoEngine.getWorldY(_y);
}
public byte getNSWE()

View File

@ -30,21 +30,21 @@ public final class GeoUtils
{
public static void debug2DLine(L2PcInstance player, int x, int y, int tx, int ty, int z)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug2DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), z);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), z);
final LinePointIterator iter = new LinePointIterator(gx, gy, tgx, tgy);
while (iter.next())
{
final int wx = GeoEngine.getInstance().getWorldX(iter.x());
final int wy = GeoEngine.getInstance().getWorldY(iter.y());
final int wx = GeoEngine.getWorldX(iter.x());
final int wy = GeoEngine.getWorldY(iter.y());
prim.addPoint(Color.RED, wx, wy, z);
}
@ -53,21 +53,21 @@ public final class GeoUtils
public static void debug3DLine(L2PcInstance player, int x, int y, int z, int tx, int ty, int tz)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug3DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), tz);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), tz);
final LinePointIterator3D iter = new LinePointIterator3D(gx, gy, z, tgx, tgy, tz);
iter.next();
int prevX = iter.x();
int prevY = iter.y();
int wx = GeoEngine.getInstance().getWorldX(prevX);
int wy = GeoEngine.getInstance().getWorldY(prevY);
int wx = GeoEngine.getWorldX(prevX);
int wy = GeoEngine.getWorldY(prevY);
int wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -78,8 +78,8 @@ public final class GeoUtils
if ((curX != prevX) || (curY != prevY))
{
wx = GeoEngine.getInstance().getWorldX(curX);
wy = GeoEngine.getInstance().getWorldY(curY);
wx = GeoEngine.getWorldX(curX);
wy = GeoEngine.getWorldY(curY);
wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -109,9 +109,8 @@ public final class GeoUtils
int iPacket = 0;
ExServerPrimitive exsp = null;
final GeoEngine gd = GeoEngine.getInstance();
final int playerGx = gd.getGeoX(player.getX());
final int playerGy = gd.getGeoY(player.getY());
final int playerGx = GeoEngine.getGeoX(player.getX());
final int playerGy = GeoEngine.getGeoY(player.getY());
for (int dx = -geoRadius; dx <= geoRadius; ++dx)
{
for (int dy = -geoRadius; dy <= geoRadius; ++dy)
@ -135,9 +134,9 @@ public final class GeoUtils
final int gx = playerGx + dx;
final int gy = playerGy + dy;
final int x = gd.getWorldX(gx);
final int y = gd.getWorldY(gy);
final int z = gd.getHeightNearest(gx, gy, player.getZ());
final int x = GeoEngine.getWorldX(gx);
final int y = GeoEngine.getWorldY(gy);
final int z = GeoEngine.getInstance().getHeightNearest(gx, gy, player.getZ());
// north arrow
Color col = getDirectionColor(gx, gy, z, GeoStructure.CELL_FLAG_N);

View File

@ -54,8 +54,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{
@ -72,8 +72,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{

View File

@ -224,7 +224,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public final int getGeoX(int worldX)
public static final int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@ -234,7 +234,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public final int getGeoY(int worldY)
public static final int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@ -244,7 +244,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public final int getWorldX(int geoX)
public static final int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@ -254,7 +254,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public final int getWorldY(int geoY)
public static final int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@ -566,6 +566,11 @@ public class GeoEngine
final int ty = target.getY();
final int tz = target.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceId(), false))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -607,7 +612,7 @@ public class GeoEngine
}
// perform geodata check
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight);
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceId()) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceId());
}
/**
@ -626,6 +631,11 @@ public class GeoEngine
final int ty = position.getY();
final int tz = position.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceId(), false))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -660,7 +670,7 @@ public class GeoEngine
}
// perform geodata check
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0);
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0, origin.getInstanceId());
}
/**
@ -673,9 +683,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character})
* @param instanceId
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, int instanceId)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -855,9 +866,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character} or {@link L2DoorInstance})
* @param instanceId
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, int instanceId)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -1038,11 +1050,6 @@ public class GeoEngine
*/
public final boolean canMoveToTarget(int ox, int oy, int oz, int tx, int ty, int tz, int instanceId)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instanceId, false))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -1087,11 +1094,6 @@ public class GeoEngine
*/
public final Location canMoveToTargetLoc(int ox, int oy, int oz, int tx, int ty, int tz, int instanceId)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instanceId, false))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);

View File

@ -51,13 +51,13 @@ public class GeoLocation extends Location
@Override
public int getX()
{
return GeoEngine.getInstance().getWorldX(_x);
return GeoEngine.getWorldX(_x);
}
@Override
public int getY()
{
return GeoEngine.getInstance().getWorldY(_y);
return GeoEngine.getWorldY(_y);
}
public byte getNSWE()

View File

@ -30,21 +30,21 @@ public final class GeoUtils
{
public static void debug2DLine(L2PcInstance player, int x, int y, int tx, int ty, int z)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug2DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), z);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), z);
final LinePointIterator iter = new LinePointIterator(gx, gy, tgx, tgy);
while (iter.next())
{
final int wx = GeoEngine.getInstance().getWorldX(iter.x());
final int wy = GeoEngine.getInstance().getWorldY(iter.y());
final int wx = GeoEngine.getWorldX(iter.x());
final int wy = GeoEngine.getWorldY(iter.y());
prim.addPoint(Color.RED, wx, wy, z);
}
@ -53,21 +53,21 @@ public final class GeoUtils
public static void debug3DLine(L2PcInstance player, int x, int y, int z, int tx, int ty, int tz)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug3DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), tz);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), tz);
final LinePointIterator3D iter = new LinePointIterator3D(gx, gy, z, tgx, tgy, tz);
iter.next();
int prevX = iter.x();
int prevY = iter.y();
int wx = GeoEngine.getInstance().getWorldX(prevX);
int wy = GeoEngine.getInstance().getWorldY(prevY);
int wx = GeoEngine.getWorldX(prevX);
int wy = GeoEngine.getWorldY(prevY);
int wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -78,8 +78,8 @@ public final class GeoUtils
if ((curX != prevX) || (curY != prevY))
{
wx = GeoEngine.getInstance().getWorldX(curX);
wy = GeoEngine.getInstance().getWorldY(curY);
wx = GeoEngine.getWorldX(curX);
wy = GeoEngine.getWorldY(curY);
wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -109,9 +109,8 @@ public final class GeoUtils
int iPacket = 0;
ExServerPrimitive exsp = null;
final GeoEngine gd = GeoEngine.getInstance();
final int playerGx = gd.getGeoX(player.getX());
final int playerGy = gd.getGeoY(player.getY());
final int playerGx = GeoEngine.getGeoX(player.getX());
final int playerGy = GeoEngine.getGeoY(player.getY());
for (int dx = -geoRadius; dx <= geoRadius; ++dx)
{
for (int dy = -geoRadius; dy <= geoRadius; ++dy)
@ -135,9 +134,9 @@ public final class GeoUtils
final int gx = playerGx + dx;
final int gy = playerGy + dy;
final int x = gd.getWorldX(gx);
final int y = gd.getWorldY(gy);
final int z = gd.getHeightNearest(gx, gy, player.getZ());
final int x = GeoEngine.getWorldX(gx);
final int y = GeoEngine.getWorldY(gy);
final int z = GeoEngine.getInstance().getHeightNearest(gx, gy, player.getZ());
// north arrow
Color col = getDirectionColor(gx, gy, z, GeoStructure.CELL_FLAG_N);

View File

@ -54,8 +54,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{
@ -72,8 +72,8 @@ public class AdminGeodata implements IAdminCommandHandler
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoEngine.getInstance().getGeoX(worldX);
final int geoY = GeoEngine.getInstance().getGeoY(worldY);
final int geoX = GeoEngine.getGeoX(worldX);
final int geoY = GeoEngine.getGeoY(worldY);
if (GeoEngine.getInstance().hasGeoPos(geoX, geoY))
{

View File

@ -226,7 +226,7 @@ public class GeoEngine
* @param worldX
* @return int : Geo X
*/
public final int getGeoX(int worldX)
public static final int getGeoX(int worldX)
{
return (MathUtil.limit(worldX, L2World.MAP_MIN_X, L2World.MAP_MAX_X) - L2World.MAP_MIN_X) >> 4;
}
@ -236,7 +236,7 @@ public class GeoEngine
* @param worldY
* @return int : Geo Y
*/
public final int getGeoY(int worldY)
public static final int getGeoY(int worldY)
{
return (MathUtil.limit(worldY, L2World.MAP_MIN_Y, L2World.MAP_MAX_Y) - L2World.MAP_MIN_Y) >> 4;
}
@ -246,7 +246,7 @@ public class GeoEngine
* @param geoX
* @return int : World X
*/
public final int getWorldX(int geoX)
public static final int getWorldX(int geoX)
{
return (MathUtil.limit(geoX, 0, GeoStructure.GEO_CELLS_X) << 4) + L2World.MAP_MIN_X + 8;
}
@ -256,7 +256,7 @@ public class GeoEngine
* @param geoY
* @return int : World Y
*/
public final int getWorldY(int geoY)
public static final int getWorldY(int geoY)
{
return (MathUtil.limit(geoY, 0, GeoStructure.GEO_CELLS_Y) << 4) + L2World.MAP_MIN_Y + 8;
}
@ -568,6 +568,16 @@ public class GeoEngine
final int ty = target.getY();
final int tz = target.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -609,7 +619,7 @@ public class GeoEngine
}
// perform geodata check
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight);
return door ? checkSeeOriginal(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld()) : checkSee(gox, goy, goz, oheight, gtx, gty, gtz, theight, origin.getInstanceWorld());
}
/**
@ -628,6 +638,16 @@ public class GeoEngine
final int ty = position.getY();
final int tz = position.getZ();
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, origin.getInstanceWorld(), false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), origin.getInstanceWorld()))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -662,7 +682,7 @@ public class GeoEngine
}
// perform geodata check
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0);
return checkSee(gox, goy, goz, oheight, gtx, gty, gtz, 0, origin.getInstanceWorld());
}
/**
@ -675,9 +695,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSee(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -857,9 +878,10 @@ public class GeoEngine
* @param gty : target Y geodata coordinate
* @param gtz : target Z geodata coordinate
* @param theight : target height (if instance of {@link Character} or {@link L2DoorInstance})
* @param instance
* @return {@code boolean} : True, when target can be seen.
*/
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight)
protected final boolean checkSeeOriginal(int gox, int goy, int goz, double oheight, int gtx, int gty, int gtz, double theight, Instance instance)
{
// get line of sight Z coordinates
double losoz = goz + ((oheight * Config.PART_OF_CHARACTER_HEIGHT) / 100);
@ -1040,16 +1062,6 @@ public class GeoEngine
*/
public final boolean canMoveToTarget(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return false;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return false;
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);
@ -1094,16 +1106,6 @@ public class GeoEngine
*/
public final Location canMoveToTargetLoc(int ox, int oy, int oz, int tx, int ty, int tz, Instance instance)
{
if (DoorData.getInstance().checkIfDoorsBetween(ox, oy, oz, tx, ty, tz, instance, false))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(ox, oy, oz), new Location(tx, ty, tz), instance))
{
return new Location(ox, oy, getHeight(ox, oy, oz));
}
// get origin and check existing geo coordinates
final int gox = getGeoX(ox);
final int goy = getGeoY(oy);

View File

@ -51,13 +51,13 @@ public class GeoLocation extends Location
@Override
public int getX()
{
return GeoEngine.getInstance().getWorldX(_x);
return GeoEngine.getWorldX(_x);
}
@Override
public int getY()
{
return GeoEngine.getInstance().getWorldY(_y);
return GeoEngine.getWorldY(_y);
}
public byte getNSWE()

View File

@ -30,21 +30,21 @@ public final class GeoUtils
{
public static void debug2DLine(L2PcInstance player, int x, int y, int tx, int ty, int z)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug2DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), z);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), z);
final LinePointIterator iter = new LinePointIterator(gx, gy, tgx, tgy);
while (iter.next())
{
final int wx = GeoEngine.getInstance().getWorldX(iter.x());
final int wy = GeoEngine.getInstance().getWorldY(iter.y());
final int wx = GeoEngine.getWorldX(iter.x());
final int wy = GeoEngine.getWorldY(iter.y());
prim.addPoint(Color.RED, wx, wy, z);
}
@ -53,21 +53,21 @@ public final class GeoUtils
public static void debug3DLine(L2PcInstance player, int x, int y, int z, int tx, int ty, int tz)
{
final int gx = GeoEngine.getInstance().getGeoX(x);
final int gy = GeoEngine.getInstance().getGeoY(y);
final int gx = GeoEngine.getGeoX(x);
final int gy = GeoEngine.getGeoY(y);
final int tgx = GeoEngine.getInstance().getGeoX(tx);
final int tgy = GeoEngine.getInstance().getGeoY(ty);
final int tgx = GeoEngine.getGeoX(tx);
final int tgy = GeoEngine.getGeoY(ty);
final ExServerPrimitive prim = new ExServerPrimitive("Debug3DLine", x, y, z);
prim.addLine(Color.BLUE, GeoEngine.getInstance().getWorldX(gx), GeoEngine.getInstance().getWorldY(gy), z, GeoEngine.getInstance().getWorldX(tgx), GeoEngine.getInstance().getWorldY(tgy), tz);
prim.addLine(Color.BLUE, GeoEngine.getWorldX(gx), GeoEngine.getWorldY(gy), z, GeoEngine.getWorldX(tgx), GeoEngine.getWorldY(tgy), tz);
final LinePointIterator3D iter = new LinePointIterator3D(gx, gy, z, tgx, tgy, tz);
iter.next();
int prevX = iter.x();
int prevY = iter.y();
int wx = GeoEngine.getInstance().getWorldX(prevX);
int wy = GeoEngine.getInstance().getWorldY(prevY);
int wx = GeoEngine.getWorldX(prevX);
int wy = GeoEngine.getWorldY(prevY);
int wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -78,8 +78,8 @@ public final class GeoUtils
if ((curX != prevX) || (curY != prevY))
{
wx = GeoEngine.getInstance().getWorldX(curX);
wy = GeoEngine.getInstance().getWorldY(curY);
wx = GeoEngine.getWorldX(curX);
wy = GeoEngine.getWorldY(curY);
wz = iter.z();
prim.addPoint(Color.RED, wx, wy, wz);
@ -109,9 +109,8 @@ public final class GeoUtils
int iPacket = 0;
ExServerPrimitive exsp = null;
final GeoEngine gd = GeoEngine.getInstance();
final int playerGx = gd.getGeoX(player.getX());
final int playerGy = gd.getGeoY(player.getY());
final int playerGx = GeoEngine.getGeoX(player.getX());
final int playerGy = GeoEngine.getGeoY(player.getY());
for (int dx = -geoRadius; dx <= geoRadius; ++dx)
{
for (int dy = -geoRadius; dy <= geoRadius; ++dy)
@ -135,9 +134,9 @@ public final class GeoUtils
final int gx = playerGx + dx;
final int gy = playerGy + dy;
final int x = gd.getWorldX(gx);
final int y = gd.getWorldY(gy);
final int z = gd.getHeightNearest(gx, gy, player.getZ());
final int x = GeoEngine.getWorldX(gx);
final int y = GeoEngine.getWorldY(gy);
final int z = GeoEngine.getInstance().getHeightNearest(gx, gy, player.getZ());
// north arrow
Color col = getDirectionColor(gx, gy, z, GeoStructure.CELL_FLAG_N);