|
|
@ -15,12 +15,12 @@ import engine.Enum.ProtectionState; |
|
|
|
import engine.Enum.TaxType; |
|
|
|
import engine.Enum.TaxType; |
|
|
|
import engine.gameManager.BuildingManager; |
|
|
|
import engine.gameManager.BuildingManager; |
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.math.Vector2f; |
|
|
|
|
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.*; |
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.geom.Path2D; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
@ -549,35 +549,12 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
return false; |
|
|
|
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_MESH_HULLS() { |
|
|
|
|
|
|
|
|
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
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(); |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
@ -586,39 +563,27 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
recordsRead++; |
|
|
|
recordsRead++; |
|
|
|
|
|
|
|
|
|
|
|
int propID = rs.getInt("propID"); |
|
|
|
int propID = rs.getInt("propID"); |
|
|
|
String[] vertStrings = rs.getString("vertices").split(";"); |
|
|
|
String[] HullStrings = rs.getString("vertices").split(";"); |
|
|
|
ArrayList<Vector2f> vertArrayList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Filter things that couldn't be wrapped
|
|
|
|
// Filter things that couldn't be wrapped
|
|
|
|
|
|
|
|
|
|
|
|
if (vertStrings.length < 3) { |
|
|
|
if (HullStrings.length < 3) { |
|
|
|
Logger.error("Prop : " + propID + " has less than 3 vertices."); |
|
|
|
Logger.error("Prop : " + propID + " has less than 3 vertices."); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
ArrayList<Vector2f> vectors = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<Float> floats = new ArrayList<>(); |
|
|
|
|
|
|
|
for(String read : vertStrings){ |
|
|
|
|
|
|
|
floats.add(Float.parseFloat(read)); |
|
|
|
|
|
|
|
if(floats.size() == 2) { |
|
|
|
|
|
|
|
vectors.add(new Vector2f(floats.get(0), floats.get(1))); |
|
|
|
|
|
|
|
floats = new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < vertStrings.length; i += 2)
|
|
|
|
Path2D.Float prop_path = BuildingManager.hullToPath2d(HullStrings); |
|
|
|
// vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[i]), Float.parseFloat(vertStrings[1 + 1])));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<ArrayList<Vector2f>> meshList; |
|
|
|
ArrayList<ArrayList<Path2D>> meshList; |
|
|
|
|
|
|
|
|
|
|
|
if (BuildingManager._hull_data.get(propID) == null) { |
|
|
|
if (BuildingManager._hull_data.get(propID) == null) { |
|
|
|
meshList = new ArrayList<>(); |
|
|
|
meshList = new ArrayList<>(); |
|
|
|
meshList.add(vectors); |
|
|
|
meshList.add(prop_path); |
|
|
|
BuildingManager._hull_data.put(propID, meshList); |
|
|
|
BuildingManager._hull_data.put(propID, meshList); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
meshList = BuildingManager._hull_data.get(propID); |
|
|
|
meshList = BuildingManager._hull_data.get(propID); |
|
|
|
meshList.add(vectors); |
|
|
|
meshList.add(prop_path); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|