forked from MagicBane/Server
Zone extents derived from zone
This commit is contained in:
@@ -11,8 +11,6 @@ package engine.db.handlers;
|
|||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.ZoneManager;
|
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -91,26 +89,6 @@ public class dbZoneHandler extends dbHandlerBase {
|
|||||||
return zoneList;
|
return zoneList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_ZONE_EXTENTS() {
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
Vector2f zoneSize = new Vector2f();
|
|
||||||
int loadNum = rs.getInt("loadNum");
|
|
||||||
zoneSize.x = rs.getFloat("xRadius");
|
|
||||||
zoneSize.y = rs.getFloat("zRadius");
|
|
||||||
ZoneManager._zone_size_data.put(loadNum, zoneSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean DELETE_ZONE(final Zone zone) {
|
public boolean DELETE_ZONE(final Zone zone) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ import org.pmw.tinylog.Logger;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ public enum ZoneManager {
|
|||||||
public static Instant hotZoneLastUpdate;
|
public static Instant hotZoneLastUpdate;
|
||||||
public static Zone hotZone = null;
|
public static Zone hotZone = null;
|
||||||
public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config.
|
public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config.
|
||||||
public static HashMap<Integer, Vector2f> _zone_size_data = new HashMap<>();
|
|
||||||
/* Instance variables */
|
/* Instance variables */
|
||||||
private static Zone seaFloor = null;
|
private static Zone seaFloor = null;
|
||||||
|
|
||||||
@@ -71,7 +74,7 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
// Find smallest zone coordinates fit into.
|
// Find smallest zone coordinates fit into.
|
||||||
|
|
||||||
public static final Zone findSmallestZone(final Vector3fImmutable loc) {
|
public static Zone findSmallestZone(final Vector3fImmutable loc) {
|
||||||
|
|
||||||
Zone zone = ZoneManager.seaFloor;
|
Zone zone = ZoneManager.seaFloor;
|
||||||
|
|
||||||
@@ -90,7 +93,7 @@ public enum ZoneManager {
|
|||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
for (Zone child : nodes) {
|
for (Zone child : nodes) {
|
||||||
|
|
||||||
if (Bounds.collide(loc, child.bounds) == true) {
|
if (Bounds.collide(loc, child.bounds)) {
|
||||||
zone = child;
|
zone = child;
|
||||||
childFound = true;
|
childFound = true;
|
||||||
break;
|
break;
|
||||||
@@ -148,11 +151,11 @@ public enum ZoneManager {
|
|||||||
return ZoneManager.zonesByName.get(zoneName);
|
return ZoneManager.zonesByName.get(zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Collection<Zone> getAllZones() {
|
public static Collection<Zone> getAllZones() {
|
||||||
return ZoneManager.zonesByUUID.values();
|
return ZoneManager.zonesByUUID.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void setHotZone(final Zone zone) {
|
public static void setHotZone(final Zone zone) {
|
||||||
|
|
||||||
if (!zone.isMacroZone())
|
if (!zone.isMacroZone())
|
||||||
return;
|
return;
|
||||||
@@ -169,7 +172,7 @@ public enum ZoneManager {
|
|||||||
if (ZoneManager.hotZone == null)
|
if (ZoneManager.hotZone == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (Bounds.collide(loc, ZoneManager.hotZone.bounds) == true);
|
return (Bounds.collide(loc, ZoneManager.hotZone.bounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Zone getSeaFloor() {
|
public static Zone getSeaFloor() {
|
||||||
@@ -180,7 +183,7 @@ public enum ZoneManager {
|
|||||||
ZoneManager.seaFloor = value;
|
ZoneManager.seaFloor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void populateWorldZones(final Zone zone) {
|
public static void populateWorldZones(final Zone zone) {
|
||||||
|
|
||||||
int loadNum = zone.template;
|
int loadNum = zone.template;
|
||||||
|
|
||||||
|
|||||||
@@ -199,15 +199,7 @@ public class Zone extends AbstractGameObject {
|
|||||||
// Set initial bounds object
|
// Set initial bounds object
|
||||||
|
|
||||||
this.bounds = Bounds.borrow();
|
this.bounds = Bounds.borrow();
|
||||||
|
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f);
|
||||||
Vector2f zoneSize = ZoneManager._zone_size_data.get(this.template);
|
|
||||||
|
|
||||||
// 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.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -360,9 +360,6 @@ public class WorldServer {
|
|||||||
Logger.info("Loading item enchants");
|
Logger.info("Loading item enchants");
|
||||||
DbManager.LootQueries.LOAD_ENCHANT_VALUES();
|
DbManager.LootQueries.LOAD_ENCHANT_VALUES();
|
||||||
|
|
||||||
Logger.info("Loading zone extent cache");
|
|
||||||
DbManager.ZoneQueries.LOAD_ZONE_EXTENTS();
|
|
||||||
|
|
||||||
Logger.info("Loading Realms");
|
Logger.info("Loading Realms");
|
||||||
Realm.loadAllRealms();
|
Realm.loadAllRealms();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user