From 5ed21f9b7639248014ba9f2e7031ba15ffccaffd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:33:49 -0400 Subject: [PATCH] Refactored Zone to new system --- src/engine/db/handlers/dbZoneHandler.java | 4 ++-- src/engine/devcmd/cmds/ZoneInfoCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 6 +++--- src/engine/net/client/msg/WorldDataMsg.java | 13 +++++-------- src/engine/objects/Zone.java | 18 ++---------------- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 66b68e69..1540196a 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -46,7 +46,7 @@ public class dbZoneHandler extends dbHandlerBase { public ArrayList GET_ALL_NODES(Zone zone) { ArrayList wsmList = new ArrayList<>(); - wsmList.addAll(zone.getNodes()); + wsmList.addAll(zone.nodes); if (zone.absX == 0.0f) { zone.absX = zone.xOffset; } @@ -56,7 +56,7 @@ public class dbZoneHandler extends dbHandlerBase { if (zone.absZ == 0.0f) { zone.absZ = zone.zOffset; } - for (Zone child : zone.getNodes()) { + for (Zone child : zone.nodes) { child.absX = child.xOffset + zone.absX; child.absY = child.yOffset + zone.absY; child.absZ = child.zOffset + zone.absZ; diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 53e7ac61..05b80230 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -120,7 +120,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { } else { output = "children:"; - ArrayList nodes = zone.getNodes(); + ArrayList nodes = zone.nodes; if (nodes.isEmpty()) output += " none"; diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 1ca43c33..f987c4d1 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -85,7 +85,7 @@ public enum ZoneManager { childFound = false; - ArrayList nodes = zone.getNodes(); + ArrayList nodes = zone.nodes; // Logger.info("soze", "" + nodes.size()); if (nodes != null) @@ -239,7 +239,7 @@ public enum ZoneManager { if (zone.peace_zone == (byte) 1) return false; // no safe zone hotzones// if (this.hotzone == null) - if (zone.getNodes().isEmpty()) + if (zone.nodes.isEmpty()) return false; if (zone.equals(ZoneManager.seaFloor)) @@ -396,7 +396,7 @@ public enum ZoneManager { treeBounds = Bounds.borrow(); treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f); - zoneList = currentZone.getNodes(); + zoneList = currentZone.nodes; for (Zone zone : zoneList) { diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index d18178e7..b24c1cf3 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -10,8 +10,10 @@ package engine.net.client.msg; +import engine.Enum; import engine.exception.SerializationException; import engine.gameManager.ConfigManager; +import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.net.AbstractConnection; import engine.net.AbstractNetMsg; @@ -44,14 +46,9 @@ public class WorldDataMsg extends ClientNetMsg { super(Protocol.NEWWORLD, origin, reader); } - private static int getTotalMapSize(Zone root) { - if (root.getNodes().isEmpty()) - return 0; + private static int getTotalMapSize() { - int size = root.getNodes().size(); - for (Zone child : root.getNodes()) - size += getTotalMapSize(child); - return size; + return DbManager.getList(Enum.GameObjectType.Zone).size(); } /** @@ -86,7 +83,7 @@ public class WorldDataMsg extends ClientNetMsg { writer.putInt(WorldServer.worldMapID); writer.putInt(0x00000000); - writer.putInt(getTotalMapSize(root) + 1); + writer.putInt(getTotalMapSize() + 1); Zone.serializeForClientMsg(root, writer); Zone hotzone = ZoneManager.hotZone; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 9b5e62ea..07cd5730 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -12,7 +12,6 @@ package engine.objects; import engine.Enum; import engine.InterestManagement.Terrain; import engine.db.archive.DataWarehouse; -import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.math.Bounds; import engine.math.Vector2f; @@ -292,19 +291,6 @@ public class Zone extends AbstractWorldObject { return this.parentZoneID; } - public ArrayList getNodes() { - - if (this.nodes == null) { - this.nodes = DbManager.ZoneQueries.GET_MAP_NODES(super.getObjectUUID()); - - //Add reverse lookup for child->parent - if (this.nodes != null) - for (Zone zone : this.nodes) - zone.setParent(this); - } - return nodes; - } - /* * Serializing */ @@ -323,10 +309,10 @@ public class Zone extends AbstractWorldObject { if (this.equals(ZoneManager.seaFloor)) return false; - if (this.getNodes().isEmpty()) + if (this.nodes.isEmpty()) return false; - if (this.getNodes().get(0).isMacroZone()) + if (this.nodes.get(0).isMacroZone()) return true; return this.parent.equals(ZoneManager.seaFloor);