|
|
|
@ -55,6 +55,7 @@ public class Building extends AbstractWorldObject {
@@ -55,6 +55,7 @@ public class Building extends AbstractWorldObject {
|
|
|
|
|
private final HashMap<Integer, DoorCloseJob> doorJobs = new HashMap<>(); |
|
|
|
|
public int meshUUID; |
|
|
|
|
public Zone parentZone; |
|
|
|
|
public int parentZoneUUID; |
|
|
|
|
public boolean reverseKOS; |
|
|
|
|
public int reserve = 0; |
|
|
|
|
public float statLat; |
|
|
|
@ -106,27 +107,23 @@ public class Building extends AbstractWorldObject {
@@ -106,27 +107,23 @@ public class Building extends AbstractWorldObject {
|
|
|
|
|
super(rs); |
|
|
|
|
|
|
|
|
|
float scale; |
|
|
|
|
Blueprint blueprint = null; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
this.meshUUID = rs.getInt("meshUUID"); |
|
|
|
|
this.setObjectTypeMask(MBServerStatics.MASK_BUILDING); |
|
|
|
|
this.blueprintUUID = rs.getInt("blueprintUUID"); |
|
|
|
|
this.gridObjectType = GridObjectType.STATIC; |
|
|
|
|
this.parentZone = DbManager.ZoneQueries.GET_BY_UID(rs.getLong("parent")); |
|
|
|
|
this.parentZoneUUID = rs.getInt("parent"); |
|
|
|
|
this.name = rs.getString("name"); |
|
|
|
|
this.ownerUUID = rs.getInt("ownerUUID"); |
|
|
|
|
|
|
|
|
|
// Orphaned Object Sanity Check
|
|
|
|
|
//This was causing ABANDONED Tols.
|
|
|
|
|
// if (objectType == DbObjectType.INVALID)
|
|
|
|
|
// this.ownerUUID = 0;
|
|
|
|
|
|
|
|
|
|
this.doorState = rs.getInt("doorState"); |
|
|
|
|
this.setHealth(rs.getInt("currentHP")); |
|
|
|
|
this.w = rs.getFloat("w"); |
|
|
|
|
this.setRot(new Vector3f(0f, rs.getFloat("rotY"), 0f)); |
|
|
|
|
this.reverseKOS = rs.getByte("reverseKOS") == 1 ? true : false; |
|
|
|
|
this.reverseKOS = rs.getByte("reverseKOS") == 1; |
|
|
|
|
this.statLat = rs.getFloat("locationX"); |
|
|
|
|
this.statAlt = rs.getFloat("locationY"); |
|
|
|
|
this.statLon = rs.getFloat("locationZ"); |
|
|
|
|
|
|
|
|
|
scale = rs.getFloat("scale"); |
|
|
|
|
this.meshScale = new Vector3f(scale, scale, scale); |
|
|
|
@ -143,79 +140,10 @@ public class Building extends AbstractWorldObject {
@@ -143,79 +140,10 @@ public class Building extends AbstractWorldObject {
|
|
|
|
|
this.level = rs.getInt("level"); |
|
|
|
|
this.isFurniture = (rs.getBoolean("isFurniture")); |
|
|
|
|
|
|
|
|
|
// Lookup building blueprint
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
|
blueprint = Blueprint._meshLookup.get(meshUUID); |
|
|
|
|
else |
|
|
|
|
blueprint = this.getBlueprint(); |
|
|
|
|
|
|
|
|
|
// Log error if something went horrible wrong
|
|
|
|
|
|
|
|
|
|
if ((this.blueprintUUID != 0) && (blueprint == null)) |
|
|
|
|
Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
// Note: We handle R8 tree edge case for mesh and health
|
|
|
|
|
// after city is loaded to avoid recursive result set call
|
|
|
|
|
// in City resulting in a stack ovreflow.
|
|
|
|
|
|
|
|
|
|
if (blueprint != null) { |
|
|
|
|
|
|
|
|
|
// Only switch mesh for player dropped structures
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID != 0) |
|
|
|
|
this.meshUUID = blueprint.getMeshForRank(rank); |
|
|
|
|
|
|
|
|
|
this.healthMax = blueprint.getMaxHealth(this.rank); |
|
|
|
|
|
|
|
|
|
// If this object has no blueprint but is a blueprint
|
|
|
|
|
// mesh then set it's current health to max health
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
|
this.setHealth(healthMax); |
|
|
|
|
|
|
|
|
|
if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK)) |
|
|
|
|
this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
this.healthMax = 100000; // Structures with no blueprint mesh
|
|
|
|
|
this.setHealth(healthMax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Null out blueprint if not needed (npc building)
|
|
|
|
|
|
|
|
|
|
if (blueprintUUID == 0) |
|
|
|
|
blueprint = null; |
|
|
|
|
|
|
|
|
|
resists = new Resists("Building"); |
|
|
|
|
this.statLat = rs.getFloat("locationX"); |
|
|
|
|
this.statAlt = rs.getFloat("locationY"); |
|
|
|
|
this.statLon = rs.getFloat("locationZ"); |
|
|
|
|
|
|
|
|
|
if (this.parentZone != null) { |
|
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); |
|
|
|
|
if (parentBuilding != null) { |
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); |
|
|
|
|
} else { |
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
// Altitude of this building is derived from the heightmap engine.
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); |
|
|
|
|
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); |
|
|
|
|
this.setLoc(tempLoc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this._strongboxValue = rs.getInt("currentGold"); |
|
|
|
|
this.maxGold = 15000000; // *** Refactor to blueprint method
|
|
|
|
|
this.reserve = rs.getInt("reserve"); |
|
|
|
|
|
|
|
|
|
// Does building have a protection contract?
|
|
|
|
|
this.taxType = TaxType.valueOf(rs.getString("taxType")); |
|
|
|
|
this.taxAmount = rs.getInt("taxAmount"); |
|
|
|
|
this.protectionState = ProtectionState.valueOf(rs.getString("protectionState")); |
|
|
|
@ -236,7 +164,6 @@ public class Building extends AbstractWorldObject {
@@ -236,7 +164,6 @@ public class Building extends AbstractWorldObject {
|
|
|
|
|
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1076,8 +1003,72 @@ public class Building extends AbstractWorldObject {
@@ -1076,8 +1003,72 @@ public class Building extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
// Lookup building blueprint
|
|
|
|
|
|
|
|
|
|
Blueprint blueprint; |
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
|
blueprint = Blueprint._meshLookup.get(meshUUID); |
|
|
|
|
else |
|
|
|
|
blueprint = this.getBlueprint(); |
|
|
|
|
|
|
|
|
|
// Log error if something went horrible wrong
|
|
|
|
|
|
|
|
|
|
if ((this.blueprintUUID != 0) && (blueprint == null)) |
|
|
|
|
Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
// Note: We handle R8 tree edge case for mesh and health
|
|
|
|
|
// after city is loaded to avoid recursive result set call
|
|
|
|
|
// in City resulting in a stack ovreflow.
|
|
|
|
|
|
|
|
|
|
if (blueprint != null) { |
|
|
|
|
|
|
|
|
|
// Only switch mesh for player dropped structures
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID != 0) |
|
|
|
|
this.meshUUID = blueprint.getMeshForRank(rank); |
|
|
|
|
|
|
|
|
|
this.healthMax = blueprint.getMaxHealth(this.rank); |
|
|
|
|
|
|
|
|
|
// If this object has no blueprint but is a blueprint
|
|
|
|
|
// mesh then set it's current health to max health
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
|
this.setHealth(healthMax); |
|
|
|
|
|
|
|
|
|
if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK)) |
|
|
|
|
this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
this.healthMax = 100000; // Structures with no blueprint mesh
|
|
|
|
|
this.setHealth(healthMax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resists = new Resists("Building"); |
|
|
|
|
|
|
|
|
|
if (this.parentZone != null) { |
|
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); |
|
|
|
|
if (parentBuilding != null) { |
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); |
|
|
|
|
} else { |
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
// Altitude of this building is derived from the heightmap engine.
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); |
|
|
|
|
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); |
|
|
|
|
this.setLoc(tempLoc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); |
|
|
|
|
this.parentZone.zoneBuildingSet.add(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Submit upgrade job if building is currently set to rank.
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|