forked from MagicBane/Server
Refactored Zone to new system
This commit is contained in:
@@ -101,16 +101,6 @@ public enum ZoneManager {
|
||||
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
|
||||
// remaining in this cycle (1am)
|
||||
|
||||
@@ -173,24 +163,23 @@ public enum ZoneManager {
|
||||
return (Bounds.collide(loc, ZoneManager.hotZone.bounds));
|
||||
}
|
||||
|
||||
public static void setSeaFloor(final Zone value) {
|
||||
ZoneManager.seaFloor = value;
|
||||
}
|
||||
|
||||
public static void populateWorldZones(final Zone zone) {
|
||||
|
||||
int loadNum = zone.template;
|
||||
public static void populateZoneCollections(final Zone zone) {
|
||||
|
||||
// Zones are added to separate
|
||||
// collections for quick access
|
||||
// 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()) {
|
||||
addMacroZone(zone);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (zone.guild_zone) {
|
||||
addPlayerCityZone(zone);
|
||||
return;
|
||||
|
||||
@@ -788,7 +788,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
if (zoneObject.parent != null)
|
||||
zoneObject.parent.addNode(zoneObject); //add as child to parent
|
||||
|
||||
ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject);
|
||||
ZoneManager.addPlayerCityZone(zoneObject);
|
||||
serverZone.addNode(zoneObject);
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ public class Zone extends AbstractWorldObject {
|
||||
this.terrain_max_y = rs.getFloat("terrain_max_y");
|
||||
this.terrain_image = rs.getInt("terrain_image");
|
||||
|
||||
// Configuration for player cities
|
||||
|
||||
if (this.guild_zone) {
|
||||
this.max_blend = 128;
|
||||
this.min_blend = 128;
|
||||
@@ -113,6 +115,21 @@ public class Zone extends AbstractWorldObject {
|
||||
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"))
|
||||
this.terrain = null;
|
||||
else
|
||||
@@ -131,15 +148,7 @@ public class Zone extends AbstractWorldObject {
|
||||
if (parentZone != null)
|
||||
parentZone.addNode(this);
|
||||
|
||||
// If zone doesn't yet hava a hash then write it back to the zone table
|
||||
|
||||
if (hash == null)
|
||||
setHash();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
ZoneManager.populateZoneCollections(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -533,32 +533,9 @@ public class WorldServer {
|
||||
|
||||
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();
|
||||
|
||||
for (Zone zone : rootParent) {
|
||||
|
||||
ZoneManager.addZone(zone.template, zone);
|
||||
ZoneManager.populateWorldZones(zone);
|
||||
|
||||
}
|
||||
|
||||
DbManager.ZoneQueries.GET_ALL_ZONES();
|
||||
DbManager.BuildingQueries.GET_ALL_BUILDINGS();
|
||||
DbManager.NPCQueries.GET_ALL_NPCS();
|
||||
DbManager.MobQueries.GET_ALL_MOBS();
|
||||
|
||||
Reference in New Issue
Block a user