Browse Source

BootySets generated with cache data loaded at bootstrap.

master
MagicBot 2 years ago
parent
commit
8e236d0780
  1. 43
      src/engine/db/handlers/dbItemBaseHandler.java
  2. 8
      src/engine/gameManager/NPCManager.java
  3. 29
      src/engine/objects/BootySetEntry.java
  4. 3
      src/engine/server/world/WorldServer.java

43
src/engine/db/handlers/dbItemBaseHandler.java

@ -10,6 +10,7 @@
package engine.db.handlers; package engine.db.handlers;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.objects.BootySetEntry;
import engine.objects.EquipmentSetEntry; import engine.objects.EquipmentSetEntry;
import engine.objects.ItemBase; import engine.objects.ItemBase;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -191,4 +192,46 @@ public class dbItemBaseHandler extends dbHandlerBase {
} }
return runeSets; return runeSets;
} }
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_FOR_MOBS() {
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();
BootySetEntry bootySetEntry;
int bootySetID;
int recordsRead = 0;
prepareCallable("SELECT * FROM static_npc_bootySet");
try {
ResultSet rs = executeQuery();
while (rs.next()) {
recordsRead++;
bootySetID = rs.getInt("bootySet");
bootySetEntry = new BootySetEntry(rs);
if (bootySets.get(bootySetID) == null){
ArrayList<BootySetEntry> bootyList = new ArrayList<>();
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
}
else{
ArrayList<BootySetEntry>bootyList = bootySets.get(bootySetID);
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
}
}
Logger.info("read: " + recordsRead + " cached: " + bootySets.size());
} catch (SQLException e) {
Logger.error( e.toString());
} finally {
closeCallable();
}
return bootySets;
}
} }

8
src/engine/gameManager/NPCManager.java

@ -1,15 +1,19 @@
package engine.gameManager; package engine.gameManager;
import engine.objects.BootySetEntry;
import engine.objects.EquipmentSetEntry; import engine.objects.EquipmentSetEntry;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public enum NPCManager { public enum NPCManager {
NPC_MANAGER; NPC_MANAGER;
public static HashMap<Integer, ArrayList<EquipmentSetEntry>> _equipmentSetMap = new HashMap<>(); public static HashMap<Integer, ArrayList<EquipmentSetEntry>> _equipmentSetMap = new HashMap<>();
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>(); public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
public static HashMap<Integer, ArrayList<BootySetEntry>> _bootySetMap = new HashMap<>();
public static void LoadAllEquipmentSets() { public static void LoadAllEquipmentSets() {
_equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); _equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
@ -18,4 +22,8 @@ public enum NPCManager {
public static void LoadAllRuneSets() { public static void LoadAllRuneSets() {
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); _runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
} }
public static void LoadAllBootySets() {
_bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS();
}
} }

29
src/engine/objects/BootySetEntry.java

@ -0,0 +1,29 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import java.sql.ResultSet;
import java.sql.SQLException;
public class BootySetEntry {
public float dropChance;
public int itemBase;
/**
* ResultSet Constructor
*/
public BootySetEntry(ResultSet rs) throws SQLException {
this.dropChance = (rs.getFloat("dropChance"));
this.itemBase = (rs.getInt("itemBase"));
}
}

3
src/engine/server/world/WorldServer.java

@ -290,6 +290,9 @@ public class WorldServer {
Logger.info("Loading NPC and Mob Rune Sets"); Logger.info("Loading NPC and Mob Rune Sets");
NPCManager.LoadAllRuneSets(); NPCManager.LoadAllRuneSets();
Logger.info("Loading Mobile Booty Sets");
NPCManager.LoadAllBootySets();
Logger.info("Loading Gold Loot for Mobbases"); Logger.info("Loading Gold Loot for Mobbases");
MobbaseGoldEntry.LoadMobbaseGold(); MobbaseGoldEntry.LoadMobbaseGold();

Loading…
Cancel
Save