diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/Terrain.java similarity index 90% rename from src/engine/InterestManagement/HeightMap.java rename to src/engine/InterestManagement/Terrain.java index a9e3cfb7..c374839d 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/Terrain.java @@ -30,17 +30,17 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.stream.Stream; -public class HeightMap { +public class Terrain { // Class variables - public static final HashMap heightmapByLoadNum = new HashMap<>(); + public static final HashMap heightmapByLoadNum = new HashMap<>(); public static final HashMap _pixelData = new HashMap<>(); // Bootstrap Tracking public static int heightMapsCreated = 0; - public static HeightMap PlayerCityHeightMap; + public static Terrain playerCityTerrain; // Heightmap data for this heightmap public final int heightMapID; @@ -60,7 +60,7 @@ public class HeightMap { public float terrain_scale; - public HeightMap(ResultSet rs) throws SQLException { + public Terrain(ResultSet rs) throws SQLException { this.heightMapID = rs.getInt("heightMapID"); this.maxHeight = rs.getInt("maxHeight"); @@ -107,13 +107,13 @@ public class HeightMap { generatePixelData(this); - HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this); + Terrain.heightmapByLoadNum.put(this.zoneLoadID, this); heightMapsCreated++; } //Created for PlayerCities - public HeightMap() { + public Terrain() { this.heightMapID = 999999; this.maxHeight = 5; // for real... @@ -149,7 +149,7 @@ public class HeightMap { this.terrain_scale = this.maxHeight / 255f; } - public HeightMap(Zone zone) { + public Terrain(Zone zone) { this.heightMapID = 999999; this.maxHeight = 0; @@ -185,15 +185,15 @@ public class HeightMap { public static void GeneratePlayerCityHeightMap() { - HeightMap.PlayerCityHeightMap = new HeightMap(); + Terrain.playerCityTerrain = new Terrain(); } public static void GenerateCustomHeightMap(Zone zone) { - HeightMap heightMap = new HeightMap(zone); + Terrain heightMap = new Terrain(zone); - HeightMap.heightmapByLoadNum.put(zone.template, heightMap); + Terrain.heightmapByLoadNum.put(zone.template, heightMap); } @@ -260,9 +260,9 @@ public class HeightMap { //generate static player city heightmap. - HeightMap.GeneratePlayerCityHeightMap(); + Terrain.GeneratePlayerCityHeightMap(); - Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); + Logger.info(Terrain.heightmapByLoadNum.size() + " Heightmaps cached."); // Load pixel data for heightmaps @@ -305,19 +305,19 @@ public class HeightMap { } - private static void generatePixelData(HeightMap heightMap) { + private static void generatePixelData(Terrain terrain) { Color color; // Generate altitude lookup table for this heightmap - heightMap.pixelColorValues = new short[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; + terrain.pixelColorValues = new short[terrain.heightmapImage.getWidth()][terrain.heightmapImage.getHeight()]; - for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { - for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { + for (int y = 0; y < terrain.heightmapImage.getHeight(); y++) { + for (int x = 0; x < terrain.heightmapImage.getWidth(); x++) { - color = new Color(heightMap.heightmapImage.getRGB(x, y)); - heightMap.pixelColorValues[x][y] = (short) color.getRed(); + color = new Color(terrain.heightmapImage.getRGB(x, y)); + terrain.pixelColorValues[x][y] = (short) color.getRed(); } } diff --git a/src/engine/db/handlers/dbHeightMapHandler.java b/src/engine/db/handlers/dbHeightMapHandler.java index 514008de..87cb9428 100644 --- a/src/engine/db/handlers/dbHeightMapHandler.java +++ b/src/engine/db/handlers/dbHeightMapHandler.java @@ -1,6 +1,6 @@ package engine.db.handlers; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.gameManager.DbManager; import org.pmw.tinylog.Logger; @@ -18,8 +18,8 @@ public class dbHeightMapHandler extends dbHandlerBase { public void LOAD_ALL_HEIGHTMAPS() { - HeightMap thisHeightmap; - HeightMap.heightMapsCreated = 0; + Terrain thisHeightmap; + Terrain.heightMapsCreated = 0; try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_heightmap INNER JOIN static_zone_size ON static_zone_size.loadNum = static_zone_heightmap.zoneLoadID")) { @@ -27,7 +27,7 @@ public class dbHeightMapHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - thisHeightmap = new HeightMap(rs); + thisHeightmap = new Terrain(rs); if (thisHeightmap.heightmapImage == null) { Logger.info("Imagemap for " + thisHeightmap.heightMapID + " was null"); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 96983f98..642c9533 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -9,7 +9,7 @@ package engine.devcmd.cmds; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ZoneManager; import engine.math.Bounds; @@ -33,11 +33,11 @@ public class GetHeightCmd extends AbstractDevCmd { Zone heightmapZone; currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone); - parentZone = HeightMap.getNextZoneWithTerrain(currentZone.parent); + heightmapZone = Terrain.getNextZoneWithTerrain(currentZone); + parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent); - float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); - float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc()); + float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); + float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.getHeightMap().getTerrainCell(zoneLoc); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 573207f7..1875a898 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -9,7 +9,7 @@ package engine.gameManager; import engine.Enum.*; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.handlers.dbEffectsBaseHandler; import engine.db.handlers.dbPowerHandler; @@ -1772,7 +1772,7 @@ public enum PowersManager { } else { targetLoc = tl; try { - targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground + targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground } catch (Exception e) { Logger.error(e); targetLoc = tl; @@ -1974,7 +1974,7 @@ public enum PowersManager { } else { targetLoc = tl; try { - targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground + targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 0c6c4a1f..25b3e2b7 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -9,7 +9,7 @@ package engine.gameManager; import engine.Enum; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; import engine.math.Bounds; @@ -468,7 +468,7 @@ public enum ZoneManager { // return height from heightmap engine at zone location - worldAlttitude = HeightMap.getWorldHeight(zone.parent, zone.getLoc()); + worldAlttitude = Terrain.getWorldHeight(zone.parent, zone.getLoc()); // Add zone offset to value @@ -479,7 +479,7 @@ public enum ZoneManager { public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { - float localAltitude = HeightMap.getWorldHeight(currentLoc); + float localAltitude = Terrain.getWorldHeight(currentLoc); Zone zone = findSmallestZone(currentLoc); return localAltitude < zone.seaLevel; diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index c87438e4..7834b0cb 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -11,7 +11,6 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index cb647707..0bf5939a 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -13,7 +13,7 @@ import engine.Enum.DispatchChannel; import engine.Enum.EffectSourceType; import engine.Enum.GameObjectType; import engine.Enum.GridObjectType; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.job.AbstractScheduleJob; import engine.job.JobContainer; @@ -506,7 +506,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { if(this instanceof AbstractCharacter && this.region != null){ this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude()); } else{ - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 442d3513..4d43e1ab 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -11,8 +11,8 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; @@ -206,7 +206,7 @@ public class Building extends AbstractWorldObject { // Altitude of this building is derived from the heightmap engine. Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); - tempLoc = new Vector3fImmutable(tempLoc.x, HeightMap.getWorldHeight(tempLoc), tempLoc.z); + tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); this.setLoc(tempLoc); } } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index d1820480..10f0204f 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -11,8 +11,8 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; @@ -588,7 +588,7 @@ public class City extends AbstractWorldObject { this.setBounds(cityBounds); if (zone.getHeightMap() == null && this.isNpc == 1 && this.getObjectUUID() != 1213) { - HeightMap.GenerateCustomHeightMap(zone); + Terrain.GenerateCustomHeightMap(zone); Logger.info(zone.zoneName + " created custom heightmap"); } } catch (Exception e) { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index a1381bb8..a063df6f 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -11,9 +11,9 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CharacterRecord; import engine.db.archive.DataWarehouse; @@ -4760,7 +4760,7 @@ public class PlayerCharacter extends AbstractCharacter { // If char is flying they aren't quite swimming try { - float localAltitude = HeightMap.getWorldHeight(currentLoc); + float localAltitude = Terrain.getWorldHeight(currentLoc); Zone zone = ZoneManager.findSmallestZone(currentLoc); @@ -4832,7 +4832,7 @@ public class PlayerCharacter extends AbstractCharacter { } else this.altitude = this.getDesiredAltitude(); - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); this.setTakeOffTime(0); MovementManager.finishChangeAltitude(this, this.getDesiredAltitude()); @@ -4840,7 +4840,7 @@ public class PlayerCharacter extends AbstractCharacter { return; } - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } public boolean hasBoon() { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index f2a7f4ee..a951daea 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -10,7 +10,7 @@ package engine.objects; import engine.Enum; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.db.archive.DataWarehouse; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; @@ -193,15 +193,15 @@ public class Zone extends AbstractGameObject { else bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); - HeightMap heightMap = this.getHeightMap(); + Terrain terrain = this.getHeightMap(); // Set heightmap blending bounds - if (heightMap == null) { + if (terrain == null) { this.blendBounds = bounds; } else { this.blendBounds = Bounds.borrow(); - this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(terrain.zone_minBlend, terrain.zone_minBlend), 0.0f); } } @@ -325,12 +325,12 @@ public class Zone extends AbstractGameObject { // Return heightmap for this Zone. - public HeightMap getHeightMap() { + public Terrain getHeightMap() { if (this.guild_zone) - return HeightMap.PlayerCityHeightMap; + return Terrain.playerCityTerrain; - return HeightMap.heightmapByLoadNum.get(this.template); + return Terrain.heightmapByLoadNum.get(this.template); } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 9f070596..595d91c8 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -13,8 +13,8 @@ import engine.Enum; import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; import engine.db.handlers.dbRuneBaseHandler; @@ -385,7 +385,7 @@ public class WorldServer { Blueprint.loadAllBlueprints(); Logger.info("Initializing Heightmap data"); - HeightMap.loadAlHeightMaps(); + Terrain.loadAlHeightMaps(); Logger.info("Loading Race data"); Enum.RaceType.initRaceTypeTables();