From 00d0048fd0177991a99e92da2c2c00a1ce862b87 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 28 Mar 2023 17:45:58 -0400 Subject: [PATCH] RuneSets generated loaded at bootstrap. --- src/engine/db/handlers/dbItemBaseHandler.java | 42 +++++++++++++++++++ src/engine/gameManager/NPCManager.java | 9 +++- src/engine/objects/MobBase.java | 2 +- src/engine/objects/NPC.java | 2 +- src/engine/server/world/WorldServer.java | 3 ++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 6217f7d3..3da0c1c2 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -9,6 +9,7 @@ package engine.db.handlers; +import engine.gameManager.NPCManager; import engine.objects.EquipmentSetEntry; import engine.objects.ItemBase; import org.pmw.tinylog.Logger; @@ -149,4 +150,45 @@ public class dbItemBaseHandler extends dbHandlerBase { } return equipmentSets; } + + public HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() { + + HashMap> runeSets = new HashMap<>(); + int runeSetID; + int runeBaseID; + int recordsRead = 0; + + prepareCallable("SELECT * FROM static_npc_runeSet"); + + try { + ResultSet rs = executeQuery(); + + while (rs.next()) { + + recordsRead++; + + runeSetID = rs.getInt("runeSet"); + runeBaseID = rs.getInt("runeBase"); + + if (runeSets.get(runeSetID) == null){ + ArrayList runeList = new ArrayList<>(); + runeList.add(runeBaseID); + runeSets.put(runeSetID, runeList); + } + else{ + ArrayListruneList = runeSets.get(runeSetID); + runeList.add(runeSetID); + runeSets.put(runeSetID, runeList); + } + } + + Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); + + } catch (SQLException e) { + Logger.error( e.toString()); + } finally { + closeCallable(); + } + return runeSets; + } } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 9c64d06c..133c381a 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -7,10 +7,15 @@ import java.util.HashMap; public enum NPCManager { NPC_MANAGER; - public static HashMap> EquipmentSetMap = new HashMap<>(); + public static HashMap> _equipmentSetMap = new HashMap<>(); + public static HashMap> _runeSetMap = new HashMap<>(); public static void LoadAllEquipmentSets() { - EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); + _equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); + } + + public static void LoadAllRuneSets() { + _runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); } } diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index cacfa794..514721b9 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -145,7 +145,7 @@ public class MobBase extends AbstractGameObject { if (equipmentSetID == 0) return equip; - equipList = NPCManager.EquipmentSetMap.get(equipmentSetID); + equipList = NPCManager._equipmentSetMap.get(equipmentSetID); if (equipList == null) return equip; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index d1943d0d..2ef673d9 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1681,7 +1681,7 @@ public class NPC extends AbstractCharacter { public static boolean UpdateEquipSetID(NPC npc, int equipSetID){ - if (!NPCManager.EquipmentSetMap.containsKey(equipSetID)) + if (!NPCManager._equipmentSetMap.containsKey(equipSetID)) return false; if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID)) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 46ce5d89..3736b776 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -287,6 +287,9 @@ public class WorldServer { Logger.info("Loading NPC and Mob Equipment Sets"); NPCManager.LoadAllEquipmentSets(); + Logger.info("Loading NPC and Mob Rune Sets"); + NPCManager.LoadAllRuneSets(); + Logger.info("Loading Gold Loot for Mobbases"); MobbaseGoldEntry.LoadMobbaseGold();