Browse Source

Completed partial refactor.

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
df54840a88
  1. 6
      src/engine/InterestManagement/Terrain.java
  2. 43
      src/engine/db/handlers/dbHeightMapHandler.java
  3. 3
      src/engine/devcmd/cmds/GetHeightCmd.java
  4. 9
      src/engine/devcmd/cmds/ZoneInfoCmd.java
  5. 1
      src/engine/gameManager/DbManager.java
  6. 37
      src/engine/objects/Zone.java

6
src/engine/InterestManagement/Terrain.java

@ -41,13 +41,13 @@ public class Terrain { @@ -41,13 +41,13 @@ public class Terrain {
Zone terrain_zone = zone;
if (zone.getHeightMap() != null)
if (zone.terrain != null)
return zone;
if (zone.equals(ZoneManager.getSeaFloor()))
return zone;
while (terrain_zone.getHeightMap() == null)
while (terrain_zone.terrain == null)
terrain_zone = terrain_zone.parent;
return terrain_zone;
@ -74,7 +74,7 @@ public class Terrain { @@ -74,7 +74,7 @@ public class Terrain {
// Interpolate height for this position using pixel array.
float interpolatedTerrainHeight = terrainZone.getHeightMap().getInterpolatedTerrainHeight(terrainLoc);
float interpolatedTerrainHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc);
interpolatedTerrainHeight += terrainZone.worldAltitude;
return interpolatedTerrainHeight;

43
src/engine/db/handlers/dbHeightMapHandler.java

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
package engine.db.handlers;
import engine.InterestManagement.Terrain;
import engine.gameManager.DbManager;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class dbHeightMapHandler extends dbHandlerBase {
public dbHeightMapHandler() {
}
public void LOAD_ALL_HEIGHTMAPS() {
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")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
thisHeightmap = new Terrain(rs);
if (thisHeightmap.heightmapImage == null) {
Logger.info("Imagemap for " + thisHeightmap.heightMapID + " was null");
continue;
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
}

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

@ -39,7 +39,8 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -39,7 +39,8 @@ public class GetHeightCmd extends AbstractDevCmd {
float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc());
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone);
Vector2f gridSquare = heightmapZone.getHeightMap().getTerrainCell(zoneLoc);
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc);
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);

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

@ -90,14 +90,11 @@ public class ZoneInfoCmd extends AbstractDevCmd { @@ -90,14 +90,11 @@ public class ZoneInfoCmd extends AbstractDevCmd {
output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
output += newline;
if (zone.getHeightMap() != null) {
output += "HeightMap ID: " + zone.getHeightMap().heightMapID;
if (zone.terrain != null) {
output += "Terrain image: " + zone.terrain_image;
output += newline;
output += "Bucket Width X : " + zone.getHeightMap().cell_size_x;
output += newline;
output += "Bucket Width Y : " + zone.getHeightMap().cell_size_y;
}
output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
output += newline;
// output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl();

1
src/engine/gameManager/DbManager.java

@ -70,7 +70,6 @@ public enum DbManager { @@ -70,7 +70,6 @@ public enum DbManager {
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler();
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
public static final dbPowerHandler PowerQueries = new dbPowerHandler();

37
src/engine/objects/Zone.java

@ -58,6 +58,7 @@ public class Zone extends AbstractGameObject { @@ -58,6 +58,7 @@ public class Zone extends AbstractGameObject {
public String hash;
public float worldAltitude = 0;
public float seaLevel = 0f;
public float sea_level_offset = 0;
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
public static long lastRespawn = 0;
public float major_radius;
@ -224,21 +225,29 @@ public class Zone extends AbstractGameObject { @@ -224,21 +225,29 @@ public class Zone extends AbstractGameObject {
this.setBounds();
this.worldAltitude = ZoneManager.caclulateWorldAltitude(this);
setSeaLevel();
}
private void setSeaLevel() {
int world_sea_level = 0;
if (this.parent == null) {
this.seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE;
this.sea_level = world_sea_level;
return;
}
if (this.getHeightMap() == null) {
this.seaLevel = this.parent.seaLevel;
return;
switch (this.sea_level_type) {
case "WORLD":
this.sea_level = world_sea_level + this.sea_level_offset;
break;
case "PARENT":
this.sea_level = this.parent.sea_level + this.sea_level_offset;
break;
case "SELF":
this.sea_level = this.worldAltitude + this.sea_level_offset;
break;
}
if (this.getHeightMap().seaLevel != 0)
this.seaLevel = this.worldAltitude + this.getHeightMap().seaLevel;
else
this.seaLevel = this.parent.seaLevel;
}
public boolean isMacroZone() {
@ -315,12 +324,4 @@ public class Zone extends AbstractGameObject { @@ -315,12 +324,4 @@ public class Zone extends AbstractGameObject {
// Return heightmap for this Zone.
public Terrain getHeightMap() {
if (this.guild_zone)
return Terrain.playerCityTerrain;
return Terrain.heightmapByLoadNum.get(this.template);
}
}

Loading…
Cancel
Save