Browse Source

Refactored Zone to new system

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
e689cb541a
  1. 25
      src/engine/gameManager/ZoneManager.java
  2. 1
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  3. 27
      src/engine/objects/Zone.java
  4. 25
      src/engine/server/world/WorldServer.java

25
src/engine/gameManager/ZoneManager.java

@ -101,16 +101,6 @@ public enum ZoneManager {
return zone; return zone;
} }
public static void addZone(final int zoneID, final Zone zone) {
ZoneManager.zonesByID.put(zoneID, zone);
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone);
}
// Returns the number of available hotZones // Returns the number of available hotZones
// remaining in this cycle (1am) // remaining in this cycle (1am)
@ -173,24 +163,23 @@ public enum ZoneManager {
return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); return (Bounds.collide(loc, ZoneManager.hotZone.bounds));
} }
public static void setSeaFloor(final Zone value) { public static void populateZoneCollections(final Zone zone) {
ZoneManager.seaFloor = value;
}
public static void populateWorldZones(final Zone zone) {
int loadNum = zone.template;
// Zones are added to separate // Zones are added to separate
// collections for quick access // collections for quick access
// based upon their type. // based upon their type.
ZoneManager.zonesByID.put(zone.template, zone);
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone);
if (zone.isMacroZone()) { if (zone.isMacroZone()) {
addMacroZone(zone); addMacroZone(zone);
return; return;
} }
if (zone.guild_zone) { if (zone.guild_zone) {
addPlayerCityZone(zone); addPlayerCityZone(zone);
return; return;

1
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -788,7 +788,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (zoneObject.parent != null) if (zoneObject.parent != null)
zoneObject.parent.addNode(zoneObject); //add as child to parent zoneObject.parent.addNode(zoneObject); //add as child to parent
ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject);
ZoneManager.addPlayerCityZone(zoneObject); ZoneManager.addPlayerCityZone(zoneObject);
serverZone.addNode(zoneObject); serverZone.addNode(zoneObject);

27
src/engine/objects/Zone.java

@ -104,6 +104,8 @@ public class Zone extends AbstractWorldObject {
this.terrain_max_y = rs.getFloat("terrain_max_y"); this.terrain_max_y = rs.getFloat("terrain_max_y");
this.terrain_image = rs.getInt("terrain_image"); this.terrain_image = rs.getInt("terrain_image");
// Configuration for player cities
if (this.guild_zone) { if (this.guild_zone) {
this.max_blend = 128; this.max_blend = 128;
this.min_blend = 128; this.min_blend = 128;
@ -113,6 +115,21 @@ public class Zone extends AbstractWorldObject {
this.terrain_type = "PLANAR"; this.terrain_type = "PLANAR";
} }
// If zone doesn't yet hava a hash then write it back to the zone table
if (hash == null)
setHash();
}
@Override
public void runAfterLoad() {
// First zone is always the seafloor
if (ZoneManager.seaFloor == null)
ZoneManager.seaFloor = this;
if (this.terrain_type.equals("NONE")) if (this.terrain_type.equals("NONE"))
this.terrain = null; this.terrain = null;
else else
@ -131,15 +148,7 @@ public class Zone extends AbstractWorldObject {
if (parentZone != null) if (parentZone != null)
parentZone.addNode(this); parentZone.addNode(this);
// If zone doesn't yet hava a hash then write it back to the zone table ZoneManager.populateZoneCollections(this);
if (hash == null)
setHash();
}
@Override
public void runAfterLoad() {
} }

25
src/engine/server/world/WorldServer.java

@ -533,32 +533,9 @@ public class WorldServer {
private void getWorldBuildingsMobsNPCs() { private void getWorldBuildingsMobsNPCs() {
ArrayList<Zone> rootParent;
rootParent = DbManager.ZoneQueries.GET_MAP_NODES(worldUUID);
if (rootParent.isEmpty()) {
Logger.error("populateWorldBuildings: No entries found in worldMap for parent " + worldUUID);
return;
}
//Set sea floor object for server
Zone seaFloor = rootParent.get(0);
seaFloor.setParent(null);
ZoneManager.setSeaFloor(seaFloor);
rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
for (Zone zone : rootParent) { DbManager.ZoneQueries.GET_ALL_ZONES();
ZoneManager.addZone(zone.template, zone);
ZoneManager.populateWorldZones(zone);
}
DbManager.BuildingQueries.GET_ALL_BUILDINGS(); DbManager.BuildingQueries.GET_ALL_BUILDINGS();
DbManager.NPCQueries.GET_ALL_NPCS(); DbManager.NPCQueries.GET_ALL_NPCS();
DbManager.MobQueries.GET_ALL_MOBS(); DbManager.MobQueries.GET_ALL_MOBS();

Loading…
Cancel
Save