From 8dc51fa2f8ce1c1460cd1611c207adbc2a8df2e0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 9 Nov 2023 14:44:44 -0500 Subject: [PATCH] Data populated at bootstrap. --- src/engine/db/handlers/dbBuildingHandler.java | 24 ++++++++++++++++++- src/engine/server/world/WorldServer.java | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index e2e165cb..aa9e078d 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -28,7 +28,6 @@ import java.sql.SQLException; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; @@ -550,6 +549,29 @@ 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; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a4be3820..acc86e1c 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -403,6 +403,9 @@ public class WorldServer { Logger.info("Loading building slot/stuck location data."); BuildingLocation.loadBuildingLocations(); + Logger.info("Populating structure to render lookup."); + DbManager.BuildingQueries.POPULATE_RENDER_LOOKUP(); + Logger.info("Loading mesh hulls."); DbManager.BuildingQueries.LOAD_MESH_HULLS();