diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 449def09..51bdda4c 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -88,6 +88,23 @@ public class dbBuildingHandler extends dbHandlerBase { return removeFromBuildings(b); } + public ArrayList GET_ALL_BUILDINGS() { + + ArrayList buildings = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + buildings = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return buildings; + } + public ArrayList GET_ALL_BUILDINGS_FOR_ZONE(Zone zone) { ArrayList buildings = new ArrayList<>(); diff --git a/src/engine/net/client/msg/SyncMessage.java b/src/engine/net/client/msg/SyncMessage.java deleted file mode 100644 index dfe5a150..00000000 --- a/src/engine/net/client/msg/SyncMessage.java +++ /dev/null @@ -1,151 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net.client.msg; - - -import engine.exception.SerializationException; -import engine.gameManager.BuildingManager; -import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; -import engine.objects.Building; -import engine.objects.Zone; -import org.pmw.tinylog.Logger; - -import java.util.ArrayList; - -public class SyncMessage extends ClientNetMsg { - - private int type; - private int size; - private int pad = 0; - private int objectType; - private int objectUUID; - - /** - * This constructor is used by NetMsgFactory. It attempts to deserialize the - * ByteBuffer into a message. If a BufferUnderflow occurs (based on reading - * past the limit) then this constructor Throws that Exception to the - * caller. - */ - public SyncMessage(AbstractConnection origin, ByteBufferReader reader) { - super(Protocol.CITYASSET, origin, reader); - } - - public SyncMessage() { - super(Protocol.CITYASSET); - } - - /** - * Deserializes the subclass specific items from the supplied NetMsgReader. - */ - @Override - protected void _deserialize(ByteBufferReader reader) { - //none yet - } - - /** - * Serializes the subclass specific items to the supplied NetMsgWriter. - */ - @Override - protected void _serialize(ByteBufferWriter writer) throws SerializationException { - //lets do returns before writing so we don't send improper structures to the client - - Building tol = BuildingManager.getBuilding(this.objectUUID); - - if (tol == null) { - Logger.debug("TOL is null"); - return; - } - Zone zone = ZoneManager.findSmallestZone(tol.getLoc()); - if (zone == null) { - Logger.debug("Zone is null"); - return; - } - ArrayList allCityAssets = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); - - // *** Refactor: collection created but never used? - - ArrayList canProtectAssets = new ArrayList<>(); - - for (Building b : allCityAssets) { - if (b.getBlueprintUUID() != 0) - canProtectAssets.add(b); - } - - // *** Refactor : Not sure what this synch message does - // Get the feeling it should be looping over upgradable - // assets. - writer.putInt(0); - writer.putInt(0); - writer.putInt(this.objectType); - writer.putInt(this.objectUUID); - writer.putInt(allCityAssets.size()); - for (Building b : allCityAssets) { - String name = b.getName(); - // if (name.equals("")) - // name = b.getBuildingSet().getName(); - writer.putInt(b.getObjectType().ordinal()); - writer.putInt(b.getObjectUUID()); - - writer.putString(b.getName()); // Blueprint name? - writer.putString(b.getGuild().getName()); - writer.putInt(20);// \/ Temp \/ - writer.putInt(b.getRank()); - writer.putInt(1); // symbol - writer.putInt(7); //TODO identify these Guild tags?? - writer.putInt(17); - writer.putInt(14); - writer.putInt(14); - writer.putInt(98);// /\ Temp /\ - - } - } - - public int getObjectType() { - return objectType; - } - - public void setObjectType(int value) { - this.objectType = value; - } - - public int getUUID() { - return objectUUID; - - } - - public int getPad() { - return pad; - } - - public void setPad(int value) { - this.pad = value; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } -} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 66088b8b..9b1a09de 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -555,67 +555,6 @@ public class WorldServer { for (Zone zone : rootParent) { ZoneManager.addZone(zone.template, zone); - - //Handle Buildings - - try { - ArrayList bList; - bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); - - for (Building b : bList) { - - b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); - b.setLoc(b.getLoc()); - } - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - - //Handle Mobs - - try { - ArrayList mobs; - mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); - - for (Mob m : mobs) { - m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); - m.setLoc(m.getLoc()); - - // Load Minions for Guard Captains here. - - if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) - DbManager.MobQueries.LOAD_GUARD_MINIONS(m); - } - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - - //Handle NPCs - - try { - ArrayList npcs; - - // Ignore NPCs on the seafloor (npc guild leaders, etc) - - if (zone.equals(seaFloor)) - continue; - - npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); - - for (NPC n : npcs) { - n.setObjectTypeMask(MBServerStatics.MASK_NPC); - n.setLoc(n.getLoc()); - } - - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - //Handle cities - - ZoneManager.loadCities(zone); ZoneManager.populateWorldZones(zone); }