From e203945ea3e028f36f68e8051570ccf4cc2fb5e8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 May 2023 15:55:15 -0400 Subject: [PATCH] Static method moved to manager singleton. --- src/engine/gameManager/ZoneManager.java | 29 ++++++++++++++++++++++++ src/engine/objects/City.java | 27 ---------------------- src/engine/server/world/WorldServer.java | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index eab3393e..f4e2f434 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -9,6 +9,8 @@ package engine.gameManager; import engine.Enum; +import engine.db.archive.CityRecord; +import engine.db.archive.DataWarehouse; import engine.math.Bounds; import engine.math.Vector2f; import engine.math.Vector3f; @@ -423,4 +425,31 @@ public enum ZoneManager { treeBounds.release(); return validLocation; } + + public static void loadCities(Zone zone) { + + ArrayList cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID()); + + for (City city : cities) { + + city.setParent(zone); + city.setObjectTypeMask(MBServerStatics.MASK_CITY); + city.setLoc(city.getLoc()); // huh? + +//not player city, must be npc city.. + + if (!zone.isPlayerCity()) + zone.setNPCCity(true); + + if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) { + + city.setHash(); + + if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) { + CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE); + DataWarehouse.pushToWarehouse(cityRecord); + } + } + } + } } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 084ab55d..4286c96c 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -746,33 +746,6 @@ public class City extends AbstractWorldObject { return open; } - public static void loadCities(Zone zone) { - - ArrayList cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID()); - - for (City city : cities) { - - city.setParent(zone); - city.setObjectTypeMask(MBServerStatics.MASK_CITY); - city.setLoc(city.location); - - //not player city, must be npc city.. - if (!zone.isPlayerCity()) - zone.setNPCCity(true); - - if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (city.hash == null)) { - - city.setHash(); - - if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) { - CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE); - DataWarehouse.pushToWarehouse(cityRecord); - } - } - } - } - - @Override public void updateDatabase() { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 98658e53..276fd9ec 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -572,7 +572,7 @@ public class WorldServer { //Handle cities - City.loadCities(zone); + ZoneManager.loadCities(zone); ZoneManager.populateWorldZones(zone); } catch (Exception e) {