forked from MagicBane/Server
Refactored Zone to new system
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -94,42 +94,26 @@ public class Zone extends AbstractWorldObject {
|
|||||||
this.icon3 = rs.getString("icon3");
|
this.icon3 = rs.getString("icon3");
|
||||||
this.min_level = rs.getInt("min_level");
|
this.min_level = rs.getInt("min_level");
|
||||||
this.max_level = rs.getInt("max_level");
|
this.max_level = rs.getInt("max_level");
|
||||||
this.major_radius = rs.getFloat("major_radius");
|
this.major_radius = rs.getFloat("major_radius");
|
||||||
this.minor_radius = rs.getFloat("minor_radius");
|
this.minor_radius = rs.getFloat("minor_radius");
|
||||||
this.min_blend = rs.getFloat("min_blend");
|
this.min_blend = rs.getFloat("min_blend");
|
||||||
this.max_blend = rs.getFloat("max_blend");
|
this.max_blend = rs.getFloat("max_blend");
|
||||||
this.sea_level_type = rs.getString("sea_level_type");
|
this.sea_level_type = rs.getString("sea_level_type");
|
||||||
this.sea_level_offset = rs.getFloat("sea_level");
|
this.sea_level_offset = rs.getFloat("sea_level");
|
||||||
this.terrain_type = rs.getString("terrain_type");
|
this.terrain_type = rs.getString("terrain_type");
|
||||||
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");
|
||||||
|
|
||||||
if (this.guild_zone) {
|
// Configuration for player cities
|
||||||
this.max_blend = 128;
|
|
||||||
this.min_blend = 128;
|
|
||||||
this.terrain_max_y = 5;
|
|
||||||
this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
|
||||||
this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
|
||||||
this.terrain_type = "PLANAR";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.terrain_type.equals("NONE"))
|
if (this.guild_zone) {
|
||||||
this.terrain = null;
|
this.max_blend = 128;
|
||||||
else
|
this.min_blend = 128;
|
||||||
this.terrain = new Terrain(this);
|
this.terrain_max_y = 5;
|
||||||
|
this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||||
//this needs to be here specifically for new zones created after server boot (e.g. player city zones)
|
this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||||
|
this.terrain_type = "PLANAR";
|
||||||
Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID);
|
}
|
||||||
this.setParent(parentZone);
|
|
||||||
|
|
||||||
if (this.min_level == 0 && parentZone != null) {
|
|
||||||
this.min_level = parentZone.min_level;
|
|
||||||
this.max_level = parentZone.max_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parentZone != null)
|
|
||||||
parentZone.addNode(this);
|
|
||||||
|
|
||||||
// If zone doesn't yet hava a hash then write it back to the zone table
|
// If zone doesn't yet hava a hash then write it back to the zone table
|
||||||
|
|
||||||
@@ -141,6 +125,31 @@ public class Zone extends AbstractWorldObject {
|
|||||||
@Override
|
@Override
|
||||||
public void runAfterLoad() {
|
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
|
||||||
|
this.terrain = new Terrain(this);
|
||||||
|
|
||||||
|
//this needs to be here specifically for new zones created after server boot (e.g. player city zones)
|
||||||
|
|
||||||
|
Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID);
|
||||||
|
this.setParent(parentZone);
|
||||||
|
|
||||||
|
if (this.min_level == 0 && parentZone != null) {
|
||||||
|
this.min_level = parentZone.min_level;
|
||||||
|
this.max_level = parentZone.max_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentZone != null)
|
||||||
|
parentZone.addNode(this);
|
||||||
|
|
||||||
|
ZoneManager.populateZoneCollections(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
|
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user