Merge remote-tracking branch 'origin/magicbox1.5' into mob-AI-debug
# Conflicts: # src/engine/ai/MobileFSM.java
This commit is contained in:
@@ -55,7 +55,7 @@ public class Boon {
|
||||
|
||||
public static void HandleBoonListsForItemBase(int itemBaseID){
|
||||
ArrayList<Boon> boons = null;
|
||||
boons = DbManager.BoonQueries.GET_BOON_AMOUNTS_FOR_ITEMBASEUUID(itemBaseID);
|
||||
boons = DbManager.BoonQueries.GET_BOON_AMOUNTS_FOR_ITEMBASE(itemBaseID);
|
||||
if (boons != null)
|
||||
GetBoonsForItemBase.put(itemBaseID, boons);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import engine.workthreads.DestroyCityThread;
|
||||
import engine.workthreads.TransferCityThread;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -87,7 +86,7 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// Players who have entered the city (used for adding and removing affects)
|
||||
|
||||
private final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
public final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
|
||||
public volatile boolean protectionEnforced = true;
|
||||
private String hash;
|
||||
@@ -98,9 +97,9 @@ public class City extends AbstractWorldObject {
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
|
||||
public City(ResultSet rs) throws SQLException, UnknownHostException {
|
||||
public City(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
try{
|
||||
try {
|
||||
this.cityName = rs.getString("name");
|
||||
this.motto = rs.getString("motto");
|
||||
this.isNpc = rs.getByte("isNpc");
|
||||
@@ -746,33 +745,6 @@ public class City extends AbstractWorldObject {
|
||||
return open;
|
||||
}
|
||||
|
||||
public static void loadCities(Zone zone) {
|
||||
|
||||
ArrayList<City> cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID());
|
||||
|
||||
for (City city : cities) {
|
||||
|
||||
city.setParent(zone);
|
||||
city.setObjectTypeMask(MBServerStatics.MASK_CITY);
|
||||
city.setLoc(city.location);
|
||||
|
||||
//not player city, must be npc city..
|
||||
if (!zone.isPlayerCity())
|
||||
zone.setNPCCity(true);
|
||||
|
||||
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (city.hash == null)) {
|
||||
|
||||
city.setHash();
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateDatabase() {
|
||||
|
||||
@@ -138,8 +138,8 @@ public class Contract extends AbstractGameObject {
|
||||
|
||||
//Specify if trainer, merchant, banker, etc via classID
|
||||
private void setBools() {
|
||||
DbManager.ContractQueries.GET_GENERIC_INVENTORY(this);
|
||||
DbManager.ContractQueries.GET_SELL_LISTS(this);
|
||||
DbManager.ContractQueries.LOAD_CONTRACT_INVENTORY(this);
|
||||
DbManager.ContractQueries.LOAD_SELL_LIST_FOR_CONTRACT(this);
|
||||
|
||||
this.isTrainer = this.classID > 2499 && this.classID < 3050 || this.classID == 2028;
|
||||
|
||||
|
||||
@@ -210,14 +210,20 @@ public class Item extends AbstractWorldObject {
|
||||
this.durabilityCurrent = rs.getShort("item_durabilityCurrent");
|
||||
this.durabilityMax = rs.getShort("item_durabilityMax");
|
||||
|
||||
String ot = DbManager.ItemQueries.GET_OWNER(this.ownerID);
|
||||
DbObjectType ownerType;
|
||||
ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID);
|
||||
|
||||
if (ot.equals("character"))
|
||||
this.ownerType = OwnerType.PlayerCharacter;
|
||||
else if (ot.equals("npc"))
|
||||
this.ownerType = OwnerType.Npc;
|
||||
else if (ot.equals("account"))
|
||||
this.ownerType = OwnerType.Account;
|
||||
switch (ownerType) {
|
||||
case CHARACTER:
|
||||
this.ownerType = OwnerType.PlayerCharacter;
|
||||
break;
|
||||
case NPC:
|
||||
this.ownerType = OwnerType.Npc;
|
||||
break;
|
||||
case ACCOUNT:
|
||||
this.ownerType = OwnerType.Account;
|
||||
break;
|
||||
}
|
||||
|
||||
this.canDestroy = true;
|
||||
|
||||
@@ -1062,7 +1068,6 @@ public float getBonusPercent(ModType modType, SourceType sourceType) {
|
||||
this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ConcurrentHashMap<String, Integer> enchantList = DbManager.EnchantmentQueries.GET_ENCHANTMENTS_FOR_ITEM(this.getObjectUUID());
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
public City guardedCity;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
@@ -806,6 +807,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
mob.npcOwner = guardCaptain;
|
||||
mob.spawnTime = (int)(-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
||||
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
|
||||
mob.guardedCity = guardCaptain.guardedCity;
|
||||
mob.parentZone = parent;
|
||||
parent.zoneMobSet.add(mob);
|
||||
return mob;
|
||||
@@ -1990,6 +1992,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else {
|
||||
this.BehaviourType = MobBehaviourType.GuardCaptain;
|
||||
this.spawnTime = 900;
|
||||
this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc);
|
||||
}
|
||||
|
||||
this.deathTime = 0;
|
||||
|
||||
@@ -206,20 +206,8 @@ public class MobBase extends AbstractGameObject {
|
||||
return this.spawnTime;
|
||||
}
|
||||
|
||||
/*
|
||||
* Database
|
||||
*/
|
||||
public static MobBase getMobBase(int id) {
|
||||
return MobBase.getMobBase(id, false);
|
||||
}
|
||||
|
||||
public static MobBase getMobBase(int id, boolean forceDB) {
|
||||
return DbManager.MobBaseQueries.GET_MOBBASE(id, forceDB);
|
||||
}
|
||||
|
||||
|
||||
public static boolean renameMobBase(int ID, String newName) {
|
||||
return DbManager.MobBaseQueries.RENAME_MOBBASE(ID, newName);
|
||||
return DbManager.MobBaseQueries.GET_MOBBASE(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -72,7 +71,7 @@ public class Realm {
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public Realm(ResultSet rs) throws SQLException, UnknownHostException {
|
||||
public Realm(ResultSet rs) throws SQLException {
|
||||
|
||||
this.mapColor = new Color(Integer.parseInt(rs.getString("realmColor"), 16));
|
||||
this.mapR = (float) (mapColor.getRed() * 0.00392156863);
|
||||
|
||||
+115
-208
@@ -30,19 +30,25 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
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<>());
|
||||
private final int playerCityID;
|
||||
private final String zoneName;
|
||||
private final float xCoord;
|
||||
private final float zCoord;
|
||||
private final float yCoord;
|
||||
public float absX = 0.0f;
|
||||
public float absY = 0.0f;
|
||||
public float absZ = 0.0f;
|
||||
private final int loadNum;
|
||||
private final byte safeZone;
|
||||
private final String Icon1;
|
||||
private final String Icon2;
|
||||
private final String Icon3;
|
||||
public float absX = 0.0f;
|
||||
public float absY = 0.0f;
|
||||
public float absZ = 0.0f;
|
||||
public int minLvl;
|
||||
public int maxLvl;
|
||||
public boolean hasBeenHotzone = false;
|
||||
private ArrayList<Zone> nodes = null;
|
||||
private int parentZoneID;
|
||||
private Zone parent = null;
|
||||
@@ -50,16 +56,9 @@ public class Zone extends AbstractGameObject {
|
||||
private boolean isNPCCity = false;
|
||||
private boolean isPlayerCity = false;
|
||||
private String hash;
|
||||
public int minLvl;
|
||||
public int maxLvl;
|
||||
|
||||
private float worldAltitude = 0;
|
||||
|
||||
private float seaLevel = 0;
|
||||
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 boolean hasBeenHotzone = false;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -87,7 +86,7 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
this.setParent(parentZone);
|
||||
|
||||
if (this.minLvl == 0 && parentZone != null){
|
||||
if (this.minLvl == 0 && parentZone != null) {
|
||||
this.minLvl = parentZone.minLvl;
|
||||
this.maxLvl = parentZone.maxLvl;
|
||||
}
|
||||
@@ -99,8 +98,61 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
if (hash == null)
|
||||
setHash();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
|
||||
|
||||
if (zone.loadNum == 0 && zone.playerCityID == 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) {
|
||||
writer.put((byte) 1); // Player City - True
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||
} else
|
||||
writer.put((byte) 0); // Player City - False
|
||||
|
||||
writer.putFloat(zone.xCoord);
|
||||
writer.putFloat(zone.zCoord);
|
||||
writer.putFloat(zone.yCoord);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(zone.loadNum);
|
||||
|
||||
if (zone.playerCityID > 0) {
|
||||
City k = City.getCity(zone.playerCityID);
|
||||
|
||||
if (k != null) {
|
||||
writer.putInt(k.getObjectType().ordinal());
|
||||
writer.putInt(k.getObjectUUID());
|
||||
} else
|
||||
writer.putLong(0x0);
|
||||
} else {
|
||||
writer.putInt(zone.getObjectType().ordinal());
|
||||
writer.putInt(zone.getObjectUUID());
|
||||
}
|
||||
writer.putInt(zone.nodes.size());
|
||||
|
||||
City city = City.getCity(zone.playerCityID);
|
||||
|
||||
if (city != null)
|
||||
writer.putString(city.getCityName());
|
||||
else
|
||||
writer.putString(zone.zoneName);
|
||||
writer.put(zone.safeZone);
|
||||
writer.putString(zone.Icon1);
|
||||
writer.putString(zone.Icon2);
|
||||
writer.putString(zone.Icon3);
|
||||
writer.put((byte) 0); // Pad
|
||||
|
||||
for (Zone child : zone.nodes) {
|
||||
Zone.serializeForClientMsg(child, writer);
|
||||
}
|
||||
}
|
||||
|
||||
/* Method sets a default value for player cities
|
||||
@@ -123,38 +175,18 @@ public class Zone extends AbstractGameObject {
|
||||
return;
|
||||
}
|
||||
|
||||
// All other zones have bounding boxes loaded from database
|
||||
ResultSet rs = DbManager.ZoneQueries.GET_ZONE_EXTENTS(this.loadNum);
|
||||
boolean loaded = false;
|
||||
Vector2f zoneSize = ZoneManager._zone_size_data.get(this.loadNum);
|
||||
|
||||
if (rs != null)
|
||||
try {
|
||||
if (rs.next()) {
|
||||
halfExtentX = rs.getFloat("xRadius");
|
||||
halfExtentY = rs.getFloat("zRadius");
|
||||
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(halfExtentX, halfExtentY), 0.0f);
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error("SQLException: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
|
||||
// Default to Citygrid size on error
|
||||
// Default to player zone size on error? Maybe log this
|
||||
|
||||
if (zoneSize != null)
|
||||
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), zoneSize, 0.0f);
|
||||
else
|
||||
bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters
|
||||
*/
|
||||
public int getPlayerCityUUID() {
|
||||
if (this.playerCityID == 0)
|
||||
return 0;
|
||||
return this.playerCityID;
|
||||
}
|
||||
|
||||
@@ -178,10 +210,6 @@ public class Zone extends AbstractGameObject {
|
||||
return loadNum;
|
||||
}
|
||||
|
||||
public int getLoadNumClient() {
|
||||
return loadNum;
|
||||
}
|
||||
|
||||
public byte getSafeZone() {
|
||||
return safeZone;
|
||||
}
|
||||
@@ -190,45 +218,9 @@ public class Zone extends AbstractGameObject {
|
||||
return Icon1;
|
||||
}
|
||||
|
||||
public String getIcon2() {
|
||||
return Icon2;
|
||||
}
|
||||
public void generateWorldAltitude() {
|
||||
|
||||
public String getIcon3() {
|
||||
return Icon3;
|
||||
}
|
||||
|
||||
public void setParent(final Zone value) {
|
||||
|
||||
this.parent = value;
|
||||
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
||||
|
||||
if (this.parent != null) {
|
||||
this.absX = this.xCoord + parent.absX;
|
||||
this.absY = this.yCoord + parent.absY;
|
||||
this.absZ = this.zCoord + parent.absZ;
|
||||
|
||||
if (this.minLvl == 0 || this.maxLvl == 0){
|
||||
this.minLvl = this.parent.minLvl;
|
||||
this.maxLvl = this.parent.maxLvl;
|
||||
}
|
||||
} else { //only the Sea Floor zone does not have a parent
|
||||
this.absX = this.xCoord;
|
||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
this.absZ = this.zCoord;
|
||||
}
|
||||
|
||||
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
||||
this.setBounds();
|
||||
|
||||
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
||||
this.seaLevel = this.getHeightMap().getSeaLevel();
|
||||
|
||||
}
|
||||
|
||||
public void generateWorldAltitude(){
|
||||
|
||||
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()){
|
||||
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()) {
|
||||
this.worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
return;
|
||||
}
|
||||
@@ -240,9 +232,9 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
//seafloor only zone with null parent;
|
||||
|
||||
while(parentZone != ZoneManager.getSeaFloor()){
|
||||
while (parentZone != ZoneManager.getSeaFloor()) {
|
||||
|
||||
if(parentZone.getHeightMap() != null){
|
||||
if (parentZone.getHeightMap() != null) {
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone);
|
||||
altitude += parentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
@@ -258,14 +250,14 @@ public class Zone extends AbstractGameObject {
|
||||
if (ZoneManager.getSeaFloor().equals(this))
|
||||
this.seaLevel = 0;
|
||||
else if
|
||||
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0){
|
||||
this.seaLevel = this.parent.seaLevel;
|
||||
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0) {
|
||||
this.seaLevel = this.parent.seaLevel;
|
||||
|
||||
}else if (this.getHeightMap() != null){
|
||||
} else if (this.getHeightMap() != null) {
|
||||
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
|
||||
}else {
|
||||
this.seaLevel = this.parent.seaLevel;
|
||||
}
|
||||
} else {
|
||||
this.seaLevel = this.parent.seaLevel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -273,6 +265,34 @@ public class Zone extends AbstractGameObject {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public void setParent(final Zone value) {
|
||||
|
||||
this.parent = value;
|
||||
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
||||
|
||||
if (this.parent != null) {
|
||||
this.absX = this.xCoord + parent.absX;
|
||||
this.absY = this.yCoord + parent.absY;
|
||||
this.absZ = this.zCoord + parent.absZ;
|
||||
|
||||
if (this.minLvl == 0 || this.maxLvl == 0) {
|
||||
this.minLvl = this.parent.minLvl;
|
||||
this.maxLvl = this.parent.maxLvl;
|
||||
}
|
||||
} else { //only the Sea Floor zone does not have a parent
|
||||
this.absX = this.xCoord;
|
||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
this.absZ = this.zCoord;
|
||||
}
|
||||
|
||||
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
||||
this.setBounds();
|
||||
|
||||
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
||||
this.seaLevel = this.getHeightMap().getSeaLevel();
|
||||
|
||||
}
|
||||
|
||||
public float getAbsX() {
|
||||
return this.absX;
|
||||
}
|
||||
@@ -302,14 +322,14 @@ public class Zone extends AbstractGameObject {
|
||||
return this.isNPCCity;
|
||||
}
|
||||
|
||||
public boolean isPlayerCity() {
|
||||
return this.isPlayerCity;
|
||||
}
|
||||
|
||||
public void setNPCCity(boolean value) {
|
||||
this.isNPCCity = value;
|
||||
}
|
||||
|
||||
public boolean isPlayerCity() {
|
||||
return this.isPlayerCity;
|
||||
}
|
||||
|
||||
public void setPlayerCity(boolean value) {
|
||||
this.isPlayerCity = value;
|
||||
}
|
||||
@@ -336,71 +356,12 @@ public class Zone extends AbstractGameObject {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public void addNode(Zone child) {
|
||||
this.nodes.add(child);
|
||||
}
|
||||
|
||||
public void removeNode(Zone child) {
|
||||
this.nodes.remove(child);
|
||||
}
|
||||
|
||||
/*
|
||||
* Serializing
|
||||
*/
|
||||
|
||||
|
||||
public static void serializeForClientMsg(Zone zone,ByteBufferWriter writer) {
|
||||
|
||||
if (zone.loadNum == 0 && zone.playerCityID == 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) {
|
||||
writer.put((byte) 1); // Player City - True
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||
} else
|
||||
writer.put((byte) 0); // Player City - False
|
||||
|
||||
writer.putFloat(zone.xCoord);
|
||||
writer.putFloat(zone.zCoord);
|
||||
writer.putFloat(zone.yCoord);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(zone.loadNum);
|
||||
|
||||
if (zone.playerCityID > 0) {
|
||||
City k = City.getCity(zone.playerCityID);
|
||||
|
||||
if (k != null) {
|
||||
writer.putInt(k.getObjectType().ordinal());
|
||||
writer.putInt(k.getObjectUUID());
|
||||
}
|
||||
else
|
||||
writer.putLong(0x0);
|
||||
} else {
|
||||
writer.putInt(zone.getObjectType().ordinal());
|
||||
writer.putInt(zone.getObjectUUID());
|
||||
}
|
||||
writer.putInt(zone.nodes.size());
|
||||
|
||||
City city = City.getCity(zone.playerCityID);
|
||||
|
||||
if (city != null)
|
||||
writer.putString(city.getCityName());
|
||||
else
|
||||
writer.putString(zone.zoneName);
|
||||
writer.put(zone.safeZone);
|
||||
writer.putString(zone.Icon1);
|
||||
writer.putString(zone.Icon2);
|
||||
writer.putString(zone.Icon3);
|
||||
writer.put((byte) 0); // Pad
|
||||
|
||||
for (Zone child : zone.nodes) {
|
||||
Zone.serializeForClientMsg(child,writer);
|
||||
}
|
||||
public void addNode(Zone child) {
|
||||
this.nodes.add(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -408,60 +369,6 @@ public class Zone extends AbstractGameObject {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public Zone findRuinedCityZone(float centerX, float centerY, float centerZ){
|
||||
Bounds cityBounds;
|
||||
cityBounds = Bounds.borrow();
|
||||
Zone RuinedZone = null;
|
||||
cityBounds.setBounds(new Vector2f(centerX, centerZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f);
|
||||
Zone currentZone = ZoneManager.findSmallestZone(new Vector3fImmutable(centerX, centerY, centerZ));
|
||||
if (currentZone != null)
|
||||
if (this.getObjectUUID() == currentZone.getObjectUUID()){
|
||||
|
||||
if (currentZone.getPlayerCityUUID() != 0){
|
||||
//null player city? skip..
|
||||
if (City.GetCityFromCache(currentZone.getPlayerCityUUID()) == null)
|
||||
RuinedZone = null;
|
||||
else //no tol? skip...
|
||||
if (City.GetCityFromCache(currentZone.getPlayerCityUUID()).getTOL() == null)
|
||||
RuinedZone = null;
|
||||
else
|
||||
if (City.GetCityFromCache(currentZone.getPlayerCityUUID()).getTOL().getRank() == -1)
|
||||
RuinedZone = currentZone;
|
||||
//Dead tree? skip.
|
||||
cityBounds.release();
|
||||
return RuinedZone;
|
||||
}
|
||||
}
|
||||
|
||||
for (Zone zone : this.getNodes()) {
|
||||
|
||||
if (zone == this)
|
||||
continue;
|
||||
|
||||
if (zone.isContinent() && zone.getPlayerCityUUID() == 0)
|
||||
continue;
|
||||
|
||||
if (zone.getPlayerCityUUID() != 0){
|
||||
//null player city? skip..
|
||||
if (City.GetCityFromCache(zone.getPlayerCityUUID()) == null)
|
||||
continue;
|
||||
//no tol? skip...
|
||||
if (City.GetCityFromCache(zone.getPlayerCityUUID()).getTOL() == null)
|
||||
continue;
|
||||
|
||||
//Dead tree? skip.
|
||||
if (Bounds.collide(zone.bounds, cityBounds, 0.0f)){
|
||||
if (City.GetCityFromCache(zone.getPlayerCityUUID()).getTOL().getRank() == -1){
|
||||
RuinedZone = zone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cityBounds.release();
|
||||
return RuinedZone;
|
||||
}
|
||||
|
||||
public boolean isContinent() {
|
||||
|
||||
if (this.equals(ZoneManager.getSeaFloor()))
|
||||
@@ -500,7 +407,7 @@ public class Zone extends AbstractGameObject {
|
||||
// Return heightmap for this Zone.
|
||||
|
||||
public HeightMap getHeightMap() {
|
||||
|
||||
|
||||
if (this.isPlayerCity)
|
||||
return HeightMap.PlayerCityHeightMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user