db handler created

This commit is contained in:
2023-11-05 12:42:18 -05:00
parent 40443a82a7
commit 19cbbd7176
@@ -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<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<>();