forked from MagicBane/Server
Reformatted file.
This commit is contained in:
@@ -34,409 +34,405 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
*/
|
*/
|
||||||
public enum ZoneManager {
|
public enum ZoneManager {
|
||||||
|
|
||||||
ZONEMANAGER;
|
ZONEMANAGER;
|
||||||
|
|
||||||
/* Instance variables */
|
/* Instance variables */
|
||||||
private static Zone seaFloor = null;
|
private static Zone seaFloor = null;
|
||||||
private static Zone hotzone = null;
|
private static Zone hotzone = null;
|
||||||
private static ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
// Find all zones coordinates fit into, starting with Sea Floor
|
// Find all zones coordinates fit into, starting with Sea Floor
|
||||||
|
|
||||||
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
|
||||||
|
|
||||||
ArrayList<Zone> allIn = new ArrayList<>();
|
ArrayList<Zone> allIn = new ArrayList<>();
|
||||||
Zone zone;
|
Zone zone;
|
||||||
|
|
||||||
zone = ZoneManager.findSmallestZone(loc);
|
zone = ZoneManager.findSmallestZone(loc);
|
||||||
|
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
allIn.add(zone);
|
allIn.add(zone);
|
||||||
while (zone.getParent() != null) {
|
while (zone.getParent() != null) {
|
||||||
zone = zone.getParent();
|
zone = zone.getParent();
|
||||||
allIn.add(zone);
|
allIn.add(zone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allIn;
|
return allIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find smallest zone coordinates fit into.
|
// Find smallest zone coordinates fit into.
|
||||||
|
|
||||||
public static final Zone findSmallestZone(final Vector3fImmutable loc) {
|
public static final Zone findSmallestZone(final Vector3fImmutable loc) {
|
||||||
|
|
||||||
Zone zone = ZoneManager.seaFloor;
|
Zone zone = ZoneManager.seaFloor;
|
||||||
|
|
||||||
if (zone == null)
|
if (zone == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
boolean childFound = true;
|
boolean childFound = true;
|
||||||
|
|
||||||
while (childFound) {
|
while (childFound) {
|
||||||
|
|
||||||
childFound = false;
|
childFound = false;
|
||||||
|
|
||||||
ArrayList<Zone> nodes = zone.getNodes();
|
ArrayList<Zone> nodes = zone.getNodes();
|
||||||
|
|
||||||
// Logger.info("soze", "" + nodes.size());
|
// Logger.info("soze", "" + nodes.size());
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
for (Zone child : nodes) {
|
for (Zone child : nodes) {
|
||||||
|
|
||||||
if (Bounds.collide(loc, child.getBounds()) == true) {
|
if (Bounds.collide(loc, child.getBounds()) == true) {
|
||||||
zone = child;
|
zone = child;
|
||||||
childFound = true;
|
childFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zone;
|
return zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addZone(final int zoneID, final Zone zone) {
|
public static void addZone(final int zoneID, final Zone zone) {
|
||||||
|
|
||||||
ZoneManager.zonesByID.put(zoneID, zone);
|
ZoneManager.zonesByID.put(zoneID, zone);
|
||||||
|
|
||||||
if (zone != null)
|
if (zone != null)
|
||||||
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
||||||
|
|
||||||
ZoneManager.zonesByName.put(zone.getName().toLowerCase(), zone);
|
ZoneManager.zonesByName.put(zone.getName().toLowerCase(), zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Zone getZoneByUUID(final int zoneUUID) {
|
public static Zone getZoneByUUID(final int zoneUUID) {
|
||||||
return ZoneManager.zonesByUUID.get(zoneUUID);
|
return ZoneManager.zonesByUUID.get(zoneUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Zone getZoneByZoneID(final int zoneID) {
|
public static Zone getZoneByZoneID(final int zoneID) {
|
||||||
|
|
||||||
return ZoneManager.zonesByID.get(zoneID);
|
return ZoneManager.zonesByID.get(zoneID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Collection<Zone> getAllZones() {
|
public static final Collection<Zone> getAllZones() {
|
||||||
return ZoneManager.zonesByUUID.values();
|
return ZoneManager.zonesByUUID.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Zone getHotZone() {
|
public static final Zone getHotZone() {
|
||||||
return ZoneManager.hotzone;
|
return ZoneManager.hotzone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void setHotZone(final Zone zone) {
|
public static final void setHotZone(final Zone zone) {
|
||||||
if (!zone.isMacroZone())
|
if (!zone.isMacroZone())
|
||||||
return;
|
return;
|
||||||
ZoneManager.hotzone = zone;
|
ZoneManager.hotzone = zone;
|
||||||
zone.hasBeenHotzone = true;
|
zone.hasBeenHotzone = true;
|
||||||
zone.becameHotzone = LocalDateTime.now();
|
zone.becameHotzone = LocalDateTime.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inHotZone(final Vector3fImmutable loc) {
|
public static boolean inHotZone(final Vector3fImmutable loc) {
|
||||||
|
|
||||||
if (ZoneManager.hotzone == null)
|
if (ZoneManager.hotzone == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (Bounds.collide(loc, ZoneManager.hotzone.getBounds()) == true);
|
return (Bounds.collide(loc, ZoneManager.hotzone.getBounds()) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSeaFloor(final Zone value) {
|
public static void setSeaFloor(final Zone value) {
|
||||||
ZoneManager.seaFloor = value;
|
ZoneManager.seaFloor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Zone getSeaFloor() {
|
public static Zone getSeaFloor() {
|
||||||
return ZoneManager.seaFloor;
|
return ZoneManager.seaFloor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void populateWorldZones(final Zone zone) {
|
public static final void populateWorldZones(final Zone zone) {
|
||||||
|
|
||||||
int loadNum = zone.getLoadNum();
|
int loadNum = zone.getLoadNum();
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
||||||
if (zone.isMacroZone()) {
|
if (zone.isMacroZone()) {
|
||||||
addMacroZone(zone);
|
addMacroZone(zone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (zone.isPlayerCity()) {
|
if (zone.isPlayerCity()) {
|
||||||
addPlayerCityZone(zone);
|
addPlayerCityZone(zone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zone.isNPCCity())
|
if (zone.isNPCCity())
|
||||||
addNPCCityZone(zone);
|
addNPCCityZone(zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addMacroZone(final Zone zone) {
|
private static void addMacroZone(final Zone zone) {
|
||||||
ZoneManager.macroZones.add(zone);
|
ZoneManager.macroZones.add(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addNPCCityZone(final Zone zone) {
|
private static void addNPCCityZone(final Zone zone) {
|
||||||
zone.setNPCCity(true);
|
zone.setNPCCity(true);
|
||||||
ZoneManager.npcCityZones.add(zone);
|
ZoneManager.npcCityZones.add(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void addPlayerCityZone(final Zone zone) {
|
public static final void addPlayerCityZone(final Zone zone) {
|
||||||
zone.setPlayerCity(true);
|
zone.setPlayerCity(true);
|
||||||
ZoneManager.playerCityZones.add(zone);
|
ZoneManager.playerCityZones.add(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void generateAndSetRandomHotzone() {
|
public static final void generateAndSetRandomHotzone() {
|
||||||
|
|
||||||
Zone hotzone;
|
Zone hotzone;
|
||||||
ArrayList<Integer> zoneArray = new ArrayList<>();
|
ArrayList<Integer> zoneArray = new ArrayList<>();
|
||||||
|
|
||||||
if (ZoneManager.macroZones.isEmpty())
|
if (ZoneManager.macroZones.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Zone zone : ZoneManager.macroZones) {
|
for (Zone zone : ZoneManager.macroZones) {
|
||||||
|
|
||||||
if (validHotZone(zone))
|
if (validHotZone(zone))
|
||||||
zoneArray.add(zone.getObjectUUID());
|
zoneArray.add(zone.getObjectUUID());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int entryIndex = ThreadLocalRandom.current().nextInt(zoneArray.size());
|
int entryIndex = ThreadLocalRandom.current().nextInt(zoneArray.size());
|
||||||
|
|
||||||
hotzone = ZoneManager.getZoneByUUID(zoneArray.get(entryIndex));
|
hotzone = ZoneManager.getZoneByUUID(zoneArray.get(entryIndex));
|
||||||
|
|
||||||
|
|
||||||
if (hotzone == null){
|
if (hotzone == null) {
|
||||||
Logger.error( "Hotzone is null");
|
Logger.error("Hotzone is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZoneManager.setHotZone(hotzone);
|
ZoneManager.setHotZone(hotzone);
|
||||||
WorldServer.setLastHZChange(System.currentTimeMillis());
|
WorldServer.setLastHZChange(System.currentTimeMillis());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final boolean validHotZone(Zone zone) {
|
public static final boolean validHotZone(Zone zone) {
|
||||||
|
|
||||||
if (zone.getSafeZone() == (byte) 1)
|
if (zone.getSafeZone() == (byte) 1)
|
||||||
return false; // no safe zone hotzones// if (this.hotzone == null)
|
return false; // no safe zone hotzones// if (this.hotzone == null)
|
||||||
|
|
||||||
if (zone.getNodes().isEmpty())
|
if (zone.getNodes().isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (zone.equals(ZoneManager.seaFloor))
|
if (zone.equals(ZoneManager.seaFloor))
|
||||||
return false;
|
return false;
|
||||||
//no duplicate hotzones
|
//no duplicate hotzones
|
||||||
if(zone.hasBeenHotzone == true){
|
if (zone.hasBeenHotzone == true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// return false; //first time setting, accept it
|
// return false; //first time setting, accept it
|
||||||
// if (this.hotzone.getUUID() == zone.getUUID())
|
// if (this.hotzone.getUUID() == zone.getUUID())
|
||||||
// return true; //no same hotzone
|
// return true; //no same hotzone
|
||||||
|
|
||||||
if (ZoneManager.hotzone != null)
|
if (ZoneManager.hotzone != null)
|
||||||
return ZoneManager.hotzone.getObjectUUID() != zone.getObjectUUID();
|
return ZoneManager.hotzone.getObjectUUID() != zone.getObjectUUID();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a MacroZone by name.
|
* Gets a MacroZone by name.
|
||||||
*
|
*
|
||||||
* @param inputName
|
* @param inputName MacroZone name to search for
|
||||||
* MacroZone name to search for
|
* @return Zone of the MacroZone, or Null
|
||||||
* @return Zone of the MacroZone, or Null
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
public static Zone findMacroZoneByName(String inputName) {
|
public static Zone findMacroZoneByName(String inputName) {
|
||||||
synchronized (ZoneManager.macroZones) {
|
synchronized (ZoneManager.macroZones) {
|
||||||
for (Zone zone : ZoneManager.macroZones) {
|
for (Zone zone : ZoneManager.macroZones) {
|
||||||
String zoneName = zone.getName();
|
String zoneName = zone.getName();
|
||||||
if (zoneName.equalsIgnoreCase(inputName))
|
if (zoneName.equalsIgnoreCase(inputName))
|
||||||
return zone;
|
return zone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts world coordinates to coordinates local to a given zone.
|
// Converts world coordinates to coordinates local to a given zone.
|
||||||
|
|
||||||
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
||||||
Zone serverZone) {
|
Zone serverZone) {
|
||||||
|
|
||||||
Vector3fImmutable localCoords;
|
Vector3fImmutable localCoords;
|
||||||
|
|
||||||
localCoords = new Vector3fImmutable(worldVector.x - serverZone.absX,
|
localCoords = new Vector3fImmutable(worldVector.x - serverZone.absX,
|
||||||
worldVector.y - serverZone.absY, worldVector.z
|
worldVector.y - serverZone.absY, worldVector.z
|
||||||
- serverZone.absZ);
|
- serverZone.absZ);
|
||||||
|
|
||||||
return localCoords;
|
return localCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2f worldToZoneSpace(Vector3fImmutable worldVector,
|
public static Vector2f worldToZoneSpace(Vector3fImmutable worldVector,
|
||||||
Zone serverZone) {
|
Zone serverZone) {
|
||||||
|
|
||||||
Vector2f localCoords;
|
Vector2f localCoords;
|
||||||
Vector2f zoneOrigin;
|
Vector2f zoneOrigin;
|
||||||
|
|
||||||
// Top left corner of zone is calculated in world space by the center and it's extents.
|
// Top left corner of zone is calculated in world space by the center and it's extents.
|
||||||
|
|
||||||
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
||||||
zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.getBounds().getHalfExtents().x, serverZone.getBounds().getHalfExtents().y));
|
zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.getBounds().getHalfExtents().x, serverZone.getBounds().getHalfExtents().y));
|
||||||
|
|
||||||
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
||||||
|
|
||||||
localCoords = new Vector2f(worldVector.x, worldVector.z);
|
localCoords = new Vector2f(worldVector.x, worldVector.z);
|
||||||
localCoords = localCoords.subtract(zoneOrigin);
|
localCoords = localCoords.subtract(zoneOrigin);
|
||||||
|
|
||||||
localCoords.setY((serverZone.getBounds().getHalfExtents().y * 2) - localCoords.y);
|
localCoords.setY((serverZone.getBounds().getHalfExtents().y * 2) - localCoords.y);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO : Make sure this value does not go outside the zone's bounds.
|
||||||
|
|
||||||
|
return localCoords;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO : Make sure this value does not go outside the zone's bounds.
|
// Converts local zone coordinates to world coordinates
|
||||||
|
|
||||||
return localCoords;
|
public static Vector3fImmutable localToWorld(Vector3fImmutable worldVector,
|
||||||
}
|
Zone serverZone) {
|
||||||
|
|
||||||
// Converts local zone coordinates to world coordinates
|
Vector3fImmutable worldCoords;
|
||||||
|
|
||||||
public static Vector3fImmutable localToWorld(Vector3fImmutable worldVector,
|
worldCoords = new Vector3fImmutable(worldVector.x + serverZone.absX,
|
||||||
Zone serverZone) {
|
worldVector.y + serverZone.absY, worldVector.z
|
||||||
|
+ serverZone.absZ);
|
||||||
|
|
||||||
Vector3fImmutable worldCoords;
|
return worldCoords;
|
||||||
|
}
|
||||||
|
|
||||||
worldCoords = new Vector3fImmutable(worldVector.x + serverZone.absX,
|
|
||||||
worldVector.y + serverZone.absY, worldVector.z
|
|
||||||
+ serverZone.absZ);
|
|
||||||
|
|
||||||
return worldCoords;
|
/**
|
||||||
}
|
* Converts from local (relative to this building) to world.
|
||||||
|
*
|
||||||
|
* @param localPos position in local reference (relative to this building)
|
||||||
|
* @return position relative to world
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static Vector3fImmutable convertLocalToWorld(Building building, Vector3fImmutable localPos) {
|
||||||
|
|
||||||
/**
|
// convert from SB rotation value to radians
|
||||||
* Converts from local (relative to this building) to world.
|
|
||||||
*
|
|
||||||
* @param localPos position in local reference (relative to this building)
|
|
||||||
* @return position relative to world
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static Vector3fImmutable convertLocalToWorld(Building building, Vector3fImmutable localPos) {
|
|
||||||
|
|
||||||
// convert from SB rotation value to radians
|
if (building.getBounds().getQuaternion() == null)
|
||||||
|
return building.getLoc();
|
||||||
|
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
|
||||||
if (building.getBounds().getQuaternion() == null)
|
// handle building rotation
|
||||||
return building.getLoc();
|
// handle building translation
|
||||||
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
|
|
||||||
// handle building rotation
|
|
||||||
// handle building translation
|
|
||||||
|
|
||||||
return building.getLoc().add(rotatedLocal.x, rotatedLocal.y,rotatedLocal.z);
|
return building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//used for regions, Building bounds not set yet.
|
|
||||||
public static Vector3f convertLocalToWorld(Building building, Vector3f localPos, Bounds bounds) {
|
|
||||||
|
|
||||||
// convert from SB rotation value to radians
|
|
||||||
|
|
||||||
|
|
||||||
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
|
|
||||||
// handle building rotation
|
|
||||||
// handle building translation
|
|
||||||
|
|
||||||
return new Vector3f(building.getLoc().add(rotatedLocal.x, rotatedLocal.y,rotatedLocal.z));
|
//used for regions, Building bounds not set yet.
|
||||||
}
|
public static Vector3f convertLocalToWorld(Building building, Vector3f localPos, Bounds bounds) {
|
||||||
|
|
||||||
public static Vector3fImmutable convertWorldToLocal(Building building, Vector3fImmutable WorldPos) {
|
// convert from SB rotation value to radians
|
||||||
Vector3fImmutable convertLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(),WorldPos,-building.getBounds().getQuaternion().angleY);
|
|
||||||
|
|
||||||
|
|
||||||
convertLoc = convertLoc.subtract(building.getLoc());
|
|
||||||
|
|
||||||
// convert from SB rotation value to radians
|
|
||||||
|
|
||||||
return convertLoc;
|
|
||||||
|
|
||||||
}
|
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
|
||||||
|
// handle building rotation
|
||||||
|
// handle building translation
|
||||||
|
|
||||||
public static Vector3fImmutable convertNPCLoc(Building building, Vector3fImmutable npcLoc) {
|
return new Vector3f(building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z));
|
||||||
|
}
|
||||||
|
|
||||||
return Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, npcLoc, -building.getBounds().getQuaternion().angleY);
|
public static Vector3fImmutable convertWorldToLocal(Building building, Vector3fImmutable WorldPos) {
|
||||||
|
Vector3fImmutable convertLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), WorldPos, -building.getBounds().getQuaternion().angleY);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method returns a city if the given location is within
|
convertLoc = convertLoc.subtract(building.getLoc());
|
||||||
// a city siege radius.
|
|
||||||
|
|
||||||
public static City getCityAtLocation(Vector3fImmutable worldLoc) {
|
// convert from SB rotation value to radians
|
||||||
|
|
||||||
Zone currentZone;
|
return convertLoc;
|
||||||
ArrayList<Zone> zoneList;
|
|
||||||
City city;
|
|
||||||
|
|
||||||
currentZone = ZoneManager.findSmallestZone(worldLoc);
|
}
|
||||||
|
|
||||||
if (currentZone.isPlayerCity())
|
public static Vector3fImmutable convertNPCLoc(Building building, Vector3fImmutable npcLoc) {
|
||||||
return City.getCity(currentZone.getPlayerCityUUID());
|
|
||||||
|
|
||||||
// Not currently on a city grid. Test nearby cities
|
return Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, npcLoc, -building.getBounds().getQuaternion().angleY);
|
||||||
// to see if we are on one of their seige bounds.
|
|
||||||
|
|
||||||
zoneList = currentZone.getNodes();
|
}
|
||||||
|
|
||||||
for (Zone zone : zoneList) {
|
// Method returns a city if the given location is within
|
||||||
|
// a city siege radius.
|
||||||
|
|
||||||
if (zone == currentZone)
|
public static City getCityAtLocation(Vector3fImmutable worldLoc) {
|
||||||
continue;
|
|
||||||
|
|
||||||
if (zone.isPlayerCity() == false)
|
Zone currentZone;
|
||||||
continue;
|
ArrayList<Zone> zoneList;
|
||||||
|
City city;
|
||||||
|
|
||||||
city = City.getCity(zone.getPlayerCityUUID());
|
currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||||
|
|
||||||
if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.SIEGE.extents))
|
if (currentZone.isPlayerCity())
|
||||||
return city;
|
return City.getCity(currentZone.getPlayerCityUUID());
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
// Not currently on a city grid. Test nearby cities
|
||||||
}
|
// to see if we are on one of their seige bounds.
|
||||||
|
|
||||||
/* Method is called when creating a new player city to
|
zoneList = currentZone.getNodes();
|
||||||
* validate that the new zone does not overlap any other
|
|
||||||
* zone that might currently exist
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static boolean validTreePlacementLoc(Zone currentZone, float positionX, float positionZ) {
|
for (Zone zone : zoneList) {
|
||||||
|
|
||||||
// Member Variable declaration
|
if (zone == currentZone)
|
||||||
|
continue;
|
||||||
|
|
||||||
ArrayList<Zone> zoneList;
|
if (zone.isPlayerCity() == false)
|
||||||
boolean validLocation = true;
|
continue;
|
||||||
Bounds treeBounds;
|
|
||||||
|
|
||||||
if (currentZone.isContininent() == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
treeBounds = Bounds.borrow();
|
|
||||||
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.SIEGE.extents, Enum.CityBoundsType.SIEGE.extents), 0.0f);
|
|
||||||
|
|
||||||
zoneList = currentZone.getNodes();
|
city = City.getCity(zone.getPlayerCityUUID());
|
||||||
|
|
||||||
|
if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.SIEGE.extents))
|
||||||
|
return city;
|
||||||
for (Zone zone : zoneList) {
|
}
|
||||||
|
|
||||||
if (zone.isContininent())
|
return null;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (Bounds.collide(treeBounds, zone.getBounds(), 0.0f))
|
/* Method is called when creating a new player city to
|
||||||
validLocation = false;
|
* validate that the new zone does not overlap any other
|
||||||
}
|
* zone that might currently exist
|
||||||
|
*/
|
||||||
|
|
||||||
treeBounds.release();
|
public static boolean validTreePlacementLoc(Zone currentZone, float positionX, float positionZ) {
|
||||||
return validLocation;
|
|
||||||
|
// Member Variable declaration
|
||||||
|
|
||||||
|
ArrayList<Zone> zoneList;
|
||||||
|
boolean validLocation = true;
|
||||||
|
Bounds treeBounds;
|
||||||
|
|
||||||
|
if (currentZone.isContininent() == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
treeBounds = Bounds.borrow();
|
||||||
|
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.SIEGE.extents, Enum.CityBoundsType.SIEGE.extents), 0.0f);
|
||||||
|
|
||||||
|
zoneList = currentZone.getNodes();
|
||||||
|
|
||||||
|
|
||||||
|
for (Zone zone : zoneList) {
|
||||||
|
|
||||||
|
if (zone.isContininent())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Bounds.collide(treeBounds, zone.getBounds(), 0.0f))
|
||||||
|
validLocation = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
treeBounds.release();
|
||||||
|
return validLocation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ public enum Protocol {
|
|||||||
ACTIVATECHARTER(0x296C0B22, UseCharterMsg.class, null),// Use Guild Charter
|
ACTIVATECHARTER(0x296C0B22, UseCharterMsg.class, null),// Use Guild Charter
|
||||||
ACTIVATENPC(0xC9AAE81E, ActivateNPCMessage.class, ActivateNPCMsgHandler.class),
|
ACTIVATENPC(0xC9AAE81E, ActivateNPCMessage.class, ActivateNPCMsgHandler.class),
|
||||||
ACTIVATEPLEDGE(0x5A694DC0, SwearInMsg.class, SwearInHandler.class), // Swear In
|
ACTIVATEPLEDGE(0x5A694DC0, SwearInMsg.class, SwearInHandler.class), // Swear In
|
||||||
ADDFRIEND(0xCFA1C787,AddFriendMessage.class,null),
|
ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null),
|
||||||
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
|
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
|
||||||
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class),
|
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class),
|
||||||
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, null), // Attack From Outside Combat Mode
|
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, null), // Attack From Outside Combat Mode
|
||||||
ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
|
ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
|
||||||
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
|
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
|
||||||
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
|
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
|
||||||
ARCMINECHANGEPRODUCTION(0x1EAA993F, ArcMineChangeProductionMsg.class, ArcMineChangeProductionMsgHandler.class),
|
ARCMINECHANGEPRODUCTION(0x1EAA993F, ArcMineChangeProductionMsg.class, ArcMineChangeProductionMsgHandler.class),
|
||||||
ARCMINETOWERCRESTUPDATE(0x34164D0D, null, null),
|
ARCMINETOWERCRESTUPDATE(0x34164D0D, null, null),
|
||||||
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
|
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
|
||||||
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
|
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
|
||||||
@@ -62,7 +62,7 @@ public enum Protocol {
|
|||||||
CHANNELMUTE(0xC1BDC53A, ChatFilterMsg.class, ChannelMuteMsgHandler.class), //Chat Channels that are turned on
|
CHANNELMUTE(0xC1BDC53A, ChatFilterMsg.class, ChannelMuteMsgHandler.class), //Chat Channels that are turned on
|
||||||
CHARSELECTSCREEN(0x682C935D, null, null), // Character Selection Screen
|
CHARSELECTSCREEN(0x682C935D, null, null), // Character Selection Screen
|
||||||
CHATCITY(0x9D402901, ChatCityMsg.class, null), // Chat Channel: /City
|
CHATCITY(0x9D402901, ChatCityMsg.class, null), // Chat Channel: /City
|
||||||
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, null), //Chat Channel: CSR
|
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, null), //Chat Channel: CSR
|
||||||
CHATGROUP(0xA895B634, ChatGroupMsg.class, null), // Chat Channel: /group
|
CHATGROUP(0xA895B634, ChatGroupMsg.class, null), // Chat Channel: /group
|
||||||
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, null), // Chat Channel: /guild
|
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, null), // Chat Channel: /guild
|
||||||
CHATIC(0x00A75F35, ChatICMsg.class, null), // Chat Channel: /IC
|
CHATIC(0x00A75F35, ChatICMsg.class, null), // Chat Channel: /IC
|
||||||
@@ -78,13 +78,13 @@ public enum Protocol {
|
|||||||
CITYZONE(0x254947F2, CityZoneMsg.class, null), //For Creating City Object Clientside(Terraform)/Rename City.
|
CITYZONE(0x254947F2, CityZoneMsg.class, null), //For Creating City Object Clientside(Terraform)/Rename City.
|
||||||
CLAIMASSET(0x948C62CC, ClaimAssetMsg.class, ClaimAssetMsgHandler.class), // ClaimAsset
|
CLAIMASSET(0x948C62CC, ClaimAssetMsg.class, ClaimAssetMsgHandler.class), // ClaimAsset
|
||||||
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
|
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
|
||||||
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, null), //Admin Command
|
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, null), //Admin Command
|
||||||
CLIENTUPDATEVAULT( 0x66EDBECD, UpdateVaultMsg.class, null),
|
CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null),
|
||||||
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, null), //Toggle Combat mode
|
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, null), //Toggle Combat mode
|
||||||
CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
|
CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
|
||||||
COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened
|
COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened
|
||||||
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
||||||
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
||||||
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, null),
|
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, null),
|
||||||
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, null), //Delete Item from Inventory
|
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, null), //Delete Item from Inventory
|
||||||
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
||||||
@@ -95,8 +95,8 @@ public enum Protocol {
|
|||||||
EQUIP(0x3CB1AF8C, TransferItemFromInventoryToEquipMsg.class, null), // Transfer Item from Inventory to Equip
|
EQUIP(0x3CB1AF8C, TransferItemFromInventoryToEquipMsg.class, null), // Transfer Item from Inventory to Equip
|
||||||
EXPERIENCE(0xC57802A7, GrantExperienceMsg.class, null), //TODO rename once identified
|
EXPERIENCE(0xC57802A7, GrantExperienceMsg.class, null), //TODO rename once identified
|
||||||
FORGETOBJECTS(0xE307A0E1, UnloadObjectsMsg.class, null), // Unload Objects
|
FORGETOBJECTS(0xE307A0E1, UnloadObjectsMsg.class, null), // Unload Objects
|
||||||
FRIENDACCEPT(0xCA297870,AcceptFriendMsg.class,FriendAcceptHandler.class),
|
FRIENDACCEPT(0xCA297870, AcceptFriendMsg.class, FriendAcceptHandler.class),
|
||||||
FRIENDDECLINE(0xF08FC279,DeclineFriendMsg.class,FriendDeclineHandler.class),
|
FRIENDDECLINE(0xF08FC279, DeclineFriendMsg.class, FriendDeclineHandler.class),
|
||||||
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
|
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
|
||||||
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
|
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
|
||||||
GLOBALCHANNELMESSAGE(0x2bf03fd2, null, null),
|
GLOBALCHANNELMESSAGE(0x2bf03fd2, null, null),
|
||||||
@@ -109,7 +109,7 @@ public enum Protocol {
|
|||||||
GUILDMEMBERONLINE(0x7B79EB3A, GuildEnterWorldMsg.class, null), // Send Enter World Message to Guild
|
GUILDMEMBERONLINE(0x7B79EB3A, GuildEnterWorldMsg.class, null), // Send Enter World Message to Guild
|
||||||
GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank
|
GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank
|
||||||
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, null),
|
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, null),
|
||||||
HIRELINGSERVICE(0xD3D93322,HirelingServiceMsg.class,HirelingServiceMsgHandler.class),
|
HIRELINGSERVICE(0xD3D93322, HirelingServiceMsg.class, HirelingServiceMsgHandler.class),
|
||||||
IGNORE(0xBD8881EE, IgnoreMsg.class, null), //client sent /ignore command
|
IGNORE(0xBD8881EE, IgnoreMsg.class, null), //client sent /ignore command
|
||||||
INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window
|
INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window
|
||||||
INVITEGROUP(0x004A2012, GroupInviteMsg.class, GroupInviteHandler.class), // Send/Receive/Deny Group Invite
|
INVITEGROUP(0x004A2012, GroupInviteMsg.class, GroupInviteHandler.class), // Send/Receive/Deny Group Invite
|
||||||
@@ -164,11 +164,11 @@ public enum Protocol {
|
|||||||
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, null), // Modify Stat
|
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, null), // Modify Stat
|
||||||
RANDOM(0xAC5D0135, RandomMsg.class, null), //RequestSend random roll
|
RANDOM(0xAC5D0135, RandomMsg.class, null), //RequestSend random roll
|
||||||
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
|
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
|
||||||
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)
|
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)
|
||||||
RECOMMENDNATION(0x6D4579E9, RecommendNationMsg.class, RecommendNationMsgHandler.class), // Recommend as Ally/Enemy, error
|
RECOMMENDNATION(0x6D4579E9, RecommendNationMsg.class, RecommendNationMsgHandler.class), // Recommend as Ally/Enemy, error
|
||||||
RECYCLEPOWER(0x24033B67, RecyclePowerMsg.class, null), //Unlock power for reUse
|
RECYCLEPOWER(0x24033B67, RecyclePowerMsg.class, null), //Unlock power for reUse
|
||||||
REMOVECHAR(0x5D3F9739, DeleteCharacterMsg.class, null), // Delete Character
|
REMOVECHAR(0x5D3F9739, DeleteCharacterMsg.class, null), // Delete Character
|
||||||
REMOVEFRIEND(0xE0D5DB42,RemoveFriendMessage.class,RemoveFriendHandler.class),
|
REMOVEFRIEND(0xE0D5DB42, RemoveFriendMessage.class, RemoveFriendHandler.class),
|
||||||
REPAIRBUILDING(0xAF8C2560, RepairBuildingMsg.class, RepairBuildingMsgHandler.class),
|
REPAIRBUILDING(0xAF8C2560, RepairBuildingMsg.class, RepairBuildingMsgHandler.class),
|
||||||
REPAIROBJECT(0x782219CE, RepairMsg.class, null), //Repair Window Req/Ack, RepairObject item Req/Ack
|
REPAIROBJECT(0x782219CE, RepairMsg.class, null), //Repair Window Req/Ack, RepairObject item Req/Ack
|
||||||
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, null), // MoveObjectToContainer Window Request
|
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, null), // MoveObjectToContainer Window Request
|
||||||
@@ -179,7 +179,7 @@ public enum Protocol {
|
|||||||
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, null), // Trade Request
|
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, null), // Trade Request
|
||||||
REQUESTTRADECANCEL(0xCB0C5735, RejectTradeRequestMsg.class, null), // Reject RequestToTrade
|
REQUESTTRADECANCEL(0xCB0C5735, RejectTradeRequestMsg.class, null), // Reject RequestToTrade
|
||||||
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, null), // Accept Trade Request
|
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, null), // Accept Trade Request
|
||||||
RESETAFTERDEATH(0xFDCBB98F,RespawnMsg.class, null), //Respawn Request/Response
|
RESETAFTERDEATH(0xFDCBB98F, RespawnMsg.class, null), //Respawn Request/Response
|
||||||
ROTATEMSG(0x57F2088E, RotateObjectMsg.class, null),
|
ROTATEMSG(0x57F2088E, RotateObjectMsg.class, null),
|
||||||
SAFEMODE(0x9CF3922A, SafeModeMsg.class, null), //Tell client they're in safe mode
|
SAFEMODE(0x9CF3922A, SafeModeMsg.class, null), //Tell client they're in safe mode
|
||||||
SCALEOBJECT(0xE2B392D9, null, null), // Adjust scale of object
|
SCALEOBJECT(0xE2B392D9, null, null), // Adjust scale of object
|
||||||
@@ -210,7 +210,7 @@ public enum Protocol {
|
|||||||
TAXCITY(0xCD41EAA6, TaxCityMsg.class, TaxCityMsgHandler.class),
|
TAXCITY(0xCD41EAA6, TaxCityMsg.class, TaxCityMsgHandler.class),
|
||||||
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
|
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
|
||||||
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
|
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
|
||||||
TERRITORYCHANGE(0x6B388C8C,TerritoryChangeMessage.class, null), //Hey rich, look what I found? :)
|
TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :)
|
||||||
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, null), //Toggle Sit/Stand
|
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, null), //Toggle Sit/Stand
|
||||||
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window
|
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window
|
||||||
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window
|
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window
|
||||||
@@ -227,7 +227,7 @@ public enum Protocol {
|
|||||||
TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory
|
TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory
|
||||||
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemFromInventoryToBankMsg.class, null), // Transfer Item from Inventory to Bank
|
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemFromInventoryToBankMsg.class, null), // Transfer Item from Inventory to Bank
|
||||||
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, null), // Transfer Item from Equip to Inventory
|
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, null), // Transfer Item from Equip to Inventory
|
||||||
UNKNOWN(0x238C9259, UnknownMsg.class,null),
|
UNKNOWN(0x238C9259, UnknownMsg.class, null),
|
||||||
UPDATECHARORMOB(0xB6D78961, null, null),
|
UPDATECHARORMOB(0xB6D78961, null, null),
|
||||||
UPDATECLIENTALLIANCES(0xF3FEB5D4, null, GuildUnknownHandler.class), //AlliancesMsg
|
UPDATECLIENTALLIANCES(0xF3FEB5D4, null, GuildUnknownHandler.class), //AlliancesMsg
|
||||||
UPDATECLIENTINVENTORIES(0xE66F533D, UpdateInventoryMsg.class, null), //Update player inventory
|
UPDATECLIENTINVENTORIES(0xE66F533D, UpdateInventoryMsg.class, null), //Update player inventory
|
||||||
@@ -247,14 +247,14 @@ public enum Protocol {
|
|||||||
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response
|
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response
|
||||||
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, null), // Request /who
|
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, null), // Request /who
|
||||||
WHORESPONSE(0xD7C36568, WhoResponseMsg.class, null), // Response /who
|
WHORESPONSE(0xD7C36568, WhoResponseMsg.class, null), // Response /who
|
||||||
REQUESTBALLLIST(0xE366FF64,RequestBallListMessage.class,RequestBallListHandler.class),
|
REQUESTBALLLIST(0xE366FF64, RequestBallListMessage.class, RequestBallListHandler.class),
|
||||||
SENDBALLENTRY(0xAC2B5EDC,SendBallEntryMessage.class,SendBallEntryHandler.class),
|
SENDBALLENTRY(0xAC2B5EDC, SendBallEntryMessage.class, SendBallEntryHandler.class),
|
||||||
UNKNOWN1(-263523523, Unknown1Msg.class,null),
|
UNKNOWN1(-263523523, Unknown1Msg.class, null),
|
||||||
DROPGOLD(1461654160,DropGoldMsg.class,null);
|
DROPGOLD(1461654160, DropGoldMsg.class, null);
|
||||||
|
|
||||||
public int opcode;
|
public int opcode;
|
||||||
private Class message;
|
private final Class message;
|
||||||
private Class handlerClass;
|
private final Class handlerClass;
|
||||||
public Constructor constructor;
|
public Constructor constructor;
|
||||||
public AbstractClientMsgHandler handler;
|
public AbstractClientMsgHandler handler;
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ public enum Protocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create instance of message handler for incoming protocol messages
|
// Create instance of message handler for incoming protocol messages
|
||||||
|
|
||||||
if (this.handlerClass != null) {
|
if (this.handlerClass != null) {
|
||||||
try {
|
try {
|
||||||
@@ -286,7 +286,7 @@ public enum Protocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<Integer, Protocol> _protocolMsgByOpcode = new HashMap<>();
|
private static final HashMap<Integer, Protocol> _protocolMsgByOpcode = new HashMap<>();
|
||||||
|
|
||||||
public static Protocol getByOpcode(int opcode) {
|
public static Protocol getByOpcode(int opcode) {
|
||||||
|
|
||||||
@@ -302,37 +302,37 @@ public enum Protocol {
|
|||||||
|
|
||||||
for (Protocol protocol : Protocol.values()) {
|
for (Protocol protocol : Protocol.values()) {
|
||||||
|
|
||||||
if (_protocolMsgByOpcode.containsKey(protocol.opcode)){
|
if (_protocolMsgByOpcode.containsKey(protocol.opcode)) {
|
||||||
Logger.error("Duplicate opcodes for " + protocol.name() + " and " + _protocolMsgByOpcode.get(protocol.opcode).name());
|
Logger.error("Duplicate opcodes for " + protocol.name() + " and " + _protocolMsgByOpcode.get(protocol.opcode).name());
|
||||||
}
|
}
|
||||||
_protocolMsgByOpcode.put(protocol.opcode, protocol);
|
_protocolMsgByOpcode.put(protocol.opcode, protocol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int FindNextValidOpcode(ByteBufferReader reader){
|
public static int FindNextValidOpcode(ByteBufferReader reader) {
|
||||||
int startPos = reader.position();
|
int startPos = reader.position();
|
||||||
int bytesLeft = reader.remaining();
|
int bytesLeft = reader.remaining();
|
||||||
|
|
||||||
|
if (bytesLeft < 4)
|
||||||
|
return startPos;
|
||||||
|
int nextPos = startPos;
|
||||||
|
for (int i = 1; i < bytesLeft; i++) {
|
||||||
|
reader.position(nextPos);
|
||||||
|
if (reader.remaining() < 4)
|
||||||
|
return reader.position();
|
||||||
|
int newOpcode = reader.getInt();
|
||||||
|
|
||||||
|
Protocol foundProtocol = Protocol.getByOpcode(newOpcode);
|
||||||
|
if (foundProtocol.equals(Protocol.NONE)) {
|
||||||
|
nextPos += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//found opcode. return position - 4 to rewind back to start of opcode, so we can handle it.
|
||||||
|
return reader.position() - 4;
|
||||||
|
}
|
||||||
|
|
||||||
if (bytesLeft < 4)
|
|
||||||
return startPos;
|
return startPos;
|
||||||
int nextPos = startPos;
|
|
||||||
for (int i = 1; i< bytesLeft; i++ ){
|
|
||||||
reader.position(nextPos);
|
|
||||||
if (reader.remaining() < 4)
|
|
||||||
return reader.position();
|
|
||||||
int newOpcode = reader.getInt();
|
|
||||||
|
|
||||||
Protocol foundProtocol = Protocol.getByOpcode(newOpcode);
|
|
||||||
if (foundProtocol.equals(Protocol.NONE)){
|
|
||||||
nextPos += 1;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//found opcode. return position - 4 to rewind back to start of opcode, so we can handle it.
|
|
||||||
return reader.position() - 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
return startPos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,77 +19,77 @@ import engine.session.Session;
|
|||||||
/*
|
/*
|
||||||
* @Author:
|
* @Author:
|
||||||
* @Summary: Processes application protocol message which displays
|
* @Summary: Processes application protocol message which displays
|
||||||
* the map interface. (Zones, Cities, Realms, Hotzones)
|
* the map interface. (Zones, Cities, Realms, Hot-zones)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CityDataHandler extends AbstractClientMsgHandler {
|
public class CityDataHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public CityDataHandler() {
|
public CityDataHandler() {
|
||||||
super(KeepAliveServerClientMsg.class);
|
super(KeepAliveServerClientMsg.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
boolean updateMine = false;
|
boolean updateMine = false;
|
||||||
boolean updateCity = false;
|
boolean updateCity = false;
|
||||||
Session playerSession;
|
Session playerSession;
|
||||||
PlayerCharacter playerCharacter;
|
PlayerCharacter playerCharacter;
|
||||||
Zone hotZone;
|
Zone hotZone;
|
||||||
|
|
||||||
playerCharacter = origin.getPlayerCharacter();
|
playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
if (playerCharacter == null)
|
if (playerCharacter == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Session is needed as param for worldObjectMsg.
|
// Session is needed as param for worldObjectMsg.
|
||||||
|
|
||||||
playerSession = SessionManager.getSession(playerCharacter);
|
playerSession = SessionManager.getSession(playerCharacter);
|
||||||
|
|
||||||
if (playerSession == null)
|
if (playerSession == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Cache current hotZone
|
// Cache current hotZone
|
||||||
|
|
||||||
hotZone = ZoneManager.getHotZone();
|
hotZone = ZoneManager.getHotZone();
|
||||||
|
|
||||||
// No reason to serialize cities and mines everytime map is
|
// No reason to serialize cities and mines everytime map is
|
||||||
// opened. Wait until something has changed.
|
// opened. Wait until something has changed.
|
||||||
|
|
||||||
if (playerCharacter.getTimeStamp("mineupdate") <= Mine.getLastChange()){
|
if (playerCharacter.getTimeStamp("mineupdate") <= Mine.getLastChange()) {
|
||||||
playerCharacter.setTimeStamp("mineupdate", System.currentTimeMillis());
|
playerCharacter.setTimeStamp("mineupdate", System.currentTimeMillis());
|
||||||
updateMine = true;
|
updateMine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerCharacter.getTimeStamp("cityUpdate") <= City.lastCityUpdate){
|
if (playerCharacter.getTimeStamp("cityUpdate") <= City.lastCityUpdate) {
|
||||||
playerCharacter.setTimeStamp("cityUpdate", System.currentTimeMillis());
|
playerCharacter.setTimeStamp("cityUpdate", System.currentTimeMillis());
|
||||||
updateCity = true;
|
updateCity = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cityDataMsg cityDataMsg = new cityDataMsg(SessionManager.getSession(playerCharacter), false);
|
cityDataMsg cityDataMsg = new cityDataMsg(SessionManager.getSession(playerCharacter), false);
|
||||||
cityDataMsg.updateMines(updateMine);
|
cityDataMsg.updateMines(updateMine);
|
||||||
cityDataMsg.updateCities(updateCity);
|
cityDataMsg.updateCities(updateCity);
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, cityDataMsg);
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, cityDataMsg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
if (playerCharacter.getTimeStamp("hotzoneupdate") <= WorldServer.getLastHZChange()) {
|
if (playerCharacter.getTimeStamp("hotzoneupdate") <= WorldServer.getLastHZChange()) {
|
||||||
|
|
||||||
if (hotZone != null) {
|
if (hotZone != null) {
|
||||||
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), hotZone.getObjectUUID());
|
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), hotZone.getObjectUUID());
|
||||||
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
|
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100);
|
playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize the realms for this map
|
// Serialize the realms for this map
|
||||||
|
|
||||||
WorldRealmMsg worldRealmMsg = new WorldRealmMsg();
|
WorldRealmMsg worldRealmMsg = new WorldRealmMsg();
|
||||||
dispatch = Dispatch.borrow(playerCharacter, worldRealmMsg);
|
dispatch = Dispatch.borrow(playerCharacter, worldRealmMsg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,251 +29,246 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class cityDataMsg extends ClientNetMsg {
|
public class cityDataMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private Session s;
|
private Session s;
|
||||||
private boolean forEnterWorld;
|
private final boolean forEnterWorld;
|
||||||
private static ByteBuffer cachedEnterWorld;
|
private static ByteBuffer cachedEnterWorld;
|
||||||
private static long cachedExpireTime;
|
private static long cachedExpireTime;
|
||||||
|
|
||||||
public static final long wdComp = 0xFF00FF0000000003L;
|
public static final long wdComp = 0xFF00FF0000000003L;
|
||||||
private static byte ver = 1;
|
private static final byte ver = 1;
|
||||||
|
|
||||||
private boolean updateCities = false;
|
private boolean updateCities = false;
|
||||||
private boolean updateRunegates = false;
|
private boolean updateRunegates = false;
|
||||||
private boolean updateMines = false;
|
private boolean updateMines = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s Session
|
||||||
* Session
|
* @param forEnterWorld boolean flag
|
||||||
* @param forEnterWorld
|
*/
|
||||||
* boolean flag
|
public cityDataMsg(Session s, boolean forEnterWorld) {
|
||||||
*/
|
super(Protocol.CITYDATA);
|
||||||
public cityDataMsg(Session s, boolean forEnterWorld) {
|
this.s = s;
|
||||||
super(Protocol.CITYDATA);
|
this.forEnterWorld = forEnterWorld;
|
||||||
this.s = s;
|
}
|
||||||
this.forEnterWorld = forEnterWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public cityDataMsg(boolean updateCities, boolean updateRunegates, boolean updateMines) {
|
public cityDataMsg(boolean updateCities, boolean updateRunegates, boolean updateMines) {
|
||||||
super(Protocol.CITYDATA);
|
super(Protocol.CITYDATA);
|
||||||
this.s = null;
|
this.s = null;
|
||||||
this.forEnterWorld = false;
|
this.forEnterWorld = false;
|
||||||
this.updateCities = updateCities;
|
this.updateCities = updateCities;
|
||||||
this.updateRunegates = updateRunegates;
|
this.updateRunegates = updateRunegates;
|
||||||
this.updateMines = updateMines;
|
this.updateMines = updateMines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public cityDataMsg(AbstractConnection origin, ByteBufferReader reader)
|
public cityDataMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
{
|
super(Protocol.CITYDATA, origin, reader);
|
||||||
super(Protocol.CITYDATA, origin, reader);
|
this.forEnterWorld = false;
|
||||||
this.forEnterWorld = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPowerOfTwoBufferSize() {
|
protected int getPowerOfTwoBufferSize() {
|
||||||
return (18); // 2^14 == 16384
|
return (18); // 2^14 == 16384
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void _serialize(ByteBufferWriter writer) {
|
protected void _serialize(ByteBufferWriter writer) {
|
||||||
if (this.forEnterWorld)
|
if (this.forEnterWorld)
|
||||||
serializeForEnterWorld(writer);
|
serializeForEnterWorld(writer);
|
||||||
else
|
else
|
||||||
serializeForMapUpdate(writer);
|
serializeForMapUpdate(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific use serializer
|
* Specific use serializer
|
||||||
*
|
*
|
||||||
* @param writer
|
* @param writer
|
||||||
*/
|
*/
|
||||||
private void serializeForMapUpdate(ByteBufferWriter writer) {
|
private void serializeForMapUpdate(ByteBufferWriter writer) {
|
||||||
|
|
||||||
//Handle City updates
|
//Handle City updates
|
||||||
|
|
||||||
if (this.updateCities) {
|
if (this.updateCities) {
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
ArrayList<City> cityList = new ArrayList<>();
|
ArrayList<City> cityList = new ArrayList<>();
|
||||||
ConcurrentHashMap<Integer, AbstractGameObject> map = DbManager.getMap(Enum.GameObjectType.City);
|
ConcurrentHashMap<Integer, AbstractGameObject> map = DbManager.getMap(Enum.GameObjectType.City);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
for (AbstractGameObject ago : map.values())
|
for (AbstractGameObject ago : map.values())
|
||||||
if (ago.getObjectType().equals(Enum.GameObjectType.City))
|
if (ago.getObjectType().equals(Enum.GameObjectType.City))
|
||||||
cityList.add((City)ago);
|
cityList.add((City) ago);
|
||||||
|
|
||||||
writer.putInt(cityList.size());
|
writer.putInt(cityList.size());
|
||||||
for (City city: cityList){
|
for (City city : cityList) {
|
||||||
City.serializeForClientMsg(city, writer);
|
City.serializeForClientMsg(city, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Logger.error("missing city map");
|
Logger.error("missing city map");
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
|
|
||||||
|
|
||||||
//Handle Runegate updates
|
//Handle Runegate updates
|
||||||
if (this.updateRunegates) {
|
if (this.updateRunegates) {
|
||||||
|
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
writer.putInt(Runegate._runegates.values().size());
|
writer.putInt(Runegate._runegates.values().size());
|
||||||
|
|
||||||
for(Runegate runegate : Runegate._runegates.values()) {
|
for (Runegate runegate : Runegate._runegates.values()) {
|
||||||
runegate._serializeForEnterWorld(writer);
|
runegate._serializeForEnterWorld(writer);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
|
|
||||||
|
|
||||||
//Handle Mine updates
|
//Handle Mine updates
|
||||||
try{
|
try {
|
||||||
if (this.updateMines) {
|
if (this.updateMines) {
|
||||||
ArrayList<Mine> mineList = new ArrayList<>();
|
ArrayList<Mine> mineList = new ArrayList<>();
|
||||||
for (Mine toAdd: Mine.mineMap.keySet()){
|
for (Mine toAdd : Mine.mineMap.keySet()) {
|
||||||
mineList.add(toAdd);
|
mineList.add(toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.putInt(mineList.size());
|
writer.putInt(mineList.size());
|
||||||
for (Mine mine: mineList)
|
for (Mine mine : mineList)
|
||||||
Mine.serializeForClientMsg(mine, writer);
|
Mine.serializeForClientMsg(mine, writer);
|
||||||
} else
|
} else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
writer.put((byte) 0); // PAD
|
writer.put((byte) 0); // PAD
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific use serializer
|
* Specific use serializer
|
||||||
*
|
*
|
||||||
* @param writer
|
* @param writer
|
||||||
*/
|
*/
|
||||||
private void serializeForEnterWorld(ByteBufferWriter writer) {
|
private void serializeForEnterWorld(ByteBufferWriter writer) {
|
||||||
if (s == null || s.getPlayerCharacter() == null)
|
if (s == null || s.getPlayerCharacter() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long startT = System.currentTimeMillis();
|
long startT = System.currentTimeMillis();
|
||||||
|
|
||||||
if (cachedEnterWorld == null) {
|
if (cachedEnterWorld == null) {
|
||||||
// Never before been cached, so init stuff
|
// Never before been cached, so init stuff
|
||||||
cachedEnterWorld = Network.byteBufferPool.getBuffer(19);
|
cachedEnterWorld = Network.byteBufferPool.getBuffer(19);
|
||||||
cachedExpireTime = 0L;
|
cachedExpireTime = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check to see if its time to renew cache.
|
//Check to see if its time to renew cache.
|
||||||
if (cachedExpireTime < System.currentTimeMillis()) {
|
if (cachedExpireTime < System.currentTimeMillis()) {
|
||||||
synchronized (cachedEnterWorld) {
|
synchronized (cachedEnterWorld) {
|
||||||
cityDataMsg.attemptSerializeForEnterWorld(cachedEnterWorld);
|
cityDataMsg.attemptSerializeForEnterWorld(cachedEnterWorld);
|
||||||
}
|
}
|
||||||
cachedExpireTime = startT + 60000;
|
cachedExpireTime = startT + 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.putBB(cachedEnterWorld);
|
writer.putBB(cachedEnterWorld);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void attemptSerializeForEnterWorld(ByteBuffer bb) {
|
private static void attemptSerializeForEnterWorld(ByteBuffer bb) {
|
||||||
bb.clear();
|
bb.clear();
|
||||||
ByteBufferWriter temp = new ByteBufferWriter(bb);
|
ByteBufferWriter temp = new ByteBufferWriter(bb);
|
||||||
temp.put((byte) 0); // PAD
|
temp.put((byte) 0); // PAD
|
||||||
|
|
||||||
|
|
||||||
ArrayList<City> cityList = new ArrayList<>();
|
ArrayList<City> cityList = new ArrayList<>();
|
||||||
ConcurrentHashMap<Integer, AbstractGameObject> map = DbManager.getMap(Enum.GameObjectType.City);
|
ConcurrentHashMap<Integer, AbstractGameObject> map = DbManager.getMap(Enum.GameObjectType.City);
|
||||||
for (AbstractGameObject ago : map.values())
|
for (AbstractGameObject ago : map.values())
|
||||||
|
|
||||||
if (ago.getObjectType().equals(Enum.GameObjectType.City))
|
if (ago.getObjectType().equals(Enum.GameObjectType.City))
|
||||||
cityList.add((City)ago);
|
cityList.add((City) ago);
|
||||||
|
|
||||||
temp.putInt(cityList.size());
|
temp.putInt(cityList.size());
|
||||||
|
|
||||||
for (City city: cityList)
|
|
||||||
City.serializeForClientMsg(city, temp);
|
|
||||||
temp.put((byte) 0); // PAD
|
|
||||||
|
|
||||||
// Serialize runegates
|
for (City city : cityList)
|
||||||
|
City.serializeForClientMsg(city, temp);
|
||||||
|
temp.put((byte) 0); // PAD
|
||||||
|
|
||||||
temp.putInt(Runegate._runegates.values().size());
|
// Serialize runegates
|
||||||
|
|
||||||
for(Runegate runegate : Runegate._runegates.values()) {
|
temp.putInt(Runegate._runegates.values().size());
|
||||||
runegate._serializeForEnterWorld(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Mine> mineList = new ArrayList<>();
|
for (Runegate runegate : Runegate._runegates.values()) {
|
||||||
for (Mine toAdd : Mine.mineMap.keySet()){
|
runegate._serializeForEnterWorld(temp);
|
||||||
mineList.add(toAdd);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
temp.putInt(mineList.size());
|
|
||||||
for (Mine mine: mineList)
|
|
||||||
Mine.serializeForClientMsg(mine, temp);
|
|
||||||
temp.put((byte) 0); // PAD
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
ArrayList<Mine> mineList = new ArrayList<>();
|
||||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
for (Mine toAdd : Mine.mineMap.keySet()) {
|
||||||
*/
|
mineList.add(toAdd);
|
||||||
@Override
|
}
|
||||||
protected void _deserialize(ByteBufferReader reader)
|
|
||||||
{
|
|
||||||
// Client only sends 11 bytes.
|
|
||||||
|
|
||||||
byte type = reader.get();
|
|
||||||
|
|
||||||
if (type == 1){
|
|
||||||
reader.get();
|
|
||||||
reader.get();
|
|
||||||
reader.getInt();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
reader.get();
|
|
||||||
reader.getInt();
|
|
||||||
reader.get();
|
|
||||||
reader.getInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
temp.putInt(mineList.size());
|
||||||
* @return the s
|
for (Mine mine : mineList)
|
||||||
*/
|
Mine.serializeForClientMsg(mine, temp);
|
||||||
public Session getS() {
|
temp.put((byte) 0); // PAD
|
||||||
return s;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the forEnterWorld
|
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||||
*/
|
*/
|
||||||
public boolean isForEnterWorld() {
|
@Override
|
||||||
return forEnterWorld;
|
protected void _deserialize(ByteBufferReader reader) {
|
||||||
}
|
// Client only sends 11 bytes.
|
||||||
|
|
||||||
public void updateCities(boolean value) {
|
byte type = reader.get();
|
||||||
this.updateCities = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateRunegates(boolean value) {
|
if (type == 1) {
|
||||||
this.updateRunegates = value;
|
reader.get();
|
||||||
}
|
reader.get();
|
||||||
|
reader.getInt();
|
||||||
|
|
||||||
public void updateMines(boolean value) {
|
} else {
|
||||||
this.updateMines = value;
|
reader.get();
|
||||||
}
|
reader.getInt();
|
||||||
|
reader.get();
|
||||||
|
reader.getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the s
|
||||||
|
*/
|
||||||
|
public Session getS() {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the forEnterWorld
|
||||||
|
*/
|
||||||
|
public boolean isForEnterWorld() {
|
||||||
|
return forEnterWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCities(boolean value) {
|
||||||
|
this.updateCities = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRunegates(boolean value) {
|
||||||
|
this.updateRunegates = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMines(boolean value) {
|
||||||
|
this.updateMines = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,20 +43,20 @@ public class HourlyJobThread implements Runnable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Zone hotzone = ZoneManager.getHotZone();
|
Zone hotzone = ZoneManager.getHotZone();
|
||||||
if(hotzone == null){
|
if (hotzone == null) {
|
||||||
//no hotzone? set one.
|
//no hotzone? set one.
|
||||||
ZoneManager.generateAndSetRandomHotzone();
|
ZoneManager.generateAndSetRandomHotzone();
|
||||||
}
|
}
|
||||||
int hotzoneDuration = Integer.valueOf(ConfigManager.MB_HOTZONE_DURATION.getValue());
|
int hotzoneDuration = Integer.valueOf(ConfigManager.MB_HOTZONE_DURATION.getValue());
|
||||||
if(((LocalDateTime.now().getHour()) - hotzone.becameHotzone.getHour()) >= hotzoneDuration) {
|
if (((LocalDateTime.now().getHour()) - hotzone.becameHotzone.getHour()) >= hotzoneDuration) {
|
||||||
ZoneManager.generateAndSetRandomHotzone();
|
ZoneManager.generateAndSetRandomHotzone();
|
||||||
hotzone = ZoneManager.getHotZone();
|
hotzone = ZoneManager.getHotZone();
|
||||||
}
|
}
|
||||||
if (hotzone == null) {
|
if (hotzone == null) {
|
||||||
Logger.error("Null hotzone returned from mapmanager");
|
Logger.error("Null hotzone returned from mapmanager");
|
||||||
} else {
|
} else {
|
||||||
Logger.info("new hotzone: " + hotzone.getName());
|
Logger.info("new hotzone: " + hotzone.getName());
|
||||||
WorldServer.setLastHZChange(System.currentTimeMillis());
|
WorldServer.setLastHZChange(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -187,7 +187,7 @@ public class HourlyJobThread implements Runnable {
|
|||||||
ArrayList<Mine> mines = Mine.getMines();
|
ArrayList<Mine> mines = Mine.getMines();
|
||||||
|
|
||||||
for (Mine mine : mines) {
|
for (Mine mine : mines) {
|
||||||
if(LocalDateTime.now().getHour() == 1400){
|
if (LocalDateTime.now().getHour() == 1400) {
|
||||||
mine.wasClaimed = false;
|
mine.wasClaimed = false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user