Browse Source

Refactored Zone to new system

combat-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. 81
      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 { @@ -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 { @@ -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;

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

@ -788,7 +788,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { @@ -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);

81
src/engine/objects/Zone.java

@ -94,42 +94,26 @@ public class Zone extends AbstractWorldObject { @@ -94,42 +94,26 @@ public class Zone extends AbstractWorldObject {
this.icon3 = rs.getString("icon3");
this.min_level = rs.getInt("min_level");
this.max_level = rs.getInt("max_level");
this.major_radius = rs.getFloat("major_radius");
this.minor_radius = rs.getFloat("minor_radius");
this.min_blend = rs.getFloat("min_blend");
this.max_blend = rs.getFloat("max_blend");
this.sea_level_type = rs.getString("sea_level_type");
this.sea_level_offset = rs.getFloat("sea_level");
this.terrain_type = rs.getString("terrain_type");
this.terrain_max_y = rs.getFloat("terrain_max_y");
this.terrain_image = rs.getInt("terrain_image");
if (this.guild_zone) {
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"))
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);
this.major_radius = rs.getFloat("major_radius");
this.minor_radius = rs.getFloat("minor_radius");
this.min_blend = rs.getFloat("min_blend");
this.max_blend = rs.getFloat("max_blend");
this.sea_level_type = rs.getString("sea_level_type");
this.sea_level_offset = rs.getFloat("sea_level");
this.terrain_type = rs.getString("terrain_type");
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;
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 zone doesn't yet hava a hash then write it back to the zone table
@ -141,6 +125,31 @@ public class Zone extends AbstractWorldObject { @@ -141,6 +125,31 @@ public class Zone extends AbstractWorldObject {
@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
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) {

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

@ -533,32 +533,9 @@ public class WorldServer { @@ -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();

Loading…
Cancel
Save