forked from MagicBane/Server
rework of world altitude calculation.
This commit is contained in:
@@ -232,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;
|
||||||
|
|
||||||
@@ -272,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) {
|
||||||
@@ -291,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone);
|
heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone);
|
||||||
parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());
|
parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());
|
||||||
|
|
||||||
// Any argument rebuilds altitude
|
|
||||||
|
|
||||||
if (words[0].isEmpty() == false)
|
|
||||||
currentZone.generateWorldAltitude();
|
|
||||||
|
|
||||||
float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
|
float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc());
|
float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc());
|
||||||
|
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
@@ -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,23 @@ public enum ZoneManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float caclulateWorldAltitude(Zone zone) {
|
||||||
|
|
||||||
|
float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
|
|
||||||
|
if (getSeaFloor().getObjectUUID() == zone.getObjectUUID()) {
|
||||||
|
return worldAlttitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zone parentZone = zone.getParent();
|
||||||
|
|
||||||
|
if (getSeaFloor().getObjectUUID() == parentZone.getObjectUUID()) {
|
||||||
|
return worldAlttitude + zone.getYCoord();
|
||||||
|
}
|
||||||
|
|
||||||
|
worldAlttitude = HeightMap.getWorldHeight(parentZone, zone.getLoc());
|
||||||
|
|
||||||
|
return worldAlttitude;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -792,10 +792,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);
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -420,8 +377,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