Browse Source

Refactored Zone to new system

combat-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 { @@ -46,7 +46,7 @@ public class dbZoneHandler extends dbHandlerBase {
public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
ArrayList<Zone> 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 { @@ -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;

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

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

6
src/engine/gameManager/ZoneManager.java

@ -85,7 +85,7 @@ public enum ZoneManager { @@ -85,7 +85,7 @@ public enum ZoneManager {
childFound = false;
ArrayList<Zone> nodes = zone.getNodes();
ArrayList<Zone> nodes = zone.nodes;
// Logger.info("soze", "" + nodes.size());
if (nodes != null)
@ -239,7 +239,7 @@ public enum ZoneManager { @@ -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 { @@ -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) {

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

@ -10,8 +10,10 @@ @@ -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 { @@ -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 { @@ -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;

18
src/engine/objects/Zone.java

@ -12,7 +12,6 @@ package engine.objects; @@ -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 { @@ -292,19 +291,6 @@ public class Zone extends AbstractWorldObject {
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
*/
@ -323,10 +309,10 @@ public class Zone extends AbstractWorldObject { @@ -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);

Loading…
Cancel
Save