From 38e25bf132b4534d2c72eaeeee072e3e2864a8c9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 18 Feb 2023 14:30:15 -0600 Subject: [PATCH] hotzone duration config, non repeating hotzones --- src/engine/gameManager/ConfigManager.java | 3 ++- src/engine/gameManager/ZoneManager.java | 7 +++++-- src/engine/objects/Zone.java | 3 ++- src/engine/workthreads/HourlyJobThread.java | 8 +++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 722d0731..83c5d57c 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -84,7 +84,8 @@ public enum ConfigManager { MB_MAGICBOT_GAMEVERSION, //drop rates MB_NORMAL_RATE, - MB_HOTZONE_RATE; + MB_HOTZONE_RATE, + MB_HOTZONE_DURATION; // Map to hold our config pulled in from the environment // We also use the config to point to the current message pump // and determine the server type at runtime. diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index ef8c1c61..80adcd74 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -44,7 +44,6 @@ public enum ZoneManager { private static Set macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>()); private static Set npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>()); private static Set playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>()); - // Find all zones coordinates fit into, starting with Sea Floor public static ArrayList getAllZonesIn(final Vector3fImmutable loc) { @@ -127,6 +126,7 @@ public enum ZoneManager { if (!zone.isMacroZone()) return; ZoneManager.hotzone = zone; + zone.hasBeenHotzone = true; } public static boolean inHotZone(final Vector3fImmutable loc) { @@ -224,7 +224,10 @@ public enum ZoneManager { if (zone.equals(ZoneManager.seaFloor)) return false; - + //no duplicate hotzones + if(zone.hasBeenHotzone == true){ + return false; + } // return false; //first time setting, accept it // if (this.hotzone.getUUID() == zone.getUUID()) // return true; //no same hotzone diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 18cccae9..0a9c23be 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -59,7 +59,8 @@ public class Zone extends AbstractGameObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); - + public boolean hasBeenHotzone = false; + public int hoursAsHotzone = 0; /** * ResultSet Constructor */ diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 059072e0..0983499d 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -45,12 +45,14 @@ public class HourlyJobThread implements Runnable { ZoneManager.generateAndSetRandomHotzone(); Zone hotzone = ZoneManager.getHotZone(); - if (hotzone == null) { Logger.error("Null hotzone returned from mapmanager"); } else { - Logger.info("new hotzone: " + hotzone.getName()); - WorldServer.setLastHZChange(System.currentTimeMillis()); + hotzone.hoursAsHotzone += 1; + if(hotzone.hoursAsHotzone >= Integer.valueOf(ConfigManager.MB_HOTZONE_DURATION.getValue())) { + Logger.info("new hotzone: " + hotzone.getName()); + WorldServer.setLastHZChange(System.currentTimeMillis()); + } } } catch (Exception e) {