forked from MagicBane/Server
Compare commits
25 Commits
hull4
..
convex-data
| Author | SHA1 | Date | |
|---|---|---|---|
| 7405d71a90 | |||
| 89f9c0471f | |||
| a94056e9e1 | |||
| 021a5a5a5a | |||
| 892174ffe1 | |||
| 536ccc2143 | |||
| 2ced2f75af | |||
| 63248ef577 | |||
| 72412a98dd | |||
| a664c8790e | |||
| 9663d87088 | |||
| 4e642b0f42 | |||
| f9fafe90d5 | |||
| 3181c465cb | |||
| 9b8be777f1 | |||
| eb5bc14974 | |||
| 7e99e8c7a4 | |||
| 9b0f4d5aef | |||
| b58049968f | |||
| 9bf0d3f7d1 | |||
| 8300c47e4a | |||
| c73fcc19f2 | |||
| f93573177a | |||
| fe9c6437d8 | |||
| c110ffc4b1 |
@@ -549,35 +549,12 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void POPULATE_RENDER_LOOKUP() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_renders`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
int structureID = rs.getInt("structureID");
|
||||
int renderID = rs.getInt("renderID");
|
||||
|
||||
if (!BuildingManager._render_lookup.containsKey(structureID))
|
||||
BuildingManager._render_lookup.put(structureID, new ArrayList<>());
|
||||
|
||||
BuildingManager._render_lookup.get(structureID).add(renderID);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_MESH_HULLS() {
|
||||
public void LOAD_CONVEX_HULLS() {
|
||||
|
||||
int recordsRead = 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_verts")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_convex_hulls")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
@@ -585,40 +562,40 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
int propID = rs.getInt("propID");
|
||||
String[] vertStrings = rs.getString("vertices").split(";");
|
||||
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
|
||||
int meshID = rs.getInt("meshID");
|
||||
String[] hullString = rs.getString("vertices").split(";");
|
||||
|
||||
// Filter things that couldn't be wrapped
|
||||
|
||||
if (vertStrings.length < 3) {
|
||||
Logger.error("Prop : " + propID + " has less than 3 vertices.");
|
||||
if (hullString.length < 3) {
|
||||
Logger.error("Mesh : " + meshID + " has less than 3 vertices.");
|
||||
continue;
|
||||
}
|
||||
ArrayList<Vector2f> vectors = new ArrayList<>();
|
||||
|
||||
ArrayList<Vector2f> convexHull = new ArrayList<>();
|
||||
ArrayList<Float> floats = new ArrayList<>();
|
||||
for(String read : vertStrings){
|
||||
|
||||
for (String read : hullString) {
|
||||
|
||||
floats.add(Float.parseFloat(read));
|
||||
if(floats.size() == 2) {
|
||||
vectors.add(new Vector2f(floats.get(0), floats.get(1)));
|
||||
floats = new ArrayList<>();
|
||||
|
||||
if (floats.size() == 2) {
|
||||
convexHull.add(new Vector2f(floats.get(0), floats.get(1)));
|
||||
floats.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ArrayList<ArrayList<Vector2f>> hullList;
|
||||
|
||||
//for (int i = 0; i < vertStrings.length; i += 2)
|
||||
// vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[i]), Float.parseFloat(vertStrings[1 + 1])));
|
||||
|
||||
ArrayList<ArrayList<Vector2f>> meshList;
|
||||
|
||||
if (BuildingManager._hull_data.get(propID) == null) {
|
||||
meshList = new ArrayList<>();
|
||||
meshList.add(vectors);
|
||||
BuildingManager._hull_data.put(propID, meshList);
|
||||
if (BuildingManager._hull_data.get(meshID) == null) {
|
||||
hullList = new ArrayList<>();
|
||||
hullList.add(convexHull);
|
||||
BuildingManager._hull_data.put(meshID, hullList);
|
||||
|
||||
} else {
|
||||
meshList = BuildingManager._hull_data.get(propID);
|
||||
meshList.add(vectors);
|
||||
hullList = BuildingManager._hull_data.get(meshID);
|
||||
hullList.add(convexHull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
public enum BuildingManager {
|
||||
|
||||
BUILDINGMANAGER;
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> _render_lookup = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<ArrayList<Vector2f>>> _hull_data = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||
|
||||
@@ -34,7 +34,6 @@ import engine.net.client.msg.UpdateObjectMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -914,7 +913,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
// Note: We handle R8 tree edge case for mesh and health
|
||||
// after city is loaded to avoid recursive result set call
|
||||
// in City resulting in a stack ovreflow.
|
||||
// in City resulting in a stack overflow.
|
||||
|
||||
if (blueprint != null) {
|
||||
|
||||
|
||||
@@ -403,11 +403,8 @@ public class WorldServer {
|
||||
Logger.info("Loading building slot/stuck location data.");
|
||||
BuildingLocation.loadBuildingLocations();
|
||||
|
||||
Logger.info("Populating structure to render lookup.");
|
||||
DbManager.BuildingQueries.POPULATE_RENDER_LOOKUP();
|
||||
|
||||
Logger.info("Loading mesh hulls.");
|
||||
DbManager.BuildingQueries.LOAD_MESH_HULLS();
|
||||
DbManager.BuildingQueries.LOAD_CONVEX_HULLS();
|
||||
|
||||
// Starting before loading of structures/guilds/characters
|
||||
// so the database connections are available to write
|
||||
|
||||
Reference in New Issue
Block a user