From 7b7492b5cc9f2b7539651f3a529d5c92f515b757 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:09:43 -0400 Subject: [PATCH] Workokrders updates as they cycle --- src/engine/db/handlers/dbWarehouseHandler.java | 12 ++++++++++++ src/engine/gameManager/ForgeManager.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index f9976885..843113d0 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -171,4 +171,16 @@ public class dbWarehouseHandler extends dbHandlerBase { } return false; } + + public void DELETE_WORKORDER(WorkOrder workOrder) { + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_workorders` WHERE `workorderID` = ?;")) { + preparedStatement.setInt(1, workOrder.workOrderID); + preparedStatement.executeUpdate(); + + } catch (SQLException e) { + Logger.error(e); + } + + } } diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index bef56746..6f17cfab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -57,6 +57,10 @@ public enum ForgeManager implements Runnable { } workOrder.runCompleted = true; + + // Update workorder to disk + + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); } if (workOrder.runCompleted) @@ -328,6 +332,11 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.total_produced = workOrder.total_produced + 1; } + + // Save updated status to disk + + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + } public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) {