_modTables populated at startup.

This commit is contained in:
2023-08-07 08:49:43 -04:00
parent 32d71df837
commit 8c4d9b66ef
3 changed files with 67 additions and 1 deletions
+39
View File
@@ -106,6 +106,45 @@ public class dbLootHandler extends dbHandlerBase {
return itemTables;
}
public HashMap<Integer, ArrayList<ModTableEntry>> LOAD_MOD_TABLES() {
HashMap<Integer, ArrayList<ModTableEntry>> modTables = new HashMap<>();
ModTableEntry modTableEntry;
int modTableID;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modTables`")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
recordsRead++;
modTableID = rs.getInt("itemTable");
modTableEntry = new ModTableEntry(rs);
if (modTables.get(modTableID) == null) {
ArrayList<ModTableEntry> modTableList = new ArrayList<>();
modTableList.add(modTableEntry);
modTables.put(modTableID, modTableList);
} else {
ArrayList<ModTableEntry> modTableList = modTables.get(modTableID);
modTableList.add(modTableEntry);
modTables.put(modTableID, modTableList);
}
}
} catch (SQLException e) {
Logger.error(e);
return modTables;
}
Logger.info("read: " + recordsRead + " cached: " + modTables.size());
return modTables;
}
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_TABLES() {
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();
+2 -1
View File
@@ -31,6 +31,7 @@ public enum LootManager {
public static HashMap<Integer, ArrayList<GenTableEntry>> _genTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ItemTableEntry>> _itemTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
//new tables
public static final HashMap<Integer, GenTable> generalItemTables = null;
@@ -55,7 +56,7 @@ public enum LootManager {
_genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES();
_itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES();
_modTables = DbManager.LootQueries.LOAD_MOD_TABLES();
DbManager.LootQueries.LOAD_ALL_GENTABLES();
DbManager.LootQueries.LOAD_ALL_ITEMTABLES();
+26
View File
@@ -0,0 +1,26 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ModTableEntry {
public int minRoll;
public int maxRoll;
public String action;
public int level;
public ModTableEntry(ResultSet rs) throws SQLException {
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.action = rs.getString("action");
this.level = rs.getInt("level");
}
}