From e38a04bf23cb52644c5c85cb113fae88f309b556 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 12 Mar 2023 10:17:25 -0500 Subject: [PATCH] convert DB lookup of mob powers to static Hashmap lookup --- src/engine/objects/Mob.java | 3 ++- src/engine/server/world/WorldServer.java | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 996d9ab4..79f009fc 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -2219,7 +2219,8 @@ public class Mob extends AbstractIntelligenceAgent { } catch(Exception e){ Logger.error( e.getMessage()); } - mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID()); + //mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID()); + mobPowers = (HashMap) WorldServer.AllMobPowers.get(this.getMobBaseID()).entrySet(); if(this.isPlayerGuard() == true){ //load guards powers ArrayList mobbases = DbManager.MobBaseQueries.GET_ALL_MOBBASES(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 20bb7f1d..3c973aa0 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -75,7 +75,7 @@ public class WorldServer { // Member variable declaration public static HashMap>> ZoneFidelityMobRunes = new HashMap<>(); - + public static HashMap> AllMobPowers; public WorldServer() { super(); } @@ -470,9 +470,22 @@ public class WorldServer { Logger.info("Running garbage collection..."); System.gc(); + Logger.info("Loading All Mob Powers..."); + GatherMobPowers(); 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 mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(mob.getMobBaseID()); + AllMobPowers.put(mob.getMobBaseID(), mobPowers); + } + } + Logger.info("Static Mob Powers HashMap Loaded Successfully..."); + } protected boolean initDatabaselayer() { // Try starting a GOM <-> DB connection.