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