Prevent probable getRegion NPEs.

This commit is contained in:
MobiusDevelopment 2021-02-22 06:13:59 +00:00
parent 3bc928f8d1
commit 82c816ccbf
21 changed files with 378 additions and 63 deletions

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -130,7 +130,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -164,7 +169,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -176,7 +186,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -130,7 +130,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -164,7 +169,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -176,7 +186,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -131,7 +131,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -165,7 +170,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -177,7 +187,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -131,7 +131,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -165,7 +170,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -177,7 +187,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**

View File

@ -133,7 +133,12 @@ public class GeoEngine
*/ */
private IRegion getRegion(int geoX, int geoY) private IRegion getRegion(int geoX, int geoY)
{ {
return _regions.get(((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y)); final int region = ((geoX / IRegion.REGION_CELLS_X) * GEO_REGIONS_Y) + (geoY / IRegion.REGION_CELLS_Y);
if ((region < 0) || (region >= _regions.length()))
{
return null;
}
return _regions.get(region);
} }
/** /**
@ -167,7 +172,12 @@ public class GeoEngine
*/ */
public boolean hasGeoPos(int geoX, int geoY) public boolean hasGeoPos(int geoX, int geoY)
{ {
return getRegion(geoX, geoY).hasGeo(); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return false;
}
return region.hasGeo();
} }
/** /**
@ -179,7 +189,12 @@ public class GeoEngine
*/ */
public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
{ {
return getRegion(geoX, geoY).checkNearestNswe(geoX, geoY, worldZ, nswe); final IRegion region = getRegion(geoX, geoY);
if (region == null)
{
return true;
}
return region.checkNearestNswe(geoX, geoY, worldZ, nswe);
} }
/** /**