Browse Source

_modtypeTables populated at startup.

master
MagicBot 1 year ago
parent
commit
f7fd544a00
  1. 39
      src/engine/db/handlers/dbLootHandler.java
  2. 3
      src/engine/gameManager/LootManager.java
  3. 24
      src/engine/loot/ModTypeTableEntry.java

39
src/engine/db/handlers/dbLootHandler.java

@ -145,6 +145,45 @@ public class dbLootHandler extends dbHandlerBase {
return modTables; return modTables;
} }
public HashMap<Integer, ArrayList<ModTypeTableEntry>> LOAD_MOD_TYPE_TABLES() {
HashMap<Integer, ArrayList<ModTypeTableEntry>> modTypeTables = new HashMap<>();
ModTypeTableEntry modTypeTableEntry;
int modTableID;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modtypeTables`")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
recordsRead++;
modTableID = rs.getInt("modType");
modTypeTableEntry = new ModTypeTableEntry(rs);
if (modTypeTables.get(modTableID) == null) {
ArrayList<ModTypeTableEntry> modTypeTableList = new ArrayList<>();
modTypeTableList.add(modTypeTableEntry);
modTypeTables.put(modTableID, modTypeTableList);
} else {
ArrayList<ModTypeTableEntry> modTypeTableList = modTypeTables.get(modTableID);
modTypeTableList.add(modTypeTableEntry);
modTypeTables.put(modTableID, modTypeTableList);
}
}
} catch (SQLException e) {
Logger.error(e);
return modTypeTables;
}
Logger.info("read: " + recordsRead + " cached: " + modTypeTables.size());
return modTypeTables;
}
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_TABLES() { public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_TABLES() {
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>(); HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();

3
src/engine/gameManager/LootManager.java

@ -32,6 +32,7 @@ public enum LootManager {
public static HashMap<Integer, ArrayList<GenTableEntry>> _genTables = new HashMap<>(); public static HashMap<Integer, ArrayList<GenTableEntry>> _genTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ItemTableEntry>> _itemTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ItemTableEntry>> _itemTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>();
//new tables //new tables
public static final HashMap<Integer, GenTable> generalItemTables = null; public static final HashMap<Integer, GenTable> generalItemTables = null;
@ -57,6 +58,8 @@ public enum LootManager {
_genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES();
_itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES(); _itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES();
_modTables = DbManager.LootQueries.LOAD_MOD_TABLES(); _modTables = DbManager.LootQueries.LOAD_MOD_TABLES();
_modTypeTables = DbManager.LootQueries.LOAD_MOD_TYPE_TABLES();
DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_GENTABLES();
DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES();

24
src/engine/loot/ModTypeTableEntry.java

@ -0,0 +1,24 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ModTypeTableEntry {
public int minRoll;
public int maxRoll;
public int modTableID;
public ModTypeTableEntry(ResultSet rs) throws SQLException {
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.modTableID = rs.getInt("subTableID");
}
}
Loading…
Cancel
Save