From 60fb2571a20326b5eb3aa71e7cc91c9b42d76282 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 3 Sep 2023 08:18:48 -0400 Subject: [PATCH] Support for loading of skill adjustment map. --- src/engine/db/handlers/dbPowerHandler.java | 45 ----------- src/engine/db/handlers/dbRuneBaseHandler.java | 80 +++++++++++++++++++ src/engine/gameManager/PowersManager.java | 1 + src/engine/powers/RuneSkillAdjustEntry.java | 21 +++++ src/engine/server/world/WorldServer.java | 9 ++- 5 files changed, 108 insertions(+), 48 deletions(-) create mode 100644 src/engine/powers/RuneSkillAdjustEntry.java diff --git a/src/engine/db/handlers/dbPowerHandler.java b/src/engine/db/handlers/dbPowerHandler.java index 5b6c3053..ae3da531 100644 --- a/src/engine/db/handlers/dbPowerHandler.java +++ b/src/engine/db/handlers/dbPowerHandler.java @@ -15,15 +15,9 @@ import engine.gameManager.PowersManager; import engine.objects.Mob; import engine.objects.PreparedStatementShared; import engine.powers.EffectsBase; -import engine.powers.RunePowerEntry; import org.pmw.tinylog.Logger; -import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; public class dbPowerHandler extends dbHandlerBase { @@ -86,43 +80,4 @@ public class dbPowerHandler extends dbHandlerBase { } } - public static HashMap> LOAD_MOB_POWERS() { - - HashMap> mobPowers = new HashMap<>(); - RunePowerEntry runePowerEntry; - - int mobbaseID; - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - - recordsRead++; - - mobbaseID = rs.getInt("rune_id"); - runePowerEntry = new RunePowerEntry(rs); - - if (mobPowers.get(mobbaseID) == null) { - ArrayList powerList = new ArrayList<>(); - powerList.add(runePowerEntry); - mobPowers.put(mobbaseID, powerList); - } else { - ArrayList powerList = mobPowers.get(mobbaseID); - powerList.add(runePowerEntry); - mobPowers.put(mobbaseID, powerList); - } - } - } catch (SQLException e) { - Logger.error(e); - return mobPowers; - } - - Logger.info("read: " + recordsRead + " cached: " + mobPowers.size()); - return mobPowers; - } - } diff --git a/src/engine/db/handlers/dbRuneBaseHandler.java b/src/engine/db/handlers/dbRuneBaseHandler.java index af66b036..1d7a79b6 100644 --- a/src/engine/db/handlers/dbRuneBaseHandler.java +++ b/src/engine/db/handlers/dbRuneBaseHandler.java @@ -11,6 +11,8 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.objects.RuneBase; +import engine.powers.RunePowerEntry; +import engine.powers.RuneSkillAdjustEntry; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -27,6 +29,84 @@ public class dbRuneBaseHandler extends dbHandlerBase { this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public static HashMap> LOAD_RUNE_POWERS() { + + HashMap> mobPowers = new HashMap<>(); + RunePowerEntry runePowerEntry; + + int rune_id; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_powers")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + rune_id = rs.getInt("rune_id"); + runePowerEntry = new RunePowerEntry(rs); + + if (mobPowers.get(rune_id) == null) { + ArrayList runePowerList = new ArrayList<>(); + runePowerList.add(runePowerEntry); + mobPowers.put(rune_id, runePowerList); + } else { + ArrayList powerList = mobPowers.get(rune_id); + powerList.add(runePowerEntry); + mobPowers.put(rune_id, powerList); + } + } + } catch (SQLException e) { + Logger.error(e); + return mobPowers; + } + + Logger.info("read: " + recordsRead + " cached: " + mobPowers.size()); + return mobPowers; + } + + public static HashMap> LOAD_RUNE_SKILL_ADJUSTS() { + + HashMap> runeSkillAdjusts = new HashMap<>(); + RuneSkillAdjustEntry runeSkillAdjustEntry; + + int rune_id; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_skill_adjusts")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + rune_id = rs.getInt("rune_id"); + runeSkillAdjustEntry = new RuneSkillAdjustEntry(rs); + + if (runeSkillAdjusts.get(rune_id) == null) { + ArrayList skillAdjustList = new ArrayList<>(); + skillAdjustList.add(runeSkillAdjustEntry); + runeSkillAdjusts.put(rune_id, skillAdjustList); + } else { + ArrayList powerList = runeSkillAdjusts.get(rune_id); + powerList.add(runeSkillAdjustEntry); + runeSkillAdjusts.put(rune_id, powerList); + } + } + } catch (SQLException e) { + Logger.error(e); + return runeSkillAdjusts; + } + + Logger.info("read: " + recordsRead + " cached: " + runeSkillAdjusts.size()); + return runeSkillAdjusts; + } + public void GET_RUNE_REQS(final RuneBase rb) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 2691631d..573207f7 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -54,6 +54,7 @@ public enum PowersManager { public static HashMap ActionTokenByIDString = new HashMap<>(); public static HashMap AnimationOverrides = new HashMap<>(); public static HashMap> _allRunePowers; + public static HashMap> _allRuneSkillAdjusts; private static JobScheduler js; public static void initPowersManager(boolean fullPowersLoad) { diff --git a/src/engine/powers/RuneSkillAdjustEntry.java b/src/engine/powers/RuneSkillAdjustEntry.java new file mode 100644 index 00000000..5fbf23c2 --- /dev/null +++ b/src/engine/powers/RuneSkillAdjustEntry.java @@ -0,0 +1,21 @@ +package engine.powers; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class RuneSkillAdjustEntry { + + public String name; + public int token; + public String skill_type; + public int rank; + + + public RuneSkillAdjustEntry(ResultSet rs) throws SQLException { + this.name = rs.getString("name"); + this.token = rs.getInt("token"); + this.skill_type = rs.getString("skill_type"); + this.rank = rs.getInt("rank"); + } + +} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 68428980..1eb95eb2 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -17,7 +17,7 @@ import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; -import engine.db.handlers.dbPowerHandler; +import engine.db.handlers.dbRuneBaseHandler; import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobContainer; @@ -351,8 +351,11 @@ public class WorldServer { Logger.info("Loading MobBases."); DbManager.MobBaseQueries.GET_ALL_MOBBASES(); - Logger.info("Loading Mob Powers"); - PowersManager._allRunePowers = dbPowerHandler.LOAD_MOB_POWERS(); + Logger.info("Loading Rune Powers"); + PowersManager._allRunePowers = dbRuneBaseHandler.LOAD_RUNE_POWERS(); + + Logger.info("Loading Rune Skill Adjusts"); + PowersManager._allRuneSkillAdjusts = dbRuneBaseHandler.LOAD_RUNE_SKILL_ADJUSTS(); Logger.info("Loading item enchants"); DbManager.LootQueries.LOAD_ENCHANT_VALUES();