Compare commits
42 Commits
97d71ec361
...
f5d83aa259
| Author | SHA1 | Date | |
|---|---|---|---|
| f5d83aa259 | |||
| 4a5c0ae5a0 | |||
| b4a4323906 | |||
| 48fc5af5f7 | |||
| a1753a28ec | |||
| fa4039cf63 | |||
| 4b0814c0a1 | |||
| 78d0b06b36 | |||
| 426bdf5df3 | |||
| 5dbad7ebd0 | |||
| 6ef33c5b7f | |||
| 3737a6eace | |||
| 967e129724 | |||
| e9d549377e | |||
| 924b8af827 | |||
| 045ee73b61 | |||
| 5d9d13ce07 | |||
| 5a1347ec50 | |||
| c705f45856 | |||
| 83fc129d05 | |||
| d7cde3a77f | |||
| afb1ad8e94 | |||
| 15a79ee9bd | |||
| 68794c170b | |||
| a9d84749ba | |||
| dd5fc323ef | |||
| cf1547d077 | |||
| 9664c99e06 | |||
| 17b7fb6999 | |||
| 21a4db8a81 | |||
| eabdabcfcd | |||
| c548383a4c | |||
| 7337f4be1e | |||
| d84f223b9d | |||
| 5431112186 | |||
| ff743151c6 | |||
| b923392b53 | |||
| 15d272c621 | |||
| eefa50b2c3 | |||
| ecc7a152f7 | |||
| 7bf31f9a47 | |||
| 7dc970ff53 |
@@ -14,9 +14,7 @@ import engine.gameManager.DbManager;
|
|||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.AbstractWorldObject;
|
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.util.MapLoader;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -93,7 +91,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
||||||
|
|
||||||
this.heightmapImage = MapLoader.flipImage(this.heightmapImage);
|
// this.heightmapImage = MapLoader.flipImage(this.heightmapImage);
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
@@ -123,35 +121,26 @@ public class HeightMap {
|
|||||||
this.outsetX = 128;
|
this.outsetX = 128;
|
||||||
this.outsetZ = 128;
|
this.outsetZ = 128;
|
||||||
|
|
||||||
|
|
||||||
// Cache the full extents to avoid the calculation
|
// Cache the full extents to avoid the calculation
|
||||||
|
|
||||||
this.fullExtentsX = halfExtentsX * 2;
|
this.fullExtentsX = halfExtentsX * 2;
|
||||||
this.fullExtentsY = halfExtentsY * 2;
|
this.fullExtentsY = halfExtentsY * 2;
|
||||||
|
|
||||||
|
|
||||||
// load the heightmap image.
|
|
||||||
|
|
||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
|
||||||
|
|
||||||
this.heightmapImage = null;
|
this.heightmapImage = null;
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
this.bucketWidthX = 1;
|
this.bucketWidthX = halfExtentsX;
|
||||||
this.bucketWidthY = 1;
|
this.bucketWidthY = halfExtentsY;
|
||||||
|
|
||||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY];
|
||||||
|
|
||||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
for (int y = 0; y < this.fullExtentsY; y++) {
|
||||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
for (int x = 0; x < this.fullExtentsX; x++) {
|
||||||
pixelColorValues[x][y] = 255;
|
pixelColorValues[x][y] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeightMap(Zone zone) {
|
public HeightMap(Zone zone) {
|
||||||
@@ -170,26 +159,21 @@ public class HeightMap {
|
|||||||
this.fullExtentsX = halfExtentsX * 2;
|
this.fullExtentsX = halfExtentsX * 2;
|
||||||
this.fullExtentsY = halfExtentsY * 2;
|
this.fullExtentsY = halfExtentsY * 2;
|
||||||
|
|
||||||
|
|
||||||
// We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin.
|
|
||||||
|
|
||||||
this.heightmapImage = null;
|
this.heightmapImage = null;
|
||||||
|
|
||||||
// Calculate the data we do not load from table
|
// Calculate the data we do not load from table
|
||||||
|
|
||||||
this.bucketWidthX = 1;
|
this.bucketWidthX = halfExtentsX;
|
||||||
this.bucketWidthY = 1;
|
this.bucketWidthY = halfExtentsY;
|
||||||
|
|
||||||
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
|
this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY];
|
||||||
|
|
||||||
for (int y = 0; y <= this.fullExtentsY; y++) {
|
for (int y = 0; y < this.fullExtentsY; y++) {
|
||||||
for (int x = 0; x <= this.fullExtentsX; x++) {
|
for (int x = 0; x < this.fullExtentsX; x++) {
|
||||||
pixelColorValues[x][y] = 255;
|
pixelColorValues[x][y] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GeneratePlayerCityHeightMap() {
|
public static void GeneratePlayerCityHeightMap() {
|
||||||
@@ -222,113 +206,9 @@ public class HeightMap {
|
|||||||
return nextZone;
|
return nextZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getWorldHeight(AbstractWorldObject worldObject) {
|
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) {
|
||||||
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
Vector2f parentLoc = new Vector2f(-1, -1);
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(worldObject.getLoc());
|
|
||||||
|
|
||||||
if (currentZone == null)
|
|
||||||
return worldObject.getAltitude();
|
|
||||||
|
|
||||||
currentZone = getNextZoneWithTerrain(currentZone);
|
|
||||||
|
|
||||||
if (currentZone == ZoneManager.getSeaFloor())
|
|
||||||
return currentZone.getAbsY() + worldObject.getAltitude();
|
|
||||||
|
|
||||||
Zone parentZone = getNextZoneWithTerrain(currentZone.getParent());
|
|
||||||
HeightMap heightMap = currentZone.getHeightMap();
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), currentZone);
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldObject.getLoc(), currentZone);
|
|
||||||
|
|
||||||
if ((parentZone != null) && (parentZone.getHeightMap() != null))
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(worldObject.getLoc(), parentZone);
|
|
||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
|
|
||||||
float worldAltitude = currentZone.getWorldAltitude();
|
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + worldAltitude;
|
|
||||||
|
|
||||||
//OUTSET
|
|
||||||
|
|
||||||
if (parentZone != null) {
|
|
||||||
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
float bucketScaleX = heightMap.outsetX / parentXRadius;
|
|
||||||
float bucketScaleZ = heightMap.outsetZ / parentZRadius;
|
|
||||||
|
|
||||||
if (bucketScaleX <= 0.40000001)
|
|
||||||
bucketScaleX = heightMap.outsetZ / parentXRadius;
|
|
||||||
|
|
||||||
if (bucketScaleX > 0.40000001)
|
|
||||||
bucketScaleX = 0.40000001f;
|
|
||||||
|
|
||||||
if (bucketScaleZ <= 0.40000001)
|
|
||||||
bucketScaleZ = heightMap.outsetX / parentZRadius;
|
|
||||||
|
|
||||||
if (bucketScaleZ > 0.40000001)
|
|
||||||
bucketScaleZ = 0.40000001f;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
float weight;
|
|
||||||
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return realWorldAltitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
|
||||||
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(worldLoc);
|
|
||||||
|
|
||||||
if (currentZone == null)
|
if (currentZone == null)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -352,7 +232,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||||
|
|
||||||
float worldAltitude = currentZone.getWorldAltitude();
|
float worldAltitude = currentZone.worldAltitude;
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + worldAltitude;
|
float realWorldAltitude = interaltitude + worldAltitude;
|
||||||
|
|
||||||
@@ -360,9 +240,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
if (parentZone != null) {
|
if (parentZone != null) {
|
||||||
|
|
||||||
// if (currentZone.getHeightMap() != null && parentZone.getHeightMap() != null && parentZone.getParent() != null && parentZone.getParent().getHeightMap() != null)
|
|
||||||
// return realWorldAltitude;
|
|
||||||
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
||||||
|
|
||||||
@@ -378,7 +255,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
double scale;
|
double scale;
|
||||||
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
||||||
@@ -396,7 +272,7 @@ public class HeightMap {
|
|||||||
float secondScale = parentCenterAltitude * scaleChild;
|
float secondScale = parentCenterAltitude * scaleChild;
|
||||||
float outsetALt = firstScale + secondScale;
|
float outsetALt = firstScale + secondScale;
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
outsetALt += currentZone.getParent().worldAltitude;
|
||||||
realWorldAltitude = outsetALt;
|
realWorldAltitude = outsetALt;
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
} else if (offsetZ > outsideGridSizeZ) {
|
||||||
@@ -415,7 +291,7 @@ public class HeightMap {
|
|||||||
float secondScale = parentCenterAltitude * scaleChild;
|
float secondScale = parentCenterAltitude * scaleChild;
|
||||||
float outsetALt = firstScale + secondScale;
|
float outsetALt = firstScale + secondScale;
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getWorldAltitude();
|
outsetALt += currentZone.getParent().worldAltitude;
|
||||||
realWorldAltitude = outsetALt;
|
realWorldAltitude = outsetALt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,85 +299,13 @@ public class HeightMap {
|
|||||||
return realWorldAltitude;
|
return realWorldAltitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
|
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
||||||
|
|
||||||
Vector2f parentLoc;
|
Zone currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||||
float outsetALt = 0;
|
|
||||||
|
|
||||||
if (zone.getParent() == null || zone.getParent().getHeightMap() == null)
|
if (currentZone == null)
|
||||||
return interpolatedAltitude + zone.getWorldAltitude();
|
return 0;
|
||||||
|
return getWorldHeight(currentZone, worldLoc);
|
||||||
if (zone.getParent() != null && zone.getParent().getHeightMap() != null) {
|
|
||||||
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(worldLocation, zone.getParent());
|
|
||||||
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLocation, zone);
|
|
||||||
|
|
||||||
float parentXRadius = zone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = zone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float bucketScaleX = zone.getHeightMap().outsetX / parentXRadius;
|
|
||||||
float bucketScaleZ = zone.getHeightMap().outsetZ / parentZRadius;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
|
|
||||||
float weight;
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone.getParent()));
|
|
||||||
|
|
||||||
parentCenterAltitude += zone.getYCoord();
|
|
||||||
parentCenterAltitude += interpolatedAltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += zone.getParent().getAbsY();
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = zone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone));
|
|
||||||
|
|
||||||
parentCenterAltitude += zone.getYCoord();
|
|
||||||
parentCenterAltitude += interpolatedAltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += zone.getParent().getAbsY();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return outsetALt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2f getGridOffset(Vector2f gridSquare) {
|
|
||||||
|
|
||||||
int floorX = (int) gridSquare.x;
|
|
||||||
int floorY = (int) gridSquare.y;
|
|
||||||
|
|
||||||
return new Vector2f(gridSquare.x - floorX, gridSquare.y - floorY);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +319,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
HeightMap.GeneratePlayerCityHeightMap();
|
HeightMap.GeneratePlayerCityHeightMap();
|
||||||
|
|
||||||
|
|
||||||
// Clear all heightmap image data as it's no longer needed.
|
// Clear all heightmap image data as it's no longer needed.
|
||||||
|
|
||||||
for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) {
|
for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) {
|
||||||
@@ -541,14 +344,18 @@ public class HeightMap {
|
|||||||
if (zoneLoc.x < 0)
|
if (zoneLoc.x < 0)
|
||||||
zoneLoc.setX(0);
|
zoneLoc.setX(0);
|
||||||
|
|
||||||
if (zoneLoc.x > this.fullExtentsX - 1)
|
if (zoneLoc.x >= this.fullExtentsX)
|
||||||
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
|
zoneLoc.setX(this.fullExtentsX);
|
||||||
|
|
||||||
if (zoneLoc.y < 0)
|
if (zoneLoc.y < 0)
|
||||||
zoneLoc.setY(0);
|
zoneLoc.setY(0);
|
||||||
|
|
||||||
if (zoneLoc.y > this.fullExtentsY - 1)
|
if (zoneLoc.y > this.fullExtentsY)
|
||||||
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
|
zoneLoc.setY(this.fullExtentsY);
|
||||||
|
|
||||||
|
// Flip Y coordinates
|
||||||
|
|
||||||
|
zoneLoc.setY(this.fullExtentsY - zoneLoc.y);
|
||||||
|
|
||||||
float xBucket = (zoneLoc.x / this.bucketWidthX);
|
float xBucket = (zoneLoc.x / this.bucketWidthX);
|
||||||
float yBucket = (zoneLoc.y / this.bucketWidthY);
|
float yBucket = (zoneLoc.y / this.bucketWidthY);
|
||||||
@@ -569,13 +376,10 @@ public class HeightMap {
|
|||||||
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
|
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
|
||||||
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
|
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
|
||||||
|
|
||||||
//flip the Y so it grabs from the bottom left instead of top left.
|
|
||||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
|
||||||
|
|
||||||
gridSquare = getGridSquare(zoneLoc);
|
gridSquare = getGridSquare(zoneLoc);
|
||||||
|
|
||||||
int gridX = (int) gridSquare.x;
|
int gridX = (int) gridSquare.x;
|
||||||
int gridY = (int) (gridSquare.y);
|
int gridY = (int) gridSquare.y;
|
||||||
|
|
||||||
if (gridX > maxX)
|
if (gridX > maxX)
|
||||||
gridX = maxX;
|
gridX = maxX;
|
||||||
@@ -618,48 +422,6 @@ public class HeightMap {
|
|||||||
return interpolatedHeight;
|
return interpolatedHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
|
|
||||||
|
|
||||||
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
|
|
||||||
|
|
||||||
Vector2f gridSquare;
|
|
||||||
|
|
||||||
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
//flip the Y so it grabs from the bottom left instead of top left.
|
|
||||||
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
|
|
||||||
|
|
||||||
gridSquare = getGridSquare(zoneLoc);
|
|
||||||
|
|
||||||
int gridX = (int) gridSquare.x;
|
|
||||||
int gridY = (int) (gridSquare.y);
|
|
||||||
|
|
||||||
float offsetX = (gridSquare.x - gridX);
|
|
||||||
float offsetY = gridSquare.y - gridY;
|
|
||||||
|
|
||||||
//get height of the 4 vertices.
|
|
||||||
|
|
||||||
float topLeftHeight = pixelColorValues[gridX][gridY];
|
|
||||||
float topRightHeight = pixelColorValues[gridX + 1][gridY];
|
|
||||||
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
|
|
||||||
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
|
|
||||||
|
|
||||||
float interpolatedHeight;
|
|
||||||
|
|
||||||
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
|
|
||||||
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
|
|
||||||
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
|
|
||||||
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
|
|
||||||
|
|
||||||
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
|
|
||||||
|
|
||||||
return interpolatedHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generatePixelData() {
|
private void generatePixelData() {
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
@@ -678,11 +440,6 @@ public class HeightMap {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getScaledHeightForColor(float color) {
|
|
||||||
|
|
||||||
return (color / 256) * this.maxHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBucketWidthX() {
|
public float getBucketWidthX() {
|
||||||
return bucketWidthX;
|
return bucketWidthX;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2022
|
|
||||||
// www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.devcmd.cmds;
|
|
||||||
|
|
||||||
import engine.InterestManagement.HeightMap;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.objects.AbstractGameObject;
|
|
||||||
import engine.objects.PlayerCharacter;
|
|
||||||
import engine.objects.Zone;
|
|
||||||
|
|
||||||
public class AuditHeightMapCmd extends AbstractDevCmd {
|
|
||||||
|
|
||||||
public AuditHeightMapCmd() {
|
|
||||||
super("auditheightmap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void _doCmd(PlayerCharacter pcSender, String[] words,
|
|
||||||
AbstractGameObject target) {
|
|
||||||
|
|
||||||
int count = Integer.parseInt(words[0]);
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
|
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
|
|
||||||
|
|
||||||
|
|
||||||
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);
|
|
||||||
|
|
||||||
if (currentZone != null && currentZone.getHeightMap() != null) {
|
|
||||||
float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
long delta = end - start;
|
|
||||||
|
|
||||||
this.throwbackInfo(pcSender, "Audit Heightmap took " + delta + " ms to run " + count + " times!");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String _getUsageString() {
|
|
||||||
return "' /auditmobs [zone.UUID]'";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String _getHelpString() {
|
|
||||||
return "Audits all the mobs in a zone.";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ import engine.InterestManagement.HeightMap;
|
|||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
@@ -26,201 +25,41 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
boolean end = true;
|
Zone currentZone;
|
||||||
|
Zone parentZone;
|
||||||
|
Zone heightmapZone;
|
||||||
|
|
||||||
float height = HeightMap.getWorldHeight(pc);
|
currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc());
|
||||||
|
heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone);
|
||||||
|
parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Altitude : " + height);
|
float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
|
float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc());
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Character Height: " + pc.getCharacterHeight());
|
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName());
|
||||||
this.throwbackInfo(pc, "Character Height to start swimming: " + pc.centerHeight);
|
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName());
|
||||||
|
this.throwbackInfo(playerCharacter, "Height returned: " + currentHeight);
|
||||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
|
||||||
this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel());
|
|
||||||
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()));
|
|
||||||
|
|
||||||
if (end)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Vector2f gridSquare;
|
|
||||||
Vector2f gridOffset;
|
|
||||||
Vector2f parentGrid;
|
|
||||||
Vector2f parentLoc = new Vector2f(-1, -1);
|
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
|
|
||||||
|
|
||||||
if (currentZone == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Zone parentZone = currentZone.getParent();
|
|
||||||
|
|
||||||
HeightMap heightMap = currentZone.getHeightMap();
|
|
||||||
|
|
||||||
|
|
||||||
//find the next parents heightmap if the currentzone heightmap is null.
|
|
||||||
while (heightMap == null) {
|
|
||||||
|
|
||||||
if (currentZone == ZoneManager.getSeaFloor()) {
|
|
||||||
this.throwbackInfo(pc, "Could not find a heightmap to get height.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.throwbackError(pc, "Heightmap does not exist for " + currentZone.getName());
|
|
||||||
this.throwbackInfo(pc, "Using parent zone instead: ");
|
|
||||||
currentZone = currentZone.getParent();
|
|
||||||
heightMap = currentZone.getHeightMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) {
|
|
||||||
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap ");
|
|
||||||
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone);
|
|
||||||
|
|
||||||
Vector3fImmutable seaFloorLocalLoc = ZoneManager.worldToLocal(pc.getLoc(), ZoneManager.getSeaFloor());
|
|
||||||
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
|
|
||||||
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
|
|
||||||
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
|
|
||||||
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
|
|
||||||
this.throwbackInfo(pc, "Local Zone Location from center : " + localLocFromCenter);
|
|
||||||
this.throwbackInfo(pc, "parent Zone Location from center : " + parentLocFromCenter);
|
|
||||||
|
|
||||||
Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent());
|
|
||||||
this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc);
|
|
||||||
|
|
||||||
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
|
|
||||||
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
|
|
||||||
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
|
|
||||||
} else
|
|
||||||
parentGrid = new Vector2f(-1, -1);
|
|
||||||
|
|
||||||
gridSquare = heightMap.getGridSquare(zoneLoc);
|
|
||||||
gridOffset = HeightMap.getGridOffset(gridSquare);
|
|
||||||
|
|
||||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, currentZone.getName());
|
|
||||||
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y);
|
|
||||||
this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y);
|
|
||||||
this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y);
|
|
||||||
|
|
||||||
if (parentGrid.x != -1) {
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
this.throwbackInfo(pc, "Parent ALTITUDE: " + (parentAltitude));
|
|
||||||
this.throwbackInfo(pc, "Parent Interpolation: " + (parentAltitude + parentZone.getWorldAltitude()));
|
|
||||||
}
|
|
||||||
this.throwbackInfo(pc, "interpolated height: " + interaltitude);
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "interpolated height with World: " + (interaltitude + currentZone.getWorldAltitude()));
|
|
||||||
|
|
||||||
float realWorldAltitude = interaltitude + currentZone.getWorldAltitude();
|
|
||||||
|
|
||||||
//OUTSET
|
|
||||||
if (parentZone != null) {
|
|
||||||
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
|
|
||||||
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
|
|
||||||
|
|
||||||
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
|
|
||||||
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
|
|
||||||
|
|
||||||
float bucketScaleX = 100 / parentXRadius;
|
|
||||||
float bucketScaleZ = 200 / parentZRadius;
|
|
||||||
|
|
||||||
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
||||||
float outsideGridSizeZ = 1 - bucketScaleZ;
|
|
||||||
float weight;
|
|
||||||
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
|
|
||||||
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
|
|
||||||
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
|
|
||||||
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getAbsY();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
} else if (offsetZ > outsideGridSizeZ) {
|
|
||||||
|
|
||||||
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
|
|
||||||
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
|
|
||||||
|
|
||||||
float scaleChild = (float) ((scale + 1) * .5);
|
|
||||||
float scaleParent = 1 - scaleChild;
|
|
||||||
float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc);
|
|
||||||
float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone));
|
|
||||||
|
|
||||||
parentCenterAltitude += currentZone.getYCoord();
|
|
||||||
parentCenterAltitude += interaltitude;
|
|
||||||
float firstScale = parentAltitude * scaleParent;
|
|
||||||
float secondScale = parentCenterAltitude * scaleChild;
|
|
||||||
float outsetALt = firstScale + secondScale;
|
|
||||||
|
|
||||||
outsetALt += currentZone.getParent().getAbsY();
|
|
||||||
realWorldAltitude = outsetALt;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float strMod = pc.statStrBase - 40;
|
|
||||||
|
|
||||||
strMod *= .00999999998f;
|
|
||||||
|
|
||||||
strMod += 1f;
|
|
||||||
|
|
||||||
float radius = 0;
|
|
||||||
switch (pc.getRaceID()) {
|
|
||||||
case 2017:
|
|
||||||
radius = 3.1415927f;
|
|
||||||
case 2000:
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
strMod *= 1.5707964f;
|
|
||||||
|
|
||||||
strMod += 3.1415927f;
|
|
||||||
|
|
||||||
strMod -= .5f;
|
|
||||||
|
|
||||||
|
|
||||||
realWorldAltitude += strMod;
|
|
||||||
|
|
||||||
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
|
|
||||||
|
|
||||||
|
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone);
|
||||||
|
Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc);
|
||||||
|
|
||||||
|
this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y);
|
||||||
|
this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName());
|
||||||
|
this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight);
|
||||||
|
this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Temporarily Changes SubRace";
|
return "Queries heightmap engine";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /subrace mobBaseID";
|
return "' /getheight";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class ZoneInfoCmd extends AbstractDevCmd {
|
|||||||
output += newline;
|
output += newline;
|
||||||
output += "Sea Level = " + zone.getSeaLevel();
|
output += "Sea Level = " + zone.getSeaLevel();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "World Altitude = " + zone.getWorldAltitude();
|
output += "World Altitude = " + zone.worldAltitude;
|
||||||
throwbackInfo(player, output);
|
throwbackInfo(player, output);
|
||||||
|
|
||||||
City city = ZoneManager.getCityAtLocation(player.getLoc());
|
City city = ZoneManager.getCityAtLocation(player.getLoc());
|
||||||
|
|||||||
@@ -128,7 +128,6 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
|
||||||
DevCmdManager.registerDevCmd(new GotoObj());
|
DevCmdManager.registerDevCmd(new GotoObj());
|
||||||
DevCmdManager.registerDevCmd(new convertLoc());
|
DevCmdManager.registerDevCmd(new convertLoc());
|
||||||
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
|
|
||||||
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
|
||||||
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package engine.gameManager;
|
package engine.gameManager;
|
||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
|
import engine.InterestManagement.HeightMap;
|
||||||
import engine.db.archive.CityRecord;
|
import engine.db.archive.CityRecord;
|
||||||
import engine.db.archive.DataWarehouse;
|
import engine.db.archive.DataWarehouse;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
@@ -453,4 +454,31 @@ public enum ZoneManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float caclulateWorldAltitude(Zone zone) {
|
||||||
|
|
||||||
|
float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
|
|
||||||
|
// Seafloor
|
||||||
|
|
||||||
|
if (zone.getParent() == null)
|
||||||
|
return worldAlttitude;
|
||||||
|
|
||||||
|
Zone parentZone = zone.getParent();
|
||||||
|
|
||||||
|
// Children of seafloor
|
||||||
|
|
||||||
|
if (parentZone.getParent() == null)
|
||||||
|
return worldAlttitude + zone.getYCoord();
|
||||||
|
|
||||||
|
// return height from heightmap engine at zone location
|
||||||
|
|
||||||
|
worldAlttitude = HeightMap.getWorldHeight(parentZone, zone.getLoc());
|
||||||
|
|
||||||
|
// Add zone offset to value
|
||||||
|
|
||||||
|
worldAlttitude += zone.getYCoord();
|
||||||
|
|
||||||
|
return worldAlttitude;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -745,7 +745,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3fImmutable plantLoc = new Vector3fImmutable(treeInfo.getLoc().x,
|
Vector3fImmutable plantLoc = new Vector3fImmutable(treeInfo.getLoc().x,
|
||||||
HeightMap.getWorldHeight(treeInfo.getLoc()),
|
0,
|
||||||
treeInfo.getLoc().z);
|
treeInfo.getLoc().z);
|
||||||
|
|
||||||
cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(),
|
cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(),
|
||||||
@@ -754,6 +754,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
plantLoc.z - serverZone.getAbsZ(), treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now());
|
plantLoc.z - serverZone.getAbsZ(), treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now());
|
||||||
|
|
||||||
// Uh oh!
|
// Uh oh!
|
||||||
|
|
||||||
if (cityObjects == null || cityObjects.isEmpty()) {
|
if (cityObjects == null || cityObjects.isEmpty()) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||||
return false;
|
return false;
|
||||||
@@ -767,7 +768,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
||||||
treeObject.runAfterLoad();
|
treeObject.runAfterLoad();
|
||||||
;
|
|
||||||
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
||||||
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
||||||
|
|
||||||
@@ -792,10 +793,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
ZoneManager.addPlayerCityZone(zoneObject);
|
ZoneManager.addPlayerCityZone(zoneObject);
|
||||||
serverZone.addNode(zoneObject);
|
serverZone.addNode(zoneObject);
|
||||||
|
|
||||||
zoneObject.generateWorldAltitude();
|
zoneObject.worldAltitude = ZoneManager.caclulateWorldAltitude(zoneObject);
|
||||||
|
|
||||||
cityObject.setParent(zoneObject);
|
cityObject.setParent(zoneObject);
|
||||||
cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already
|
cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already
|
||||||
|
|
||||||
//Link the tree of life with the new zone
|
//Link the tree of life with the new zone
|
||||||
|
|
||||||
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||||
@@ -817,7 +819,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
City.lastCityUpdate = System.currentTimeMillis();
|
City.lastCityUpdate = System.currentTimeMillis();
|
||||||
treeObject.setLoc(treeObject.getLoc());
|
treeObject.setLoc(treeObject.getLoc());
|
||||||
InterestManager.setObjectDirty(treeObject);
|
InterestManager.setObjectDirty(treeObject);
|
||||||
// WorldGrid.addObject(treeObject, playerCharacter);
|
|
||||||
|
|
||||||
serverRealm.addCity(cityObject.getObjectUUID());
|
serverRealm.addCity(cityObject.getObjectUUID());
|
||||||
playerNation.setCityUUID(cityObject.getObjectUUID());
|
playerNation.setCityUUID(cityObject.getObjectUUID());
|
||||||
@@ -915,6 +916,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
// Early exit if something went horribly wrong
|
// Early exit if something went horribly wrong
|
||||||
// with locating the current realm and/or zone
|
// with locating the current realm and/or zone
|
||||||
|
|
||||||
if (serverZone == null)
|
if (serverZone == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -977,7 +979,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
City cityObject;
|
City cityObject;
|
||||||
PlacementInfo buildingList;
|
PlacementInfo buildingList;
|
||||||
|
|
||||||
// Setup working variables we'll need
|
// Setup working variables
|
||||||
|
|
||||||
buildingList = msg.getFirstPlacementInfo();
|
buildingList = msg.getFirstPlacementInfo();
|
||||||
|
|
||||||
serverZone = ZoneManager.findSmallestZone(buildingList.getLoc());
|
serverZone = ZoneManager.findSmallestZone(buildingList.getLoc());
|
||||||
@@ -1090,7 +1093,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
placementCost = 0; // reset placement cost for fix bug with wall pieces somethings not taking gold out if forced an error.
|
placementCost = 0; // reset placement cost for fix bug with wall pieces somethings not taking gold out if forced an error.
|
||||||
|
|
||||||
|
|
||||||
// Overlap check and wall deed verifications
|
// Overlap check and wall deed verifications
|
||||||
for (PlacementInfo wall : walls) {
|
for (PlacementInfo wall : walls) {
|
||||||
|
|
||||||
@@ -1109,7 +1111,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
for (Building building : serverZone.zoneBuildingSet) {
|
for (Building building : serverZone.zoneBuildingSet) {
|
||||||
|
|
||||||
|
|
||||||
//TODO Clean up collision with placementInfo. don't need to create the same placementinfo bounds for collision checks on each building.
|
//TODO Clean up collision with placementInfo. don't need to create the same placementinfo bounds for collision checks on each building.
|
||||||
if ((building.getBlueprintUUID() != 0) && (Bounds.collide(wall, building) == true)) {
|
if ((building.getBlueprintUUID() != 0) && (Bounds.collide(wall, building) == true)) {
|
||||||
|
|
||||||
@@ -1129,12 +1130,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
placementCost = PlaceAssetMsg.getWallCost(wall.getBlueprintUUID());
|
placementCost = PlaceAssetMsg.getWallCost(wall.getBlueprintUUID());
|
||||||
|
|
||||||
if (!itemMan.modifyInventoryGold(-placementCost)) {
|
if (!itemMan.modifyInventoryGold(-placementCost)) {
|
||||||
ChatManager.chatSystemInfo(player, player.getFirstName() + " can't has free moneys! no for real.. Thor.. seriously... I didnt fix it because you getting laid isnt important enough for me.");
|
ChatManager.chatSystemInfo(player, player.getFirstName() + " can't has free moneys! no for real.. Thor.. seriously... I didnt fix it because you getting laid isnt important enough for me.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to place wall piece
|
// Attempt to place wall piece
|
||||||
|
|
||||||
wallPiece = createStructure(player, wall, serverZone);
|
wallPiece = createStructure(player, wall, serverZone);
|
||||||
@@ -1145,14 +1148,12 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// walls are auto protected
|
// walls are auto protected
|
||||||
|
|
||||||
wallPiece.setProtectionState(ProtectionState.PROTECTED);
|
wallPiece.setProtectionState(ProtectionState.PROTECTED);
|
||||||
PlaceAssetMsg.sendPlaceAssetConfirmWall(origin, serverZone);
|
PlaceAssetMsg.sendPlaceAssetConfirmWall(origin, serverZone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deduct gold from character's inventory
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1172,6 +1173,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All siege buildings build in 15 minutes
|
// All siege buildings build in 15 minutes
|
||||||
|
|
||||||
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
||||||
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
|
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
|
||||||
completionDate = DateTime.now().plusMinutes(15);
|
completionDate = DateTime.now().plusMinutes(15);
|
||||||
@@ -1191,6 +1193,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
completionDate, blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
|
||||||
|
|
||||||
// Make sure we have a valid mesh
|
// Make sure we have a valid mesh
|
||||||
|
|
||||||
if (newMesh == null) {
|
if (newMesh == null) {
|
||||||
Logger.error("CreateStructure: DB returned null object.");
|
Logger.error("CreateStructure: DB returned null object.");
|
||||||
return null;
|
return null;
|
||||||
@@ -1362,15 +1365,16 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
newMesh = (Building) ago;
|
newMesh = (Building) ago;
|
||||||
newMesh.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
newMesh.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||||
MaintenanceManager.setMaintDateTime(newMesh, LocalDateTime.now().plusDays(7));
|
MaintenanceManager.setMaintDateTime(newMesh, LocalDateTime.now().plusDays(7));
|
||||||
// WorldGrid.addObject(newMesh, player);
|
|
||||||
newMesh.setLoc(newMesh.getLoc());
|
newMesh.setLoc(newMesh.getLoc());
|
||||||
InterestManager.setObjectDirty(newMesh);
|
InterestManager.setObjectDirty(newMesh);
|
||||||
newMesh.runAfterLoad();
|
newMesh.runAfterLoad();
|
||||||
} else if (ago.getObjectType() == GameObjectType.Warehouse) {
|
} else if (ago.getObjectType() == GameObjectType.Warehouse) {
|
||||||
Warehouse warehouse = (Warehouse) ago;
|
Warehouse warehouse = (Warehouse) ago;
|
||||||
City city = City.getCity(currentZone.getPlayerCityUUID());
|
City city = City.getCity(currentZone.getPlayerCityUUID());
|
||||||
|
|
||||||
if (city == null)
|
if (city == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
city.setWarehouseBuildingID(newMesh.getObjectUUID());
|
city.setWarehouseBuildingID(newMesh.getObjectUUID());
|
||||||
Warehouse.warehouseByBuildingUUID.put(newMesh.getObjectUUID(), warehouse);
|
Warehouse.warehouseByBuildingUUID.put(newMesh.getObjectUUID(), warehouse);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
|||||||
return;
|
return;
|
||||||
this.lastLoc = new Vector3fImmutable(this.loc);
|
this.lastLoc = new Vector3fImmutable(this.loc);
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.loc = this.loc.setY(HeightMap.getWorldHeight(this) + this.getAltitude());
|
this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||||
|
|
||||||
//lets not add mob to world grid if he is currently despawned.
|
//lets not add mob to world grid if he is currently despawned.
|
||||||
if (this.getObjectType().equals(GameObjectType.Mob) && ((Mob) this).despawned)
|
if (this.getObjectType().equals(GameObjectType.Mob) && ((Mob) this).despawned)
|
||||||
|
|||||||
+57
-136
@@ -66,9 +66,6 @@ public class City extends AbstractWorldObject {
|
|||||||
private int realmID;
|
private int realmID;
|
||||||
private int radiusType;
|
private int radiusType;
|
||||||
private float bindRadius;
|
private float bindRadius;
|
||||||
private float statLat;
|
|
||||||
private float statAlt;
|
|
||||||
private float statLon;
|
|
||||||
private float bindX;
|
private float bindX;
|
||||||
private float bindZ;
|
private float bindZ;
|
||||||
private byte isNpc; //aka Safehold
|
private byte isNpc; //aka Safehold
|
||||||
@@ -77,7 +74,7 @@ public class City extends AbstractWorldObject {
|
|||||||
private boolean forceRename = false;
|
private boolean forceRename = false;
|
||||||
private boolean noTeleport = false; //used by npc cities
|
private boolean noTeleport = false; //used by npc cities
|
||||||
private boolean noRepledge = false; //used by npc cities
|
private boolean noRepledge = false; //used by npc cities
|
||||||
private boolean isOpen = false;
|
private final boolean isOpen = false;
|
||||||
private int treeOfLifeID;
|
private int treeOfLifeID;
|
||||||
private Vector3fImmutable location = Vector3fImmutable.ZERO;
|
private Vector3fImmutable location = Vector3fImmutable.ZERO;
|
||||||
|
|
||||||
@@ -113,10 +110,7 @@ public class City extends AbstractWorldObject {
|
|||||||
if (establishedTimeStamp != null)
|
if (establishedTimeStamp != null)
|
||||||
this.established = java.time.LocalDateTime.ofInstant(establishedTimeStamp.toInstant(), ZoneId.systemDefault());
|
this.established = java.time.LocalDateTime.ofInstant(establishedTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||||
|
|
||||||
this.location = new Vector3fImmutable(rs.getFloat("xCoord"), rs.getFloat("yCoord"), rs.getFloat("zCoord"));
|
this.location = Vector3fImmutable.ZERO;
|
||||||
this.statLat = rs.getFloat("xCoord");
|
|
||||||
this.statAlt = rs.getFloat("yCoord");
|
|
||||||
this.statLon = rs.getFloat("zCoord");
|
|
||||||
|
|
||||||
java.sql.Timestamp realmTaxTimeStamp = rs.getTimestamp("realmTaxDate");
|
java.sql.Timestamp realmTaxTimeStamp = rs.getTimestamp("realmTaxDate");
|
||||||
|
|
||||||
@@ -159,11 +153,6 @@ public class City extends AbstractWorldObject {
|
|||||||
this.motto = guild.getMotto();
|
this.motto = guild.getMotto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Disabled till i finish.
|
|
||||||
// this.reverseKOS = rs.getInt("kos") == 1;
|
|
||||||
|
|
||||||
|
|
||||||
Zone zone = ZoneManager.getZoneByUUID(rs.getInt("parent"));
|
Zone zone = ZoneManager.getZoneByUUID(rs.getInt("parent"));
|
||||||
|
|
||||||
if (zone != null)
|
if (zone != null)
|
||||||
@@ -171,18 +160,12 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
//npc cities without heightmaps except swampstone are specials.
|
//npc cities without heightmaps except swampstone are specials.
|
||||||
|
|
||||||
|
|
||||||
this.realmID = rs.getInt("realmID");
|
this.realmID = rs.getInt("realmID");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *** Refactor: Is this working? Intended to supress
|
|
||||||
// login server errors from attempting to
|
|
||||||
// load cities/realms along with players
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -208,7 +191,6 @@ public class City extends AbstractWorldObject {
|
|||||||
Logger.error("NULL TOL FOR " + city.cityName);
|
Logger.error("NULL TOL FOR " + city.cityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Assign city owner
|
// Assign city owner
|
||||||
|
|
||||||
if (city.getTOL() != null)
|
if (city.getTOL() != null)
|
||||||
@@ -226,7 +208,8 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
rulingNation = rulingGuild.getNation();
|
rulingNation = rulingGuild.getNation();
|
||||||
|
|
||||||
// Begin Serialzing soverign guild data
|
// Begin Serializing sovereign guild data
|
||||||
|
|
||||||
writer.putInt(city.getObjectType().ordinal());
|
writer.putInt(city.getObjectType().ordinal());
|
||||||
writer.putInt(city.getObjectUUID());
|
writer.putInt(city.getObjectUUID());
|
||||||
writer.putString(city.cityName);
|
writer.putString(city.cityName);
|
||||||
@@ -281,7 +264,6 @@ public class City extends AbstractWorldObject {
|
|||||||
writer.putInt(rulingNation.getObjectUUID());
|
writer.putInt(rulingNation.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Serialize nation name
|
// Serialize nation name
|
||||||
|
|
||||||
if (rulingNation.isEmptyGuild())
|
if (rulingNation.isEmptyGuild())
|
||||||
@@ -303,16 +285,8 @@ public class City extends AbstractWorldObject {
|
|||||||
else
|
else
|
||||||
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName());
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName());
|
||||||
|
|
||||||
|
|
||||||
writer.putLocalDateTime(city.established);
|
writer.putLocalDateTime(city.established);
|
||||||
|
|
||||||
// writer.put((byte) city.established.getDayOfMonth());
|
|
||||||
// writer.put((byte) city.established.minusMonths(1).getMonth().getValue());
|
|
||||||
// writer.putInt((int) years);
|
|
||||||
// writer.put((byte) hours);
|
|
||||||
// writer.put((byte) minutes);
|
|
||||||
// writer.put((byte) seconds);
|
|
||||||
|
|
||||||
writer.putFloat(city.location.x);
|
writer.putFloat(city.location.x);
|
||||||
writer.putFloat(city.location.y);
|
writer.putFloat(city.location.y);
|
||||||
writer.putFloat(city.location.z);
|
writer.putFloat(city.location.z);
|
||||||
@@ -351,6 +325,7 @@ public class City extends AbstractWorldObject {
|
|||||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
||||||
|
|
||||||
//add npc cities
|
//add npc cities
|
||||||
|
|
||||||
for (AbstractGameObject ago : worldCities.values()) {
|
for (AbstractGameObject ago : worldCities.values()) {
|
||||||
|
|
||||||
if (ago.getObjectType().equals(GameObjectType.City)) {
|
if (ago.getObjectType().equals(GameObjectType.City)) {
|
||||||
@@ -367,6 +342,7 @@ public class City extends AbstractWorldObject {
|
|||||||
//list Player cities
|
//list Player cities
|
||||||
|
|
||||||
//open city, just list
|
//open city, just list
|
||||||
|
|
||||||
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
||||||
|
|
||||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
|
||||||
@@ -376,7 +352,9 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
|
|
||||||
} else if (city.isNpc == 1) {
|
} else if (city.isNpc == 1) {
|
||||||
|
|
||||||
//list NPC cities
|
//list NPC cities
|
||||||
|
|
||||||
Guild g = city.getGuild();
|
Guild g = city.getGuild();
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
if (city.isNpc == 1)
|
if (city.isNpc == 1)
|
||||||
@@ -386,32 +364,34 @@ public class City extends AbstractWorldObject {
|
|||||||
} else if (pc.getLevel() > 9)
|
} else if (pc.getLevel() > 9)
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
|
|
||||||
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) {
|
} else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax())
|
||||||
|
|
||||||
|
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cities;
|
return cities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter pc) {
|
public static ArrayList<City> getCitiesToRepledgeTo(PlayerCharacter playerCharacter) {
|
||||||
|
|
||||||
ArrayList<City> cities = new ArrayList<>();
|
ArrayList<City> cities = new ArrayList<>();
|
||||||
if (pc == null)
|
|
||||||
|
if (playerCharacter == null)
|
||||||
return cities;
|
return cities;
|
||||||
Guild pcG = pc.getGuild();
|
|
||||||
|
Guild pcG = playerCharacter.getGuild();
|
||||||
|
|
||||||
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(Enum.GameObjectType.City);
|
||||||
|
|
||||||
//add npc cities
|
//add npc cities
|
||||||
|
|
||||||
for (AbstractGameObject ago : worldCities.values()) {
|
for (AbstractGameObject ago : worldCities.values()) {
|
||||||
if (ago.getObjectType().equals(GameObjectType.City)) {
|
if (ago.getObjectType().equals(GameObjectType.City)) {
|
||||||
|
|
||||||
City city = (City) ago;
|
City city = (City) ago;
|
||||||
|
|
||||||
if (city.noRepledge)
|
if (city.noRepledge)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -419,11 +399,12 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
//list Player cities
|
//list Player cities
|
||||||
//open city, just list
|
//open city, just list
|
||||||
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
|
|
||||||
|
if (playerCharacter.getAccount().status.equals(AccountStatus.ADMIN)) {
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
} else if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
} else if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
|
||||||
|
|
||||||
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
|
if (!BuildingManager.IsPlayerHostile(city.getTOL(), playerCharacter))
|
||||||
cities.add(city); //verify nation or guild is same
|
cities.add(city); //verify nation or guild is same
|
||||||
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG))
|
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG))
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
@@ -431,15 +412,16 @@ public class City extends AbstractWorldObject {
|
|||||||
} else if (city.isNpc == 1) {
|
} else if (city.isNpc == 1) {
|
||||||
//list NPC cities
|
//list NPC cities
|
||||||
|
|
||||||
Guild g = city.getGuild();
|
Guild guild = city.getGuild();
|
||||||
if (g == null) {
|
|
||||||
|
if (guild == null) {
|
||||||
if (city.isNpc == 1)
|
if (city.isNpc == 1)
|
||||||
if (city.isNoobIsle == 1) {
|
if (city.isNoobIsle == 1) {
|
||||||
if (pc.getLevel() < 21)
|
if (playerCharacter.getLevel() < 21)
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
} else if (pc.getLevel() > 9)
|
} else if (playerCharacter.getLevel() > 9)
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
} else if (pc.getLevel() >= g.getRepledgeMin() && pc.getLevel() <= g.getRepledgeMax()) {
|
} else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) {
|
||||||
|
|
||||||
cities.add(city);
|
cities.add(city);
|
||||||
}
|
}
|
||||||
@@ -455,6 +437,7 @@ public class City extends AbstractWorldObject {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId);
|
City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId);
|
||||||
|
|
||||||
if (city != null)
|
if (city != null)
|
||||||
return city;
|
return city;
|
||||||
|
|
||||||
@@ -471,8 +454,10 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean renameCity(String cityName) {
|
public boolean renameCity(String cityName) {
|
||||||
|
|
||||||
if (!DbManager.CityQueries.renameCity(this, cityName))
|
if (!DbManager.CityQueries.renameCity(this, cityName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!DbManager.CityQueries.updateforceRename(this, false))
|
if (!DbManager.CityQueries.updateforceRename(this, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -482,17 +467,22 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateTOL(Building tol) {
|
public boolean updateTOL(Building tol) {
|
||||||
|
|
||||||
if (tol == null)
|
if (tol == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!DbManager.CityQueries.updateTOL(this, tol.getObjectUUID()))
|
if (!DbManager.CityQueries.updateTOL(this, tol.getObjectUUID()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.treeOfLifeID = tol.getObjectUUID();
|
this.treeOfLifeID = tol.getObjectUUID();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean renameCityForNewPlant(String cityName) {
|
public boolean renameCityForNewPlant(String cityName) {
|
||||||
|
|
||||||
if (!DbManager.CityQueries.renameCity(this, cityName))
|
if (!DbManager.CityQueries.renameCity(this, cityName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!DbManager.CityQueries.updateforceRename(this, true))
|
if (!DbManager.CityQueries.updateforceRename(this, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -515,19 +505,11 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Building getTOL() {
|
public Building getTOL() {
|
||||||
|
|
||||||
if (this.treeOfLifeID == 0)
|
if (this.treeOfLifeID == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return BuildingManager.getBuildingFromCache(this.treeOfLifeID);
|
return BuildingManager.getBuildingFromCache(this.treeOfLifeID);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIsNoobIsle() {
|
|
||||||
return isNoobIsle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPopulation() {
|
|
||||||
return population;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,14 +539,6 @@ public class City extends AbstractWorldObject {
|
|||||||
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
|
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLatitude() {
|
|
||||||
return this.location.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getLongitude() {
|
|
||||||
return this.location.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAltitude() {
|
public float getAltitude() {
|
||||||
return this.location.y;
|
return this.location.y;
|
||||||
}
|
}
|
||||||
@@ -574,34 +548,10 @@ public class City extends AbstractWorldObject {
|
|||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getIsNpcOwned() {
|
|
||||||
return isNpc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getIsSafeHold() {
|
|
||||||
return this.isSafeHold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSafeHold() {
|
public boolean isSafeHold() {
|
||||||
return (this.isSafeHold == (byte) 1);
|
return (this.isSafeHold == (byte) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getIsCapital() {
|
|
||||||
return isCapital;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsCapital(boolean state) {
|
|
||||||
this.isCapital = (state) ? (byte) 1 : (byte) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRadiusType() {
|
|
||||||
return this.radiusType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBindRadius() {
|
|
||||||
return this.bindRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRank() {
|
public int getRank() {
|
||||||
return (this.getTOL() == null) ? 0 : this.getTOL().getRank();
|
return (this.getTOL() == null) ? 0 : this.getTOL().getRank();
|
||||||
}
|
}
|
||||||
@@ -624,7 +574,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
|
|
||||||
this.parentZone = zone;
|
this.parentZone = zone;
|
||||||
this.location = new Vector3fImmutable(zone.absX + statLat, zone.absY + statAlt, zone.absZ + statLon);
|
this.location = new Vector3fImmutable(zone.absX, zone.absY, zone.absZ);
|
||||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||||
this.location.y,
|
this.location.y,
|
||||||
this.location.z + this.bindZ);
|
this.location.z + this.bindZ);
|
||||||
@@ -646,15 +596,6 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCityZone(Zone zone) {
|
|
||||||
|
|
||||||
if (zone == null || this.parentZone == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return zone.getObjectUUID() == this.parentZone.getObjectUUID();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbstractCharacter getOwner() {
|
public AbstractCharacter getOwner() {
|
||||||
|
|
||||||
if (this.getTOL() == null)
|
if (this.getTOL() == null)
|
||||||
@@ -676,13 +617,13 @@ public class City extends AbstractWorldObject {
|
|||||||
if (this.getTOL() == null)
|
if (this.getTOL() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
if (this.isNpc == 1) {
|
if (this.isNpc == 1) {
|
||||||
|
|
||||||
if (this.getTOL().getOwner() == null)
|
if (this.getTOL().getOwner() == null)
|
||||||
return null;
|
return null;
|
||||||
return this.getTOL().getOwner().getGuild();
|
return this.getTOL().getOwner().getGuild();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (this.getTOL().getOwner() == null)
|
if (this.getTOL().getOwner() == null)
|
||||||
return null;
|
return null;
|
||||||
return this.getTOL().getOwner().getGuild();
|
return this.getTOL().getOwner().getGuild();
|
||||||
@@ -690,13 +631,16 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean openCity(boolean open) {
|
public boolean openCity(boolean open) {
|
||||||
|
|
||||||
if (!DbManager.CityQueries.updateOpenCity(this, open))
|
if (!DbManager.CityQueries.updateOpenCity(this, open))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.open = open;
|
this.open = open;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3fImmutable getBindLoc() {
|
public Vector3fImmutable getBindLoc() {
|
||||||
|
|
||||||
Vector3fImmutable treeLoc = null;
|
Vector3fImmutable treeLoc = null;
|
||||||
|
|
||||||
if (this.getTOL() != null && this.getTOL().getRank() == 8)
|
if (this.getTOL() != null && this.getTOL().getRank() == 8)
|
||||||
@@ -706,7 +650,9 @@ public class City extends AbstractWorldObject {
|
|||||||
return treeLoc;
|
return treeLoc;
|
||||||
|
|
||||||
if (this.radiusType == 1 && this.bindRadius > 0f) {
|
if (this.radiusType == 1 && this.bindRadius > 0f) {
|
||||||
|
|
||||||
//square radius
|
//square radius
|
||||||
|
|
||||||
float x = this.bindLoc.getX();
|
float x = this.bindLoc.getX();
|
||||||
float z = this.bindLoc.getZ();
|
float z = this.bindLoc.getZ();
|
||||||
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * this.bindRadius;
|
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * this.bindRadius;
|
||||||
@@ -827,7 +773,6 @@ public class City extends AbstractWorldObject {
|
|||||||
try {
|
try {
|
||||||
this.getTOL().addEffectBit((1 << 16));
|
this.getTOL().addEffectBit((1 << 16));
|
||||||
this.getBane().getStone().addEffectBit((1 << 19));
|
this.getBane().getStone().addEffectBit((1 << 19));
|
||||||
;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info("Failed ao add bane effects on city." + e.getMessage());
|
Logger.info("Failed ao add bane effects on city." + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -852,6 +797,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (playerObject == null)
|
if (playerObject == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc()))
|
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -868,8 +814,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
// Remove the city effect from the ago's internal collection
|
// Remove the city effect from the ago's internal collection
|
||||||
|
|
||||||
if (this.getEffects().containsKey(Integer.toString(effectBase.getUUID())))
|
this.getEffects().remove(Integer.toString(effectBase.getUUID()));
|
||||||
this.getEffects().remove(Integer.toString(effectBase.getUUID()));
|
|
||||||
|
|
||||||
// Any players currently in the zone will not be processed by the heartbeat
|
// Any players currently in the zone will not be processed by the heartbeat
|
||||||
// so we do it here manually
|
// so we do it here manually
|
||||||
@@ -878,6 +823,7 @@ public class City extends AbstractWorldObject {
|
|||||||
for (Integer playerID : this._playerMemory) {
|
for (Integer playerID : this._playerMemory) {
|
||||||
|
|
||||||
player = PlayerCharacter.getFromCache(playerID);
|
player = PlayerCharacter.getFromCache(playerID);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -893,8 +839,10 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Warehouse getWarehouse() {
|
public Warehouse getWarehouse() {
|
||||||
|
|
||||||
if (this.warehouseBuildingID == 0)
|
if (this.warehouseBuildingID == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return Warehouse.warehouseByBuildingUUID.get(this.warehouseBuildingID);
|
return Warehouse.warehouseByBuildingUUID.get(this.warehouseBuildingID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1066,8 +1014,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
_playerMemory.removeAll(toRemove);
|
_playerMemory.removeAll(toRemove);
|
||||||
for (Integer removalUUID : toRemove) {
|
for (Integer removalUUID : toRemove) {
|
||||||
if (this.cityOutlaws.contains(removalUUID))
|
this.cityOutlaws.remove(removalUUID);
|
||||||
this.cityOutlaws.remove(removalUUID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1168,6 +1115,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
// All protection contracts are void upon transfer of a city
|
// All protection contracts are void upon transfer of a city
|
||||||
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
|
||||||
|
|
||||||
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip()
|
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip()
|
||||||
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
|
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
|
||||||
cityBuilding.setProtectionState(ProtectionState.NONE);
|
cityBuilding.setProtectionState(ProtectionState.NONE);
|
||||||
@@ -1199,7 +1147,6 @@ public class City extends AbstractWorldObject {
|
|||||||
Zone cityZone;
|
Zone cityZone;
|
||||||
sourceGuild = sourcePlayer.getGuild();
|
sourceGuild = sourcePlayer.getGuild();
|
||||||
|
|
||||||
|
|
||||||
if (sourceGuild == null)
|
if (sourceGuild == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1255,14 +1202,6 @@ public class City extends AbstractWorldObject {
|
|||||||
this.forceRename = forceRename;
|
this.forceRename = forceRename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReverseKOS() {
|
|
||||||
return reverseKOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReverseKOS(boolean reverseKOS) {
|
|
||||||
this.reverseKOS = reverseKOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
public String getHash() {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
@@ -1290,26 +1229,6 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO use this for taxing later.
|
|
||||||
// public boolean isAfterTaxPeriod(LocalDateTime dateTime,PlayerCharacter player){
|
|
||||||
// if (dateTime.isBefore(realmTaxDate)){
|
|
||||||
// String wait = "";
|
|
||||||
// float hours = 1000*60*60;
|
|
||||||
// float seconds = 1000;
|
|
||||||
// float hoursUntil = realmTaxDate.minus(dateTime.get).getMillis() /hours;
|
|
||||||
// int secondsUntil = (int) (realmTaxDate.minus(dateTime.getMillis()).getMillis() /seconds);
|
|
||||||
// if (hoursUntil < 1)
|
|
||||||
// wait = "You must wait " + secondsUntil + " seconds before taxing this city again!";
|
|
||||||
// else
|
|
||||||
// wait = "You must wait " + hoursUntil + " hours before taxing this city again!";
|
|
||||||
// ErrorPopupMsg.sendErrorMsg(player, wait);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public synchronized boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) {
|
public synchronized boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) {
|
||||||
|
|
||||||
// Member variable declaration
|
// Member variable declaration
|
||||||
@@ -1322,12 +1241,12 @@ public class City extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
City city = building.getCity();
|
City city = building.getCity();
|
||||||
|
|
||||||
if (city == null) {
|
if (city == null) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (playerGuild == null || playerGuild.isEmptyGuild()) {
|
if (playerGuild == null || playerGuild.isEmptyGuild()) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!");
|
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!");
|
||||||
return true;
|
return true;
|
||||||
@@ -1352,6 +1271,7 @@ public class City extends AbstractWorldObject {
|
|||||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!");
|
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Realm targetRealm = RealmMap.getRealmForCity(city);
|
Realm targetRealm = RealmMap.getRealmForCity(city);
|
||||||
|
|
||||||
if (targetRealm == null) {
|
if (targetRealm == null) {
|
||||||
@@ -1380,31 +1300,32 @@ public class City extends AbstractWorldObject {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.realmTaxDate.isAfter(LocalDateTime.now()))
|
if (this.realmTaxDate.isAfter(LocalDateTime.now()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (msg.getResources().size() == 0)
|
if (msg.getResources().size() == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (city.getWarehouse() == null)
|
if (city.getWarehouse() == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Warehouse ruledWarehouse = playerGuild.getOwnedCity().getWarehouse();
|
Warehouse ruledWarehouse = playerGuild.getOwnedCity().getWarehouse();
|
||||||
|
|
||||||
if (ruledWarehouse == null)
|
if (ruledWarehouse == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
ItemBase.getItemHashIDMap();
|
ItemBase.getItemHashIDMap();
|
||||||
|
|
||||||
ArrayList<Integer> resources = new ArrayList<>();
|
ArrayList<Integer> resources = new ArrayList<>();
|
||||||
|
|
||||||
float taxPercent = msg.getTaxPercent();
|
float taxPercent = msg.getTaxPercent();
|
||||||
|
|
||||||
if (taxPercent > 20)
|
if (taxPercent > 20)
|
||||||
taxPercent = .20f;
|
taxPercent = .20f;
|
||||||
|
|
||||||
for (int resourceHash : msg.getResources().keySet()) {
|
for (int resourceHash : msg.getResources().keySet()) {
|
||||||
if (ItemBase.getItemHashIDMap().get(resourceHash) != null)
|
if (ItemBase.getItemHashIDMap().get(resourceHash) != null)
|
||||||
resources.add(ItemBase.getItemHashIDMap().get(resourceHash));
|
resources.add(ItemBase.getItemHashIDMap().get(resourceHash));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Integer itemBaseID : resources) {
|
for (Integer itemBaseID : resources) {
|
||||||
@@ -1422,6 +1343,7 @@ public class City extends AbstractWorldObject {
|
|||||||
ErrorPopupMsg.sendErrorMsg(player, "Failed to Update next Tax Date due to internal Error. City was not charged taxes this time.");
|
ErrorPopupMsg.sendErrorMsg(player, "Failed to Update next Tax Date due to internal Error. City was not charged taxes this time.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse);
|
city.getWarehouse().transferResources(player, msg, resources, taxPercent, ruledWarehouse);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1439,6 +1361,5 @@ public class City extends AbstractWorldObject {
|
|||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4834,7 +4834,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
} else
|
} else
|
||||||
this.altitude = this.getDesiredAltitude();
|
this.altitude = this.getDesiredAltitude();
|
||||||
|
|
||||||
this.loc = this.loc.setY(HeightMap.getWorldHeight(this) + this.getAltitude());
|
this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||||
|
|
||||||
this.setTakeOffTime(0);
|
this.setTakeOffTime(0);
|
||||||
MovementManager.finishChangeAltitude(this, this.getDesiredAltitude());
|
MovementManager.finishChangeAltitude(this, this.getDesiredAltitude());
|
||||||
@@ -4842,7 +4842,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loc = this.loc.setY(HeightMap.getWorldHeight(this) + this.getAltitude());
|
this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBoon() {
|
public boolean hasBoon() {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class Zone extends AbstractGameObject {
|
|||||||
private boolean isNPCCity = false;
|
private boolean isNPCCity = false;
|
||||||
private boolean isPlayerCity = false;
|
private boolean isPlayerCity = false;
|
||||||
private String hash;
|
private String hash;
|
||||||
private float worldAltitude = 0;
|
public float worldAltitude = 0;
|
||||||
private float seaLevel = 0;
|
private float seaLevel = 0;
|
||||||
//public static ArrayList<Mob> respawnQue = new ArrayList<>();
|
//public static ArrayList<Mob> respawnQue = new ArrayList<>();
|
||||||
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
@@ -220,49 +220,6 @@ public class Zone extends AbstractGameObject {
|
|||||||
return Icon1;
|
return Icon1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateWorldAltitude() {
|
|
||||||
|
|
||||||
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()) {
|
|
||||||
this.worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Zone parentZone = this.parent;
|
|
||||||
|
|
||||||
Zone currentZone = this;
|
|
||||||
float altitude = this.absY;
|
|
||||||
|
|
||||||
//seafloor only zone with null parent;
|
|
||||||
|
|
||||||
while (parentZone != ZoneManager.getSeaFloor()) {
|
|
||||||
|
|
||||||
if (parentZone.getHeightMap() != null) {
|
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone);
|
|
||||||
altitude += parentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
|
||||||
|
|
||||||
}
|
|
||||||
currentZone = parentZone;
|
|
||||||
parentZone = parentZone.parent;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.worldAltitude = altitude;
|
|
||||||
|
|
||||||
if (ZoneManager.getSeaFloor().equals(this))
|
|
||||||
this.seaLevel = 0;
|
|
||||||
else if
|
|
||||||
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0) {
|
|
||||||
this.seaLevel = this.parent.seaLevel;
|
|
||||||
|
|
||||||
} else if (this.getHeightMap() != null) {
|
|
||||||
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
|
|
||||||
} else {
|
|
||||||
this.seaLevel = this.parent.seaLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Zone getParent() {
|
public Zone getParent() {
|
||||||
return this.parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
@@ -272,26 +229,34 @@ public class Zone extends AbstractGameObject {
|
|||||||
this.parent = value;
|
this.parent = value;
|
||||||
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
||||||
|
|
||||||
if (this.parent != null) {
|
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
||||||
this.absX = this.xCoord + parent.absX;
|
|
||||||
this.absY = this.yCoord + parent.absY;
|
|
||||||
this.absZ = this.zCoord + parent.absZ;
|
|
||||||
|
|
||||||
if (this.minLvl == 0 || this.maxLvl == 0) {
|
// Seafloor
|
||||||
this.minLvl = this.parent.minLvl;
|
|
||||||
this.maxLvl = this.parent.maxLvl;
|
if (this.parent == null) {
|
||||||
}
|
|
||||||
} else { //only the Sea Floor zone does not have a parent
|
|
||||||
this.absX = this.xCoord;
|
this.absX = this.xCoord;
|
||||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
this.absZ = this.zCoord;
|
this.absZ = this.zCoord;
|
||||||
|
this.seaLevel = 0;
|
||||||
|
this.setBounds();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.absX = this.xCoord + parent.absX;
|
||||||
|
this.absY = this.yCoord + parent.absY;
|
||||||
|
this.absZ = this.zCoord + parent.absZ;
|
||||||
|
|
||||||
|
if (this.minLvl == 0 || this.maxLvl == 0) {
|
||||||
|
this.minLvl = this.parent.minLvl;
|
||||||
|
this.maxLvl = this.parent.maxLvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
|
||||||
this.setBounds();
|
this.setBounds();
|
||||||
|
|
||||||
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
||||||
this.seaLevel = this.getHeightMap().getSeaLevel();
|
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
|
||||||
|
else
|
||||||
|
this.seaLevel = this.parent.seaLevel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,8 +385,4 @@ public class Zone extends AbstractGameObject {
|
|||||||
return seaLevel;
|
return seaLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getWorldAltitude() {
|
|
||||||
return worldAltitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -566,8 +566,7 @@ public class WorldServer {
|
|||||||
for (Zone zone : rootParent) {
|
for (Zone zone : rootParent) {
|
||||||
|
|
||||||
ZoneManager.addZone(zone.getLoadNum(), zone);
|
ZoneManager.addZone(zone.getLoadNum(), zone);
|
||||||
zone.generateWorldAltitude();
|
zone.worldAltitude = ZoneManager.caclulateWorldAltitude(zone);
|
||||||
|
|
||||||
|
|
||||||
//Handle Buildings
|
//Handle Buildings
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user