Browse Source

Refactored Zone to new system

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
5ed21f9b76
  1. 4
      src/engine/db/handlers/dbZoneHandler.java
  2. 2
      src/engine/devcmd/cmds/ZoneInfoCmd.java
  3. 6
      src/engine/gameManager/ZoneManager.java
  4. 13
      src/engine/net/client/msg/WorldDataMsg.java
  5. 18
      src/engine/objects/Zone.java

4
src/engine/db/handlers/dbZoneHandler.java

@ -46,7 +46,7 @@ public class dbZoneHandler extends dbHandlerBase {
public ArrayList<Zone> GET_ALL_NODES(Zone zone) { public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
ArrayList<Zone> wsmList = new ArrayList<>(); ArrayList<Zone> wsmList = new ArrayList<>();
wsmList.addAll(zone.getNodes()); wsmList.addAll(zone.nodes);
if (zone.absX == 0.0f) { if (zone.absX == 0.0f) {
zone.absX = zone.xOffset; zone.absX = zone.xOffset;
} }
@ -56,7 +56,7 @@ public class dbZoneHandler extends dbHandlerBase {
if (zone.absZ == 0.0f) { if (zone.absZ == 0.0f) {
zone.absZ = zone.zOffset; zone.absZ = zone.zOffset;
} }
for (Zone child : zone.getNodes()) { for (Zone child : zone.nodes) {
child.absX = child.xOffset + zone.absX; child.absX = child.xOffset + zone.absX;
child.absY = child.yOffset + zone.absY; child.absY = child.yOffset + zone.absY;
child.absZ = child.zOffset + zone.absZ; child.absZ = child.zOffset + zone.absZ;

2
src/engine/devcmd/cmds/ZoneInfoCmd.java

@ -120,7 +120,7 @@ public class ZoneInfoCmd extends AbstractDevCmd {
} else { } else {
output = "children:"; output = "children:";
ArrayList<Zone> nodes = zone.getNodes(); ArrayList<Zone> nodes = zone.nodes;
if (nodes.isEmpty()) if (nodes.isEmpty())
output += " none"; output += " none";

6
src/engine/gameManager/ZoneManager.java

@ -85,7 +85,7 @@ public enum ZoneManager {
childFound = false; childFound = false;
ArrayList<Zone> nodes = zone.getNodes(); ArrayList<Zone> nodes = zone.nodes;
// Logger.info("soze", "" + nodes.size()); // Logger.info("soze", "" + nodes.size());
if (nodes != null) if (nodes != null)
@ -239,7 +239,7 @@ public enum ZoneManager {
if (zone.peace_zone == (byte) 1) if (zone.peace_zone == (byte) 1)
return false; // no safe zone hotzones// if (this.hotzone == null) return false; // no safe zone hotzones// if (this.hotzone == null)
if (zone.getNodes().isEmpty()) if (zone.nodes.isEmpty())
return false; return false;
if (zone.equals(ZoneManager.seaFloor)) if (zone.equals(ZoneManager.seaFloor))
@ -396,7 +396,7 @@ public enum ZoneManager {
treeBounds = Bounds.borrow(); treeBounds = Bounds.borrow();
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f); 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) { for (Zone zone : zoneList) {

13
src/engine/net/client/msg/WorldDataMsg.java

@ -10,8 +10,10 @@
package engine.net.client.msg; package engine.net.client.msg;
import engine.Enum;
import engine.exception.SerializationException; import engine.exception.SerializationException;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.net.AbstractConnection; import engine.net.AbstractConnection;
import engine.net.AbstractNetMsg; import engine.net.AbstractNetMsg;
@ -44,14 +46,9 @@ public class WorldDataMsg extends ClientNetMsg {
super(Protocol.NEWWORLD, origin, reader); super(Protocol.NEWWORLD, origin, reader);
} }
private static int getTotalMapSize(Zone root) { private static int getTotalMapSize() {
if (root.getNodes().isEmpty())
return 0;
int size = root.getNodes().size(); return DbManager.getList(Enum.GameObjectType.Zone).size();
for (Zone child : root.getNodes())
size += getTotalMapSize(child);
return size;
} }
/** /**
@ -86,7 +83,7 @@ public class WorldDataMsg extends ClientNetMsg {
writer.putInt(WorldServer.worldMapID); writer.putInt(WorldServer.worldMapID);
writer.putInt(0x00000000); writer.putInt(0x00000000);
writer.putInt(getTotalMapSize(root) + 1); writer.putInt(getTotalMapSize() + 1);
Zone.serializeForClientMsg(root, writer); Zone.serializeForClientMsg(root, writer);
Zone hotzone = ZoneManager.hotZone; Zone hotzone = ZoneManager.hotZone;

18
src/engine/objects/Zone.java

@ -12,7 +12,6 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.Terrain; import engine.InterestManagement.Terrain;
import engine.db.archive.DataWarehouse; import engine.db.archive.DataWarehouse;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Bounds; import engine.math.Bounds;
import engine.math.Vector2f; import engine.math.Vector2f;
@ -292,19 +291,6 @@ public class Zone extends AbstractWorldObject {
return this.parentZoneID; return this.parentZoneID;
} }
public ArrayList<Zone> 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 * Serializing
*/ */
@ -323,10 +309,10 @@ public class Zone extends AbstractWorldObject {
if (this.equals(ZoneManager.seaFloor)) if (this.equals(ZoneManager.seaFloor))
return false; return false;
if (this.getNodes().isEmpty()) if (this.nodes.isEmpty())
return false; return false;
if (this.getNodes().get(0).isMacroZone()) if (this.nodes.get(0).isMacroZone())
return true; return true;
return this.parent.equals(ZoneManager.seaFloor); return this.parent.equals(ZoneManager.seaFloor);

Loading…
Cancel
Save