diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 375dbf17..efa5e550 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -15,6 +15,7 @@ import engine.Enum.ProtectionState; import engine.Enum.TaxType; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; +import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.*; import org.joda.time.DateTime; @@ -548,6 +549,45 @@ public class dbBuildingHandler extends dbHandlerBase { return false; } + public void LOAD_MESH_HULLS() { + + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_verts")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + int propID = rs.getInt("propID"); + String[] vertStrings = rs.getString("vertices").split(";"); + ArrayList vertArrayList = new ArrayList<>(); + + vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[0]), Float.parseFloat(vertStrings[1]))); + vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[2]), Float.parseFloat(vertStrings[3]))); + + ArrayList> meshList; + + if (BuildingManager._hull_data.get(propID) == null) { + meshList = new ArrayList<>(); + BuildingManager._hull_data.put(propID, meshList); + meshList.add(propID, vertArrayList); + } else { + meshList = BuildingManager._hull_data.get(propID); + meshList.add(propID, vertArrayList); + } + } + + } catch (SQLException e) { + Logger.error(e); + } + + Logger.info("read: " + recordsRead + " cached: " + BuildingManager._hull_data.size()); + } + public HashMap> LOAD_BUILDING_REGIONS() { HashMap> regionList = new HashMap<>();