Build zone templates from CZONE instead of static_zone_templates
ZoneManager._zone_templates now holds the parser's CZoneTemplate: every CZONE template plus the player-city template 0, still built in code. Zone and Terrain read the mbEnums sea level and terrain types instead of strings. The static_zone_templates loader goes with the old map type; the table stays until Task 4.2. Parity: all 861 templates, every column the server read (type, name, peace, radii, blends, sea level and type, water, terrain gen, type, max_y, image) identical to the JSON. Value changes: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac1fcaecf5
commit
4299b27422
6 files changed
+48
-60
No files matched your search
@@ -11,6 +11,7 @@ package engine.InterestManagement;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mbEnums;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class Terrain {
|
||||
// Configure PLANAR zones to use the same 16x16 pixel image
|
||||
// that all similar terrains share. (See JSON)
|
||||
|
||||
if (this.zone.template.terrain_type.equals("PLANAR"))
|
||||
if (this.zone.template.terrain_type == mbEnums.TerrainGenType.PLANAR)
|
||||
this.heightmap = 1006300; // all 0
|
||||
|
||||
// Load pixel data for this terrain from cache
|
||||
@@ -71,8 +72,8 @@ public class Terrain {
|
||||
// the blending area between child and parent terrains when
|
||||
// they are stitched together.
|
||||
|
||||
this.blend_values.x = this.zone.template.max_blend;
|
||||
this.blend_values.y = this.zone.template.min_blend;
|
||||
this.blend_values.x = this.zone.template.zone_max_blend;
|
||||
this.blend_values.y = this.zone.template.zone_min_blend;
|
||||
|
||||
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
|
||||
this.blend_values.y / this.zone.major_radius);
|
||||
@@ -217,8 +218,8 @@ public class Terrain {
|
||||
|
||||
// Normalize terrain offset
|
||||
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.major_radius,
|
||||
Math.abs(zone_offset.y) / this.zone.template.minor_radius);
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.zone_major_radius,
|
||||
Math.abs(zone_offset.y) / this.zone.template.zone_minor_radius);
|
||||
|
||||
float blendCoefficient;
|
||||
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.mbEnums;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.ZoneTemplate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -68,40 +66,6 @@ public class dbZoneHandler extends dbHandlerBase {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void LOAD_ALL_ZONE_TEMPLATES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_templates")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
ZoneTemplate zoneTemplate = new ZoneTemplate(rs);
|
||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
||||
}
|
||||
|
||||
// Add player city
|
||||
|
||||
ZoneTemplate zoneTemplate = new ZoneTemplate();
|
||||
|
||||
zoneTemplate.templateID = 0;
|
||||
zoneTemplate.sea_level_type = "PARENT";
|
||||
zoneTemplate.sea_level = 0;
|
||||
zoneTemplate.max_blend = 128;
|
||||
zoneTemplate.min_blend = 128;
|
||||
zoneTemplate.terrain_max_y = 5;
|
||||
zoneTemplate.major_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
zoneTemplate.minor_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
zoneTemplate.terrain_type = "PLANAR";
|
||||
|
||||
ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean DELETE_ZONE(final Zone zone) {
|
||||
|
||||
if (DbManager.refuseStaticWrite(zone))
|
||||
|
||||
@@ -37,8 +37,8 @@ public class GetHeightCmd extends AbstractDevCmd {
|
||||
|
||||
Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
|
||||
Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.major_radius,
|
||||
Math.abs(childZoneOffset.y) / heightmapZone.template.minor_radius);
|
||||
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.zone_major_radius,
|
||||
Math.abs(childZoneOffset.y) / heightmapZone.template.zone_minor_radius);
|
||||
Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone);
|
||||
|
||||
float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc);
|
||||
@@ -74,7 +74,7 @@ public class GetHeightCmd extends AbstractDevCmd {
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
|
||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.zone_max_blend + " /" + heightmapZone.template.zone_min_blend);
|
||||
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import engine.mbEnums;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Zone;
|
||||
import engine.objects.ZoneTemplate;
|
||||
import engine.parsers.objects.CZoneTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum ZoneManager {
|
||||
|
||||
ZONEMANAGER;
|
||||
|
||||
public static HashMap<Integer, ZoneTemplate> _zone_templates = new HashMap<>();
|
||||
public static HashMap<Integer, CZoneTemplate> _zone_templates = new HashMap<>();
|
||||
|
||||
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||
@@ -51,6 +51,29 @@ public enum ZoneManager {
|
||||
/* Instance variables */
|
||||
public static Zone seaFloor = null;
|
||||
|
||||
// CZONE templates plus the server's player-city template 0, which has no CZONE file
|
||||
|
||||
public static void loadZoneTemplates() {
|
||||
|
||||
CZoneTemplate playerCityTemplate = new CZoneTemplate();
|
||||
|
||||
_zone_templates.putAll(CZoneTemplate._zones);
|
||||
|
||||
playerCityTemplate.template_id = 0;
|
||||
playerCityTemplate.zone_sea_level_type = mbEnums.SeaLevelType.PARENT;
|
||||
playerCityTemplate.zone_sea_level = 0;
|
||||
playerCityTemplate.zone_max_blend = 128;
|
||||
playerCityTemplate.zone_min_blend = 128;
|
||||
playerCityTemplate.terrain_max_y = 5;
|
||||
playerCityTemplate.zone_major_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
playerCityTemplate.zone_minor_radius = (int) mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
playerCityTemplate.terrain_type = mbEnums.TerrainGenType.PLANAR;
|
||||
|
||||
_zone_templates.put(playerCityTemplate.template_id, playerCityTemplate);
|
||||
|
||||
Logger.info("Zone templates: " + _zone_templates.size());
|
||||
}
|
||||
|
||||
// Find all zones coordinates fit into, starting with Sea Floor
|
||||
|
||||
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mbEnums;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.parsers.objects.CZoneTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class Zone extends AbstractWorldObject {
|
||||
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
||||
public ZoneTemplate template;
|
||||
public CZoneTemplate template;
|
||||
|
||||
public final int playerCityUUID;
|
||||
public final String zoneName;
|
||||
@@ -168,14 +169,14 @@ public class Zone extends AbstractWorldObject {
|
||||
this.minor_radius = mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
this.major_radius = mbEnums.CityBoundsType.ZONE.halfExtents;
|
||||
} else {
|
||||
this.minor_radius = this.template.minor_radius;
|
||||
this.major_radius = this.template.major_radius;
|
||||
this.minor_radius = this.template.zone_minor_radius;
|
||||
this.major_radius = this.template.zone_major_radius;
|
||||
}
|
||||
|
||||
this.setParent();
|
||||
this.setBounds();
|
||||
|
||||
if (this.template.terrain_type.equals("NONE"))
|
||||
if (this.template.terrain_type == mbEnums.TerrainGenType.NONE)
|
||||
this.terrain = null;
|
||||
else
|
||||
this.terrain = new Terrain(this);
|
||||
@@ -244,15 +245,15 @@ public class Zone extends AbstractWorldObject {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.template.sea_level_type) {
|
||||
case "WORLD":
|
||||
this.sea_level = world_sea_level + this.template.sea_level;
|
||||
switch (this.template.zone_sea_level_type) {
|
||||
case WORLD:
|
||||
this.sea_level = world_sea_level + this.template.zone_sea_level;
|
||||
break;
|
||||
case "PARENT":
|
||||
this.sea_level = this.parent.sea_level + this.template.sea_level;
|
||||
case PARENT:
|
||||
this.sea_level = this.parent.sea_level + this.template.zone_sea_level;
|
||||
break;
|
||||
case "SELF":
|
||||
this.sea_level = this.global_height + this.template.sea_level;
|
||||
case SELF:
|
||||
this.sea_level = this.global_height + this.template.zone_sea_level;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,9 +298,6 @@ public class WorldServer {
|
||||
Logger.info("Initializing Errant Guild");
|
||||
Guild.getErrantGuild();
|
||||
|
||||
Logger.info("Loading zone template data");
|
||||
DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES();
|
||||
|
||||
Logger.info("Loading Compound Curves");
|
||||
CompoundCurveTemplate._curves = CompoundCurveParser.parseCompoundCurvesFile();
|
||||
|
||||
@@ -440,6 +437,8 @@ public class WorldServer {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ZoneManager.loadZoneTemplates();
|
||||
|
||||
Logger.info("Loading Rune Power Requirements");
|
||||
PowerReq.loadRunePowers();
|
||||
|
||||
|
||||
Reference in new issue
Block a user