diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index f1606434..1ca43c33 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -101,16 +101,6 @@ public enum ZoneManager { return zone; } - public static void addZone(final int zoneID, final Zone zone) { - - ZoneManager.zonesByID.put(zoneID, zone); - - ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); - - ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone); - - } - // Returns the number of available hotZones // remaining in this cycle (1am) @@ -173,24 +163,23 @@ public enum ZoneManager { return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); } - public static void setSeaFloor(final Zone value) { - ZoneManager.seaFloor = value; - } - - public static void populateWorldZones(final Zone zone) { - - int loadNum = zone.template; + public static void populateZoneCollections(final Zone zone) { // Zones are added to separate // collections for quick access // based upon their type. + ZoneManager.zonesByID.put(zone.template, zone); + + ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); + + ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone); + if (zone.isMacroZone()) { addMacroZone(zone); return; } - if (zone.guild_zone) { addPlayerCityZone(zone); return; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 0d6e0bc8..1f40da87 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -788,7 +788,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (zoneObject.parent != null) zoneObject.parent.addNode(zoneObject); //add as child to parent - ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject); ZoneManager.addPlayerCityZone(zoneObject); serverZone.addNode(zoneObject); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index a63ac369..9b5e62ea 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -94,42 +94,26 @@ public class Zone extends AbstractWorldObject { this.icon3 = rs.getString("icon3"); this.min_level = rs.getInt("min_level"); this.max_level = rs.getInt("max_level"); - this.major_radius = rs.getFloat("major_radius"); - this.minor_radius = rs.getFloat("minor_radius"); - this.min_blend = rs.getFloat("min_blend"); - this.max_blend = rs.getFloat("max_blend"); - this.sea_level_type = rs.getString("sea_level_type"); - this.sea_level_offset = rs.getFloat("sea_level"); - this.terrain_type = rs.getString("terrain_type"); - this.terrain_max_y = rs.getFloat("terrain_max_y"); - this.terrain_image = rs.getInt("terrain_image"); - - if (this.guild_zone) { - this.max_blend = 128; - this.min_blend = 128; - this.terrain_max_y = 5; - this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "PLANAR"; - } - - if (this.terrain_type.equals("NONE")) - this.terrain = null; - else - this.terrain = new Terrain(this); - - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) - - Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); - this.setParent(parentZone); - - if (this.min_level == 0 && parentZone != null) { - this.min_level = parentZone.min_level; - this.max_level = parentZone.max_level; - } - - if (parentZone != null) - parentZone.addNode(this); + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); + this.min_blend = rs.getFloat("min_blend"); + this.max_blend = rs.getFloat("max_blend"); + this.sea_level_type = rs.getString("sea_level_type"); + this.sea_level_offset = rs.getFloat("sea_level"); + this.terrain_type = rs.getString("terrain_type"); + this.terrain_max_y = rs.getFloat("terrain_max_y"); + this.terrain_image = rs.getInt("terrain_image"); + + // Configuration for player cities + + if (this.guild_zone) { + this.max_blend = 128; + this.min_blend = 128; + this.terrain_max_y = 5; + this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.terrain_type = "PLANAR"; + } // If zone doesn't yet hava a hash then write it back to the zone table @@ -141,6 +125,31 @@ public class Zone extends AbstractWorldObject { @Override public void runAfterLoad() { + // First zone is always the seafloor + + if (ZoneManager.seaFloor == null) + ZoneManager.seaFloor = this; + + if (this.terrain_type.equals("NONE")) + this.terrain = null; + else + this.terrain = new Terrain(this); + + //this needs to be here specifically for new zones created after server boot (e.g. player city zones) + + Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); + this.setParent(parentZone); + + if (this.min_level == 0 && parentZone != null) { + this.min_level = parentZone.min_level; + this.max_level = parentZone.max_level; + } + + if (parentZone != null) + parentZone.addNode(this); + + ZoneManager.populateZoneCollections(this); + } public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e77430e3..853ac58b 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -533,32 +533,9 @@ public class WorldServer { private void getWorldBuildingsMobsNPCs() { - ArrayList rootParent; - - rootParent = DbManager.ZoneQueries.GET_MAP_NODES(worldUUID); - - if (rootParent.isEmpty()) { - Logger.error("populateWorldBuildings: No entries found in worldMap for parent " + worldUUID); - return; - } - - //Set sea floor object for server - - Zone seaFloor = rootParent.get(0); - seaFloor.setParent(null); - ZoneManager.setSeaFloor(seaFloor); - - rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor)); - long start = System.currentTimeMillis(); - for (Zone zone : rootParent) { - - ZoneManager.addZone(zone.template, zone); - ZoneManager.populateWorldZones(zone); - - } - + DbManager.ZoneQueries.GET_ALL_ZONES(); DbManager.BuildingQueries.GET_ALL_BUILDINGS(); DbManager.NPCQueries.GET_ALL_NPCS(); DbManager.MobQueries.GET_ALL_MOBS();