Browse Source

db handler created

hull4
MagicBot 1 year ago
parent
commit
19cbbd7176
  1. 40
      src/engine/db/handlers/dbBuildingHandler.java

40
src/engine/db/handlers/dbBuildingHandler.java

@ -15,6 +15,7 @@ import engine.Enum.ProtectionState; @@ -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 { @@ -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<Vector2f> 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<ArrayList<Vector2f>> 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<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() {
HashMap<Integer, ArrayList<BuildingRegions>> regionList = new HashMap<>();

Loading…
Cancel
Save