Browse Source

rework of world altitude calculation.

feature-workorder
MagicBot 1 year ago
parent
commit
045ee73b61
  1. 6
      src/engine/InterestManagement/HeightMap.java
  2. 5
      src/engine/devcmd/cmds/GetHeightCmd.java
  3. 2
      src/engine/devcmd/cmds/ZoneInfoCmd.java
  4. 20
      src/engine/gameManager/ZoneManager.java
  5. 3
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  6. 49
      src/engine/objects/Zone.java
  7. 3
      src/engine/server/world/WorldServer.java

6
src/engine/InterestManagement/HeightMap.java

@ -232,7 +232,7 @@ public class HeightMap { @@ -232,7 +232,7 @@ public class HeightMap {
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
float worldAltitude = currentZone.getWorldAltitude();
float worldAltitude = currentZone.worldAltitude;
float realWorldAltitude = interaltitude + worldAltitude;
@ -272,7 +272,7 @@ public class HeightMap { @@ -272,7 +272,7 @@ public class HeightMap {
float secondScale = parentCenterAltitude * scaleChild;
float outsetALt = firstScale + secondScale;
outsetALt += currentZone.getParent().getWorldAltitude();
outsetALt += currentZone.getParent().worldAltitude;
realWorldAltitude = outsetALt;
} else if (offsetZ > outsideGridSizeZ) {
@ -291,7 +291,7 @@ public class HeightMap { @@ -291,7 +291,7 @@ public class HeightMap {
float secondScale = parentCenterAltitude * scaleChild;
float outsetALt = firstScale + secondScale;
outsetALt += currentZone.getParent().getWorldAltitude();
outsetALt += currentZone.getParent().worldAltitude;
realWorldAltitude = outsetALt;
}
}

5
src/engine/devcmd/cmds/GetHeightCmd.java

@ -36,11 +36,6 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -36,11 +36,6 @@ public class GetHeightCmd extends AbstractDevCmd {
heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone);
parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());
// Any argument rebuilds altitude
if (words[0].isEmpty() == false)
currentZone.generateWorldAltitude();
float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc());
float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc());

2
src/engine/devcmd/cmds/ZoneInfoCmd.java

@ -104,7 +104,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { @@ -104,7 +104,7 @@ public class ZoneInfoCmd extends AbstractDevCmd {
output += newline;
output += "Sea Level = " + zone.getSeaLevel();
output += newline;
output += "World Altitude = " + zone.getWorldAltitude();
output += "World Altitude = " + zone.worldAltitude;
throwbackInfo(player, output);
City city = ZoneManager.getCityAtLocation(player.getLoc());

20
src/engine/gameManager/ZoneManager.java

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
package engine.gameManager;
import engine.Enum;
import engine.InterestManagement.HeightMap;
import engine.db.archive.CityRecord;
import engine.db.archive.DataWarehouse;
import engine.math.Bounds;
@ -453,4 +454,23 @@ public enum ZoneManager { @@ -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;
}
}

3
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -792,10 +792,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { @@ -792,10 +792,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
ZoneManager.addPlayerCityZone(zoneObject);
serverZone.addNode(zoneObject);
zoneObject.generateWorldAltitude();
zoneObject.worldAltitude = ZoneManager.caclulateWorldAltitude(zoneObject);
cityObject.setParent(zoneObject);
cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already
//Link the tree of life with the new zone
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);

49
src/engine/objects/Zone.java

@ -56,7 +56,7 @@ public class Zone extends AbstractGameObject { @@ -56,7 +56,7 @@ public class Zone extends AbstractGameObject {
private boolean isNPCCity = false;
private boolean isPlayerCity = false;
private String hash;
private float worldAltitude = 0;
public float worldAltitude = 0;
private float seaLevel = 0;
//public static ArrayList<Mob> respawnQue = new ArrayList<>();
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
@ -220,49 +220,6 @@ public class Zone extends AbstractGameObject { @@ -220,49 +220,6 @@ public class Zone extends AbstractGameObject {
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() {
return this.parent;
}
@ -420,8 +377,4 @@ public class Zone extends AbstractGameObject { @@ -420,8 +377,4 @@ public class Zone extends AbstractGameObject {
return seaLevel;
}
public float getWorldAltitude() {
return worldAltitude;
}
}

3
src/engine/server/world/WorldServer.java

@ -566,8 +566,7 @@ public class WorldServer { @@ -566,8 +566,7 @@ public class WorldServer {
for (Zone zone : rootParent) {
ZoneManager.addZone(zone.getLoadNum(), zone);
zone.generateWorldAltitude();
zone.worldAltitude = ZoneManager.caclulateWorldAltitude(zone);
//Handle Buildings

Loading…
Cancel
Save