forked from MagicBane/Server
class and table schema now conform to JSON
This commit is contained in:
@@ -33,12 +33,12 @@ public class Zone extends AbstractGameObject {
|
||||
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final int playerCityID;
|
||||
public final int playerCityUUID;
|
||||
public final String zoneName;
|
||||
public final float xCoord;
|
||||
public final float zCoord;
|
||||
public final float yCoord;
|
||||
public final int loadNum;
|
||||
public final float xOffset;
|
||||
public final float zOffset;
|
||||
public final float yOffset;
|
||||
public final int zoneTemplate;
|
||||
public final byte peaceZone;
|
||||
public final String Icon1;
|
||||
public final String Icon2;
|
||||
@@ -54,13 +54,13 @@ public class Zone extends AbstractGameObject {
|
||||
public Zone parent = null;
|
||||
public Bounds bounds;
|
||||
public boolean isNPCCity = false;
|
||||
public boolean isPlayerCity = false;
|
||||
public boolean isGuildZone;
|
||||
public String hash;
|
||||
public float worldAltitude = 0;
|
||||
public float seaLevel = 0f;
|
||||
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public static long lastRespawn = 0;
|
||||
public Bounds maxBlend;
|
||||
public Bounds blendBounds;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
@@ -68,22 +68,21 @@ public class Zone extends AbstractGameObject {
|
||||
public Zone(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
this.parentZoneID = rs.getInt("parent");
|
||||
this.playerCityID = rs.getInt("isPlayerCity");
|
||||
this.isPlayerCity = this.playerCityID != 0;
|
||||
this.playerCityUUID = rs.getInt("playerCityUUID");
|
||||
this.isGuildZone = this.playerCityUUID != 0;
|
||||
this.zoneName = rs.getString("Name");
|
||||
this.xCoord = rs.getFloat("XCoord");
|
||||
this.zCoord = rs.getFloat("ZCoord");
|
||||
this.yCoord = rs.getFloat("YOffset");
|
||||
this.loadNum = rs.getInt("LoadNum");
|
||||
this.peaceZone = rs.getByte("SafeZone");
|
||||
this.Icon1 = rs.getString("Icon1");
|
||||
this.Icon2 = rs.getString("Icon2");
|
||||
this.Icon3 = rs.getString("Icon3");
|
||||
this.xOffset = rs.getFloat("xOffset");
|
||||
this.zOffset = rs.getFloat("zOffset");
|
||||
this.yOffset = rs.getFloat("yOffset");
|
||||
this.zoneTemplate = rs.getInt("zoneTemplate");
|
||||
this.peaceZone = rs.getByte("paceZone");
|
||||
this.Icon1 = rs.getString("icon1");
|
||||
this.Icon2 = rs.getString("icon2");
|
||||
this.Icon3 = rs.getString("icon3");
|
||||
this.minLvl = rs.getInt("min_level");
|
||||
this.maxLvl = rs.getInt("max_level");
|
||||
this.hash = rs.getString("hash");
|
||||
|
||||
this.minLvl = rs.getInt("minLvl");
|
||||
this.maxLvl = rs.getInt("maxLvl");
|
||||
|
||||
//this needs to be here specifically for new zones created after server boot (e.g. player city zones)
|
||||
|
||||
Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID);
|
||||
@@ -107,28 +106,28 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
|
||||
|
||||
if (zone.loadNum == 0 && zone.playerCityID == 0)
|
||||
if (zone.zoneTemplate == 0 && zone.playerCityUUID == 0)
|
||||
Logger.warn("Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
|
||||
|
||||
// Player City Terraform values serialized here.
|
||||
|
||||
if (zone.playerCityID > 0) {
|
||||
if (zone.playerCityUUID > 0) {
|
||||
writer.put((byte) 1); // Player City - True
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents);
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents);
|
||||
} else
|
||||
writer.put((byte) 0); // Player City - False
|
||||
|
||||
writer.putFloat(zone.xCoord);
|
||||
writer.putFloat(zone.zCoord);
|
||||
writer.putFloat(zone.yCoord);
|
||||
writer.putFloat(zone.xOffset);
|
||||
writer.putFloat(zone.zOffset);
|
||||
writer.putFloat(zone.yOffset);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(zone.loadNum);
|
||||
writer.putInt(zone.zoneTemplate);
|
||||
|
||||
if (zone.playerCityID > 0) {
|
||||
City k = City.getCity(zone.playerCityID);
|
||||
if (zone.playerCityUUID > 0) {
|
||||
City k = City.getCity(zone.playerCityUUID);
|
||||
|
||||
if (k != null) {
|
||||
writer.putInt(k.getObjectType().ordinal());
|
||||
@@ -141,7 +140,7 @@ public class Zone extends AbstractGameObject {
|
||||
}
|
||||
writer.putInt(zone.nodes.size());
|
||||
|
||||
City city = City.getCity(zone.playerCityID);
|
||||
City city = City.getCity(zone.playerCityUUID);
|
||||
|
||||
if (city != null)
|
||||
writer.putString(city.getCityName());
|
||||
@@ -168,7 +167,7 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
this.bounds = Bounds.borrow();
|
||||
|
||||
Vector2f zoneSize = ZoneManager._zone_size_data.get(this.loadNum);
|
||||
Vector2f zoneSize = ZoneManager._zone_size_data.get(this.zoneTemplate);
|
||||
|
||||
// Default to player zone size on error? Maybe log this
|
||||
|
||||
@@ -182,10 +181,10 @@ public class Zone extends AbstractGameObject {
|
||||
// Set heightmap blending bounds
|
||||
|
||||
if (heightMap == null) {
|
||||
this.maxBlend = bounds;
|
||||
this.blendBounds = bounds;
|
||||
} else {
|
||||
this.maxBlend = Bounds.borrow();
|
||||
this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f);
|
||||
this.blendBounds = Bounds.borrow();
|
||||
this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -198,17 +197,17 @@ public class Zone extends AbstractGameObject {
|
||||
// Seafloor
|
||||
|
||||
if (this.parent == null) {
|
||||
this.absX = this.xCoord;
|
||||
this.absX = this.xOffset;
|
||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
this.absZ = this.zCoord;
|
||||
this.absZ = this.zOffset;
|
||||
this.seaLevel = 0;
|
||||
this.setBounds();
|
||||
return;
|
||||
}
|
||||
|
||||
this.absX = this.xCoord + parent.absX;
|
||||
this.absY = this.yCoord + parent.absY;
|
||||
this.absZ = this.zCoord + parent.absZ;
|
||||
this.absX = this.xOffset + parent.absX;
|
||||
this.absY = this.yOffset + parent.absY;
|
||||
this.absZ = this.zOffset + parent.absZ;
|
||||
|
||||
if (this.minLvl == 0 || this.maxLvl == 0) {
|
||||
this.minLvl = this.parent.minLvl;
|
||||
@@ -239,7 +238,7 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
// Macro zones have icons.
|
||||
|
||||
if (this.isPlayerCity == true)
|
||||
if (this.isGuildZone == true)
|
||||
return false;
|
||||
|
||||
if (this.parent == null)
|
||||
@@ -311,10 +310,10 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
public HeightMap getHeightMap() {
|
||||
|
||||
if (this.isPlayerCity)
|
||||
if (this.isGuildZone)
|
||||
return HeightMap.PlayerCityHeightMap;
|
||||
|
||||
return HeightMap.heightmapByLoadNum.get(this.loadNum);
|
||||
return HeightMap.heightmapByLoadNum.get(this.zoneTemplate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user