From a17b9fdd13fb5bdb901874a1a206f9107436c260 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 06:04:37 -0400 Subject: [PATCH] Zone extents derived from zone --- src/engine/db/handlers/dbZoneHandler.java | 22 ---------------------- src/engine/gameManager/ZoneManager.java | 19 +++++++++++-------- src/engine/objects/Zone.java | 10 +--------- src/engine/server/world/WorldServer.java | 3 --- 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index b782ad38..9cceccaa 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -11,8 +11,6 @@ package engine.db.handlers; import engine.Enum; import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; -import engine.math.Vector2f; import engine.objects.Zone; import org.pmw.tinylog.Logger; @@ -91,26 +89,6 @@ public class dbZoneHandler extends dbHandlerBase { return zoneList; } - public void LOAD_ZONE_EXTENTS() { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - Vector2f zoneSize = new Vector2f(); - int loadNum = rs.getInt("loadNum"); - zoneSize.x = rs.getFloat("xRadius"); - zoneSize.y = rs.getFloat("zRadius"); - ZoneManager._zone_size_data.put(loadNum, zoneSize); - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public boolean DELETE_ZONE(final Zone zone) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index e4a0c7b9..32f463fc 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -25,7 +25,10 @@ import org.pmw.tinylog.Logger; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -46,7 +49,7 @@ public enum ZoneManager { public static Instant hotZoneLastUpdate; public static Zone hotZone = null; public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config. - public static HashMap _zone_size_data = new HashMap<>(); + /* Instance variables */ private static Zone seaFloor = null; @@ -71,7 +74,7 @@ public enum ZoneManager { // Find smallest zone coordinates fit into. - public static final Zone findSmallestZone(final Vector3fImmutable loc) { + public static Zone findSmallestZone(final Vector3fImmutable loc) { Zone zone = ZoneManager.seaFloor; @@ -90,7 +93,7 @@ public enum ZoneManager { if (nodes != null) for (Zone child : nodes) { - if (Bounds.collide(loc, child.bounds) == true) { + if (Bounds.collide(loc, child.bounds)) { zone = child; childFound = true; break; @@ -148,11 +151,11 @@ public enum ZoneManager { return ZoneManager.zonesByName.get(zoneName); } - public static final Collection getAllZones() { + public static Collection getAllZones() { return ZoneManager.zonesByUUID.values(); } - public static final void setHotZone(final Zone zone) { + public static void setHotZone(final Zone zone) { if (!zone.isMacroZone()) return; @@ -169,7 +172,7 @@ public enum ZoneManager { if (ZoneManager.hotZone == null) return false; - return (Bounds.collide(loc, ZoneManager.hotZone.bounds) == true); + return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); } public static Zone getSeaFloor() { @@ -180,7 +183,7 @@ public enum ZoneManager { ZoneManager.seaFloor = value; } - public static final void populateWorldZones(final Zone zone) { + public static void populateWorldZones(final Zone zone) { int loadNum = zone.template; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index b4e69507..76ac747c 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -199,15 +199,7 @@ public class Zone extends AbstractGameObject { // Set initial bounds object this.bounds = Bounds.borrow(); - - Vector2f zoneSize = ZoneManager._zone_size_data.get(this.template); - - // Default to player zone size on error? Maybe log this - - if (zoneSize != null) - this.bounds.setBounds(new Vector2f(this.absX, this.absZ), zoneSize, 0.0f); - else - bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); + this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f); } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 275925d6..66088b8b 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -360,9 +360,6 @@ public class WorldServer { Logger.info("Loading item enchants"); DbManager.LootQueries.LOAD_ENCHANT_VALUES(); - Logger.info("Loading zone extent cache"); - DbManager.ZoneQueries.LOAD_ZONE_EXTENTS(); - Logger.info("Loading Realms"); Realm.loadAllRealms();