Browse Source

convert DB lookup of mob powers to static Hashmap lookup

master
FatBoy-DOTC 2 years ago
parent
commit
e38a04bf23
  1. 3
      src/engine/objects/Mob.java
  2. 17
      src/engine/server/world/WorldServer.java

3
src/engine/objects/Mob.java

@ -2219,7 +2219,8 @@ public class Mob extends AbstractIntelligenceAgent {
} catch(Exception e){ } catch(Exception e){
Logger.error( e.getMessage()); Logger.error( e.getMessage());
} }
mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID()); //mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID());
mobPowers = (HashMap<Integer, Integer>) WorldServer.AllMobPowers.get(this.getMobBaseID()).entrySet();
if(this.isPlayerGuard() == true){ if(this.isPlayerGuard() == true){
//load guards powers //load guards powers
ArrayList<MobBase> mobbases = DbManager.MobBaseQueries.GET_ALL_MOBBASES(); ArrayList<MobBase> mobbases = DbManager.MobBaseQueries.GET_ALL_MOBBASES();

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

@ -75,7 +75,7 @@ public class WorldServer {
// Member variable declaration // Member variable declaration
public static HashMap<Integer,HashMap<Integer,ArrayList<Integer>>> ZoneFidelityMobRunes = new HashMap<>(); public static HashMap<Integer,HashMap<Integer,ArrayList<Integer>>> ZoneFidelityMobRunes = new HashMap<>();
public static HashMap<Integer,HashMap<Integer,Integer>> AllMobPowers;
public WorldServer() { public WorldServer() {
super(); super();
} }
@ -470,9 +470,22 @@ public class WorldServer {
Logger.info("Running garbage collection..."); Logger.info("Running garbage collection...");
System.gc(); System.gc();
Logger.info("Loading All Mob Powers...");
GatherMobPowers();
return true; return true;
} }
private void GatherMobPowers(){
for(Mob mob : DbManager.MobQueries.GET_ALL_MOBS()){
if(DbManager.MobBaseQueries.LOAD_STATIC_POWERS(mob.getMobBaseID()).isEmpty() == true){
continue;
}
else {
HashMap<Integer, Integer> mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(mob.getMobBaseID());
AllMobPowers.put(mob.getMobBaseID(), mobPowers);
}
}
Logger.info("Static Mob Powers HashMap Loaded Successfully...");
}
protected boolean initDatabaselayer() { protected boolean initDatabaselayer() {
// Try starting a GOM <-> DB connection. // Try starting a GOM <-> DB connection.

Loading…
Cancel
Save