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

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

@ -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 {
float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc());
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); 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, "Current Zone : " + currentZone.zoneName);
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);

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

@ -90,14 +90,11 @@ public class ZoneInfoCmd extends AbstractDevCmd {
output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
output += newline; output += newline;
if (zone.getHeightMap() != null) { if (zone.terrain != null) {
output += "HeightMap ID: " + zone.getHeightMap().heightMapID; output += "Terrain image: " + zone.terrain_image;
output += newline; 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 += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y;
output += newline; output += newline;
// output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl(); // output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl();

1
src/engine/gameManager/DbManager.java

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

37
src/engine/objects/Zone.java

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

Loading…
Cancel
Save